From c18c7026f1164448e234a020dabed27ece8d8f9c Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Fri, 29 Dec 2023 09:18:43 +0000 Subject: [PATCH 1/3] Reorganise file layout and install for multiple platforms. This commit has two aims. First, install new files (systemd, bash completion) as appropriate: this forces us to drop BSD make compatibility (oh well). Second, regoranise the repository a bit to allow future expansion for other non-Linux platforms, which may also want to include extra files like these. --- Makefile | 13 +++++++++- README.Linux.md | 24 +++++++++++++++++++ README.md | 24 ------------------- pizauth.conf.example => examples/pizauth.conf | 0 .../systemd-dropins}/age.conf | 0 .../systemd-dropins}/gpg-dump.conf | 0 .../systemd/user/pizauth.service | 0 .../bash/completion.bash | 0 8 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 README.Linux.md rename pizauth.conf.example => examples/pizauth.conf (100%) rename {systemd-dropins => examples/systemd-dropins}/age.conf (100%) rename {systemd-dropins => examples/systemd-dropins}/gpg-dump.conf (100%) rename pizauth.service => lib/systemd/user/pizauth.service (100%) rename pizauth.bashcomp => share/bash/completion.bash (100%) diff --git a/Makefile b/Makefile index d7621dd..0db46ef 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ all: target/release/pizauth target/release/pizauth: cargo build --release +PLATFORM=$(shell uname) + install: target/release/pizauth install -d ${PREFIX}/bin install -c -m 555 target/release/pizauth ${PREFIX}/bin/pizauth @@ -14,7 +16,16 @@ install: target/release/pizauth install -c -m 444 pizauth.1 ${MAN_PREFIX}/man1/pizauth.1 install -c -m 444 pizauth.conf.5 ${MAN_PREFIX}/man5/pizauth.conf.5 install -d ${PREFIX}/share/examples/pizauth - install -c -m 444 pizauth.conf.example ${PREFIX}/share/examples/pizauth + install -c -m 444 examples/pizauth.conf ${PREFIX}/share/examples/pizauth/pizauth.conf + install -d ${PREFIX}/share/pizauth/bash + install -c -m 444 share/bash/completion.bash ${PREFIX}/share/pizauth/bash/completion.bash +ifeq ($(PLATFORM), Linux) + install -d ${PREFIX}/lib/systemd/user + install -c -m 444 lib/systemd/user/pizauth.service ${PREFIX}/lib/systemd/user/pizauth.service + install -d ${PREFIX}/share/examples/pizauth/systemd-dropins + install -c -m 444 examples/systemd-dropins/age.conf ${PREFIX}/share/examples/pizauth/systemd-dropins/age.conf + install -c -m 444 examples/systemd-dropins/gpg-dump.conf ${PREFIX}/share/examples/pizauth/systemd-dropins/gpg-dump.conf +endif test: cargo test diff --git a/README.Linux.md b/README.Linux.md new file mode 100644 index 0000000..9023eb3 --- /dev/null +++ b/README.Linux.md @@ -0,0 +1,24 @@ +# pizauth on Linux + +Pizauth comes with a systemd unit and example configurations. To start pizauth: + +```sh +$ systemctl --user start pizauth.service +``` + +If you want `pizauth` to start on login, run + +```sh +$ systemctl --user enable pizauth.service +``` + +In `/usr/share/examples/pizauth/systemd-dropins` are templates for saving +pizauth dumps encrypted with `age` and `gpg`. To use them, run + +```sh +$ systemctl --user edit pizauth.service +``` + +and paste whichever of the templates suits you in the file `systemctl` opens. +Make sure to modify the references to private/public keys/IDs in the temalpte +file to point to your keys/IDs. diff --git a/README.md b/README.md index 369d1b0..8ad9aac 100644 --- a/README.md +++ b/README.md @@ -126,30 +126,6 @@ Note that: becoming invalid and pizauth realising that has happened and notifying you to request a new token. -### Systemd unit - -Pizauth ships with a systemd unit and example configurations. -To start `pizauth`, run - -```sh -$ systemctl --user start pizauth.service -``` - -If you want `pizauth` to start on login, run - -```sh -$ systemctl --user enable pizauth.service -``` - -Finally, in `systemd-dropins/` you'll find templates for saving pizauth dumps -encrypted with `age` and `gpg`. To use them, run - -```sh -$ systemctl --user edit pizauth.service -``` - -and paste whichever of these templates suits you in the file `systemctl` opens. -(Modify the references to private/public keys to actually point to your keys!) ## Command-line interface diff --git a/pizauth.conf.example b/examples/pizauth.conf similarity index 100% rename from pizauth.conf.example rename to examples/pizauth.conf diff --git a/systemd-dropins/age.conf b/examples/systemd-dropins/age.conf similarity index 100% rename from systemd-dropins/age.conf rename to examples/systemd-dropins/age.conf diff --git a/systemd-dropins/gpg-dump.conf b/examples/systemd-dropins/gpg-dump.conf similarity index 100% rename from systemd-dropins/gpg-dump.conf rename to examples/systemd-dropins/gpg-dump.conf diff --git a/pizauth.service b/lib/systemd/user/pizauth.service similarity index 100% rename from pizauth.service rename to lib/systemd/user/pizauth.service diff --git a/pizauth.bashcomp b/share/bash/completion.bash similarity index 100% rename from pizauth.bashcomp rename to share/bash/completion.bash From 61aff4906ed4bcf6bce49c7a0af30b4208c9ea9a Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Mon, 1 Jan 2024 08:16:57 +0000 Subject: [PATCH 2/3] Add PHONY targets. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 0db46ef..c94749c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ PREFIX ?= /usr/local MAN_PREFIX ?= ${PREFIX}/man +.PHONY: all install test distrib + all: target/release/pizauth target/release/pizauth: From c79bed0d92c7381f930c175ef3d289b47764502e Mon Sep 17 00:00:00 2001 From: Laurence Tratt Date: Sun, 7 Jan 2024 08:32:26 +0000 Subject: [PATCH 3/3] Use `DESTDIR` as the means for controlling installation. Also use a cunning trick for `MANDIR` (based on an example pointed out to me in batsignal) to select a location that works as expected for both BSD and Linux file systems. --- Makefile | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index c94749c..e4bea3e 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,13 @@ PREFIX ?= /usr/local -MAN_PREFIX ?= ${PREFIX}/man +BINDIR ?= ${PREFIX}/bin +LIBDIR ?= ${PREFIX}/lib +SHAREDIR ?= ${PREFIX}/share +EXAMPLESDIR ?= ${SHAREDIR}/examples + +MANDIR.${PREFIX} = ${PREFIX}/share/man +MANDIR./usr/local = /usr/local/man +MANDIR. = /usr/share/man +MANDIR ?= ${MANDIR.${PREFIX}} .PHONY: all install test distrib @@ -11,22 +19,22 @@ target/release/pizauth: PLATFORM=$(shell uname) install: target/release/pizauth - install -d ${PREFIX}/bin - install -c -m 555 target/release/pizauth ${PREFIX}/bin/pizauth - install -d ${MAN_PREFIX}/man1 - install -d ${MAN_PREFIX}/man5 - install -c -m 444 pizauth.1 ${MAN_PREFIX}/man1/pizauth.1 - install -c -m 444 pizauth.conf.5 ${MAN_PREFIX}/man5/pizauth.conf.5 - install -d ${PREFIX}/share/examples/pizauth - install -c -m 444 examples/pizauth.conf ${PREFIX}/share/examples/pizauth/pizauth.conf - install -d ${PREFIX}/share/pizauth/bash - install -c -m 444 share/bash/completion.bash ${PREFIX}/share/pizauth/bash/completion.bash + install -d ${DESTDIR}${BINDIR} + install -c -m 555 target/release/pizauth ${DESTDIR}${BINDIR}/pizauth + install -d ${DESTDIR}${MANDIR}/man1 + install -d ${DESTDIR}${MANDIR}/man5 + install -c -m 444 pizauth.1 ${DESTDIR}${MANDIR}/man1/pizauth.1 + install -c -m 444 pizauth.conf.5 ${DESTDIR}${MANDIR}/man5/pizauth.conf.5 + install -d ${DESTDIR}${EXAMPLESDIR}/pizauth + install -c -m 444 examples/pizauth.conf ${DESTDIR}${EXAMPLESDIR}/pizauth/pizauth.conf + install -d ${DESTDIR}${SHAREDIR}/pizauth/bash + install -c -m 444 share/bash/completion.bash ${DESTDIR}${SHAREDIR}/pizauth/bash/completion.bash ifeq ($(PLATFORM), Linux) - install -d ${PREFIX}/lib/systemd/user - install -c -m 444 lib/systemd/user/pizauth.service ${PREFIX}/lib/systemd/user/pizauth.service - install -d ${PREFIX}/share/examples/pizauth/systemd-dropins - install -c -m 444 examples/systemd-dropins/age.conf ${PREFIX}/share/examples/pizauth/systemd-dropins/age.conf - install -c -m 444 examples/systemd-dropins/gpg-dump.conf ${PREFIX}/share/examples/pizauth/systemd-dropins/gpg-dump.conf + install -d ${DESTDIR}${LIBDIR}/systemd/user + install -c -m 444 lib/systemd/user/pizauth.service ${DESTDIR}${LIBDIR}/systemd/user/pizauth.service + install -d ${DESTDIR}${EXAMPLESDIR}/pizauth/systemd-dropins + install -c -m 444 examples/systemd-dropins/age.conf ${DESTDIR}${EXAMPLESDIR}/pizauth/systemd-dropins/age.conf + install -c -m 444 examples/systemd-dropins/gpg-dump.conf ${DESTDIR}${EXAMPLESDIR}/pizauth/systemd-dropins/gpg-dump.conf endif test: