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 |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 3 | # ${COMMIT_ID}: commit id (if not master) |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 4 | # ${USERNAME}: username (if not default to https) |
| 5 | # ${GPG_KEY_ID}: gpg key id (if not don't sign) |
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 |
Paul Menzel | 38a906b | 2017-09-27 15:06:57 +0200 | [diff] [blame] | 16 | TZ=UTC0 |
Alexander Couzens | 871da8e | 2016-09-09 00:05:54 +0200 | [diff] [blame] | 17 | export LC_ALL LANG TZ |
| 18 | |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 19 | if [ -z "$VERSION_NAME" ] || [ "$VERSION_NAME" = "--help" ] || [ -z "$COMMIT_ID" ]; then |
| 20 | echo "usage: $0 <version> <commit id> [username] [gpg key id]" |
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" |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 25 | echo "username: clone the tree using ssh://USERNAME - defaults to https://" |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 26 | echo "gpg key id: used to tag the version, and generate a gpg signature" |
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 | |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 37 | if [ ! -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 Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 43 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 44 | |
| 45 | cd "coreboot-${VERSION_NAME}" || exit 1 |
| 46 | if [ -n "$COMMIT_ID" ]; then |
| 47 | git reset --hard "$COMMIT_ID" |
Patrick Georgi | 68e3f6d | 2016-01-29 23:02:56 +0100 | [diff] [blame] | 48 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 49 | |
Patrick Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 50 | git submodule update --init --checkout |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 51 | if [ -n "$GPG_KEY_ID" ]; then |
| 52 | 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] | 53 | else |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 54 | git tag -a --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME" |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 55 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 56 | |
| 57 | 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] | 58 | tstamp=$(git log --pretty=format:%ci -1) |
Patrick Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 59 | cd .. |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 60 | |
Martin Roth | 1a90359 | 2016-10-05 16:35:29 -0600 | [diff] [blame] | 61 | 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" |
| 62 | 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] | 63 | |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 64 | if [ -n "${GPG_KEY_ID}" ]; then |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 65 | 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 Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 67 | fi |