Skip to content

Commit 108b5a6

Browse files
author
Jean 28518
committed
Rework flatpak installation because of dead flathub v1 api
1 parent 241f85f commit 108b5a6

5 files changed

Lines changed: 117 additions & 81 deletions

File tree

lib/layouts/main_screen/main_search.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,13 @@ class _MainSearchState extends State<MainSearch> {
483483
heavyEntries.addAll(snaps);
484484
}
485485

486+
if (Linux.currentenvironment.installedSoftwareManagers
487+
.contains(SOFTWARE_MANAGERS.FLATPAK)) {
488+
List<ActionEntry> flatpaks =
489+
await Linux.getInstallableFlatpakPackagesForKeyword(keyword);
490+
heavyEntries.addAll(flatpaks);
491+
}
492+
486493
if (Linux.currentenvironment.installedSoftwareManagers
487494
.contains(SOFTWARE_MANAGERS.PACMAN)) {
488495
List<ActionEntry> pacmanEntries =

lib/services/linux.dart

Lines changed: 57 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,16 @@ class Linux {
569569
if ((softwareManager == null ||
570570
softwareManager == SOFTWARE_MANAGERS.FLATPAK) &&
571571
isFlatpakInstalled) {
572-
commandQueue.add(
573-
LinuxCommand(
574-
userId: currentenvironment.currentUserId,
575-
command:
576-
"${getExecutablePathOfSoftwareManager(SOFTWARE_MANAGERS.FLATPAK)} remove $appCode -y --noninteractive",
577-
),
578-
);
572+
commandQueue.add(LinuxCommand(
573+
userId: currentenvironment.currentUserId,
574+
command:
575+
"${getExecutablePathOfSoftwareManager(SOFTWARE_MANAGERS.FLATPAK)} remove $appCode -y --noninteractive",
576+
));
577+
commandQueue.add(LinuxCommand(
578+
userId: 0,
579+
command:
580+
"${getExecutablePathOfSoftwareManager(SOFTWARE_MANAGERS.FLATPAK)} uninstall $appCode -y --noninteractive --system",
581+
));
579582
}
580583
}
581584

@@ -1484,6 +1487,53 @@ class Linux {
14841487
return results;
14851488
}
14861489

1490+
static Future<List<ActionEntry>> getInstallableFlatpakPackagesForKeyword(
1491+
String keyword) async {
1492+
if (keyword.length <= 3) {
1493+
return [];
1494+
}
1495+
String output = await runCommandWithCustomArguments(
1496+
getExecutablePathOfSoftwareManager(SOFTWARE_MANAGERS.FLATPAK),
1497+
["search", keyword, "--columns=application,name,description"]);
1498+
output = output.trim();
1499+
List<String> lines = output.split("\n");
1500+
1501+
if (output.contains("No matches found")) {
1502+
return [];
1503+
}
1504+
1505+
print(output);
1506+
print(lines.length);
1507+
1508+
if (lines.length > 100) {
1509+
return [];
1510+
}
1511+
1512+
List<ActionEntry> results = [];
1513+
for (String line in lines) {
1514+
List<String> lineParts = line.split("\t");
1515+
if (lineParts.length < 3) {
1516+
continue;
1517+
}
1518+
String appID = lineParts[0].trim();
1519+
String appName = lineParts[1].trim();
1520+
String appDescription = lineParts[2].trim();
1521+
results.add(ActionEntry(
1522+
iconWidget: Icon(
1523+
Icons.archive,
1524+
size: 48,
1525+
color: MintY.currentColor,
1526+
),
1527+
name: "Install $appName (Flatpak)",
1528+
description: appDescription,
1529+
action: "flatpak-install:$appID",
1530+
priority: -20,
1531+
));
1532+
}
1533+
1534+
return results;
1535+
}
1536+
14871537
/// Only returns results if keyword is longer than 3 and there are under 100 results.
14881538
static Future<List<ActionEntry>> getInstallableZypperPackagesForKeyword(
14891539
String keyword) async {
@@ -2179,44 +2229,6 @@ class Linux {
21792229
Linux.runCommand("/sbin/shutdown $minutes");
21802230
}
21812231

2182-
static Future<List<ActionEntry>> getAvailableFlatpaks(
2183-
BuildContext context) async {
2184-
String homeDir = Linux.getHomeDirectory();
2185-
2186-
List<ActionEntry> returnValue = [];
2187-
try {
2188-
String installedFlatpaks = await Linux.runCommandWithCustomArguments(
2189-
"/usr/bin/flatpak", ["list", "--app", "--columns=application"]);
2190-
2191-
File flathubIndexFile =
2192-
File("$homeDir.config/linux-assistant/flathub_index.json");
2193-
List<dynamic> responseMap =
2194-
json.decode(flathubIndexFile.readAsStringSync());
2195-
for (Map<String, dynamic> app in responseMap) {
2196-
if (!installedFlatpaks
2197-
.contains(app["flatpakAppId"].toString().trim())) {
2198-
ActionEntry entry = ActionEntry(
2199-
name: AppLocalizations.of(context)!
2200-
.installX("${app["name"]} (Flatpak)"),
2201-
description: app["summary"],
2202-
action: "flatpak-install:${app["flatpakAppId"]}",
2203-
priority: -19.0,
2204-
iconWidget: Icon(
2205-
Icons.archive_rounded,
2206-
size: 48,
2207-
color: MintY.currentColor,
2208-
),
2209-
excludeFromSearchProposal: true,
2210-
);
2211-
returnValue.add(entry);
2212-
}
2213-
}
2214-
} catch (e) {
2215-
print(e.toString());
2216-
}
2217-
return returnValue;
2218-
}
2219-
22202232
static Future<String> getUsername() async {
22212233
final int id = currentenvironment.currentUserId;
22222234
return (await runCommand("id -nu $id")).trim();

lib/services/main_search_loader.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,6 @@ class _MainSearchLoaderState extends State<MainSearchLoader> {
6969
_onTimeoutOfSearchLoadingModule("browserBookmarks")));
7070
}
7171

72-
// Flatpak Index Installations
73-
if (configHandler.getValueUnsafe("search_filter_install_software", true)) {
74-
print("Loading flatpaks");
75-
futures.add(Linux.getAvailableFlatpaks(context).timeout(timeoutDuration,
76-
onTimeout: () => _onTimeoutOfSearchLoadingModule("flatpaks")));
77-
}
78-
7972
// Deinstallation Entries.
8073
if (configHandler.getValueUnsafe(
8174
"search_filter_uninstall_software", true)) {

pubspec.lock

Lines changed: 51 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ packages:
4545
dependency: transitive
4646
description:
4747
name: collection
48-
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
48+
sha256: a1ace0a119f20aabc852d165077c036cd864315bd99b7eaa10a60100341941bf
4949
url: "https://pub.dev"
5050
source: hosted
51-
version: "1.18.0"
51+
version: "1.19.0"
5252
crypto:
5353
dependency: "direct main"
5454
description:
@@ -77,10 +77,10 @@ packages:
7777
dependency: "direct main"
7878
description:
7979
name: fl_chart
80-
sha256: "749b3342ea3e95cbf61a0fec31a62606e837377b8b6d0caa7367a7ef80f38b7d"
80+
sha256: "5a74434cc83bf64346efb562f1a06eefaf1bcb530dc3d96a104f631a1eff8d79"
8181
url: "https://pub.dev"
8282
source: hosted
83-
version: "0.55.2"
83+
version: "0.65.0"
8484
flutter:
8585
dependency: "direct main"
8686
description: flutter
@@ -161,10 +161,34 @@ packages:
161161
dependency: "direct main"
162162
description:
163163
name: intl
164-
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
164+
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
165165
url: "https://pub.dev"
166166
source: hosted
167-
version: "0.18.1"
167+
version: "0.19.0"
168+
leak_tracker:
169+
dependency: transitive
170+
description:
171+
name: leak_tracker
172+
sha256: "7bb2830ebd849694d1ec25bf1f44582d6ac531a57a365a803a6034ff751d2d06"
173+
url: "https://pub.dev"
174+
source: hosted
175+
version: "10.0.7"
176+
leak_tracker_flutter_testing:
177+
dependency: transitive
178+
description:
179+
name: leak_tracker_flutter_testing
180+
sha256: "9491a714cca3667b60b5c420da8217e6de0d1ba7a5ec322fab01758f6998f379"
181+
url: "https://pub.dev"
182+
source: hosted
183+
version: "3.0.8"
184+
leak_tracker_testing:
185+
dependency: transitive
186+
description:
187+
name: leak_tracker_testing
188+
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
189+
url: "https://pub.dev"
190+
source: hosted
191+
version: "3.0.1"
168192
lints:
169193
dependency: transitive
170194
description:
@@ -185,34 +209,34 @@ packages:
185209
dependency: transitive
186210
description:
187211
name: matcher
188-
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
212+
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
189213
url: "https://pub.dev"
190214
source: hosted
191-
version: "0.12.16"
215+
version: "0.12.16+1"
192216
material_color_utilities:
193217
dependency: transitive
194218
description:
195219
name: material_color_utilities
196-
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
220+
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
197221
url: "https://pub.dev"
198222
source: hosted
199-
version: "0.5.0"
223+
version: "0.11.1"
200224
meta:
201225
dependency: transitive
202226
description:
203227
name: meta
204-
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
228+
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
205229
url: "https://pub.dev"
206230
source: hosted
207-
version: "1.10.0"
231+
version: "1.15.0"
208232
path:
209233
dependency: transitive
210234
description:
211235
name: path
212-
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
236+
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
213237
url: "https://pub.dev"
214238
source: hosted
215-
version: "1.8.3"
239+
version: "1.9.0"
216240
path_parsing:
217241
dependency: transitive
218242
description:
@@ -241,7 +265,7 @@ packages:
241265
dependency: transitive
242266
description: flutter
243267
source: sdk
244-
version: "0.0.99"
268+
version: "0.0.0"
245269
source_span:
246270
dependency: transitive
247271
description:
@@ -254,10 +278,10 @@ packages:
254278
dependency: transitive
255279
description:
256280
name: stack_trace
257-
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
281+
sha256: "9f47fd3630d76be3ab26f0ee06d213679aa425996925ff3feffdec504931c377"
258282
url: "https://pub.dev"
259283
source: hosted
260-
version: "1.11.1"
284+
version: "1.12.0"
261285
stream_channel:
262286
dependency: transitive
263287
description:
@@ -270,10 +294,10 @@ packages:
270294
dependency: transitive
271295
description:
272296
name: string_scanner
273-
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
297+
sha256: "688af5ed3402a4bde5b3a6c15fd768dbf2621a614950b17f04626c431ab3c4c3"
274298
url: "https://pub.dev"
275299
source: hosted
276-
version: "1.2.0"
300+
version: "1.3.0"
277301
term_glyph:
278302
dependency: transitive
279303
description:
@@ -286,10 +310,10 @@ packages:
286310
dependency: transitive
287311
description:
288312
name: test_api
289-
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
313+
sha256: "664d3a9a64782fcdeb83ce9c6b39e78fd2971d4e37827b9b06c3aa1edc5e760c"
290314
url: "https://pub.dev"
291315
source: hosted
292-
version: "0.6.1"
316+
version: "0.7.3"
293317
typed_data:
294318
dependency: transitive
295319
description:
@@ -338,14 +362,14 @@ packages:
338362
url: "https://pub.dev"
339363
source: hosted
340364
version: "2.1.4"
341-
web:
365+
vm_service:
342366
dependency: transitive
343367
description:
344-
name: web
345-
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
368+
name: vm_service
369+
sha256: f6be3ed8bd01289b34d679c2b62226f63c0e69f9fd2e50a6b3c1c729a961041b
346370
url: "https://pub.dev"
347371
source: hosted
348-
version: "0.3.0"
372+
version: "14.3.0"
349373
window_manager:
350374
dependency: "direct main"
351375
description:
@@ -363,5 +387,5 @@ packages:
363387
source: hosted
364388
version: "6.3.0"
365389
sdks:
366-
dart: ">=3.2.0-194.0.dev <4.0.0"
367-
flutter: ">=3.7.0-0"
390+
dart: ">=3.4.0 <4.0.0"
391+
flutter: ">=3.18.0-18.0.pre.54"

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ dependencies:
3131
sdk: flutter
3232
flutter_localizations:
3333
sdk: flutter
34-
intl: ^0.18.0
34+
intl: ^0.19.0
3535

3636

3737
# The following adds the Cupertino Icons font to your application.
3838
# Use with the CupertinoIcons class for iOS style icons.
39-
fl_chart: ^0.55.0
39+
fl_chart: ^0.65.0
4040
flutter_svg_provider: ^1.0.3
4141
hotkey_manager: ^0.1.7
4242
window_manager: ^0.3.1

0 commit comments

Comments
 (0)