]> git.etc.gen.nz Git - mythtv-status.git/commitdiff
Substitute paths on installation
authorAndrew Ruthven <andrew@etc.gen.nz>
Wed, 20 Dec 2023 10:22:24 +0000 (23:22 +1300)
committerAndrew Ruthven <andrew@etc.gen.nz>
Wed, 1 Jan 2025 07:49:43 +0000 (20:49 +1300)
.gitignore
Makefile
bin/health-check.in [moved from bin/health-check with 85% similarity]
bin/mythtv-update-motd.in [moved from bin/mythtv-update-motd with 94% similarity]
bin/mythtv_recording_now.in [moved from bin/mythtv_recording_now with 88% similarity]
bin/mythtv_recording_soon.in [moved from bin/mythtv_recording_soon with 92% similarity]
debian/patches/series
molly-guard/40-mythtv-recording-soon.in [moved from molly-guard/40-mythtv-recording-soon with 80% similarity]
systemd/mythtv-status.service.in [moved from systemd/mythtv-status.service with 50% similarity]
systemd/mythtv-status_health-check.service.in [moved from systemd/mythtv-status_health-check.service with 70% similarity]
systemd/mythtv-status_update-motd.service.in [moved from systemd/mythtv-status_update-motd.service with 72% similarity]

index 8ef099327d9269b1fd824107d0756dc70ba77f58..857cb14a0543f41f528f41c4cee713d54fcffbac 100644 (file)
@@ -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
index d76c7224c9404878585b8d9efee05a331611b512..42b7da5f7be21533ddb89bb345386fc12801d523 100755 (executable)
--- 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
similarity index 85%
rename from bin/health-check
rename to bin/health-check.in
index 636145768478f7b164858b39a4888b694c13ec66..c43c6490b8a0cd9ba4c9bb4c33280b414eb1f7a7 100755 (executable)
@@ -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
similarity index 94%
rename from bin/mythtv-update-motd
rename to bin/mythtv-update-motd.in
index be0042b8284d73c3f1038f4cdd7dddb16361722d..550c909b88f8a1d98c992598e6287bd7dbf95e07 100755 (executable)
@@ -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.
similarity index 88%
rename from bin/mythtv_recording_now
rename to bin/mythtv_recording_now.in
index 62368a7a8af4e03a9f78800f3cc31ff6173c54b0..d27b1f8822c34bd1e1c3faff442e147f614dfdf4 100755 (executable)
@@ -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
similarity index 92%
rename from bin/mythtv_recording_soon
rename to bin/mythtv_recording_soon.in
index 65d1c6a1ad98196ac4fd6d5d08d6cc18e27c77f8..0c2e65320025b0e6b177fd685ee8e021dc1b8f42 100755 (executable)
@@ -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 ]
index 28f24fa07187efc1e42656f7b3d33c54f58f6f27..5a818954d80b4a8052e3d7252fd6f438f0c42509 100644 (file)
@@ -1 +1 @@
-makefile-debian-paths.patch
+#makefile-debian-paths.patch
similarity index 80%
rename from molly-guard/40-mythtv-recording-soon
rename to molly-guard/40-mythtv-recording-soon.in
index d12e89380a4cf6333bfae0261179e8668f1adfc5..b29f53cfb8b3583d1712b0bf785aed3a4e05eba1 100755 (executable)
@@ -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 || :
similarity index 50%
rename from systemd/mythtv-status.service
rename to systemd/mythtv-status.service.in
index 84dcd1988010d0ab61a95ec50fb2ce43ef0c743e..8d7015e95ca4b3b46dd7387a8743612a5fc099ab 100644 (file)
@@ -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
similarity index 70%
rename from systemd/mythtv-status_health-check.service
rename to systemd/mythtv-status_health-check.service.in
index fbd0a0ae32ccdc8f9ba07c3e9662535c5297dd94..28d549e4b9c8c3251a1f1c47003cf25e38a65c53 100644 (file)
@@ -4,4 +4,4 @@ Documentation=man:mythtv-status(1)
 
 [Service]
 Type=oneshot
-ExecStart=/usr/libexec/mythtv-status/health-check
+ExecStart=@@LIBEXECDIR@@/health-check
similarity index 72%
rename from systemd/mythtv-status_update-motd.service
rename to systemd/mythtv-status_update-motd.service.in
index 8ad6dfb81790dc7645b2fd62ccfcc4f4ad57c656..0e4849731bbc40d0829f4dbea187a8e486d297ac 100644 (file)
@@ -4,4 +4,4 @@ Documentation=man:mythtv-update-motd(8)
 
 [Service]
 Type=oneshot
-ExecStart=/usr/sbin/mythtv-update-motd
+ExecStart=@@SBINDIR@@/mythtv-update-motd