From: Andrew Ruthven Date: Wed, 20 Dec 2023 10:22:24 +0000 (+1300) Subject: Substitute paths on installation X-Git-Tag: 1.2.0~8 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=507728f910a98b3d52c8fcafe388ef9ca61bdb58;p=mythtv-status.git Substitute paths on installation --- diff --git a/.gitignore b/.gitignore index 8ef0993..857cb14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,14 @@ build-stamp build -debian/mythtv-status.debhelper.log .pc *.swp + +# The following files are auto-generated from .in files. +bin/health-check +bin/mythtv-update-motd +bin/mythtv_recording_now +bin/mythtv_recording_soon +molly-guard/40-mythtv-recording-soon +systemd/mythtv-status.service +systemd/mythtv-status_health-check.service +systemd/mythtv-status_update-motd.service diff --git a/Makefile b/Makefile index d76c722..42b7da5 100755 --- a/Makefile +++ b/Makefile @@ -1,12 +1,16 @@ #!/usr/bin/make -f -BINDIR=$(DESTDIR)/usr/bin -LIBEXECDIR=$(DESTDIR)/usr/libexec/mythtv-status -MANDIR=$(DESTDIR)/usr/man -MOLLY_GUARDDIR=$(DESTDIR)/etc/molly-guard/run.d -SBINDIR=$(DESTDIR)/usr/sbin -SYSTEMDDIR=$(DESTDIR)/usr/lib/systemd/system -UPDATE_MOTDDIR=$(DESTDIR)/etc/update-motd.d +BINDIR?=/usr/bin +LIBEXECDIR?=/usr/libexec/mythtv-status +MANDIR?=/usr/man +MOLLY_GUARDDIR?=/etc/molly-guard/run.d +SBINDIR?=/usr/sbin +SYSTEMDDIR?=/usr/lib/systemd/system +VARLIBDIR?=/var/lib/mythtv-status +UPDATE_MOTDDIR?=/etc/update-motd.d + +FILES_TO_SUBSTITUTE=$(wildcard */*.in) +SUBSTITUTED_FILES=$(shell echo $(FILES_TO_SUBSTITUTE) | sed 's/\.in//g') package=mythtv-status releases=sid @@ -62,6 +66,9 @@ $(tarball): ../$(package)_$(deb_version).debian.tar.?z \ ../build/$(release) +$(SUBSTITUTED_FILES): $(FILES_TO_SUBSTITUTE) + sed -e 's,@@BINDIR@@,$(BINDIR),g;s,@@VARLIBDIR@@,$(VARLIBDIR),g;s,@@LIBEXECDIR@@,$(LIBEXECDIR),g;s,@@SBINDIR@@,$(SBINDIR),g' $@.in > $@ + publish: $(RELEASE_FILES) for release in $(releases); do reprepro includedsc $$release ../build/$$release/$(package)_$(deb_version).dsc; done for release in $(releases); do reprepro includedeb $$release ../build/$$release/$(package)_$(deb_version)_all.deb; done @@ -72,37 +79,43 @@ publish: $(RELEASE_FILES) upload: $(RELEASE_FILES) for release in $(releases); do cd ../build/$$release; dput $(package)_$(deb_version)*.changes; done -install: - install -d $(BINDIR) - install -d $(SBINDIR) - install -d $(LIBEXECDIR) - install -d $(MANDIR)/man1 - install -d $(MANDIR)/man8 - install -d $(SYSTEMDDIR) - install -m 775 bin/mythtv-status $(BINDIR) - install -m 775 bin/mythtv_recording_now $(BINDIR) - install -m 775 bin/mythtv_recording_soon $(BINDIR) - install -m 775 bin/mythtv-update-motd $(SBINDIR) - install -m 775 bin/health-check $(LIBEXECDIR) - pod2man bin/mythtv-status > $(MANDIR)/man1/mythtv-status.1 - install -m 644 man/mythtv-update-motd.8 $(MANDIR)/man8 - install -m 644 man/mythtv_recording_now.1 $(MANDIR)/man1 - install -m 644 man/mythtv_recording_soon.1 $(MANDIR)/man1 - install -m 644 systemd/* $(SYSTEMDDIR) +build: $(SUBSTITUTED_FILES) + @touch build.stamp + +install: $(SUBSTITUTED_FILES) + install -d $(DESTDIR)$(BINDIR) + install -d $(DESTDIR)$(SBINDIR) + install -d $(DESTDIR)$(LIBEXECDIR) + install -d $(DESTDIR)$(MANDIR)/man1 + install -d $(DESTDIR)$(MANDIR)/man8 + install -d $(DESTDIR)$(SYSTEMDDIR) + install -m 775 bin/mythtv-status $(DESTDIR)$(BINDIR) + install -m 775 bin/mythtv_recording_now $(DESTDIR)$(BINDIR) + install -m 775 bin/mythtv_recording_soon $(DESTDIR)$(BINDIR) + install -m 775 bin/mythtv-update-motd $(DESTDIR)$(SBINDIR) + install -m 775 bin/health-check $(DESTDIR)$(LIBEXECDIR) + pod2man bin/mythtv-status > $(DESTDIR)$(MANDIR)/man1/mythtv-status.1 + install -m 644 man/mythtv-update-motd.8 $(DESTDIR)$(MANDIR)/man8 + install -m 644 man/mythtv_recording_now.1 $(DESTDIR)$(MANDIR)/man1 + install -m 644 man/mythtv_recording_soon.1 $(DESTDIR)$(MANDIR)/man1 + install -m 644 systemd/*.service $(DESTDIR)$(SYSTEMDDIR) + install -m 644 systemd/*.timer $(DESTDIR)$(SYSTEMDDIR) # Only install these files if the directories already exist. - [ -d $(MOLLY_GUARDDIR) ] && \ - install -m 775 molly-guard/* $(MOLLY_GUARDDIR) - [ -d $(UPDATE_MOTDDIR) ] && \ - install -m 775 update-motd.d/* $(UPDATE_MOTDDIR) + if [ -d $(DESTDIR)$(MOLLY_GUARDDIR) ]; then \ + install -m 775 molly-guard/40-mythtv-recording-soon $(DESTDIR)$(MOLLY_GUARDDIR); \ + fi + if [ -d $(DESTDIR)$(UPDATE_MOTDDIR) ]; then \ + install -m 775 update-motd.d/* $(DESTDIR)$(UPDATE_MOTDDIR); \ + fi test: PERL_DL_NONLAZY=1 perl "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE))" $(TEST_FILES) clean: - @rm -rf build + @rm -rf build.stamp $(SUBSTITUTED_FILES) clean_pkg: @rm -f ../$(package)*.changes ../$(package)*.dsc ../$(package)*.tar.gz ../$(package)*.deb -.PHONY: release clean install test dist +.PHONY: release clean install test dist build diff --git a/bin/health-check b/bin/health-check.in similarity index 85% rename from bin/health-check rename to bin/health-check.in index 6361457..c43c649 100755 --- a/bin/health-check +++ b/bin/health-check.in @@ -18,7 +18,7 @@ then exit fi -/usr/bin/mythtv-status --host "${HOST:-localhost}" --email "${EMAIL:-root}" "${EMAIL_ARGS:---email-only-on-alert}" +@@BINDIR@@/mythtv-status --host "${HOST:-localhost}" --email "${EMAIL:-root}" "${EMAIL_ARGS:---email-only-on-alert}" # Keep things happy by always having a return code of 0. exit 0 diff --git a/bin/mythtv-update-motd b/bin/mythtv-update-motd.in similarity index 94% rename from bin/mythtv-update-motd rename to bin/mythtv-update-motd.in index be0042b..550c909 100755 --- a/bin/mythtv-update-motd +++ b/bin/mythtv-update-motd.in @@ -25,7 +25,7 @@ if [ "$-" = "*i*" ] || [ -t 0 ] then echo Going to update the MOTD for the MythTV status else - if [ "$UPDATE_MOTD" != "yes" ] || [ -f /var/lib/mythtv-status/motd_update_disabled ] + if [ "$UPDATE_MOTD" != "yes" ] || [ -f @@VARLIBDIR@@/motd_update_disabled ] then exit fi @@ -90,7 +90,7 @@ fi [ "$UPDATE_MOTD_ARGS" = "" ] && UPDATE_MOTD_ARGS=$ARGS ret=0 -mythtv-status $UPDATE_MOTD_ARGS -h "${HOST:-localhost}" >> $TEMPFILE || ret=$? +@@BINDIR@@/mythtv-status $UPDATE_MOTD_ARGS -h "${HOST:-localhost}" >> $TEMPFILE || ret=$? if [ $ret -eq 0 ] || [ $ret -eq 1 ]; then if [ ! -f $TEMPFILE ]; then echo My temporary file has gone away, failed. diff --git a/bin/mythtv_recording_now b/bin/mythtv_recording_now.in similarity index 88% rename from bin/mythtv_recording_now rename to bin/mythtv_recording_now.in index 62368a7..d27b1f8 100755 --- a/bin/mythtv_recording_now +++ b/bin/mythtv_recording_now.in @@ -15,7 +15,7 @@ [ -r /etc/sysconfig/mythtv-status ] && . /etc/sysconfig/mythtv-status -/usr/bin/mythtv-status -h "${HOST:-localhost}" --return-code-only --recording-now +@@BINDIR@@/mythtv-status -h "${HOST:-localhost}" --return-code-only --recording-now if [ $? -eq 1 ] then diff --git a/bin/mythtv_recording_soon b/bin/mythtv_recording_soon.in similarity index 92% rename from bin/mythtv_recording_soon rename to bin/mythtv_recording_soon.in index 65d1c6a..0c2e653 100755 --- a/bin/mythtv_recording_soon +++ b/bin/mythtv_recording_soon.in @@ -21,7 +21,7 @@ else ARGS="--recording-in-warn 600" fi -/usr/bin/mythtv-status -h "${HOST:-localhost}" --return-code-only \ +@@BINDIR@@/mythtv-status -h "${HOST:-localhost}" --return-code-only \ --recording-now --next-recording $ARGS if [ $? -eq 1 ] diff --git a/debian/patches/series b/debian/patches/series index 28f24fa..5a81895 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1 @@ -makefile-debian-paths.patch +#makefile-debian-paths.patch diff --git a/molly-guard/40-mythtv-recording-soon b/molly-guard/40-mythtv-recording-soon.in similarity index 80% rename from molly-guard/40-mythtv-recording-soon rename to molly-guard/40-mythtv-recording-soon.in index d12e893..b29f53c 100755 --- a/molly-guard/40-mythtv-recording-soon +++ b/molly-guard/40-mythtv-recording-soon.in @@ -8,8 +8,8 @@ ME=molly-guard -if [ ! -f /usr/bin/mythtv_recording_soon ]; then - echo "I: $ME: I can't find /usr/bin/mythtv_recording_soon, skipping check" >&2 +if [ ! -f @@BINDIR@@/mythtv_recording_soon ]; then + echo "I: $ME: I can't find @@BINDIR@@/mythtv_recording_soon, skipping check" >&2 exit 0 fi @@ -22,7 +22,7 @@ sigh() } -if /usr/bin/mythtv_recording_soon; then +if @@BINDIR@@/mythtv_recording_soon; then trap 'echo;sigh' 1 2 3 10 12 15 printf "MythTV is either recording now, or will be soon. Type YES to %s: " "$MOLLYGUARD_CMD" read CONFIRM || : diff --git a/systemd/mythtv-status.service b/systemd/mythtv-status.service.in similarity index 50% rename from systemd/mythtv-status.service rename to systemd/mythtv-status.service.in index 84dcd19..8d7015e 100644 --- a/systemd/mythtv-status.service +++ b/systemd/mythtv-status.service.in @@ -7,9 +7,9 @@ Documentation=man:mythtv-status [Service] Type=oneshot RemainAfterExit=true -ExecStart=/bin/sh -c "rm -f /var/lib/mythtv-status/motd_update_disabled" -ExecStart=/usr/sbin/mythtv-update-motd -ExecStop=/bin/sh -c "touch /var/lib/mythtv-status/motd_update_disabled; rm -f /run/motd.mythtv-status"; +ExecStart=/bin/sh -c "rm -f @@VARLIBDIR@@/motd_update_disabled" +ExecStart=@@SBINDIR@@/mythtv-update-motd +ExecStop=/bin/sh -c "touch @@VARLIBDIR@@/motd_update_disabled; rm -f /run/motd.mythtv-status"; [Install] WantedBy=multi-user.target diff --git a/systemd/mythtv-status_health-check.service b/systemd/mythtv-status_health-check.service.in similarity index 70% rename from systemd/mythtv-status_health-check.service rename to systemd/mythtv-status_health-check.service.in index fbd0a0a..28d549e 100644 --- a/systemd/mythtv-status_health-check.service +++ b/systemd/mythtv-status_health-check.service.in @@ -4,4 +4,4 @@ Documentation=man:mythtv-status(1) [Service] Type=oneshot -ExecStart=/usr/libexec/mythtv-status/health-check +ExecStart=@@LIBEXECDIR@@/health-check diff --git a/systemd/mythtv-status_update-motd.service b/systemd/mythtv-status_update-motd.service.in similarity index 72% rename from systemd/mythtv-status_update-motd.service rename to systemd/mythtv-status_update-motd.service.in index 8ad6dfb..0e48497 100644 --- a/systemd/mythtv-status_update-motd.service +++ b/systemd/mythtv-status_update-motd.service.in @@ -4,4 +4,4 @@ Documentation=man:mythtv-update-motd(8) [Service] Type=oneshot -ExecStart=/usr/sbin/mythtv-update-motd +ExecStart=@@SBINDIR@@/mythtv-update-motd