blob: a3cec3eb8c142fb920ce2abb8d07ac375cce20e7 [file] [log] [blame]
Patrick Georgif61c9e92015-07-13 22:48:46 +02001#!/bin/bash
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +02002# ${VERSION_NAME}: new version name
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +02003# ${COMMIT_ID}: commit id (if not master)
Martin Roth7a00a632017-04-04 15:05:24 -06004# ${USERNAME}: username (if not default to https)
5# ${GPG_KEY_ID}: gpg key id (if not don't sign)
Martin Rothdd78aa62016-10-04 16:45:17 -06006VERSION_NAME=$1
7COMMIT_ID=$2
8USERNAME=$3
9GPG_KEY_ID=$4
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020010
Patrick Georgif61c9e92015-07-13 22:48:46 +020011set -e
Alexander Couzens871da8e2016-09-09 00:05:54 +020012
13# set local + tz to be reproducible
14LC_ALL=C
15LANG=C
Paul Menzel38a906b2017-09-27 15:06:57 +020016TZ=UTC0
Alexander Couzens871da8e2016-09-09 00:05:54 +020017export LC_ALL LANG TZ
18
Martin Roth7a00a632017-04-04 15:05:24 -060019if [ -z "$VERSION_NAME" ] || [ "$VERSION_NAME" = "--help" ] || [ -z "$COMMIT_ID" ]; then
20 echo "usage: $0 <version> <commit id> [username] [gpg key id]"
Martin Rothdd78aa62016-10-04 16:45:17 -060021 echo "Tags a new coreboot version and creates a tar archive"
22 echo
23 echo "version: New version name to tag the tree with"
24 echo "commit id: check out this commit-id after cloning the coreboot tree"
Martin Rothdd78aa62016-10-04 16:45:17 -060025 echo "username: clone the tree using ssh://USERNAME - defaults to https://"
Martin Roth7a00a632017-04-04 15:05:24 -060026 echo "gpg key id: used to tag the version, and generate a gpg signature"
Patrick Georgif61c9e92015-07-13 22:48:46 +020027 exit 1
28fi
Martin Rothdd78aa62016-10-04 16:45:17 -060029
30# Verify that tar supports --sort
31if ! tar --sort=name -cf /dev/null /dev/null 2>/dev/null ; then
32 echo "Error: The installed version of tar does not support --sort"
33 echo " GNU tar version 1.28 or greater is required. Exiting."
34 exit 1
35fi
36
Martin Roth7a00a632017-04-04 15:05:24 -060037if [ ! -d "coreboot-${VERSION_NAME}" ]; then
38 if [ -n "${USERNAME}" ]; then
39 git clone "ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git" "coreboot-${VERSION_NAME}"
40 else
41 git clone https://review.coreboot.org/coreboot.git "coreboot-${VERSION_NAME}"
42 fi
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020043fi
Martin Rothdd78aa62016-10-04 16:45:17 -060044
45cd "coreboot-${VERSION_NAME}" || exit 1
46if [ -n "$COMMIT_ID" ]; then
47 git reset --hard "$COMMIT_ID"
Patrick Georgi68e3f6d2016-01-29 23:02:56 +010048fi
Martin Rothdd78aa62016-10-04 16:45:17 -060049
Patrick Georgif61c9e92015-07-13 22:48:46 +020050git submodule update --init --checkout
Martin Rothdd78aa62016-10-04 16:45:17 -060051if [ -n "$GPG_KEY_ID" ]; then
52 git tag -a -s -u "$GPG_KEY_ID" --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020053else
Martin Rothdd78aa62016-10-04 16:45:17 -060054 git tag -a --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020055fi
Martin Rothdd78aa62016-10-04 16:45:17 -060056
57printf "%s-%s\n" "$VERSION_NAME" "$(git log --pretty=%H|head -1)" > .coreboot-version
Patrick Georgi68e3f6d2016-01-29 23:02:56 +010058tstamp=$(git log --pretty=format:%ci -1)
Patrick Georgif61c9e92015-07-13 22:48:46 +020059cd ..
Martin Rothdd78aa62016-10-04 16:45:17 -060060
Martin Roth1a903592016-10-05 16:35:29 -060061tar --sort=name --mtime="$tstamp" --owner=coreboot:1000 --group=coreboot:1000 --exclude=*/.git --exclude=*/.gitignore --exclude="coreboot-${VERSION_NAME}/3rdparty/blobs" -cvf - "coreboot-${VERSION_NAME}" |xz -9 > "coreboot-${VERSION_NAME}.tar.xz"
62tar --sort=name --mtime="$tstamp" --owner=coreboot:1000 --group=coreboot:1000 --exclude=*/.git --exclude=*/.gitignore -cvf - "coreboot-${VERSION_NAME}/3rdparty/blobs" |xz -9 > "coreboot-blobs-${VERSION_NAME}.tar.xz"
Martin Rothdd78aa62016-10-04 16:45:17 -060063
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020064if [ -n "${GPG_KEY_ID}" ]; then
Martin Rothdd78aa62016-10-04 16:45:17 -060065 gpg2 --armor --local-user "$GPG_KEY_ID" --output "coreboot-${VERSION_NAME}.tar.xz.sig" --detach-sig "coreboot-${VERSION_NAME}.tar.xz"
66 gpg2 --armor --local-user "$GPG_KEY_ID" --output "coreboot-blobs-${VERSION_NAME}.tar.xz.sig" --detach-sig "coreboot-blobs-${VERSION_NAME}.tar.xz"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020067fi