1
0
Fork 0
progress-linux/debian/progress-linux.postinst
Daniel Baumann 423c65dd99
Adding debian version 20250601-1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 19:47:53 +02:00

267 lines
4.6 KiB
Bash
Executable file

#!/bin/sh
set -e
PROJECT="progress-linux"
DOMAIN="progress-linux.org"
PACKAGES="https://deb.progress-linux.org/packages"
KEY="/usr/share/progress-linux/pgp-keys/deb.progress-linux.org.gpg"
Install_apt_sources ()
{
cat > "/etc/apt/sources.list.d/${PROJECT}.sources" << EOF
# /etc/apt/sources.list.d/${PROJECT}.sources
EOF
}
Remove_apt_sources ()
{
rm -f "/etc/apt/sources.list.d/${PROJECT}.sources"
}
Install_apt_preferences ()
{
cat > "/etc/apt/preferences.d/${PROJECT}.pref" << EOF
# /etc/apt/preferences.d/${PROJECT}.pref
EOF
}
Remove_apt_preferences ()
{
rm -f "/etc/apt/preferences.d/${PROJECT}.pref"
}
Configure_apt_sources ()
{
# Configure repositories: ${release}, ${release}-security, ${release}-updates, ${release}-backports
SUITES=""
for ARCHIVE in ${ARCHIVES}
do
case "${ARCHIVE}" in
*-extras|*-test)
;;
*)
SUITES="${SUITES} ${ARCHIVE}"
Configure_apt_preferences ${ARCHIVE}
;;
esac
done
COMPONENTS="$(echo ${ARCHIVE_AREAS} | sed -e 's| restricted||')"
SUITES="$(echo ${SUITES} | sed -e 's|^ *||')"
if [ -n "${SUITES}" ]
then
Configure_apt_sources_stanza "${SUITES}" "${COMPONENTS}"
fi
# Configure repositories: ${release}-extras, ${release}-test, ${release}-backports-extras, ${release}-backports-test
SUITES=""
for ARCHIVE in ${ARCHIVES}
do
case "${ARCHIVE}" in
*-extras|*-test)
SUITES="${SUITES} ${ARCHIVE}"
Configure_apt_preferences ${ARCHIVE}
;;
*)
;;
esac
done
COMPONENTS="${ARCHIVE_AREAS}"
SUITES="$(echo ${SUITES} | sed -e 's|^ *||')"
if [ -n "${SUITES}" ]
then
Configure_apt_sources_stanza "${SUITES}" "${COMPONENTS}"
fi
}
Configure_apt_sources_stanza ()
{
SUITES="${1}"
COMPONENTS="${2}"
cat >> "/etc/apt/sources.list.d/${PROJECT}.sources" << EOF
Types: deb
URIs: ${MIRROR}
Suites: ${SUITES}
Components: ${COMPONENTS}
PDiffs: no
Signed-By: ${KEY}
EOF
}
Configure_apt_preferences ()
{
ARCHIVE="${1}"
case "${ARCHIVE}" in
*-backports*)
PIN_PRIORITY="${BACKPORTS_PRIORITY}"
;;
*)
PIN_PRIORITY="999"
;;
esac
cat >> "/etc/apt/preferences.d/${PROJECT}.pref" << EOF
Package: *
Pin: release o=${PROJECT}, n=${ARCHIVE}
Pin-Priority: ${PIN_PRIORITY}
EOF
}
Configure_ssh_known_hosts ()
{
KEY="$(cat /usr/share/${PROJECT}/ssh-keys/ssh.${DOMAIN}.pub)"
if [ ! -e "/etc/ssh/ssh_known_hosts" ]
then
mkdir -p /etc/ssh
cat > "/etc/ssh/ssh_known_hosts" << EOF
# /etc/ssh/ssh_known_hosts
@cert-authority *.${DOMAIN} ${KEY}
EOF
else
grep -v "^@cert-authority \*.${DOMAIN}" /etc/ssh/ssh_known_hosts > /etc/ssh/ssh_known_hosts.tmp
cat >> "/etc/ssh/ssh_known_hosts.tmp" << EOF
@cert-authority *.${DOMAIN} ${KEY}
EOF
mv -f /etc/ssh/ssh_known_hosts.tmp /etc/ssh/ssh_known_hosts
fi
}
Remove_ssh_known_hosts ()
{
if [ ! -e /etc/ssh/ssh_known_hosts ]
then
return
fi
# ssh cert-authority
grep -v "^@cert-authority \*.${DOMAIN}" /etc/ssh/ssh_known_hosts > /etc/ssh/ssh_known_hosts.tmp
if [ "$(md5sum /etc/ssh/ssh_known_hosts.tmp | cut -d' ' -f1)" = "2a2b4fdd70705b2029b35a24217138e6" ]
then
rm -f /etc/ssh/ssh_known_hosts.tmp
rm -f /etc/ssh/ssh_known_hosts
rmdir /etc/ssh > /dev/null 2>&1 || true
else
mv -f /etc/ssh/ssh_known_hosts.tmp /etc/ssh/ssh_known_hosts
fi
}
Clean ()
{
# Remove apt keys
rm -f "/etc/apt/trusted.gpg.d/${PROJECT}.gpg"
# Remove apt lists
rm -f "/etc/apt/sources.list.d/${PROJECT}.list"
}
case "${1}" in
configure)
. /usr/share/debconf/confmodule
db_get ${PROJECT}/archives
ARCHIVES="$(echo ${RET} | sed -e 's|, | |g')" # multiselect w/ empty
db_get ${PROJECT}/archive-areas
ARCHIVE_AREAS="$(echo ${RET:-main} | sed -e 's|, | |g')" # string w/o empty
db_get ${PROJECT}/mirror
MIRROR="$(echo ${RET:-${PACKAGES}})" # string w/o empty
db_stop
BACKPORTS_PRIORITY="100"
for ARCHIVE in ${ARCHIVES}
do
case "${ARCHIVE}" in
engywuck|fuchur|graograman|horok|illuan)
BACKPORTS_PRIORITY="999"
;;
esac
done
DEBIAN_VERSION="$(cat /etc/debian_version)"
case "${DEBIAN_VERSION}" in
10.*|buster/sid)
;;
11.*|bullseye/sid)
;;
12.*|bookworm/sid)
;;
13.*|trixie/sid)
;;
14.*|forky/sid)
;;
*)
echo "W: unsupported debian release"
Remove_apt_sources
Remove_apt_preferences
Remove_ssh_known_hosts
exit 0
;;
esac
# apt
if [ -n "${ARCHIVES}" ]
then
Install_apt_sources
Install_apt_preferences
Configure_apt_sources
else
Remove_apt_sources
Remove_apt_preferences
fi
# openssh-server
Configure_ssh_known_hosts
# upgrading from buster
Clean
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`${1}'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0