Update IDF for download verification
[tails.git] / bin / merge-main-branch
blobc38eb7963fb41d7e86f309870a57c730c8186413
1 #!/bin/bash
3 # shellcheck disable=SC2029
5 set -eu
7 error () {
8 echo "error: ${*}" >&2
9 exit 1
12 USAGE="Usage: $(basename "$0") SRC DST"
14 [ $# -eq 2 ] || error "$USAGE"
16 SRC="$1"
17 DST="$2"
18 WORKDIR=$(mktemp -d)
20 packages_in_suite() {
21 local suite="$1"
22 [ -n "$suite" ] || return 1
23 ssh reprepro@incoming.deb.tails.boum.org reprepro list "$suite" \
24 | sed -r 's,^([^|]+\|){2},,' \
25 | sort --stable --key=1,1 --key=2,2
28 ### Save the list of packages currently present in the APT suite we
29 ### want to merge into
31 packages_in_suite "$DST" > "$WORKDIR/$DST.orig.list"
33 ### Make sure we are not going to overwrite newer packages with older
34 ### ones
36 echo "I: Diff between the $SRC and $DST custom APT suites:"
38 ssh reprepro@incoming.deb.tails.boum.org \
39 tails-diff-suites "$SRC" "$DST"
41 echo "Check if the above diff makes sense!" \
42 "For instance, if any package in ${DST} has a higher version you" \
43 "should investigate if you want to proceed with the merge or " \
44 "if you need a more careful approach cherry-picking specific " \
45 "packages from ${SRC}"
46 echo ""
47 echo -n "Proceed with the merge? (y/n) "
48 read -r answer
49 [ "$answer" = 'y' ] || exit 1
51 echo "I: merging the $SRC Git branch into $DST"
52 echo "I: If you have to resolve a merge conflict in debian/changelog,"
53 echo "I: ensure only the latest UNRELEASED entry is present,"
54 echo "and remove older versions that were never released."
55 git checkout "$DST"
56 git merge "origin/$DST"
57 git merge "$SRC"
59 echo "I: merging the $SRC APT suite into $DST"
60 ssh reprepro@incoming.deb.tails.boum.org \
61 tails-merge-suite "$SRC" "$DST"
63 echo "I: Restoring config/base_branch on $DST if needed"
64 echo "${DST}" > config/base_branch
65 git commit config/base_branch -m "Restore ${DST}'s base branch." || :
67 echo "I: Pushing the $DST Git branch"
68 git push origin "${DST}:${DST}"
70 packages_in_suite "$DST" > "$WORKDIR/$DST.new.list"
72 echo "I: Diff between the $DST APT suite before and after merging:"
73 set +e
74 diff -Naur "$WORKDIR/$DST.orig.list" "$WORKDIR/$DST.new.list"
75 RET=$?
76 set -e
77 case "$RET" in
78 0|1)
79 # diff did its job just fine
83 # diff had trouble
84 error "diff(1) failed."
87 # undocumented diff exit code
88 error "diff(1) returned $? -- I don't know what it means."
90 esac
91 echo "Verify that the merge did not re-add to $DST any package that was"
92 echo "removed from it on purpose earlier."
93 echo "If there are any, remove them manually."