Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Patrick Georgi | 1afe286 | 2020-05-10 17:34:15 +0200 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0-only |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 3 | # ${VERSION_NAME}: new version name |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 4 | # ${COMMIT_ID}: commit id (if not master) |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 5 | # ${USERNAME}: username (if not default to https) |
| 6 | # ${GPG_KEY_ID}: gpg key id (if not don't sign) |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 7 | VERSION_NAME=$1 |
| 8 | COMMIT_ID=$2 |
| 9 | USERNAME=$3 |
| 10 | GPG_KEY_ID=$4 |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 11 | |
Patrick Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 12 | set -e |
Alexander Couzens | 871da8e | 2016-09-09 00:05:54 +0200 | [diff] [blame] | 13 | |
Patrick Georgi | d198e2e | 2019-11-19 17:09:30 +0100 | [diff] [blame] | 14 | if [ -z "$GPG_TTY" ]; then |
| 15 | export GPG_TTY=$(tty) |
| 16 | fi |
| 17 | |
Alexander Couzens | 871da8e | 2016-09-09 00:05:54 +0200 | [diff] [blame] | 18 | # set local + tz to be reproducible |
| 19 | LC_ALL=C |
| 20 | LANG=C |
Paul Menzel | 38a906b | 2017-09-27 15:06:57 +0200 | [diff] [blame] | 21 | TZ=UTC0 |
Alexander Couzens | 871da8e | 2016-09-09 00:05:54 +0200 | [diff] [blame] | 22 | export LC_ALL LANG TZ |
| 23 | |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 24 | if [ -z "$VERSION_NAME" ] || [ "$VERSION_NAME" = "--help" ] || [ -z "$COMMIT_ID" ]; then |
| 25 | echo "usage: $0 <version> <commit id> [username] [gpg key id]" |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 26 | echo "Tags a new coreboot version and creates a tar archive" |
| 27 | echo |
| 28 | echo "version: New version name to tag the tree with" |
| 29 | 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] | 30 | echo "username: clone the tree using ssh://USERNAME - defaults to https://" |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 31 | 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] | 32 | exit 1 |
| 33 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 34 | |
| 35 | # Verify that tar supports --sort |
| 36 | if ! tar --sort=name -cf /dev/null /dev/null 2>/dev/null ; then |
| 37 | echo "Error: The installed version of tar does not support --sort" |
| 38 | echo " GNU tar version 1.28 or greater is required. Exiting." |
| 39 | exit 1 |
| 40 | fi |
| 41 | |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 42 | if [ ! -d "coreboot-${VERSION_NAME}" ]; then |
Patrick Georgi | 54cabb9 | 2019-11-19 17:11:04 +0100 | [diff] [blame] | 43 | if [ -d .git ]; then |
| 44 | GIT_REF_OPTS="--reference . --dissociate" |
| 45 | elif [ -d ../../.git ]; then |
| 46 | GIT_REF_OPTS="--reference ../.. --dissociate" |
| 47 | fi |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 48 | if [ -n "${USERNAME}" ]; then |
Patrick Georgi | 54cabb9 | 2019-11-19 17:11:04 +0100 | [diff] [blame] | 49 | git clone ${GIT_REF_OPTS} "ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git" "coreboot-${VERSION_NAME}" |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 50 | else |
Patrick Georgi | 54cabb9 | 2019-11-19 17:11:04 +0100 | [diff] [blame] | 51 | git clone ${GIT_REF_OPTS} https://review.coreboot.org/coreboot.git "coreboot-${VERSION_NAME}" |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 52 | fi |
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 | cd "coreboot-${VERSION_NAME}" || exit 1 |
| 56 | if [ -n "$COMMIT_ID" ]; then |
| 57 | git reset --hard "$COMMIT_ID" |
Patrick Georgi | 68e3f6d | 2016-01-29 23:02:56 +0100 | [diff] [blame] | 58 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 59 | |
Patrick Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 60 | git submodule update --init --checkout |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 61 | if [ -n "$GPG_KEY_ID" ]; then |
| 62 | 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] | 63 | else |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 64 | git tag -a --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME" |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 65 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 66 | |
| 67 | 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] | 68 | tstamp=$(git log --pretty=format:%ci -1) |
Patrick Georgi | f61c9e9 | 2015-07-13 22:48:46 +0200 | [diff] [blame] | 69 | cd .. |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 70 | |
Patrick Georgi | 85678b8 | 2019-11-19 17:12:05 +0100 | [diff] [blame] | 71 | exclude_paths="3rdparty/blobs " |
| 72 | exclude_paths+="3rdparty/fsp " |
| 73 | exclude_paths+="3rdparty/intel-microcode " |
Patrick Georgi | a4f5954 | 2019-11-19 17:12:42 +0100 | [diff] [blame] | 74 | exclude_paths+="3rdparty/amd_blobs " |
Julius Werner | bc1cb38 | 2020-06-18 15:03:22 -0700 | [diff] [blame] | 75 | exclude_paths+="3rdparty/qc_blobs " |
Patrick Georgi | 85678b8 | 2019-11-19 17:12:05 +0100 | [diff] [blame] | 76 | for i in ${exclude_paths}; do |
| 77 | blobs_paths+="coreboot-${VERSION_NAME}/${i} " |
| 78 | exclude_opts+="--exclude=coreboot-${VERSION_NAME}/${i} " |
| 79 | done |
| 80 | |
| 81 | tar --sort=name --mtime="$tstamp" --owner=coreboot:1000 --group=coreboot:1000 --exclude=*/.git --exclude=*/.gitignore ${exclude_opts} -cvf - "coreboot-${VERSION_NAME}" |xz -9 > "coreboot-${VERSION_NAME}.tar.xz" |
| 82 | tar --sort=name --mtime="$tstamp" --owner=coreboot:1000 --group=coreboot:1000 --exclude=*/.git --exclude=*/.gitignore -cvf - ${blobs_paths} |xz -9 > "coreboot-blobs-${VERSION_NAME}.tar.xz" |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 83 | |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 84 | if [ -n "${GPG_KEY_ID}" ]; then |
Patrick Georgi | 3b2305e | 2018-12-20 17:21:08 +0100 | [diff] [blame] | 85 | gpg --armor --local-user "$GPG_KEY_ID" --output "coreboot-${VERSION_NAME}.tar.xz.sig" --detach-sig "coreboot-${VERSION_NAME}.tar.xz" |
| 86 | gpg --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] | 87 | fi |