Patrick Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 1 | #!/bin/bash |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 2 | # ${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 Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 6 | VERSION_NAME=$1 |
| 7 | COMMIT_ID=$2 |
| 8 | USERNAME=$3 |
| 9 | GPG_KEY_ID=$4 |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 10 | |
Patrick Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 11 | set -e |
Alexander Couzens | 871da8e | 2016-09-09 00:05:54 +0200 | [diff] [blame] | 12 | |
| 13 | # set local + tz to be reproducible |
| 14 | LC_ALL=C |
| 15 | LANG=C |
| 16 | TZ=UTC |
| 17 | export LC_ALL LANG TZ |
| 18 | |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 19 | if [ -z "$VERSION_NAME" ] || [ "$VERSION_NAME" = "--help" ]; then |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 20 | echo "usage: $0 <version> [commit id] [gpg key id] [username]" |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 21 | 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 Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 27 | exit 1 |
| 28 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 29 | |
| 30 | # Verify that tar supports --sort |
| 31 | if ! 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 |
| 35 | fi |
| 36 | |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 37 | if [ -n "${USERNAME}" ]; then |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 38 | git clone "ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git" "coreboot-${VERSION_NAME}" |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 39 | else |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 40 | git clone https://review.coreboot.org/coreboot.git "coreboot-${VERSION_NAME}" |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 41 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 42 | |
| 43 | cd "coreboot-${VERSION_NAME}" || exit 1 |
| 44 | if [ -n "$COMMIT_ID" ]; then |
| 45 | git reset --hard "$COMMIT_ID" |
Patrick Georgi | 68e3f6d | 2016-01-29 23:02:56 +0100 | [diff] [blame] | 46 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 47 | |
Patrick Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 48 | git submodule update --init --checkout |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 49 | if [ -n "$GPG_KEY_ID" ]; then |
| 50 | git tag -a -s -u "$GPG_KEY_ID" --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME" |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 51 | else |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 52 | git tag -a --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME" |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 53 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 54 | |
| 55 | printf "%s-%s\n" "$VERSION_NAME" "$(git log --pretty=%H|head -1)" > .coreboot-version |
Patrick Georgi | 68e3f6d | 2016-01-29 23:02:56 +0100 | [diff] [blame] | 56 | tstamp=$(git log --pretty=format:%ci -1) |
Patrick Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 57 | cd .. |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 58 | |
Martin Roth | 1a90359 | 2016-10-05 16:35:29 -0600 | [diff] [blame] | 59 | tar --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" |
| 60 | tar --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 Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 61 | |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 62 | if [ -n "${GPG_KEY_ID}" ]; then |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 63 | 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 Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 65 | fi |