Skyedra / UnspamifyUbuntu

Remove spam from Ubuntu
MIT License
167 stars 9 forks source link

Ubuntu 22.04 update-manager needs patch / not compatible with Unspamify #10

Closed reneas closed 9 months ago

reneas commented 10 months ago

I installed fake-ubuntu-advantage-tools and everything is working fine, no Ubuntu Pro ads showing anymore. Problem is now: I can't open the Software Update Settings neither from the update dialogue nor from the menu . If I press on the button "Einstellungen" (Settings in German" in the following window it will only show a loading icon for a second and then return to the update window without opening any settings. image

Also after finishing the update I can't access the settings through the button shown there: image

I am running Ubuntu 22.04.3 LTS with GNOME 42.9 on a Lenovo ThinkPad L13 Yoga.

Skyedra commented 10 months ago

Hmm, looks like this is update-manager program maybe? Did you do the "Patch Update Manager (for Ubuntu 23.04+ Desktop only)" section of instructions?

I actually just do updates via command line myself heh so I haven't tried this part much

reneas commented 10 months ago

Yes this is the update-manager and no I didn't try the section you mentioned since it says "for Ubuntu 23.04+ Desktop only" and I'm running 22.04. Thing is, I do updates via command line as well, but the update-manager pops up by itself from time to time, so I'm using that as well when it presents itself.

Do you think I should try to patch the update-manager as shown in the Readme section?

Skyedra commented 10 months ago

Hmmm, I have not tried it before, so proceed with caution. I would suggest backing up the affected files from that section first. Then, if the dry run check (first step) does not cleanly apply, then do not proceed to the second step. Good luck and let us know how it goes :)

reneas commented 10 months ago

okay so first it had issues, because the file is read-only. after runnig it with sudo I got the following error message:

checking file /usr/lib/python3/dist-packages/UpdateManager/UpdateManager.py
Hunk #1 FAILED at 44.
Hunk #2 FAILED at 278.
2 out of 3 hunks FAILED

Guess I shouldn't proceed with the patch :cry:

Maybe its just fine, that I can't access the Preferences GUI and I'll be fine with the command line. Was just noticing this and thought I better tell you guys

Skyedra commented 10 months ago

Correct, definitely don't proceed as is :sweat_smile:

Someone will need to write a patch for the 22.04 version (if you end up trying this, definitely send it along! ;))

For now, I will update the issue title and leave it open, since it would be nice for this project to be able to support this in 22.04 given it will still be LTS supported until April 2027. Thanks for the report, though!

reneas commented 10 months ago

Unfortunately I think fixing this issue is way out of my league, so I'll have to pass and let someone else do the hard work :)

reneas commented 10 months ago

some further information on this: when I run the update-manager from terminal and hit the button to get to the settings, the command line output looks like this

Traceback (most recent call last):
  File "/usr/bin/software-properties-gtk", line 37, in <module>
    from softwareproperties.gtk.SoftwarePropertiesGtk import SoftwarePropertiesGtk
  File "/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py", line 57, in <module>
    from .UbuntuProPage import UbuntuProPage
  File "/usr/lib/python3/dist-packages/softwareproperties/gtk/UbuntuProPage.py", line 27, in <module>
    from .DialogUaAttach import DialogUaAttach
  File "/usr/lib/python3/dist-packages/softwareproperties/gtk/DialogUaAttach.py", line 25, in <module>
    from uaclient.api.u.pro.attach.magic.initiate.v1 import initiate
ModuleNotFoundError: No module named 'uaclient'

so after commenting all the import lines in /usr/lib/python3/dist-packages/softwareproperties/gtk/DialogUaAttach.py that relate to uaclient I got the following message:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 177, in activate_name_owner
    return self.get_name_owner(bus_name)
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 361, in get_name_owner
    return self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NameHasNoOwner: Could not get owner of name 'com.canonical.UbuntuAdvantage': no such name

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/software-properties-gtk", line 100, in <module>
    app = SoftwarePropertiesGtk(datadir=options.data_dir, options=options, file=file)
  File "/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py", line 254, in __init__
    self.init_ubuntu_pro()
  File "/usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py", line 1661, in init_ubuntu_pro
    self.ubuntu_pro_page = UbuntuProPage(self)
  File "/usr/lib/python3/dist-packages/softwareproperties/gtk/UbuntuProPage.py", line 120, in __init__
    self.ua_object = bus.get_object('com.canonical.UbuntuAdvantage', '/com/canonical/UbuntuAdvantage/Manager')
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 241, in get_object
    return self.ProxyObjectClass(self, bus_name, object_path,
  File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 250, in __init__
    self._named_service = conn.activate_name_owner(bus_name)
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 182, in activate_name_owner
    self.start_service_by_name(bus_name)
  File "/usr/lib/python3/dist-packages/dbus/bus.py", line 277, in start_service_by_name
    return (True, self.call_blocking(BUS_DAEMON_NAME, BUS_DAEMON_PATH,
  File "/usr/lib/python3/dist-packages/dbus/connection.py", line 652, in call_blocking
    reply_message = self.send_message_with_reply_and_block(
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.ServiceUnknown: The name com.canonical.UbuntuAdvantage was not provided by any .service files

So it seems the program is still looking for Ubuntu Advantage and can't seem to find it. No idea on how to fix that issue but this should be a good starting point

reneas commented 10 months ago

Okay sorry for the back and forth but after thinking about it, maybe changing the contents of /usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py and stopping it from calling for any kind of Ubuntu Pro related library or function would be the better way? I'm new to Python but I'm gonna try to find a solution, no promises made though!

reneas commented 10 months ago

okay final comment on this :rofl:

after commenting the following lines it works again!

line 57:

from .UbuntuProPage import UbuntuProPage

line 254:

self.init_ubuntu_pro()

lines 1660 & 1661:

def init_ubuntu_pro(self):
        self.ubuntu_pro_page = UbuntuProPage(self)

maybe there is some way of implementing this into the package?

Skyedra commented 10 months ago

Neat! If you want to put that together as a .patch file like the other one, I'll add it to the instructions :)

reneas commented 10 months ago

I'll look into it tomorrow, thanks for the instructions :)

reneas commented 10 months ago

okay so i saw that there is already an open pull request #6 where the required path files are pretty much already there. i still made two new ones, which solve the issue by

  1. deactivating ubuntu pro features in the /usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py with this patch file:

SoftwarePropertiesGtk.py.patch

command for this one: patch /usr/lib/python3/dist-packages/softwareproperties/gtk/SoftwarePropertiesGtk.py /path/to/SoftwarePropertiesGtk.py.patch

  1. deleting the whole ubuntu pro tab from the Software Properties in /usr/share/software-properties/gtkbuilder/main.ui with this patch file:

main.ui.patch

command for this one:

patch /usr/share/software-properties/gtkbuilder/main.ui /path/to/main.ui.patch

unfortunately github told me that it doesn't support the file type although *.patch files are in the list of supported file types so i uploaded them as .txt. obviously before applying the patch the .txt file extension has to be removed.

with this setup i have no problems with ubuntu pro anywhere. so maybe we can merge this issue and #6 and close them after adding the files to the repo?

Skyedra commented 9 months ago

Cool, yeah I didn't realize that older patch only worked on 22.04. So now that I understand that, I went ahead and approved it and updated the docs.

I'm using the originally supplied patch because:

If the separated files does anything the earlier single file does not, please let me know. Regardless, thanks for the additional information as it did help :)