blob: f609bf194e40a32950dfcf1fb9c57139b10e39ec [file] [log] [blame]
Yegor Timoshenkoc2e49412018-10-07 01:58:27 +00001#!/usr/bin/env bash
Patrick Georgi1afe2862020-05-10 17:34:15 +02002# SPDX-License-Identifier: GPL-2.0-only
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +02003# ${VERSION_NAME}: new version name
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +02004# ${COMMIT_ID}: commit id (if not master)
Martin Roth7a00a632017-04-04 15:05:24 -06005# ${USERNAME}: username (if not default to https)
6# ${GPG_KEY_ID}: gpg key id (if not don't sign)
Martin Rothdd78aa62016-10-04 16:45:17 -06007VERSION_NAME=$1
8COMMIT_ID=$2
9USERNAME=$3
10GPG_KEY_ID=$4
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020011
Patrick Georgif61c9e92015-07-13 22:48:46 +020012set -e
Alexander Couzens871da8e2016-09-09 00:05:54 +020013
Patrick Georgid198e2e2019-11-19 17:09:30 +010014if [ -z "$GPG_TTY" ]; then
15 export GPG_TTY=$(tty)
16fi
17
Alexander Couzens871da8e2016-09-09 00:05:54 +020018# set local + tz to be reproducible
19LC_ALL=C
20LANG=C
Paul Menzel38a906b2017-09-27 15:06:57 +020021TZ=UTC0
Alexander Couzens871da8e2016-09-09 00:05:54 +020022export LC_ALL LANG TZ
23
Martin Roth7a00a632017-04-04 15:05:24 -060024if [ -z "$VERSION_NAME" ] || [ "$VERSION_NAME" = "--help" ] || [ -z "$COMMIT_ID" ]; then
25 echo "usage: $0 <version> <commit id> [username] [gpg key id]"
Martin Rothdd78aa62016-10-04 16:45:17 -060026 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 Rothdd78aa62016-10-04 16:45:17 -060030 echo "username: clone the tree using ssh://USERNAME - defaults to https://"
Martin Roth7a00a632017-04-04 15:05:24 -060031 echo "gpg key id: used to tag the version, and generate a gpg signature"
Patrick Georgif61c9e92015-07-13 22:48:46 +020032 exit 1
33fi
Martin Rothdd78aa62016-10-04 16:45:17 -060034
35# Verify that tar supports --sort
36if ! 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
40fi
41
Martin Roth7a00a632017-04-04 15:05:24 -060042if [ ! -d "coreboot-${VERSION_NAME}" ]; then
Martin Rothb621d9b2022-09-02 14:23:25 -060043 declare -a GIT_REF_OPTS
Patrick Georgi54cabb92019-11-19 17:11:04 +010044 if [ -d .git ]; then
Martin Rothb621d9b2022-09-02 14:23:25 -060045 GIT_REF_OPTS=("--reference" "." "--dissociate")
Patrick Georgi54cabb92019-11-19 17:11:04 +010046 elif [ -d ../../.git ]; then
Martin Rothb621d9b2022-09-02 14:23:25 -060047 GIT_REF_OPTS=("--reference" "../.." "--dissociate")
Patrick Georgi54cabb92019-11-19 17:11:04 +010048 fi
Martin Roth7a00a632017-04-04 15:05:24 -060049 if [ -n "${USERNAME}" ]; then
Martin Rothb621d9b2022-09-02 14:23:25 -060050 git clone "${GIT_REF_OPTS[@]}" "ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git" "coreboot-${VERSION_NAME}" --
Martin Roth7a00a632017-04-04 15:05:24 -060051 else
Martin Rothb621d9b2022-09-02 14:23:25 -060052 git clone "${GIT_REF_OPTS[@]}" https://review.coreboot.org/coreboot.git "coreboot-${VERSION_NAME}" --
Martin Roth7a00a632017-04-04 15:05:24 -060053 fi
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020054fi
Martin Rothdd78aa62016-10-04 16:45:17 -060055
56cd "coreboot-${VERSION_NAME}" || exit 1
57if [ -n "$COMMIT_ID" ]; then
58 git reset --hard "$COMMIT_ID"
Patrick Georgi68e3f6d2016-01-29 23:02:56 +010059fi
Martin Rothdd78aa62016-10-04 16:45:17 -060060
Felix Singerff6416f2021-10-17 16:07:07 +020061util/crossgcc/buildgcc -W > .crossgcc-version
62
Patrick Georgif61c9e92015-07-13 22:48:46 +020063git submodule update --init --checkout
Martin Rothdd78aa62016-10-04 16:45:17 -060064if [ -n "$GPG_KEY_ID" ]; then
65 git tag -a -s -u "$GPG_KEY_ID" --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020066else
Martin Rothdd78aa62016-10-04 16:45:17 -060067 git tag -a --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020068fi
Martin Rothdd78aa62016-10-04 16:45:17 -060069
Paul Menzel1ff61252022-06-03 08:31:18 +020070printf "%s-%s\n" "$VERSION_NAME" "$(git log --pretty=%h -1)" > .coreboot-version
Patrick Georgi68e3f6d2016-01-29 23:02:56 +010071tstamp=$(git log --pretty=format:%ci -1)
Patrick Georgif61c9e92015-07-13 22:48:46 +020072cd ..
Martin Rothdd78aa62016-10-04 16:45:17 -060073
Patrick Georgi85678b82019-11-19 17:12:05 +010074exclude_paths="3rdparty/blobs "
75exclude_paths+="3rdparty/fsp "
76exclude_paths+="3rdparty/intel-microcode "
Patrick Georgia4f59542019-11-19 17:12:42 +010077exclude_paths+="3rdparty/amd_blobs "
Julius Wernerbc1cb382020-06-18 15:03:22 -070078exclude_paths+="3rdparty/qc_blobs "
Martin Roth8da4bfe2022-06-02 19:56:23 -060079
Martin Rothb621d9b2022-09-02 14:23:25 -060080declare -a blobs_paths
81declare -a exclude_opts
Patrick Georgi85678b82019-11-19 17:12:05 +010082for i in ${exclude_paths}; do
Martin Rothb621d9b2022-09-02 14:23:25 -060083 blobs_paths+=("coreboot-${VERSION_NAME}/${i}")
84 exclude_opts+=("--exclude=coreboot-${VERSION_NAME}/${i}")
Patrick Georgi85678b82019-11-19 17:12:05 +010085done
86
Martin Rothb621d9b2022-09-02 14:23:25 -060087tar --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"
88tar --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 Rothdd78aa62016-10-04 16:45:17 -060089
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020090if [ -n "${GPG_KEY_ID}" ]; then
Patrick Georgi3b2305e2018-12-20 17:21:08 +010091 gpg --armor --local-user "$GPG_KEY_ID" --output "coreboot-${VERSION_NAME}.tar.xz.sig" --detach-sig "coreboot-${VERSION_NAME}.tar.xz"
92 gpg --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 +020093fi