diff options
| -rw-r--r-- | packages.yaml | 8 | ||||
| -rwxr-xr-x | packagesync-ng | 66 |
2 files changed, 74 insertions, 0 deletions
diff --git a/packages.yaml b/packages.yaml new file mode 100644 index 0000000..3b85b7d --- /dev/null +++ b/packages.yaml @@ -0,0 +1,8 @@ +install: + netinstall: [apt-listchanges, bash, bash-completion, busybox, bzip2, console-setup, coreutils, cpio, cron, cron-daemon-common, dash, debianutils, dhcpcd-base, diffutils, dpkg, e2fsprogs, findutils, gettext-base, grep, groff-base, grub-common, gzip, hostname, ifupdown, inetutils-telnet, init, initramfs-tools, installation-report, iproute2, iputils-ping, keyboard-configuration, kmod, less, libbpf1, libcap2-bin, libelf1t64, libext2fs2t64, libfdisk1, libjansson4, liblockfile-bin, libmnl0, libnewt0.52, libnftables1, libnftnl11, libpopt0, libreadline8t64, libslang2, libss2, libtirpc-common, libtirpc3t64, libxtables12, linux-image-amd64, login, logrotate, logsave, lsof, man-db, media-types, nano, ncurses-bin, netbase, netcat-traditional, nftables, os-prober, pciutils, perl, readline-common, reportbug, sed, tar, task-english, task-ssh-server, traceroute, tzdata, udev, util-linux-extra, vim-common, vim-tiny, wget, whiptail, wtmpdb, xz-utils, zstd] + restic: [restic] + wireguard: [wireguard-tools] + +remove: + example: + - IHateThisPackageAndIDontWantItInstalled diff --git a/packagesync-ng b/packagesync-ng new file mode 100755 index 0000000..664db99 --- /dev/null +++ b/packagesync-ng @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +echo "WARNING: This project will happily delete all your packages if you are not careful!" +echo "To Proceed acknowledge that you have read this by deleting the \`exit 77\` line in this script" +exit 77 + +PACKAGE_NAME=herk +PACKAGE_MAINTAINER="herk <debian@herkulessi.de>" + +set -eu +umask 077 +TEMPDIR=$(mktemp -d -t packagesync-XXXXXXXX) + +cd "$TEMPDIR" || exit 1 + +MISSING_DEPENDENCIES=() +command -v yq >/dev/null 2>&1 || MISSING_DEPENDENCIES+=(yq) +command -v equivs-build >/dev/null 2>&1 || MISSING_DEPENDENCIES+=(equivs) +command -v stat >/dev/null 2>&1 || MISSING_DEPENDENCIES+=(coreutils) +command -v mktemp >/dev/null 2>&1 || MISSING_DEPENDENCIES+=(coreutils) + +set +u +if [ "${#MISSING_DEPENDENCIES}" -gt 0 ]; then + echo "Installing missing dependencies:" "${MISSING_DEPENDENCIES[@]}" ... + apt-get install --no-install-recommends -yq "${MISSING_DEPENDENCIES[@]}" + echo "Done installing dependencies." +fi +set -u + +OLD_VERSION=$(dpkg-query --showformat='${Version}' --show "$PACKAGE_NAME" 2>/dev/null || echo 0) +NEW_VERSION=$(stat -c %Y /etc/packages.yaml) + +if [ "$OLD_VERSION" -ge "$NEW_VERSION" ]; then + cd / + rm -rf "$TEMPDIR" + apt-mark manual "$PACKAGE_NAME" + apt-mark showmanual | grep -v "^${PACKAGE_NAME}$" | xargs apt-mark auto || true # ignore empty list + apt-get autoremove --purge -yq + exit 0 +fi + +cat > "$PACKAGE_NAME" << EOF +Section: misc +Priority: optional +Standards-Version: 3.9.2 + +Package: $PACKAGE_NAME +Version: $NEW_VERSION +Maintainer: $PACKAGE_MAINTAINER +Depends: $(< /etc/packages.yaml yq -r '.install | to_entries | map(.value) | add | map(tostring) | join(", ")'), apt, coreutils, equivs, findutils, yq +Conflicts: $(< /etc/packages.yaml yq -r '.remove | to_entries | map(.value) | add | map(tostring) | join(", ")') +Description: Metapackage for all needed packages. + This is a dummy package, depending on other packages to make Package Management easier. +EOF + +equivs-build "$PACKAGE_NAME" + +apt-get install -yq --no-install-recommends ./${PACKAGE_NAME}_${NEW_VERSION}_all.deb + +apt-mark manual "$PACKAGE_NAME" +apt-mark showmanual | grep -v "^${PACKAGE_NAME}$" | xargs apt-mark auto || true # ignore empty list + +apt-get autoremove -yq --purge + +cd / +rm -rf "$TEMPDIR" |
