diff options
Diffstat (limited to 'aptly')
-rw-r--r-- | aptly/Makefile | 21 | ||||
-rwxr-xr-x | aptly/bin/aptly-lirionde | 213 | ||||
-rw-r--r-- | aptly/etc/aptly-lirionde.conf | 18 |
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-24 | 2 | -2/+3 | ||
| | |||||
* | syntax error | H. P. | 2022-03-23 | 1 | -1/+1 |
| | |||||
* | distinguish rel from fedora, adopting the rh corporate turquois | H. P. | 2022-03-23 | 1 | -2/+4 |
| | |||||
* | Merge branch 'testing' of git.lirion.de:/var/cache/git/dotfiles into testing | H. P. | 2022-03-23 | 1 | -2/+4 |
|\ | |||||
| * | own colours for AIX | H. P. | 2022-03-23 | 1 | -2/+4 |
| | | |||||
* | | fixes | H. P. | 2022-03-23 | 2 | -5/+9 |
|/ | |||||
* | +test: debian pink for debian systems | H. P. | 2022-03-23 | 1 | -2/+5 |
| | |||||
* | less variable spam | H. P. | 2022-03-23 | 1 | -23/+25 |
| | |||||
* | $SSH_AUTH_SOCK only on the admin stations | H. P. | 2022-03-23 | 1 | -2/+10 |
| | |||||
* | alias for ssh-with-gpg | H. P. | 2022-03-23 | 1 | -0/+1 |
| | |||||
* | launch dirmngr | H. P. | 2022-03-23 | 1 | -1/+1 |
| | |||||
* | adding gpg-connect-agent to ssh agent machines | H. P. | 2022-03-23 | 1 | -0/+1 |
| | |||||
* | Hide grep output | H. P. | 2022-03-22 | 1 | -1/+1 |
| | |||||
* | +doc for SSHAGH | H. P. | 2022-03-21 | 1 | -0/+2 |
| | |||||
* | Execute ssh agent only on machines we want to be the source | H. P. | 2022-03-21 | 2 | -1/+7 |
| | | | | Also, see ssh_config(5) and ForwardAgent | ||||
* | varname fumble | H. P. | 2022-03-21 | 1 | -1/+1 |
| | |||||
* | +function for adding ssh keys | H. P. | 2022-03-21 | 2 | -1/+10 |
| | |||||
* | ...already marked for export in postexec | H. P. | 2022-03-21 | 1 | -1/+0 |
| | | | | This reverts commit 99e0da1b6441da25a0d3427638f0fd1a20076f87. | ||||
* | mark SSH agent variables for export | H. P. | 2022-03-21 | 1 | -0/+1 |
| | |||||
* | Adding postexec for "last-mile tasks" | H. P. | 2022-03-21 | 1 | -0/+4 |
| | |||||
* | Doesn't work | H. P. | 2022-03-21 | 1 | -8/+0 |
| | |||||
* | intermed: squeeze double ; after sourcing sshenv | H. P. | 2022-03-21 | 1 | -1/+1 |
| | |||||
* | "typo": wrong folder | H. P. | 2022-03-19 | 1 | -1/+1 |
| | |||||
* | +ssh-agent-launcher in bashexec | H. P. | 2022-03-19 | 1 | -0/+4 |
| | |||||
* | Initial commit | H. P. | 2022-03-19 | 4 | -0/+366 |