[buildbot] phase1: add helper scripts for creating branches and tags
LEDE Commits
lede-commits at lists.infradead.org
Mon Nov 28 11:26:00 PST 2016
jow pushed a commit to buildbot.git, branch master:
https://git.lede-project.org/13ae49f20e554bee97c0d7b0f866f45dd4173b42
commit 13ae49f20e554bee97c0d7b0f866f45dd4173b42
Author: Jo-Philipp Wich <jo at mein.io>
AuthorDate: Mon Nov 28 19:35:40 2016 +0100
phase1: add helper scripts for creating branches and tags
These scripts will be used to prepare release branches and repository tags.
Signed-off-by: Jo-Philipp Wich <jo at mein.io>
---
phase1/makebranch.sh | 137 +++++++++++++++++++++++++++++++++++++++++
phase1/maketag.sh | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 305 insertions(+)
diff --git a/phase1/makebranch.sh b/phase1/makebranch.sh
new file mode 100755
index 0000000..016f3a8
--- /dev/null
+++ b/phase1/makebranch.sh
@@ -0,0 +1,137 @@
+#!/usr/bin/env bash
+
+git_author="Release System"
+git_email="lede-dev at lists.infradead.org"
+
+base_url="http://downloads.lede-project.org/releases"
+
+[ -f "./feeds.conf.default" ] || {
+ echo "Please execute as ./${0##*/}" >&2
+ exit 1
+}
+
+usage() {
+ {
+ echo ""
+ echo "Usage: $0 [-i] [-a <Git author>] [-e <Git email>] \\"
+ echo " [-u <Download base url>] -n <codename> -v <version>"
+ echo ""
+ echo "-i"
+ echo "Exit successfully if branch already exists"
+ echo ""
+ echo "-a Git author [$git_author]"
+ echo "Override the author name used for automated Git commits"
+ echo ""
+ echo "-e Git email [$git_email]"
+ echo "Override the email used for automated Git commits"
+ echo ""
+ echo "-u Download base url [$base_url]"
+ echo "Use the given URL as base for download repositories"
+ echo ""
+ exit 1
+ } >&2
+}
+
+while getopts "a:e:iu:n:v:" opt; do
+ case "$opt" in
+ a) git_author="$OPTARG" ;;
+ e) git_email="$OPTARG" ;;
+ i) ignore_existing=1 ;;
+ u) base_url="${OPTARG%/}" ;;
+ n) codename="$OPTARG" ;;
+ v)
+ case "$OPTARG" in
+ [0-9]*.[0-9]*)
+ version="$(echo "$OPTARG" | cut -d. -f1-2)"
+ ;;
+ *)
+ echo "Unexpected version format: $OPTARG" >&2
+ exit 1
+ ;;
+ esac
+ ;;
+ \?)
+ echo "Unexpected option: -$OPTARG" >&2
+ usage
+ ;;
+ :)
+ echo "Missing argument for option: -$OPTARG" >&2
+ usage
+ ;;
+ esac
+done
+
+[ -n "$codename" -a -n "$version" ] || usage
+
+if git rev-parse "lede-${version}^{tree}" >/dev/null 2>/dev/null; then
+ if [ -z "$ignore_existing" ]; then
+ echo "Branch lede-${version} already exists!" >&2
+ exit 1
+ fi
+
+ exit 0
+fi
+
+revnum="$(./scripts/getver.sh)"
+githash="$(git log --format=%h -1)"
+
+prev_branch="$(git symbolic-ref -q HEAD)"
+
+if [ "$prev_branch" != "refs/heads/master" ]; then
+ echo "Expecting current branch name to be \"master\"," \
+ "but it is \"${prev_branch#refs/heads/}\" - aborting."
+
+ exit 1
+fi
+
+export GIT_AUTHOR_NAME="$git_author"
+export GIT_AUTHOR_EMAIL="$git_email"
+export GIT_COMMITTER_NAME="$git_author"
+export GIT_COMMITTER_EMAIL="$git_email"
+
+git checkout -b "lede-$version"
+
+while read type name url; do
+ case "$type" in
+ src-git)
+ case "$url" in
+ *^*|*\;*) : ;;
+ *)
+ ref="$(git ls-remote "$url" "lede-$version")"
+
+ if [ -z "$ref" ]; then
+ echo "WARNING: Feed \"$name\" provides no" \
+ "\"lede-$version\" branch - using master!" >&2
+ else
+ url="$url;lede-$version"
+ fi
+ ;;
+ esac
+ echo "$type $name $url"
+ ;;
+ src-*)
+ echo "$type $name $url"
+ ;;
+ esac
+done < feeds.conf.default > feeds.conf.branch && \
+ mv feeds.conf.branch feeds.conf.default
+
+sed -e 's!^RELEASE:=.*!RELEASE:='"$codename"'!g' \
+ -e 's!\(VERSION_NUMBER:=\$(if .*\),[^,]*)!\1,'"$version-HEAD"')!g' \
+ -e 's!\(VERSION_CODE:=\$(if .*\),[^,]*)!\1,$(REVISION))!g' \
+ -e 's!\(VERSION_REPO:=\$(if .*\),[^,]*)!\1,'"$base_url/$version-HEAD"')!g' \
+ include/version.mk > include/version.branch && \
+ mv include/version.branch include/version.mk
+
+sed -e 's!http://downloads.lede-project.org/[^"]*!'"$base_url/$version-HEAD"'!g' \
+ package/base-files/image-config.in > package/base-files/image-config.branch && \
+ mv package/base-files/image-config.branch package/base-files/image-config.in
+
+git commit -sm "LEDE v$version: set branch defaults" \
+ feeds.conf.default \
+ include/version.mk \
+ package/base-files/image-config.in
+
+git --no-pager log -p -1
+git push origin "refs/heads/lede-$version:refs/heads/lede-$version"
+git checkout "${prev_branch#refs/heads/}"
diff --git a/phase1/maketag.sh b/phase1/maketag.sh
new file mode 100755
index 0000000..c233e44
--- /dev/null
+++ b/phase1/maketag.sh
@@ -0,0 +1,168 @@
+#!/usr/bin/env bash
+
+git_author="Release System"
+git_email="lede-dev at lists.infradead.org"
+
+base_url="http://downloads.lede-project.org/releases"
+
+[ -f "./feeds.conf.default" ] || {
+ echo "Please execute as ./${0##*/}" >&2
+ exit 1
+}
+
+usage() {
+ {
+ echo ""
+ echo "Usage: $0 [-i] [-a <Git author>] [-e <Git email>] \\"
+ echo " [-k <GPG key id>] [-p <GPG passphrase file>] \\"
+ echo " [-u <Download base url>] -v <version>"
+ echo ""
+ echo "-i"
+ echo "Exit successfully if tag already exists"
+ echo ""
+ echo "-a Git author [$git_author]"
+ echo "Override the author name used for automated Git commits"
+ echo ""
+ echo "-e Git email [$git_email]"
+ echo "Override the email used for automated Git commits"
+ echo ""
+ echo "-k GPG key id [none]"
+ echo "Enable GPG signing of tags with given GPG key id"
+ echo ""
+ echo "-p GPG passphrase file [none]"
+ echo "Use the passphrase stored in the given file for signing"
+ echo ""
+ echo "-u Download base url [$base_url]"
+ echo "Use the given URL as base for download repositories"
+ echo ""
+ exit 1
+ } >&2
+}
+
+while getopts "a:e:ik:p:u:v:" opt; do
+ case "$opt" in
+ a) git_author="$OPTARG" ;;
+ e) git_email="$OPTARG" ;;
+ i) ignore_existing=1 ;;
+ k) gpg_keyid="${OPTARG#0x}" ;;
+ p) gpg_passfile="${OPTARG}" ;;
+ u) base_url="${OPTARG%/}" ;;
+ v)
+ case "$OPTARG" in
+ [0-9]*.[0-9]*.[0-9]*)
+ version="$OPTARG"
+ basever="$(echo "$version" | cut -d. -f1-2)"
+ ;;
+ *)
+ echo "Unexpected version format: $OPTARG" >&2
+ exit 1
+ ;;
+ esac
+ ;;
+ \?)
+ echo "Unexpected option: -$OPTARG" >&2
+ usage
+ ;;
+ :)
+ echo "Missing argument for option: -$OPTARG" >&2
+ usage
+ ;;
+ esac
+done
+
+[ -n "$version" ] || usage
+
+if git rev-parse "v${version}^{tag}" >/dev/null 2>/dev/null; then
+ if [ -z "$ignore_existing" ]; then
+ echo "Tag v${version} already exists!" >&2
+ exit 1
+ fi
+
+ exit 0
+fi
+
+revnum="$(./scripts/getver.sh)"
+githash="$(git log --format=%h -1)"
+
+prev_branch="$(git symbolic-ref -q HEAD)"
+
+case "$prev_branch" in
+ *-$basever) : ;;
+ *)
+ echo "Expecting current branch name to end in \"-$basever\"," \
+ "but it is \"${prev_branch#refs/heads/}\" - aborting."
+
+ exit 1
+ ;;
+esac
+
+export GIT_AUTHOR_NAME="$git_author"
+export GIT_AUTHOR_EMAIL="$git_email"
+export GIT_COMMITTER_NAME="$git_author"
+export GIT_COMMITTER_EMAIL="$git_email"
+
+git checkout -b "release-$version"
+
+while read type name url; do
+ case "$type" in
+ src-git)
+ case "$url" in
+ *^*) sha1="${url##*^}" ;;
+ *\;*) sha1="$(git ls-remote "${url%;*}" "${url##*;}")" ;;
+ *) sha1="$(git ls-remote "$url" "master")" ;;
+ esac
+ echo "$type $name ${url%[;^]*}${sha1:+^${sha1:0:40}}"
+ ;;
+ src-svn)
+ case "$url" in
+ *\;*) rev="${url##*;}" ;;
+ *) rev="$(svn log -l 1 "$url" | sed -ne '2s/ .*$//p')" ;;
+ esac
+ echo "$type $name ${url%;*}${rev:+;$rev}"
+ ;;
+ src-*)
+ echo "$type $name $url"
+ ;;
+ esac
+done < feeds.conf.default > feeds.conf.tagged && \
+ mv feeds.conf.tagged feeds.conf.default
+
+sed -e 's!\(VERSION_NUMBER:=\$(if .*\),[^,]*)!\1,'"$version"')!g' \
+ -e 's!\(VERSION_CODE:=\$(if .*\),[^,]*)!\1,'"$revnum-$githash"')!g' \
+ -e 's!\(VERSION_REPO:=\$(if .*\),[^,]*)!\1,'"$base_url/$version"')!g' \
+ include/version.mk > include/version.tagged && \
+ mv include/version.tagged include/version.mk
+
+sed -e 's!http://downloads.lede-project.org/[^"]*!'"$base_url/$version"'!g' \
+ package/base-files/image-config.in > package/base-files/image-config.tagged && \
+ mv package/base-files/image-config.tagged package/base-files/image-config.in
+
+git commit -sm "LEDE v$version: adjust config defaults" \
+ feeds.conf.default \
+ include/version.mk \
+ package/base-files/image-config.in
+
+
+if [ -n "$gpg_keyid" -a -n "$gpg_passfile" ]; then
+ gpg_script="$(tempfile)"
+
+ cat <<-EOT > "$gpg_script"
+ #!/usr/bin/env bash
+ exec $(which gpg) --batch --passphrase-file $gpg_passfile "\$@"
+ EOT
+
+ chmod 0700 "$gpg_script"
+fi
+
+git ${gpg_script:+-c "gpg.program=$gpg_script"} tag \
+ -a "v$version" \
+ -m "LEDE v$version Release" \
+ ${gpg_keyid:+-s -u "$gpg_keyid"}
+
+[ -n "$gpg_script" ] && rm -f "$gpg_script"
+
+git checkout "${prev_branch#refs/heads/}"
+git branch -D "release-$version"
+
+git --no-pager show "v$version"
+git push --follow-tags origin "refs/tags/v$version:refs/tags/v$version"
More information about the lede-commits
mailing list