Commit 9766b011 authored by intrigeri's avatar intrigeri
Browse files

tails-diff-suite: when --iso is specified, take into account config/{base_branch,APT_overlays}.

parent 6ea4afb7
......@@ -3,36 +3,149 @@
set -e
set -u
case "$1" in
-i|--iso)
MODE=iso
shift
;;
*)
MODE=this_suite_only
esac
OLD="$1"
NEW="$2"
USAGE="Usage: tails-diff-suites OLD NEW"
### Constants
#
# Regexps here are Extended Regular Expressions, unless said otherwise.
USAGE="Usage: tails-diff-suites [-d|--deep] BRANCH_1 BRANCH_2"
GIT_DIR=/srv/reprepro/tails.git
BRANCH_RE='^[.a-zA-Z0-9_/-]+$'
APT_SUITE_RE='^[.a-z0-9-]+$'
TAG_RE='^[0-9][0-9.]*(?:-(?:alpha|beta|rc)\d*)?$'
### Functions
. /usr/local/share/tails-reprepro/functions.sh
# -------------------- XXX: move to functions.sh ---------------------
assert_is_branch_name() {
local branch="$1"
if ! echo "$branch" | grep -q -E "$BRANCH_RE" ; then
error "Invalid branch name: '$branch'"
fi
}
assert_is_apt_suite() {
local suite="$1"
if ! echo "$suite" | grep -q -E "$APT_SUITE_RE" ; then
error "Invalid APT suite name: '$suite'"
fi
}
assert_is_list_of_apt_suites() {
for suite in "$@" ; do
assert_is_apt_suite "$suite"
done
}
is_tag() {
local rev="$1"
echo "$rev" | grep -q -E "$TAG_RE"
}
# -------------------- XXX -------------------------------------------
packages_in_suite() {
local suite="$1"
[ -n "$suite" ] || return 1
reprepro list "$suite" | sed -r 's,^([^|]+\|){2},,'
}
packages_in_suites() {
for suite in "$@" ; do
packages_in_suite "$suite"
done
}
packages_in_iso() {
local branch="$1"
local git_dir="$2"
[ -n "$branch" ] || return 1
[ -n "$git_dir" ] || return 2
# Gather information from the content of the branch we are looking
# at. Let's try to be a bit defensive, as we don't want to trust
# config/{base_branch,APT_overlays} too much... even though the
# rest of the build system would run plenty of code from said
# branch, but at least it's (hopefully) clear to its users, which
# may not necessarily be the case here.
# XXX: this won't work when the last version in debian/changelog
# has been released, in which case we should look into the tag's
# APT suite instead of the base branch's one. But duplicating more
# code from tails-custom-apt-sources feels even worse, and the
# needed refactoring (#9171) may be tricky.
base_branch=$(git --git-dir="$git_dir" show "${branch}:config/base_branch")
assert_is_branch_name "$base_branch"
base_branch_suite=$(ref_name_to_suite "$base_branch")
assert_is_apt_suite "$base_branch_suite"
overlays=$(git --git-dir="$git_dir" show "${branch}:config/APT_overlays")
assert_is_list_of_apt_suites $overlays
# And now we have all the info we need to output the suites we want
# Cheat a bit to allow the user to compare tags.
if is_tag "$branch" ; then
packages_in_suite "$branch"
else
packages_in_suite "$base_branch_suite"
fi
packages_in_suites $overlays
}
### Sanity checks
[ -n "$OLD" ] || error "$USAGE"
[ -n "$NEW" ] || error "$USAGE"
[ "$OLD" != "$NEW" ] || error "Cannot diff an APT suite with itself."
assert_is_branch_name "$OLD"
assert_is_branch_name "$NEW"
[ -n "$GIT_DIR" ] || error "GIT_DIR ($GIT_DIR) is not set."
[ -d "$GIT_DIR" ] || error "GIT_DIR ($GIT_DIR) is not a directory."
[ -r "$GIT_DIR" ] || error "GIT_DIR ($GIT_DIR) is not readable."
### Main
WORKDIR=$(mktemp -d)
OLDLIST="$WORKDIR/{$OLD}.list"
NEWLIST="$WORKDIR/{$NEW}.list"
OLDLIST="$WORKDIR/$(ref_name_to_suite "$OLD").list"
NEWLIST="$WORKDIR/$(ref_name_to_suite "$NEW").list"
packages_in_suite "$OLD" > "$OLDLIST"
packages_in_suite "$NEW" > "$NEWLIST"
case "$MODE" in
iso)
packages_in_iso "$OLD" "$GIT_DIR" > "$OLDLIST"
packages_in_iso "$NEW" "$GIT_DIR" > "$NEWLIST"
;;
this_suite_only)
OLD_SUITE=$(ref_name_to_suite "$OLD")
NEW_SUITE=$(ref_name_to_suite "$NEW")
packages_in_suite "$OLD_SUITE" > "$OLDLIST"
packages_in_suite "$NEW_SUITE" > "$NEWLIST"
;;
*)
error "Unsupported mode: '$MODE'"
esac
diff -Naur "$OLDLIST" "$NEWLIST"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment