Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
setup-apt-repo: Support installing an APT preferences file.
Anders Kaseorgfdc129499338
diff --git a/scripts/lib/setup-apt-repo b/scripts/lib/setup-apt-repoindex d3bfb0d28a2..b35d8e9e0e9 100755--- a/scripts/lib/setup-apt-repo+++ b/scripts/lib/setup-apt-repo@@ -13,6 +13,7 @@ set -xset -eset -uset -o pipefail+shopt -s extglobverify=falseargs="$(getopt -o '' --long verify,list: -- "$@")"@@ -40,6 +41,7 @@ donemkdir -p /var/lib/zulipSOURCES_FILE=/etc/apt/sources.list.d/$LIST.list+PREF_FILE=/etc/apt/preferences.d/$LIST.prefSTAMP_FILE=/etc/apt/sources.list.d/$LIST.list.apt-update-in-progressZULIP_SCRIPTS="$(cd "$(dirname "$(dirname "$0")")" && pwd)"@@ -64,7 +66,7 @@ EOFexit 1fi-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"# Ensure that DEPENDENCIES_HASH_FILE exists before hashing it.touch "$DEPENDENCIES_HASH_FILE"@@ -78,11 +80,8 @@ elif [ "$verify" == true ]; thenexit 1fi-# Ensure that the sources file exists-touch "$SOURCES_FILE"--# Hash it to check if the sources file is changed by the script later.-zulip_source_hash=$(sha1sum "$SOURCES_FILE")+# Hash to check if the configuration is changed by the script later.+hashes=$(sha256sum "$SOURCES_FILE" "$PREF_FILE" 2>/dev/null || true)pre_setup_deps=(lsb-release apt-transport-https ca-certificates gnupg curl)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/"*.asccp "$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" ]; thenexport LIST_PATHexport STAMP_FILEbash "$LIST_PATH/custom.sh"fi-if [ "$zulip_source_hash" = "$(sha1sum "$SOURCES_FILE")" ] && ! [ -e "$STAMP_FILE" ]; then- echo "zulip.list file did not change; skipping apt-get update"+if [ "$hashes" = "$(sha256sum "$SOURCES_FILE" "$PREF_FILE" 2>/dev/null || true)" ] && ! [ -e "$STAMP_FILE" ]; then+ echo "APT configuration did not change; skipping apt-get update"else# 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