Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide apps from the Ubuntu repos #1492

Merged
merged 19 commits into from
Apr 2, 2021
Merged

Conversation

meisenzahl
Copy link
Member

@meisenzahl meisenzahl commented Feb 20, 2021

Closes #1432

Before

Bildschirmfoto von 2021-02-20 08-02-19

After

Bildschirmfoto von 2021-02-20 08-07-11

Implementation

Most simple way to hide apps from Ubuntu repos based on

public string origin_description {
owned get {
unowned string origin = component.get_origin ();
if (backend is PackageKitBackend) {
if (origin == APPCENTER_PACKAGE_ORIGIN) {
return _("AppCenter");
} else if (origin == DEPRECATED_ELEMENTARY_STABLE_PACKAGE_ORIGIN || origin == ELEMENTARY_STABLE_PACKAGE_ORIGIN) {
return _("elementary Updates");
} else if (origin.has_prefix ("ubuntu-")) {
return _("Ubuntu (non-curated)");
}

@hanaral
Copy link

hanaral commented Feb 22, 2021

This is obviously a good thing in the long term, but should it be done before releasing a new version of io.elementary.BaseApp?

@davidmhewitt
Copy link
Member

davidmhewitt commented Feb 24, 2021

The more efficient way to do this would be to ensure that those appstream components are never loaded into the pool in the first place, so we don't have to iterate over however many thousand components and do a string comparison.

I think this patch (against master) achieves that but I haven't had chance to test it thoroughly:

diff --git a/src/Core/PackageKitBackend.vala b/src/Core/PackageKitBackend.vala
index cd258abc..ceb34167 100644
--- a/src/Core/PackageKitBackend.vala
+++ b/src/Core/PackageKitBackend.vala
@@ -151,6 +151,15 @@ public class AppCenterCore.PackageKitBackend : Backend, Object {
 
         package_list = new Gee.HashMap<string, AppCenterCore.Package> (null, null);
         appstream_pool = new AppStream.Pool ();
+
+        // Only use a user cache, the system cache probably contains all the Ubuntu components
+        appstream_pool.set_cache_flags (AppStream.CacheFlags.USE_USER);
+
+        // Clear out the default set of metadata locations and only use the folder that gets populated
+        // with elementary's AppStream data.
+        appstream_pool.clear_metadata_locations ();
+        appstream_pool.add_metadata_location ("/usr/share/app-info");
+
         // We don't want to show installed desktop files here
         appstream_pool.set_flags (appstream_pool.get_flags () & ~AppStream.PoolFlags.READ_DESKTOP_FILES);

The other thing we almost certainly want to do here is guard this with a meson option so Pop!_OS can easily disable this downstream, and other distros (where this will be less portable) can choose to disable it too.

@meisenzahl
Copy link
Member Author

@davidmhewitt thanks for looking into this and providing a solution. I have modified my implementation based on your suggestion and guarded it with a meson option.

@cassidyjames
Copy link
Contributor

It looks like this branch breaks the "More apps from…" footer at the bottom; at least in this branch, I no longer see apps from the same app developer, even when they are from Flathub.

@davidmhewitt
Copy link
Member

Yeah, I wonder why 😆

public Gee.Collection<Package> get_packages_by_author (string author, int max) {
return new Gee.ArrayList<Package> ();
}

meson_options.txt Outdated Show resolved Hide resolved
@davidmhewitt davidmhewitt merged commit 40fd578 into master Apr 2, 2021
@davidmhewitt davidmhewitt deleted the hide-apps-from-the-ubuntu-repos branch April 2, 2021 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide apps from the Ubuntu repos
4 participants