mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 08:26:11 +00:00
scripts: Make setup-apt-repo a no-op if nothing has changed.
This performance optimization is important for being able to run this from puppet in our production environment.
This commit is contained in:
@@ -2,9 +2,25 @@
|
|||||||
set -x
|
set -x
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Ensure the directory for LAST_DEPENDENCIES_HASH exists
|
||||||
|
mkdir -p /var/lib/zulip
|
||||||
|
|
||||||
SOURCES_FILE=/etc/apt/sources.list.d/zulip.list
|
SOURCES_FILE=/etc/apt/sources.list.d/zulip.list
|
||||||
STAMP_FILE=/etc/apt/sources.list.d/zulip.list.apt-update-in-progress
|
STAMP_FILE=/etc/apt/sources.list.d/zulip.list.apt-update-in-progress
|
||||||
|
|
||||||
|
ZULIP_SCRIPTS="$(dirname "$(dirname "$0")")"
|
||||||
|
DEPENDENCIES_HASH=$(sha1sum "$ZULIP_SCRIPTS/setup/"*.asc "$0")
|
||||||
|
DEPENDENCIES_HASH_FILE="/var/lib/zulip/setup-repositories-state"
|
||||||
|
# Ensure that DEPENDENCIES_HASH_FILE exists before hashing it.
|
||||||
|
touch "$DEPENDENCIES_HASH_FILE"
|
||||||
|
LAST_DEPENDENCIES_HASH="$(cat "$DEPENDENCIES_HASH_FILE")"
|
||||||
|
|
||||||
|
# First, we only do anything in setup-apt-repo if any of its inputs
|
||||||
|
# (apt keys, code, etc.) changed.
|
||||||
|
if [ "$DEPENDENCIES_HASH" = "$LAST_DEPENDENCIES_HASH" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Ensure that the sources file exists
|
# Ensure that the sources file exists
|
||||||
touch "$SOURCES_FILE"
|
touch "$SOURCES_FILE"
|
||||||
|
|
||||||
@@ -48,3 +64,5 @@ else
|
|||||||
touch "$STAMP_FILE"
|
touch "$STAMP_FILE"
|
||||||
apt-get update && rm -f "$STAMP_FILE"
|
apt-get update && rm -f "$STAMP_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "$DEPENDENCIES_HASH" > "$DEPENDENCIES_HASH_FILE"
|
||||||
|
|||||||
Reference in New Issue
Block a user