summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Hills2016-08-15 19:14:24 -0400
committerAndrew Hills2016-08-15 19:14:24 -0400
commit0ac55ccfcd712f0ee160495d2138aac5cbce8d68 (patch)
treefda641e3992dffacc7c5b6b1586ae0169c50dcf7
parent112f4ae0d90137031d993f96eb27233b24950f0d (diff)
downloadaur-0ac55ccfcd712f0ee160495d2138aac5cbce8d68.tar.gz
Add systemd units and change packaging strategy
-rw-r--r--PKGBUILD28
-rw-r--r--hosts-gen.install10
-rw-r--r--hosts-gen.path10
-rw-r--r--hosts-gen.service10
4 files changed, 44 insertions, 14 deletions
diff --git a/PKGBUILD b/PKGBUILD
index ab54a0e56b46..5c9cc85e515c 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -3,7 +3,7 @@ pkgname=hosts-gen
pkgver=0.9
# No actual releases provided; find the right commit and download a snapshot from cgit
_pkgcommit=d3015d319d378390139455731b974569fbc2cd40
-pkgrel=1
+pkgrel=2
epoch=
pkgdesc="A little framework to generate /etc/hosts from /etc/hosts.d"
arch=('any')
@@ -15,23 +15,27 @@ backup=()
options=()
install="$pkgname.install"
source=("http://git.r-36.net/$pkgname/snapshot/$pkgname-$_pkgcommit.tar.bz2"
- "$pkgname-$pkgver-usr-bin.patch"
- "$pkgname-$pkgver-doc.patch")
+ "$pkgname.path"
+ "$pkgname.service")
md5sums=('534edf642f15df0a073a716967724065'
- 'd05c8b504ace226881e800cbad95ac9b'
- 'bb63beb2068c3aac04caefaa2ee926b6')
+ '470be01a8490fc054fb0a04d3a74eed1'
+ '12ed5fdea9f047bb03e61e8f846c641a')
validpgpkeys=()
-prepare() {
- cd "$pkgname-$_pkgcommit"
- for patchname in usr-bin doc; do
- patch -p1 < "$srcdir/$pkgname-$pkgver-$patchname.patch"
- done
-}
-
package() {
cd "$pkgname-$_pkgcommit"
make DESTDIR="$pkgdir/" install
# Generate this from /etc/hosts on install
rm "$pkgdir/etc/hosts.d/01-hosts.local"
+ # Correct executable location
+ mkdir -p "$pkgdir/usr"
+ mv "$pkgdir/bin" "$pkgdir/usr/bin"
+ # Install documentation
+ mkdir -p "$pkgdir/usr/share/doc/$pkgname"
+ install -m0644 "$srcdir/$pkgname-$_pkgcommit/README" "$pkgdir/usr/share/doc/$pkgname/README"
+ install -m0644 "$srcdir/$pkgname-$_pkgcommit/LICENSE" "$pkgdir/usr/share/doc/$pkgname/LICENSE"
+ # Install systemd units
+ mkdir -p "$pkgdir/usr/lib/systemd/system"
+ install -m0644 "$srcdir/$pkgname.path" "$pkgdir/usr/lib/systemd/system/$pkgname.path"
+ install -m0644 "$srcdir/$pkgname.service" "$pkgdir/usr/lib/systemd/system/$pkgname.service"
}
diff --git a/hosts-gen.install b/hosts-gen.install
index 3c5b3ce12b82..d17c6f2dd912 100644
--- a/hosts-gen.install
+++ b/hosts-gen.install
@@ -2,8 +2,14 @@ post_install() {
echo 'Copying existing hosts file to 01-hosts.local'
cp -v etc/hosts etc/hosts.d/01-hosts.local
echo
- echo 'Changes to /etc/hosts will be lost when hosts-gen is run. Put new'
- echo 'entries in files in /etc/hosts.d.'
+ echo ' :: Changes to /etc/hosts will be lost when hosts-gen is run. Put new'
+ echo ' :: entries in files in /etc/hosts.d.'
+ echo
+ echo ' :: To automatically generate the hosts file whenever hosts.d files'
+ echo ' :: are added or changed, enable the hosts-gen.path unit:'
+ echo
+ echo ' systemctl enable hosts-gen.path'
+ echo
}
pre_remove() {
diff --git a/hosts-gen.path b/hosts-gen.path
new file mode 100644
index 000000000000..4e32c98f89b3
--- /dev/null
+++ b/hosts-gen.path
@@ -0,0 +1,10 @@
+[Unit]
+Description=Automatically regenerate hosts from hosts.d
+Documentation=file:/usr/share/doc/hosts-gen/README
+
+[Path]
+PathChanged=/etc/hosts.d
+Unit=hosts-gen.service
+
+[Install]
+WantedBy=default.target
diff --git a/hosts-gen.service b/hosts-gen.service
new file mode 100644
index 000000000000..8354c6da8c96
--- /dev/null
+++ b/hosts-gen.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Automatically regenerate hosts from hosts.d
+Documentation=file:/usr/share/doc/hosts-gen/README
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/hosts-gen
+
+[Install]
+WantedBy=default.target