package/gpsd: Fix systemd service installation and paths
PATCH 1/1 package/gpsd: Fix systemd service installation and paths
Fix several issues with systemd service file installation for gpsd:
-systemd support in the gpsd build was defaulting to enabled or not based on whether the host system had systemd directories present. Set this explicitly based on whether BR2_INIT_SYSTEMD is set.
-The installed systemd service files referenced paths in /usr/local when the actual binaries are installed in /usr. Replace /usr/local with /usr in the installed service files.
-When BR2_PACKAGE_HAS_UDEV was enabled, all of the binaries were re-installed again, along with the udev rules, as part of the post-install hooks. Just choose between using install and udev-install based on whether udev is enabled to avoid redundant re-installations.
--- package/gpsd/gpsd.mk | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
package/gpsd/gpsd.mk +12 -9
@@ -24,7 +24,8 @@ GPSD_SCONS_OPTS = \ sysroot=$(STAGING_DIR)\ strip=no\ python=no \ - qt=no + qt=no \ + systemd=$(if $(BR2_INIT_SYSTEMD),yes,no) ifeq ($(BR2_PACKAGE_NCURSES),y) GPSD_DEPENDENCIES += ncurses
@@ -216,7 +217,7 @@ define GPSD_INSTALL_TARGET_CMDS DESTDIR=$(TARGET_DIR) \ $(HOST_DIR)/bin/python2 $(SCONS) \ $(GPSD_SCONS_OPTS) \ - install) + $(if $(BR2_PACKAGE_HAS_UDEV),udev-install,install)) endef define GPSD_INSTALL_INIT_SYSV
@@ -224,6 +225,14 @@ define GPSD_INSTALL_INIT_SYSV $(SED) 's,^DEVICES=.*,DEVICES=$(BR2_PACKAGE_GPSD_DEVICES),' $(TARGET_DIR)/etc/init.d/S50gpsd endef +define GPSD_INSTALL_INIT_SYSTEMD +# systemd unit files are installed automatically, but need to update the +# /usr/local path references in the provided files to /usr. + $(SED) 's%/usr/local%/usr%' \ + $(TARGET_DIR)/usr/lib/systemd/system/gpsd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/gpsdctl at .service +endef + define GPSD_INSTALL_STAGING_CMDS (cd $(@D); \ $(GPSD_SCONS_ENV) \
@@ -233,16 +242,10 @@ define GPSD_INSTALL_STAGING_CMDS install) endef -# After installing the udev rule, make it writable so that this +# After the udev rule is installed, make it writable so that this # package can be re-built/re-installed. ifeq ($(BR2_PACKAGE_HAS_UDEV),y) define GPSD_INSTALL_UDEV_RULES - (cd $(@D); \ - $(GPSD_SCONS_ENV) \ - DESTDIR=$(TARGET_DIR) \ - $(HOST_DIR)/bin/python2 $(SCONS) \ - $(GPSD_SCONS_OPTS) \ - udev-install) chmod u+w $(TARGET_DIR)/lib/udev/rules.d/25-gpsd.rules endef
Signature · 1 line
1.8.3.1
PATCH 1/1 package/gpsd: Fix systemd service installation and paths
Hello Robert,
Thanks for this patch!
Quoted 9 lines · On Wed, 29 May 2019 17:02:41 -0600 Robert Hancock <[email protected]> wrote:
Fix several issues with systemd service file installation for gpsd:
-systemd support in the gpsd build was defaulting to enabled or not based on whether the host system had systemd directories present. Set this explicitly based on whether
BR2_INIT_SYSTEMDis set.-The installed systemd service files referenced paths in
/usr/localwhen the actual binaries are installed in /usr. Replace/usr/localwith /usr in the installed service files.
I have not looked into the gpsd build system, but I was wondering if there was a way to convince gpsd to produce those files with the right prefix (i.e /usr instead or /usr/local).
Quoted 4 lines
-When
BR2_PACKAGE_HAS_UDEVwas enabled, all of the binaries were re-installed again, along with the udev rules, as part of the post-install hooks. Just choose between using install and udev-install based on whether udev is enabled to avoid redundant re-installations.
This should be part of a separate patch, because it's not a fix, just an unrelated optimization.
But in fact, the systemd fixes could also be two separate patches.
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/1 package/gpsd: Fix systemd service installation and paths
Quoted 13 lines · Thomas Petazzoni
Hello Robert,
Thanks for this patch!
Quoted 6 lines · On Wed, 29 May 2019 17:02:41 -0600 Robert Hancock <[email protected]> wrote:
Fix several issues with systemd service file installation for gpsd:
-systemd support in the gpsd build was defaulting to enabled or not based on whether the host system had systemd directories present. Set this explicitly based on whether
BR2_INIT_SYSTEMDis set.
Quoted 7 lines
Quoted 3 lines
-The installed systemd service files referenced paths in
/usr/localwhen the actual binaries are installed in /usr. Replace/usr/localwith /usr in the installed service files.I have not looked into the gpsd build system, but I was wondering if there was a way to convince gpsd to produce those files with the right prefix (i.e /usr instead or
/usr/local).
As far as I can see, no - the service files are just part of the gpsd source tree and the build system installs them as-is, there's no mechanism provided to set the prefix etc.
Quoted 8 lines
Quoted 5 lines
-When
BR2_PACKAGE_HAS_UDEVwas enabled, all of the binaries were re-installed again, along with the udev rules, as part of the post-install hooks. Just choose between using install and udev-install based on whether udev is enabled to avoid redundant re-installations.This should be part of a separate patch, because it's not a fix, just an unrelated optimization.
I suppose it wasn't obvious from the description, but this issue actually caused problems with fixing the systemd service file paths, since we would fix the paths after the files were installed, but then udev-install was being run afterwards and reinstalled everything, which wiped out our fix.
Quoted 7 lines
But in fact, the systemd fixes could also be two separate patches.
Thanks,
Thomas
Signature · 4 lines
Robert Hancock Senior Software Developer SED Systems, a division of Calian Ltd. Email: hancock at sedsystems.ca
Arnout Vandecappelle
AppliedPATCH 1/1 package/gpsd: Fix systemd service installation and paths
In reply to Robert HancockQuoted 10 lines · Robert Hancock
Fix several issues with systemd service file installation for gpsd:
-systemd support in the gpsd build was defaulting to enabled or not based on whether the host system had systemd directories present. Set this explicitly based on whether
BR2_INIT_SYSTEMDis set.-The installed systemd service files referenced paths in
/usr/localwhen the actual binaries are installed in /usr. Replace/usr/localwith /usr in the installed service files.
Quoted 6 lines
-When
BR2_PACKAGE_HAS_UDEVwas enabled, all of the binaries were re-installed again, along with the udev rules, as part of the post-install hooks. Just choose between using install and udev-install based on whether udev is enabled to avoid redundant re-installations.Signed-off-by Robert Hancock <[email protected]>
Applied to master, thanks, with a small changes.
package/gpsd/gpsd.mk define GPSD_INSTALL_INIT_SYSV · line 230
Quoted 4 lines
package/gpsd/gpsd.mk +3
-0+define GPSD_INSTALL_INIT_SYSTEMD +# systemd unit files are installed automatically, but need to update the +# /usr/local path references in the provided files to /usr.
Comments inside a define get passed to the shell, which is not so nice. So I
moved these out before the define.
Regards,
Arnout
Quoted 27 lines
package/gpsd/gpsd.mk +6
-7+ $(SED) 's%/usr/local%/usr%' \ + $(TARGET_DIR)/usr/lib/systemd/system/gpsd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/gpsdctl at .service +endef + define GPSD_INSTALL_STAGING_CMDS (cd $(@D); \ $(GPSD_SCONS_ENV) \@@ -233,16 +242,10 @@ define GPSD_INSTALL_STAGING_CMDS install) endef -# After installing the udev rule, make it writable so that this +# After the udev rule is installed, make it writable so that this # package can be re-built/re-installed. ifeq ($(BR2_PACKAGE_HAS_UDEV),y) define GPSD_INSTALL_UDEV_RULES - (cd $(@D); \ - $(GPSD_SCONS_ENV) \ - DESTDIR=$(TARGET_DIR) \ - $(HOST_DIR)/bin/python2 $(SCONS) \ - $(GPSD_SCONS_OPTS) \ - udev-install) chmod u+w $(TARGET_DIR)/lib/udev/rules.d/25-gpsd.rules endef