mirror of https://github.com/zulip/zulip.git
setup-apt-repo: Support installing an APT preferences file.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
7077a289ae
commit
fdc1294993
|
@ -13,6 +13,7 @@ set -x
|
||||||
set -e
|
set -e
|
||||||
set -u
|
set -u
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
verify=false
|
verify=false
|
||||||
args="$(getopt -o '' --long verify,list: -- "$@")"
|
args="$(getopt -o '' --long verify,list: -- "$@")"
|
||||||
|
@ -40,6 +41,7 @@ done
|
||||||
mkdir -p /var/lib/zulip
|
mkdir -p /var/lib/zulip
|
||||||
|
|
||||||
SOURCES_FILE=/etc/apt/sources.list.d/$LIST.list
|
SOURCES_FILE=/etc/apt/sources.list.d/$LIST.list
|
||||||
|
PREF_FILE=/etc/apt/preferences.d/$LIST.pref
|
||||||
STAMP_FILE=/etc/apt/sources.list.d/$LIST.list.apt-update-in-progress
|
STAMP_FILE=/etc/apt/sources.list.d/$LIST.list.apt-update-in-progress
|
||||||
|
|
||||||
ZULIP_SCRIPTS="$(cd "$(dirname "$(dirname "$0")")" && pwd)"
|
ZULIP_SCRIPTS="$(cd "$(dirname "$(dirname "$0")")" && pwd)"
|
||||||
|
@ -64,7 +66,7 @@ EOF
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEPENDENCIES_HASH=$(sha1sum "$LIST_PATH/"*.asc "$0")
|
DEPENDENCIES_HASH="$(sha256sum "$LIST_PATH"/?(*.asc|"$release.list"|"$LIST.pref"|custom.sh) "$ZULIP_SCRIPTS/lib/setup-apt-repo")"
|
||||||
DEPENDENCIES_HASH_FILE="/var/lib/zulip/setup-repositories-state-$LIST"
|
DEPENDENCIES_HASH_FILE="/var/lib/zulip/setup-repositories-state-$LIST"
|
||||||
# Ensure that DEPENDENCIES_HASH_FILE exists before hashing it.
|
# Ensure that DEPENDENCIES_HASH_FILE exists before hashing it.
|
||||||
touch "$DEPENDENCIES_HASH_FILE"
|
touch "$DEPENDENCIES_HASH_FILE"
|
||||||
|
@ -78,11 +80,8 @@ elif [ "$verify" == true ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ensure that the sources file exists
|
# Hash to check if the configuration is changed by the script later.
|
||||||
touch "$SOURCES_FILE"
|
hashes=$(sha256sum "$SOURCES_FILE" "$PREF_FILE" 2>/dev/null || true)
|
||||||
|
|
||||||
# Hash it to check if the sources file is changed by the script later.
|
|
||||||
zulip_source_hash=$(sha1sum "$SOURCES_FILE")
|
|
||||||
|
|
||||||
pre_setup_deps=(lsb-release apt-transport-https ca-certificates gnupg curl)
|
pre_setup_deps=(lsb-release apt-transport-https ca-certificates gnupg curl)
|
||||||
if ! apt-get -dy install "${pre_setup_deps[@]}"; then
|
if ! apt-get -dy install "${pre_setup_deps[@]}"; then
|
||||||
|
@ -93,14 +92,20 @@ apt-get -y install "${pre_setup_deps[@]}"
|
||||||
apt-key add "$LIST_PATH/"*.asc
|
apt-key add "$LIST_PATH/"*.asc
|
||||||
cp "$LIST_PATH/$release.list" "$SOURCES_FILE"
|
cp "$LIST_PATH/$release.list" "$SOURCES_FILE"
|
||||||
|
|
||||||
|
if [ -e "$LIST_PATH/$LIST.pref" ]; then
|
||||||
|
cp "$LIST_PATH/$LIST.pref" "$PREF_FILE"
|
||||||
|
else
|
||||||
|
rm -f "$PREF_FILE"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -e "$LIST_PATH/custom.sh" ]; then
|
if [ -e "$LIST_PATH/custom.sh" ]; then
|
||||||
export LIST_PATH
|
export LIST_PATH
|
||||||
export STAMP_FILE
|
export STAMP_FILE
|
||||||
bash "$LIST_PATH/custom.sh"
|
bash "$LIST_PATH/custom.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$zulip_source_hash" = "$(sha1sum "$SOURCES_FILE")" ] && ! [ -e "$STAMP_FILE" ]; then
|
if [ "$hashes" = "$(sha256sum "$SOURCES_FILE" "$PREF_FILE" 2>/dev/null || true)" ] && ! [ -e "$STAMP_FILE" ]; then
|
||||||
echo "zulip.list file did not change; skipping apt-get update"
|
echo "APT configuration did not change; skipping apt-get update"
|
||||||
else
|
else
|
||||||
# We create this stamp file to ensure `apt-get update` will be run
|
# We create this stamp file to ensure `apt-get update` will be run
|
||||||
# the next time this script is invoked, and each time after, until
|
# the next time this script is invoked, and each time after, until
|
||||||
|
|
Loading…
Reference in New Issue