125 lines
3.4 KiB
Bash
Executable File
125 lines
3.4 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
PROGRAM=${0##*/}
|
|
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
PACKAGE_DIR="$ROOT/packages"
|
|
HOLD_PACKAGES="libmailutils9t64 libmu-dbm9t64 mailutils-common libspf2-2t64 libsrs2-0"
|
|
|
|
die()
|
|
{
|
|
echo "$PROGRAM: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
need_root()
|
|
{
|
|
[ "$(id -u)" -eq 0 ] || die "run this installer as root"
|
|
}
|
|
|
|
check_target()
|
|
{
|
|
[ -r /etc/os-release ] || die "cannot identify the operating system"
|
|
. /etc/os-release
|
|
[ "${ID:-}" = debian ] || die "this bundle targets Debian"
|
|
[ "${VERSION_CODENAME:-}" = trixie ] ||
|
|
die "this bundle targets Debian Trixie, found ${VERSION_CODENAME:-unknown}"
|
|
command -v apt-get >/dev/null || die "apt-get is required"
|
|
command -v apt-mark >/dev/null || die "apt-mark is required"
|
|
command -v dpkg-deb >/dev/null || die "dpkg-deb is required"
|
|
}
|
|
|
|
verify_bundle()
|
|
{
|
|
[ -f "$ROOT/SHA256SUMS" ] || die "SHA256SUMS is missing"
|
|
(cd "$ROOT" && sha256sum -c SHA256SUMS)
|
|
}
|
|
|
|
find_package_file()
|
|
{
|
|
wanted=$1
|
|
found=
|
|
for file in "$PACKAGE_DIR"/*.deb; do
|
|
[ -f "$file" ] || continue
|
|
package=$(dpkg-deb -f "$file" Package)
|
|
if [ "$package" = "$wanted" ]; then
|
|
[ -z "$found" ] || die "more than one $wanted package is present"
|
|
found=$file
|
|
fi
|
|
done
|
|
[ -n "$found" ] || die "required package $wanted is absent"
|
|
printf '%s\n' "$found"
|
|
}
|
|
|
|
patched_version()
|
|
{
|
|
file=$(find_package_file "$1")
|
|
version=$(dpkg-deb -f "$file" Version)
|
|
case $version in
|
|
*+bongo*) ;;
|
|
*) die "$1 does not carry a Bongo patched version: $version" ;;
|
|
esac
|
|
printf '%s\n' "$version"
|
|
}
|
|
|
|
unhold()
|
|
{
|
|
need_root
|
|
present=
|
|
for package in $HOLD_PACKAGES; do
|
|
if dpkg-query -W -f='${Status}\n' "$package" 2>/dev/null |
|
|
grep -q '^install ok installed$'; then
|
|
present="$present $package"
|
|
fi
|
|
done
|
|
[ -z "$present" ] || apt-mark unhold $present
|
|
echo "Bongo patched-library holds removed."
|
|
}
|
|
|
|
install_bundle()
|
|
{
|
|
need_root
|
|
check_target
|
|
verify_bundle
|
|
|
|
install_files=
|
|
for package in $HOLD_PACKAGES; do
|
|
version=$(patched_version "$package")
|
|
file=$(find_package_file "$package")
|
|
echo "Selected $package $version"
|
|
install_files="$install_files $file"
|
|
done
|
|
|
|
bongo_file=$(find_package_file bongo)
|
|
echo "Selected bongo $(dpkg-deb -f "$bongo_file" Version)"
|
|
install_files="$install_files $bongo_file"
|
|
|
|
# apt resolves ordinary Trixie dependencies and displays any MTA package
|
|
# replacement before it proceeds. Bongo itself intentionally remains
|
|
# outside the hold set so subsequent Bongo releases remain upgradeable.
|
|
apt-get install $install_files
|
|
|
|
for package in $HOLD_PACKAGES; do
|
|
expected=$(patched_version "$package")
|
|
installed=$(dpkg-query -W -f='${Version}' "$package")
|
|
[ "$installed" = "$expected" ] ||
|
|
die "$package version mismatch: expected $expected, found $installed"
|
|
done
|
|
apt-mark hold $HOLD_PACKAGES
|
|
|
|
echo
|
|
echo "Bongo and its patched libraries are installed."
|
|
echo "Bongo remains upgradeable; only patched libraries are held."
|
|
echo "Run '$PROGRAM --unhold' before deliberately replacing those libraries."
|
|
echo "Run 'bongo-setup' before enabling bongo.service on a new server."
|
|
}
|
|
|
|
case ${1:-install} in
|
|
install) install_bundle ;;
|
|
--unhold) unhold ;;
|
|
--help|-h)
|
|
echo "Usage: $PROGRAM [install|--unhold]"
|
|
;;
|
|
*) die "unknown option: $1" ;;
|
|
esac
|