summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorone-d-wide2022-10-25 22:07:53 +0300
committerone-d-wide2022-10-25 22:07:53 +0300
commiteb9bd2abadad64ab30beb05a2556c727280d846c (patch)
tree8c23065f6fc9863e3ea5d106ecc922809b1f5362
parentc6f3fbdc7478e598f607e6ed9daa581e39a41fcd (diff)
downloadaur-eb9bd2abadad64ab30beb05a2556c727280d846c.tar.gz
Replace .hooks with .install
-rw-r--r--.SRCINFO5
-rw-r--r--PKGBUILD42
-rw-r--r--systemd-hosts.d.install17
3 files changed, 24 insertions, 40 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 52b6f2da5f98..c36c8fd36a91 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,8 +1,9 @@
pkgbase = systemd-hosts.d
pkgdesc = Keep your hosts records in logically separated files
- pkgver = 0.3
- pkgrel = 1
+ pkgver = 0.4
+ pkgrel = 2
url = https://github.com/one-d-wide/systemd-hosts.d
+ install = systemd-hosts.d.install
arch = any
license = GPL3
makedepends = git
diff --git a/PKGBUILD b/PKGBUILD
index 705cf76a73a1..6398b9367ab9 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,13 +1,14 @@
# Maintainer: onedwide <one-d-wide@protonmail.com>
pkgname=systemd-hosts.d
-pkgver=0.3
-pkgrel=1
+pkgver=0.4
+pkgrel=2
pkgdesc='Keep your hosts records in logically separated files'
url='https://github.com/one-d-wide/systemd-hosts.d'
arch=('any')
license=(GPL3)
depends=('filesystem' 'systemd')
makedepends=('git')
+install=$pkgname.install
source=("git+$url.git")
sha256sums=('SKIP')
@@ -17,43 +18,8 @@ pkgver() {
printf "0.%s" "$(git rev-list --count HEAD)"
}
-prepare() {
- cd "$pkgname"
- cat > systemd-hosts.d.hook <<EOF
-[Trigger]
-Operation = Install
-Operation = Upgrade
-Type = Package
-Target = systemd-hosts.d
-
-[Action]
-Description = Saving /etc/hosts to /etc/hosts.d/hosts
-When = PostTransaction
-Depends = filesystem
-Exec = /bin/sh -c '[[ ! -L /etc/hosts ]] && mv -b /etc/hosts /etc/hosts.d/hosts.conf; ln -sf /run/hosts /etc/hosts'
-EOF
- cat > systemd-hosts.d-cleanup.hook <<EOF
-[Trigger]
-Operation = Remove
-Type = Package
-Target = systemd-hosts.d
-
-[Action]
-Description = Returning normal /etc/hosts file
-When = PreTransaction
-Depends = filesystem
-Exec = /bin/sh -c '[[ -L /etc/hosts ]] && rm /etc/hosts; mv /etc/hosts.d/hosts.conf /etc/hosts || mv /run/hosts /etc/hosts || cat >/etc/hosts'
-EOF
-}
-
package() {
- cd "$pkgname"
+ cd "$pkgname"
mkdir -pm755 "$pkgdir/etc/hosts.d"
- install -Dm644 systemd-hosts.d{,-cleanup}.hook -t "$pkgdir"/usr/share/libalpm/hooks
install -Dm644 systemd-hosts.d.{path,service} -t "$pkgdir"/usr/lib/systemd/system
-
- install -d -m755 "$pkgdir"/usr/lib/systemd/system/network-pre.target.wants
- ln -s ../systemd-hosts.d.path "$pkgdir"/usr/lib/systemd/system/network-pre.target.wants/systemd-hosts.d.path
- install -d -m755 "$pkgdir"/usr/lib/systemd/system/network-pre.target.requires
- ln -s ../systemd-hosts.d.service "$pkgdir"/usr/lib/systemd/system/network-pre.target.requires/systemd-hosts.d.service
}
diff --git a/systemd-hosts.d.install b/systemd-hosts.d.install
new file mode 100644
index 000000000000..76acc77cf0c5
--- /dev/null
+++ b/systemd-hosts.d.install
@@ -0,0 +1,17 @@
+post_install() {
+ [[ ! -L /etc/hosts ]] &&
+ mv -b /etc/hosts /etc/hosts.d/hosts.conf
+ ln -sf /run/hosts /etc/hosts
+ systemctl enable --now systemd-hosts.d.service
+ systemctl enable --now systemd-hosts.d.path
+}
+
+pre_remove() {
+ [[ -L /etc/hosts ]] &&
+ rm /etc/hosts
+ mv /etc/hosts.d/hosts.conf /etc/hosts ||
+ mv /run/hosts /etc/hosts ||
+ touch /etc/hosts
+ systemctl disable --now systemd-hosts.d.service
+ systemctl disable --now systemd-hosts.d.path
+}