3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #158787: Pantheon: enable packagekit and drop appcenter patch

This commit is contained in:
Bobby Rong 2022-02-10 12:56:27 +08:00 committed by GitHub
commit 4118c7ad03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 256 deletions

View file

@ -135,6 +135,7 @@ in
services.bamf.enable = true;
services.colord.enable = mkDefault true;
services.fwupd.enable = mkDefault true;
services.packagekit.enable = mkDefault true;
services.touchegg.enable = mkDefault true;
services.touchegg.package = pkgs.pantheon.touchegg;
services.tumbler.enable = mkDefault true;
@ -272,7 +273,7 @@ in
})
(mkIf serviceCfg.apps.enable {
environment.systemPackages = (with pkgs.pantheon; pkgs.gnome.removePackagesByName [
environment.systemPackages = with pkgs.pantheon; pkgs.gnome.removePackagesByName ([
elementary-calculator
elementary-calendar
elementary-camera
@ -286,7 +287,11 @@ in
elementary-terminal
elementary-videos
epiphany
] config.environment.pantheon.excludePackages);
] ++ lib.optionals config.services.flatpak.enable [
# Only install appcenter if flatpak is enabled before
# https://github.com/NixOS/nixpkgs/issues/15932 is resolved.
appcenter
]) config.environment.pantheon.excludePackages;
# needed by screenshot
fonts.fonts = [

View file

@ -105,10 +105,10 @@ switchboard-with-plugs.override {
</term>
<listitem>
<para>
AppCenter has been available since 20.03, but it is of little use. This is because there is no functioning PackageKit backend for Nix 2.0. Starting from 21.11, the Flatpak backend should work so you can install some Flatpak applications using it. See this <link xlink:href="https://github.com/NixOS/nixpkgs/issues/70214">issue</link>.
AppCenter has been available since 20.03. Starting from 21.11, the Flatpak backend should work so you can install some Flatpak applications using it. However, due to missing appstream metadata, the Packagekit backend does not function currently. See this <link xlink:href="https://github.com/NixOS/nixpkgs/issues/15932">issue</link>.
</para>
<para>
To use AppCenter on NixOS, add <literal>pantheon.appcenter</literal> to <xref linkend="opt-environment.systemPackages" />, <link linkend="module-services-flatpak">enable Flatpak support</link> and optionally add the <literal>appcenter</literal> Flatpak remote:
If you are using Pantheon, AppCenter should be installed by default if you have <link linkend="module-services-flatpak">Flatpak support</link> enabled. If you also wish to add the <literal>appcenter</literal> Flatpak remote:
</para>
<screen>
<prompt>$ </prompt>flatpak remote-add --if-not-exists appcenter https://flatpak.elementary.io/repo.flatpakrepo

View file

@ -1,240 +0,0 @@
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,

View file

@ -38,13 +38,6 @@ stdenv.mkDerivation rec {
sha256 = "sha256-xktIHQHmz5gh72NEz9UQ9fMvBlj1BihWxHgxsHmTIB0=";
};
patches = [
# Introduces a packagekit_backend meson flag.
# Makes appcenter actually work by using only the flatpak backend.
# https://github.com/elementary/appcenter/pull/1739
./add-packagekit-backend-option.patch
];
nativeBuildInputs = [
appstream-glib
dbus # for pkg-config
@ -77,8 +70,6 @@ stdenv.mkDerivation rec {
mesonFlags = [
"-Dpayments=false"
"-Dcurated=false"
# This option is introduced in add-packagekit-backend-option.patch
"-Dpackagekit_backend=false"
];
postPatch = ''

View file

@ -47,8 +47,7 @@ stdenv.mkDerivation rec {
'';
preInstall = ''
# Install our override for plank dockitems as Appcenter is not ready to be preinstalled.
# See: https://github.com/NixOS/nixpkgs/issues/70214.
# Install our override for plank dockitems as the desktop file path is different.
schema_dir=$out/share/glib-2.0/schemas
install -D ${./overrides/plank-dockitems.gschema.override} $schema_dir/plank-dockitems.gschema.override

View file

@ -0,0 +1,2 @@
[PlankDockItemPreferences]
Launcher=file:///run/current-system/sw/share/applications/io.elementary.appcenter.desktop

View file

@ -1,2 +1,2 @@
[net.launchpad.plank.dock.settings]
dock-items=['gala-multitaskingview.dockitem','org.gnome.Epiphany.dockitem','io.elementary.mail.dockitem','io.elementary.tasks.dockitem','io.elementary.calendar.dockitem','io.elementary.music.dockitem','io.elementary.videos.dockitem','io.elementary.photos.dockitem','io.elementary.switchboard.dockitem']
dock-items=['gala-multitaskingview.dockitem','org.gnome.Epiphany.dockitem','io.elementary.mail.dockitem','io.elementary.tasks.dockitem','io.elementary.calendar.dockitem','io.elementary.music.dockitem','io.elementary.videos.dockitem','io.elementary.photos.dockitem','io.elementary.switchboard.dockitem','io.elementary.appcenter.dockitem']