[coreboot-gerrit] New patch to review for coreboot: Update build-release script

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Wed Oct 5 00:45:39 CEST 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16883

-gerrit

commit c4a5181f653d1e204d9402afd49a442dd92386cd
Author: Martin Roth <martinroth at google.com>
Date:   Tue Oct 4 16:45:17 2016 -0600

    Update build-release script
    
    - Add more help text.
    - Remove braces from variables where the variable is isolated.
    - Remove --recurse-submodules from clone.  This breaks on old coreboot
    versions.
    - Add some whitespace between blocks.
    - Fix all shellcheck warnings.
    - Verify tar version and fail if it doesn't support --sort.
    
    Change-Id: I4a49df99532d9a92a4a05bceff16f96a4fc3e205
    Signed-off-by: Martin Roth <martinroth at google.com>
---
 util/release/build-release | 56 ++++++++++++++++++++++++++++++----------------
 1 file changed, 37 insertions(+), 19 deletions(-)

diff --git a/util/release/build-release b/util/release/build-release
index 11e7177..2525252 100755
--- a/util/release/build-release
+++ b/util/release/build-release
@@ -3,10 +3,10 @@
 # ${GPG_KEY_ID}: gpg key id (if not don't sign)
 # ${USERNAME}: username (if not default to https)
 # ${COMMIT_ID}: commit id (if not master)
-VERSION_NAME=${1}
-COMMIT_ID=${2}
-USERNAME=${3}
-GPG_KEY_ID=${4}
+VERSION_NAME=$1
+COMMIT_ID=$2
+USERNAME=$3
+GPG_KEY_ID=$4
 
 set -e
 
@@ -16,32 +16,50 @@ LANG=C
 TZ=UTC
 export LC_ALL LANG TZ
 
-if [ -z "${VERSION_NAME}" ] || [ "${VERSION_NAME}" = "--help" ]; then
+if [ -z "$VERSION_NAME" ] || [ "$VERSION_NAME" = "--help" ]; then
 	echo "usage: $0 <version> [commit id] [gpg key id] [username]"
-	echo "tags a new coreboot version and creates a tar archive"
+	echo "Tags a new coreboot version and creates a tar archive"
+	echo
+	echo "version:    New version name to tag the tree with"
+	echo "commit id:  check out this commit-id after cloning the coreboot tree"
+	echo "gpg key id: used to tag the version, and generate a gpg signature"
+	echo "username:   clone the tree using ssh://USERNAME - defaults to https://"
 	exit 1
 fi
+
+# Verify that gnu tar v1.28 or newer is present to support --sort
+tarversion=$(tar --version | grep '(GNU tar)' | sed 's/.*) //' | sed 's/\.//2')
+if [ -z "$tarversion" ] || (( $(echo "$tarversion < 1.28" | bc -l) )); then
+	echo "Error: GNU tar version 1.28 or greater is required.  Exiting."
+	exit 1
+fi
+
 if [ -n "${USERNAME}" ]; then
-	git clone --recurse-submodules ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git coreboot-${VERSION_NAME}
+	git clone "ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git" "coreboot-${VERSION_NAME}"
 else
-	git clone --recurse-submodules https://review.coreboot.org/coreboot.git coreboot-${VERSION_NAME}
+	git clone https://review.coreboot.org/coreboot.git "coreboot-${VERSION_NAME}"
 fi
-cd coreboot-${VERSION_NAME}
-if [ -n "${COMMIT_ID}" ]; then
-	git reset --hard ${COMMIT_ID}
+
+cd "coreboot-${VERSION_NAME}" || exit 1
+if [ -n "$COMMIT_ID" ]; then
+	git reset --hard "$COMMIT_ID"
 fi
+
 git submodule update --init --checkout
-if [ -n "${GPG_KEY_ID}" ]; then
-	git tag -a -s -u ${GPG_KEY_ID} --force ${VERSION_NAME} -m "coreboot version ${VERSION_NAME}"
+if [ -n "$GPG_KEY_ID" ]; then
+	git tag -a -s -u "$GPG_KEY_ID" --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
 else
-	git tag -a --force ${VERSION_NAME} -m "coreboot version ${VERSION_NAME}"
+	git tag -a --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
 fi
-printf "${VERSION_NAME}-$(git log --pretty=%H|head -1)\n" > .coreboot-version
+
+printf "%s-%s\n" "$VERSION_NAME"  "$(git log --pretty=%H|head -1)" > .coreboot-version
 tstamp=$(git log --pretty=format:%ci -1)
 cd ..
-tar --sort=name --mtime="$tstamp" --owner=coreboot:1000 --group=coreboot:1000 --exclude-vcs --exclude=coreboot-${VERSION_NAME}/3rdparty/blobs -cvf - coreboot-${VERSION_NAME} |xz -9 > coreboot-${VERSION_NAME}.tar.xz
-tar --sort=name --mtime="$tstamp" --owner=coreboot:1000 --group=coreboot:1000 --exclude-vcs -cvf - coreboot-${VERSION_NAME}/3rdparty/blobs |xz -9 > coreboot-blobs-${VERSION_NAME}.tar.xz
+
+tar --sort=name --mtime="$tstamp" --owner=coreboot:1000 --group=coreboot:1000 --exclude-vcs --exclude="coreboot-${VERSION_NAME}/3rdparty/blobs" -cvf - "coreboot-${VERSION_NAME}" |xz -9 > "coreboot-${VERSION_NAME}.tar.xz"
+tar --sort=name --mtime="$tstamp" --owner=coreboot:1000 --group=coreboot:1000 --exclude-vcs -cvf - "coreboot-${VERSION_NAME}/3rdparty/blobs" |xz -9 > "coreboot-blobs-${VERSION_NAME}.tar.xz"
+
 if [ -n "${GPG_KEY_ID}" ]; then
-	gpg2 --armor --local-user ${GPG_KEY_ID} --output coreboot-${VERSION_NAME}.tar.xz.sig --detach-sig coreboot-${VERSION_NAME}.tar.xz
-	gpg2 --armor --local-user ${GPG_KEY_ID} --output coreboot-blobs-${VERSION_NAME}.tar.xz.sig --detach-sig coreboot-blobs-${VERSION_NAME}.tar.xz
+	gpg2 --armor --local-user "$GPG_KEY_ID" --output "coreboot-${VERSION_NAME}.tar.xz.sig" --detach-sig "coreboot-${VERSION_NAME}.tar.xz"
+	gpg2 --armor --local-user "$GPG_KEY_ID" --output "coreboot-blobs-${VERSION_NAME}.tar.xz.sig" --detach-sig "coreboot-blobs-${VERSION_NAME}.tar.xz"
 fi



More information about the coreboot-gerrit mailing list