Change:
<del> From b5d7cb20713eff3b3729e5c5fdd2f15680a29385 Mon Sep 17 00:00:00 2001 From: Bobby Rong <rjl931189261@126.com> Date: Sun, 31 Oct 2021 23:12:46 +0800 Subject: [PATCH] build: add packagekit_backend option --- .github/workflows/main.yml      |  7 +++++++ meson_options.txt               |  1 + src/Application.vala            |  4 ++++ src/Core/BackendAggregator.vala |  2 ++ src/Core/Package.vala           | 21 +++++++++++++-------- src/Core/UpdateManager.vala     |  6 ++++++ src/Views/Homepage.vala         |  4 ++++ src/meson.build                 | 10 ++++++++-- 8 files changed, 45 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index daf13654..5dc5a2fb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -42,6 +42,13 @@ jobs: meson configure -Dcurated=false -Dpayments=false -Dsharing=false -Dname=Pop!_Shop build ninja -C build install +    - name: Build (NixOS) +      env: +        DESTDIR: out +      run: | +        meson configure -Dcurated=false -Dpayments=false -Dpackagekit_backend=false build +        ninja -C build install + lint: runs-on: ubuntu-latest diff --git a/meson_options.txt b/meson_options.txt index 0ae93d07..37a6cd8a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -4,3 +4,4 @@ option('name', type : 'string', value : 'AppCenter', description : 'The name of option('payments', type : 'boolean', value : true, description : 'Enable payment features and display paid apps') option('sharing', type : 'boolean', value : true, description : 'Display sharing features, i.e. copyable URLs to appcenter.elementary.io') option('hide_upstream_distro_apps', type : 'boolean', value : true, description : 'Used for hiding Ubuntu repo apps on elementary OS') +option('packagekit_backend', type : 'boolean', value : true, description : 'Enable PackageKit backend') diff --git a/src/Application.vala b/src/Application.vala index 65fae5aa..7c075076 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -167,9 +167,11 @@ public class AppCenter.App : Gtk.Application { var client = AppCenterCore.Client.get_default (); +#if PACKAGEKIT_BACKEND if (fake_update_packages != null) { AppCenterCore.PackageKitBackend.get_default ().fake_packages = fake_update_packages; } +#endif if (silent) { NetworkMonitor.get_default ().network_changed.connect ((available) => { @@ -183,6 +185,7 @@ public class AppCenter.App : Gtk.Application { return; } +#if PACKAGEKIT_BACKEND if (local_path != null) { var file = File.new_for_commandline_arg (local_path); @@ -192,6 +195,7 @@ public class AppCenter.App : Gtk.Application { warning ("Failed to load local AppStream XML file: %s", e.message); } } +#endif if (main_window == null) { main_window = new MainWindow (this); diff --git a/src/Core/BackendAggregator.vala b/src/Core/BackendAggregator.vala index 539dba98..feb1eaa9 100644 --- a/src/Core/BackendAggregator.vala +++ b/src/Core/BackendAggregator.vala @@ -26,8 +26,10 @@ public class AppCenterCore.BackendAggregator : Backend, Object { construct { backends = new Gee.ArrayList<unowned Backend> (); +#if PACKAGEKIT_BACKEND backends.add (PackageKitBackend.get_default ()); backends.add (UbuntuDriversBackend.get_default ()); +#endif backends.add (FlatpakBackend.get_default ()); unowned Gtk.Application app = (Gtk.Application) GLib.Application.get_default (); diff --git a/src/Core/Package.vala b/src/Core/Package.vala index d6f12f15..8dbd7a22 100644 --- a/src/Core/Package.vala +++ b/src/Core/Package.vala @@ -328,7 +328,14 @@ public class AppCenterCore.Package : Object { public string origin_description { owned get { unowned string origin = component.get_origin (); -            if (backend is PackageKitBackend) { +            if (backend is FlatpakBackend) { +                var fp_package = this as FlatpakPackage; +                if (fp_package != null && fp_package.installation == FlatpakBackend.system_installation) { +                    return _("%s (system-wide)").printf (origin); +                } +                return origin; +#if PACKAGEKIT_BACKEND +            } else if (backend is PackageKitBackend) { if (origin == APPCENTER_PACKAGE_ORIGIN) { return _("AppCenter"); } else if (origin == ELEMENTARY_STABLE_PACKAGE_ORIGIN) { @@ -336,15 +343,9 @@ public class AppCenterCore.Package : Object { } else if (origin.has_prefix ("ubuntu-")) { return _("Ubuntu (non-curated)"); } -            } else if (backend is FlatpakBackend) { -                var fp_package = this as FlatpakPackage; -                if (fp_package != null && fp_package.installation == FlatpakBackend.system_installation) { -                    return _("%s (system-wide)").printf (origin); -                } - -                return origin; } else if (backend is UbuntuDriversBackend) { return _("Ubuntu Drivers"); +#endif } return _("Unknown Origin (non-curated)"); @@ -434,11 +435,15 @@ public class AppCenterCore.Package : Object { _author_title = null; backend_details = null; +#if PACKAGEKIT_BACKEND // The version on a PackageKit package comes from the package not AppStream, so only reset the version // on other backends if (!(backend is PackageKitBackend)) { _latest_version = null; } +#else +        _latest_version = null; +#endif this.component = component; } diff --git a/src/Core/UpdateManager.vala b/src/Core/UpdateManager.vala index 9deceaf5..c92c0d37 100644 --- a/src/Core/UpdateManager.vala +++ b/src/Core/UpdateManager.vala @@ -52,6 +52,7 @@ public class AppCenterCore.UpdateManager : Object { installed_package.update_state (); } +#if PACKAGEKIT_BACKEND Pk.Results pk_updates; unowned PackageKitBackend client = PackageKitBackend.get_default (); try { @@ -60,10 +61,12 @@ public class AppCenterCore.UpdateManager : Object { warning ("Unable to get updates from PackageKit backend: %s", e.message); return 0; } +#endif uint os_count = 0; string os_desc = ""; +#if PACKAGEKIT_BACKEND var package_array = pk_updates.get_package_array (); debug ("PackageKit backend reports %d updates", package_array.length); @@ -87,6 +90,7 @@ public class AppCenterCore.UpdateManager : Object { ); } }); +#endif os_updates.component.set_pkgnames ({}); os_updates.change_information.clear_update_info (); @@ -159,6 +163,7 @@ public class AppCenterCore.UpdateManager : Object { count += 1; } +#if PACKAGEKIT_BACKEND pk_updates.get_details_array ().foreach ((pk_detail) => { var pk_package = new Pk.Package (); try { @@ -181,6 +186,7 @@ public class AppCenterCore.UpdateManager : Object { critical (e.message); } }); +#endif os_updates.update_state (); return count; diff --git a/src/Views/Homepage.vala b/src/Views/Homepage.vala index 3673903f..2e128e77 100644 --- a/src/Views/Homepage.vala +++ b/src/Views/Homepage.vala @@ -107,9 +107,13 @@ public class AppCenter.Homepage : AbstractView { column_spacing = 24, orientation = Gtk.Orientation.VERTICAL }; +#if PACKAGEKIT_BACKEND grid.add (banner_revealer); grid.add (recently_updated_revealer); grid.add (categories_label); +#else +        category_flow.margin_top = 12; +#endif grid.add (category_flow); scrolled_window = new Gtk.ScrolledWindow (null, null) { diff --git a/src/meson.build b/src/meson.build index 7b319fc6..d1d77931 100644 --- a/src/meson.build +++ b/src/meson.build @@ -12,10 +12,8 @@ appcenter_files = files( 'Core/FlatpakBackend.vala', 'Core/Job.vala', 'Core/Package.vala', -    'Core/PackageKitBackend.vala', 'Core/ScreenshotCache.vala', 'Core/Task.vala', -    'Core/UbuntuDriversBackend.vala', 'Core/UpdateManager.vala', 'Dialogs/InstallFailDialog.vala', 'Dialogs/NonCuratedWarningDialog.vala', @@ -76,6 +74,14 @@ if get_option('hide_upstream_distro_apps') args += '--define=HIDE_UPSTREAM_DISTRO_APPS' endif +if get_option('packagekit_backend') +    args += '--define=PACKAGEKIT_BACKEND' +    appcenter_files += files( +        'Core/PackageKitBackend.vala', +        'Core/UbuntuDriversBackend.vala', +    ) +endif + executable( meson.project_name(), appcenter_files, </del>

Discussion:
Elementary's AppCenter will use Flatpak in the future for their packages. Since we support Flatpak, we would be able to support AppCenter. If we support PackageKit, it would even be possible to install Nix packages with AppCenter. (Needs ) In that case native Nix packages should be preferred. I think AppCenter would be perfect for elementary's Pantheon desktop and we should support it (if possible). That way we would also be able to install all Apps from their store and even pay the developers. It would be great to be able to pay-what-you-want even for native Nix packages installed with AppCenter! what do you think? Related to
Sounds great I believe to start I can just package Appcenter. I'll do that as a part of
It seems fedora gave up on Appcenter But I think with flatpak they've given it some future in other distributions.
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly: for maintainers and people that previously touched the related code and @ mention them in a comment. on the . 3. Ask on the on .
would still be nice
I used the Software app in gnome3 and the flatpacked software is pretty meh. I could replace all the ones I was interested in with native NixPkgs. I think it's achievable for us to have a packagekit backend again, listing all the packages that have .desktop files in them. This would have many advantages over flatpack and give NixPkgs a chance at mainstream success.
while i agree with your long term goal, this is probably easier to achieve. And the elementary AppCenter has only original programs designed for elementary OS mostly not packaged for Nix.

Having had a look at it, I wouldn't object to having the appcenter in nixpkgs, but I won't be the one packaging it :)
you don't have to :) another idea i had was to automatically package all AppCenter apps for Nix (). To have a great desktop experience with a graphical package manager, a packagekit backend would be perfect. That way we don't have to develop our own GUI and it's perfectly integrated in the desktop. ()
I marked this as stale due to inactivity. &rarr;
I am not sure about the status of appcenter before my last push in , and I am not sure if can resolve something (this does not actually clean up everything related to packagekit, so maybe not a solution to ). But I am able to install some apps with the flatpak backend from it now (you can try by adding or ). Update: Just dropped more stuff. !
I would say this works now. I can install, update and remove flatpaks. ! I just had to enable flatpak support and install appcenter. And add the elementary repo: should we document these steps?
Yeah the manual needs update (), I didn't noticed that when doing . I am also thinking of whether we should make appcenter installed by default.
I am also thinking of whether we should make appcenter installed by default. We should do that only when it's usable. So we would have to enable flatpak too, but i think most nixos users wouldn't want that by default. It also should add the elementary repo automatically. I would like to have appcenter installed by default when it supports nix packages via packagekit.
Hope this works... Not familiar with appcenter's code base and cannot do more so far...
is just merged, I will see if the patch is still needed.
Probably still need for the appcenter to display stuff (at least I assume that is why nothing is displayed in GNOME Software).
I just realized that I am stupid and did not enable in previous testing. The (only) motivation of the patch is to prevent the non-working packagekit backend from blocking the flatpak backend functioning, after some testing I came to the conclusion that it should only be the case when is not enabled. I will make a pull request soon.