blob: 895285e2e96af1abd72858ea77cde0b20ea072c6 [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
3# ${GPG_KEY_ID}: gpg key id (if not don't sign)
4# ${USERNAME}: username (if not default to https)
5# ${COMMIT_ID}: commit id (if not master)
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
16TZ=UTC
17export LC_ALL LANG TZ
18
Martin Rothdd78aa62016-10-04 16:45:17 -060019if [ -z "$VERSION_NAME" ] || [ "$VERSION_NAME" = "--help" ]; then
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020020 echo "usage: $0 <version> [commit id] [gpg key id] [username]"
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"
25 echo "gpg key id: used to tag the version, and generate a gpg signature"
26 echo "username: clone the tree using ssh://USERNAME - defaults to https://"
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
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020037if [ -n "${USERNAME}" ]; then
Martin Rothdd78aa62016-10-04 16:45:17 -060038 git clone "ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git" "coreboot-${VERSION_NAME}"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020039else
Martin Rothdd78aa62016-10-04 16:45:17 -060040 git clone https://review.coreboot.org/coreboot.git "coreboot-${VERSION_NAME}"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020041fi
Martin Rothdd78aa62016-10-04 16:45:17 -060042
43cd "coreboot-${VERSION_NAME}" || exit 1
44if [ -n "$COMMIT_ID" ]; then
45 git reset --hard "$COMMIT_ID"
Patrick Georgi68e3f6d2016-01-29 23:02:56 +010046fi
Martin Rothdd78aa62016-10-04 16:45:17 -060047
Patrick Georgif61c9e92015-07-13 22:48:46 +020048git submodule update --init --checkout
Martin Rothdd78aa62016-10-04 16:45:17 -060049if [ -n "$GPG_KEY_ID" ]; then
50 git tag -a -s -u "$GPG_KEY_ID" --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020051else
Martin Rothdd78aa62016-10-04 16:45:17 -060052 git tag -a --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020053fi
Martin Rothdd78aa62016-10-04 16:45:17 -060054
55printf "%s-%s\n" "$VERSION_NAME" "$(git log --pretty=%H|head -1)" > .coreboot-version
Patrick Georgi68e3f6d2016-01-29 23:02:56 +010056tstamp=$(git log --pretty=format:%ci -1)
Patrick Georgif61c9e92015-07-13 22:48:46 +020057cd ..
Martin Rothdd78aa62016-10-04 16:45:17 -060058
Martin Roth1a903592016-10-05 16:35:29 -060059tar --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"
60tar --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 -060061
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020062if [ -n "${GPG_KEY_ID}" ]; then
Martin Rothdd78aa62016-10-04 16:45:17 -060063 gpg2 --armor --local-user "$GPG_KEY_ID" --output "coreboot-${VERSION_NAME}.tar.xz.sig" --detach-sig "coreboot-${VERSION_NAME}.tar.xz"
64 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 +020065fi