summaryrefslogtreecommitdiffstats
path: root/auto
diff options
context:
space:
mode:
authorTails developers <amnesia@boum.org>2012-02-04 11:35:31 +0100
committerTails developers <amnesia@boum.org>2012-02-04 11:35:31 +0100
commita440a29de9efe3032ac8b11fa2d8990b04d34d5e (patch)
tree3f456d6b8bb7dab1dc5569c9516007b9b33ca219 /auto
parent30ac1cfab32ffed6ea92beba6713c2fb3d23f89f (diff)
Import script that generates custom APT sources lines, and its Cucumber tests.
Diffstat (limited to 'auto')
-rwxr-xr-xauto/scripts/tails-custom-apt-sources56
1 files changed, 56 insertions, 0 deletions
diff --git a/auto/scripts/tails-custom-apt-sources b/auto/scripts/tails-custom-apt-sources
new file mode 100755
index 0000000..7e26096
--- /dev/null
+++ b/auto/scripts/tails-custom-apt-sources
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+set -e
+
+APT_MIRROR_URL="http://deb.tails.boum.org/"
+DEFAULT_COMPONENTS="main"
+
+git_tag_exists() {
+ local tag="$1"
+
+ test -f ".git/refs/tags/$tag"
+}
+
+version_was_released() {
+ local version="$1"
+
+ git_tag_exists "$version"
+}
+
+version_in_changelog() {
+ dpkg-parsechangelog | awk '/^Version: / { print $2 }'
+}
+
+output_apt_binary_source() {
+ local suite="$1"
+ local components="${2:-$DEFAULT_COMPONENTS}"
+
+ echo "deb $APT_MIRROR_URL $suite $components"
+}
+
+current_branch() {
+ git branch | awk '/^\* / { print $2 }'
+}
+
+on_topic_branch() {
+ current_branch | grep -qE '^(feature|bug|bugfix)/'
+}
+
+branch_name_to_suite() {
+ local branch="$1"
+
+ echo "$branch" | sed -e 's,[^a-z0-9-],-,ig' | tr '[A-Z]' '[a-z]'
+}
+
+
+if version_was_released "$(version_in_changelog)"; then
+ output_apt_binary_source "$(version_in_changelog)"
+elif [ "$(current_branch)" = "testing" ]; then
+ output_apt_binary_source testing
+else
+ output_apt_binary_source devel
+fi
+
+if on_topic_branch; then
+ output_apt_binary_source "$(branch_name_to_suite $(current_branch))"
+fi