Merge branch 'stable' into devel
[tails.git] / bin / add-APT-overlay
blob05e5b1695fa2683be764e63afef11d2386f8fffe
1 #!/bin/bash
3 set -e
4 set -u
5 set -x
7 GIT_TOPLEVEL_DIR=$(git rev-parse --show-toplevel)
8 . "$GIT_TOPLEVEL_DIR"/auto/scripts/utils.sh
10 OVERLAY=$(branch_name_to_suite "$(git_current_branch)")
11 OVERLAY_FILE="${GIT_TOPLEVEL_DIR}/config/APT_overlays.d/${OVERLAY}"
12 TICKET=$(git_current_branch | perl -p -E 's/.*?(\d{4,6}).*/$1/')
14 usage() {
15 echo "Usage: $NAME [OPTION]
16 Enables an APT overlay for the current topic branch.
18 Options:
19 --print Don't do anything, just print the name of the suite
20 --wait Wait for the suite to be created on the server. This does *not* enable the APT overlay.
21 --enable This is the normal behavior: enables an APT overlay
25 wait_suite_ready() {
26 url="https://deb.tails.boum.org/dists/${OVERLAY}"
27 while ! curl -s --fail "$url" > /dev/null
29 sleep 5
30 done
33 NAME=$(basename "${0}")
34 LONGOPTS="wait,print,enable,help"
35 if ! getopt -Qq -o "" --longoptions $LONGOPTS -n "${NAME}" -- "$@"
36 then
37 echo "Use --help for usage information" >&2
38 exit 2
40 OPTS=$(getopt -o "" --longoptions $LONGOPTS -n "${NAME}" -- "$@")
41 eval set -- "$OPTS"
42 while [ $# -gt 0 ]; do
43 case $1 in
44 --print)
45 echo "$OVERLAY"
46 exit 0
48 --wait)
49 wait_suite_ready
50 exit
52 --enable)
54 --help)
55 usage
56 exit 0
58 esac
59 shift
60 done
62 touch "${OVERLAY_FILE}"
63 git add "${OVERLAY_FILE}"
64 git commit -m "Enable the ${OVERLAY} APT overlay (refs: #${TICKET})."
65 git show