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

Bug: Remove reliance on usrmerge diversions #3252

Open
orndorffgrant opened this issue Aug 2, 2024 · 1 comment
Open

Bug: Remove reliance on usrmerge diversions #3252

orndorffgrant opened this issue Aug 2, 2024 · 1 comment
Assignees
Labels
bug something isn't working P - Low S - Triaged Must have priority label

Comments

@orndorffgrant
Copy link
Collaborator

Description of the bug

ubuntu-pro-client ships systemd units to /libon all releases, which are then diverted to /usr/lib on focal onward.

Expected behavior

ubuntu-pro-client should ship systemd units to the correct location per ubuntu release. /lib on bionic and earlier, /usr/lib on focal and later.

Current behavior

ubuntu-pro-client ships systemd units to /lib on all releases, which are then diverted to /usr/lib on focal onward.

To Reproduce

dpkg -L will show the diversion on any ubuntu machine focal onward

System information:

  • Ubuntu release: focal onward
  • Pro Client version: 34

Additional context

At least on xenial, the units need to be delivered to /lib - if they are put in /usr/lib, then they won't be correctly enabled and started.

@orndorffgrant orndorffgrant added the bug something isn't working label Aug 2, 2024
@orndorffgrant orndorffgrant added S - Triaged Must have priority label P - Low and removed triaged labels Sep 12, 2024
@dheyay
Copy link
Contributor

dheyay commented Sep 18, 2024

The current issue arises because the debian helper version we are using doesn't properly handle systemd files in the /usr/lib/ directory. Instead, it looks for files in the outdated /lib/ directory. Fixing this might require a re-write of the debian/rules using a newer debian helper version.

Reference: https://github.com/Debian/debhelper/blob/master/dh_systemd_enable

Short fix tried to resolve the issue was:

In debian/rules:
Changes take into account we still use the /usr/lib focal onwards

ifneq (${VERSION_ID},"16.04")
	# Only install cloud-id-shim on Xenial
-       rm $(CURDIR)/debian/ubuntu-pro-client/lib/systemd/system/ubuntu-advantage-cloud-id-shim.service
+	ifeq (${VERSION_ID},"18.04")
+		# If on bionic, remove from /lib/
+		rm $(CURDIR)/debian/ubuntu-pro-client/lib/systemd/system/ubuntu-advantage-cloud-id-shim.service
+	else
+		# For other versions, remove from usr/lib/
+		rm $(CURDIR)/debian/ubuntu-pro-client/usr/lib/systemd/system/ubuntu-advantage-cloud-id-shim.service
+	endif
endif

	# Move ua-auto-attach.service out to ubuntu-pro-auto-attach
-	mkdir -p debian/ubuntu-pro-auto-attach/lib/systemd/system
-	mv debian/ubuntu-pro-client/lib/systemd/system/ua-auto-attach.* debian/ubuntu-pro-auto-attach/lib/systemd/system
+	if [ "${VERSION_ID}" = "16.04" ] || [ "${VERSION_ID}" = "18.04" ]; then
+		mkdir -p debian/ubuntu-pro-auto-attach/lib/systemd/system
+		mv debian/ubuntu-pro-client/lib/systemd/system/ua-auto-attach.* debian/ubuntu-pro-auto-attach/lib/systemd/system
+	else
+		mkdir -p debian/ubuntu-pro-auto-attach/usr/lib/systemd/system
+		mv debian/ubuntu-pro-client/usr/lib/systemd/system/ua-auto-attach.* debian/ubuntu-pro-auto-attach/usr/lib/systemd/system
+	fi

And in setup.py:
To re-direct the files to the correct directory based on release

def _get_data_files():
+    series = system.get_release_info().series
+    if series == "xenial":
+        systemd_files = ("/lib/systemd/system", glob.glob("systemd/*"))
+    else:
+        systemd_files =  ("/usr/lib/systemd/system", glob.glob("systemd/*"))
    return [
        ("/etc/ubuntu-advantage", ["uaclient.conf"]),
        ("/etc/update-motd.d", glob.glob("update-motd.d/*")),
        ("/usr/lib/ubuntu-advantage", glob.glob("lib/[!_]*")),
        ("/usr/share/keyrings", glob.glob("keyrings/*")),
        (
            "/etc/update-manager/release-upgrades.d/",
            ["release-upgrades.d/ubuntu-advantage-upgrades.cfg"],
        ),
        ("/etc/apt/preferences.d", glob.glob("preferences.d/*")),
        (defaults.CONFIG_DEFAULTS["data_dir"], []),
-        ("/lib/systemd/system", glob.glob("systemd/*")),
+       systemd_files,
        (
            "/usr/share/apport/package-hooks",
            ["apport/source_ubuntu-advantage-tools.py"],
        ),
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working P - Low S - Triaged Must have priority label
Projects
None yet
Development

No branches or pull requests

2 participants