summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2013-05-05 23:07:06 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2013-05-05 23:07:06 +0200
commit2587acda28156f50149a15cad67d0c0bc1eb0bb4 (patch)
tree5b9a1cccd3a513caddc171bc76b38428eeaa78be
parent11f6a8ce077bf403cf0b1945f8385a6653162c05 (diff)
downloadnetctl-2587acda28156f50149a15cad67d0c0bc1eb0bb4.tar.gz
netctl-2587acda28156f50149a15cad67d0c0bc1eb0bb4.tar.xz
Use pkg-config to obtain the systemd system unit directory
This ensures the units are installed correctly if systemd is installed in an alternate location like /lib/systemd. Idem for the location of profile-based units. Based on a proposal by: Mike Gilbert <floppym@gentoo.org>
-rw-r--r--Makefile33
-rw-r--r--contrib/PKGBUILD.in (renamed from contrib/PKGBUILD)9
-rw-r--r--[-rwxr-xr-x]src/netctl.in (renamed from src/netctl)6
3 files changed, 29 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index bf48aa5..2fcf62b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,11 @@
export VERSION = 1.0
+PKG_CONFIG ?= pkg-config
+
+sd_var = $(shell $(PKG_CONFIG) --variable=systemd$(1) systemd)
+systemdsystemconfdir = $(call sd_var,systemconfdir)
+systemdsystemunitdir = $(call sd_var,systemunitdir)
+
.PHONY: install tarball pkgbuild clean
install:
@@ -15,35 +21,38 @@ install:
install -m755 src/lib/{auto.action,network} $(DESTDIR)/usr/lib/network/
# Scripts
install -d $(DESTDIR)/usr/bin
+ sed -e "s|@systemdsystemconfdir@|$(systemdsystemconfdir)|g" \
+ -e "s|@systemdsystemunitdir@|$(systemdsystemunitdir)|g" \
+ src/netctl.in > $(DESTDIR)/usr/bin/netctl
+ chmod 755 $(DESTDIR)/usr/bin/netctl
install -m755 \
- src/netctl \
src/netctl-auto \
src/wifi-menu \
$(DESTDIR)/usr/bin/
install -Dm755 src/ifplugd.action $(DESTDIR)/etc/ifplugd/netctl.action
# Services
- install -d $(DESTDIR)/usr/lib/systemd/system
- install -m644 services/*.service $(DESTDIR)/usr/lib/systemd/system/
+ install -d $(DESTDIR)$(systemdsystemunitdir)
+ install -m644 services/*.service $(DESTDIR)$(systemdsystemunitdir)/
tarball: netctl-$(VERSION).tar.xz
netctl-$(VERSION).tar.xz:
$(MAKE) -B -C docs
- cp src/netctl{,.orig}
- sed -i "s/NETCTL_VERSION=.*/NETCTL_VERSION=$(VERSION)/" src/netctl
+ cp src/netctl.in{,.orig}
+ sed -i "s|NETCTL_VERSION=.*|NETCTL_VERSION=$(VERSION)|" src/netctl.in
git stash save -q
git archive -o netctl-$(VERSION).tar --prefix=netctl-$(VERSION)/ stash
git stash pop -q
- mv src/netctl{.orig,}
- tar --exclude-vcs --transform "s%^%netctl-$(VERSION)/%" --owner=root --group=root --mtime=./netctl-$(VERSION).tar -rf netctl-$(VERSION).tar docs/*.[1-8]
+ mv src/netctl.in{.orig,}
+ tar --exclude-vcs --transform "s|^|netctl-$(VERSION)/|" --owner=root --group=root --mtime=./netctl-$(VERSION).tar -rf netctl-$(VERSION).tar docs/*.[1-8]
xz netctl-$(VERSION).tar
gpg --detach-sign $@
pkgbuild: PKGBUILD
-PKGBUILD: netctl-$(VERSION).tar.xz
- sed -e "s/%pkgver%/$(VERSION)/g" \
- -e "s/%md5sum%/$(shell md5sum $< | cut -d ' ' -f 1)/" \
- -e "s/%md5sum.sig%/$(shell md5sum $<.sig | cut -d ' ' -f 1)/" \
- contrib/PKGBUILD > $@
+PKGBUILD: netctl-$(VERSION).tar.xz contrib/PKGBUILD.in
+ sed -e "s|@pkgver@|$(VERSION)|g" \
+ -e "s|@md5sum@|$(shell md5sum $< | cut -d ' ' -f 1)|" \
+ -e "s|@md5sum.sig@|$(shell md5sum $<.sig | cut -d ' ' -f 1)|" \
+ $(lastword $^) > $@
upload: netctl-$(VERSION).tar.xz
scp $< $<.sig nymeria.archlinux.org:/srv/ftp/other/packages/netctl
diff --git a/contrib/PKGBUILD b/contrib/PKGBUILD.in
index 0190048..3c7b9b0 100644
--- a/contrib/PKGBUILD
+++ b/contrib/PKGBUILD.in
@@ -1,14 +1,15 @@
# Maintainer: Jouke Witteveen <j.witteveen@gmail.com>
pkgname=netctl
-pkgver=%pkgver%
+pkgver=@pkgver@
pkgrel=1
pkgdesc='Profile based systemd network management'
url='http://projects.archlinux.org/netctl.git/'
license=('GPL')
groups=('base')
depends=('coreutils' 'iproute2' 'openresolv')
-#makedepends=('asciidoc') # The source tarball includes pre-built documentation.
+# The source tarball includes pre-built (using asciidoc) documentation.
+makedepends=('pkg-config')
optdepends=('dialog: for the menu based wifi assistant'
'dhclient: for DHCP support (or dhcpcd)'
'dhcpcd: for DHCP support (or dhclient)'
@@ -21,8 +22,8 @@ optdepends=('dialog: for the menu based wifi assistant'
)
source=(ftp://ftp.archlinux.org/other/packages/netctl/netctl-${pkgver}.tar.xz{,.sig})
arch=('any')
-md5sums=('%md5sum%'
- '%md5sum.sig%')
+md5sums=('@md5sum@'
+ '@md5sum.sig@')
package() {
cd "$srcdir/netctl-${pkgver}"
diff --git a/src/netctl b/src/netctl.in
index 4441838..2d04d28 100755..100644
--- a/src/netctl
+++ b/src/netctl.in
@@ -100,13 +100,13 @@ switch_to() {
}
unit_enable() {
- local unit="/etc/systemd/system/netctl@$(sd_escape "$1").service"
+ local unit="@systemdsystemconfdir@/netctl@$(sd_escape "$1").service"
if [[ -e $unit ]]; then
report_error "A unit file for profile '$1' already exists"
return 1
fi
load_profile "$1"
- echo ".include /usr/lib/systemd/system/netctl@.service" > "$unit"
+ echo ".include @systemdsystemunitdir@/netctl@.service" > "$unit"
echo -e "\n[Unit]" >> "$unit"
[[ -n $Description ]] && echo "Description=$Description" >> "$unit"
if [[ -n ${BindsToInterfaces=$Interface} ]]; then
@@ -126,7 +126,7 @@ unit_enable() {
}
unit_disable() {
- local unit="/etc/systemd/system/netctl@$(sd_escape "$1").service"
+ local unit="@systemdsystemconfdir@/netctl@$(sd_escape "$1").service"
if sd_call "is-enabled --quiet" "$1" &> /dev/null; then
sd_call disable "$1"
fi