git.lirion.de

Of git, get, and gud

summaryrefslogtreecommitdiffstats
path: root/aptly
diff options
context:
space:
mode:
Diffstat (limited to 'aptly')
-rw-r--r--aptly/Makefile21
-rwxr-xr-xaptly/bin/aptly-lirionde213
-rw-r--r--aptly/etc/aptly-lirionde.conf18
3 files changed, 252 insertions, 0 deletions
diff --git a/aptly/Makefile b/aptly/Makefile
new file mode 100644
index 0000000..bd29cbb
--- /dev/null
+++ b/aptly/Makefile
@@ -0,0 +1,21 @@
+all:
+
+
+install: copy-etc copy-bin
+
+
+copy-etc: mkdir-etc
+ @if [ ! -e /etc/aptly-lirionde/aptly.conf ]; then \
+ install -vpm0644 -oroot -groot -t /etc/lirion/aptly.conf ./etc/aptly-lirionde.conf; \
+ else printf '/etc/lirion/aptly.conf existing, skipping.\n'; \
+ fi
+
+mkdir-etc:
+ @install -dvm0755 -oroot -groot /etc/lirion
+
+
+copy-bin:
+ @install -vpm0755 -oroot -groot -t /usr/bin bin/aptly-lirionde
+
+
+.PHONY: mkdir-etc copy-etc copy-bin
diff --git a/aptly/bin/aptly-lirionde b/aptly/bin/aptly-lirionde
new file mode 100755
index 0000000..8933cd3
--- /dev/null
+++ b/aptly/bin/aptly-lirionde
@@ -0,0 +1,213 @@
+#!/usr/bin/env bash
+
+# Manages aptly input repositories and publishes a merged output repository.
+# Structure is as follows:
+# repo1 ───> snapshot "repo1-%Y-%m-%d" ─┬─> snapshot "%Y-%m-%d" ───> publish inside $TBASE/public
+# │
+# repo2 ───> snapshot "repo2-%Y-%m-%d" ─┘
+#
+# Furthermore, our PACKAGE input folder is /tmp/aptly with repository names as subfolder, so if
+# you want a new package added inside repo1, you would place a file inside /tmp/aptly/repo1/.
+# The package would then be added and its file inside /tmp be removed.
+#
+# Why bash?
+# 1. This script is INTERACTIVE, it asks for your GPG passphrase before signing packages
+# 2. It still uses a lot of syscalls like aptly
+# 3. The steps we do are still not that resource-hungry, so the downsides while using bash are rather low
+# The combination of these three led to bash in the first iteration.
+#
+# What doesn't this script do?
+# 1. It does not create the source repos or the aptly config.
+# 2. It does not repair if one of the parts of the structure above is missing; in that case,
+# we assume an extraordinary failure and will fail ourselves. Exception: We skip failing
+# on removal if a published repo or a snapshot does not exist.
+# 3. It does not manage multiple snapshots yet. Nor does it cleanup snapshot remainders in case the script
+# is interrupted. Both can be considered a TODO.
+
+
+MYCONF="/etc/lirion/aptly.conf"
+if [ ! -r "$MYCONF" ];then
+ printf '%b cannot be read, exiting!\n' "$MYCONF" >&2
+ exit 254
+else
+ # shellcheck disable=SC1091,SC1090
+ source "$MYCONF" || exit 254
+fi
+
+MALFORMED=0
+[ -z "$MYREPS" ] && MALFORMED=1
+[ -z "$GPGKEY" ] && MALFORMED=1
+[ -z "$GPGTESTKEY" ] && GPGKEY="$GPGTESTKEY"
+[ -z "$PBASE" ] && MALFORMED=1
+[ -z "$TBASE" ] && MALFORMED=1
+
+[ "$MALFORMED" -eq 1 ] && printf '%b malformed, exiting.\n' "$MYCONF" >&2 && exit 253
+
+
+printf -v repjoined "%s-$(date -I) " "${MYREPS[@]}"
+
+# shellcheck disable=SC1091
+source /usr/lib/lirion/ln-initfunctions || exit 10
+
+SNDATE="$(aptly snapshot list -raw | head -n1)"
+if ! printf '%b' "$SNDATE" | grep -P '^[0-9]{4}-[0-9]{2}-[0-9]{2}$' > /dev/null; then
+ SNDATE="$(date -I)"
+fi
+printf -v repoldjoined "%s-$SNDATE " "${MYREPS[@]}"
+printf 'Snapshot suffix that will be deleted: %b\n' "$SNDATE" || exit 11
+
+printf 'Have you added all packages? :)\n'
+printf 'Starting snapshots and publication\033[s in '
+for ((i=5;i>0;--i)); do
+ printf '\r\033[u\033[K in %b...' "$i"
+ sleep 1
+done
+printf '\r\033[u\033[K:\n'
+
+for rep in "${MYREPS[@]}"; do
+ if ! aptly repo list -raw 2>/dev/null | grep -P "^${rep}$" >/dev/null; then
+ lnfail "repository ${rep} does not exist!"
+ fi
+ lnbegin "Adding packages to repo $rep"
+ if [ ! -d "${PBASE}/$rep" ]; then
+ lnskip "source directory not existing"
+ continue
+ fi
+ readarray -t debfiles < <(
+ find "${PBASE}/$rep" -type l -name "*deb" 2>/dev/null
+ find "${PH. P.
2022-03-242-2/+3
|
* syntax errorH. P. 2022-03-231-1/+1
|
* distinguish rel from fedora, adopting the rh corporate turquoisH. P. 2022-03-231-2/+4
|
* Merge branch 'testing' of git.lirion.de:/var/cache/git/dotfiles into testingH. P. 2022-03-231-2/+4
|\
| * own colours for AIXH. P. 2022-03-231-2/+4
| |
* | fixesH. P. 2022-03-232-5/+9
|/
* +test: debian pink for debian systemsH. P. 2022-03-231-2/+5
|
* less variable spamH. P. 2022-03-231-23/+25
|
* $SSH_AUTH_SOCK only on the admin stationsH. P. 2022-03-231-2/+10
|
* alias for ssh-with-gpgH. P. 2022-03-231-0/+1
|
* launch dirmngrH. P. 2022-03-231-1/+1
|
* adding gpg-connect-agent to ssh agent machinesH. P. 2022-03-231-0/+1
|
* Hide grep outputH. P. 2022-03-221-1/+1
|
* +doc for SSHAGHH. P. 2022-03-211-0/+2
|
* Execute ssh agent only on machines we want to be the sourceH. P. 2022-03-212-1/+7
| | | | Also, see ssh_config(5) and ForwardAgent
* varname fumbleH. P. 2022-03-211-1/+1
|
* +function for adding ssh keysH. P. 2022-03-212-1/+10
|
* ...already marked for export in postexecH. P. 2022-03-211-1/+0
| | | | This reverts commit 99e0da1b6441da25a0d3427638f0fd1a20076f87.
* mark SSH agent variables for exportH. P. 2022-03-211-0/+1
|
* Adding postexec for "last-mile tasks"H. P. 2022-03-211-0/+4
|
* Doesn't workH. P. 2022-03-211-8/+0
|
* intermed: squeeze double ; after sourcing sshenvH. P. 2022-03-211-1/+1
|
* "typo": wrong folderH. P. 2022-03-191-1/+1
|
* +ssh-agent-launcher in bashexecH. P. 2022-03-191-0/+4
|
* Initial commitH. P. 2022-03-194-0/+366