blob: 5bbc1b5d7a16079d90af8ca944e8d1a6706befc2 [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
Martin Roth60f367a2023-01-10 20:17:22 -07004# ${COMMIT_ID}: commit id for new version
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
Martin Roth60f367a2023-01-10 20:17:22 -070014TIME_FILE="$(mktemp -d)/.coreboot-time"
15COREBOOT_RELEASE_NAME=coreboot-${VERSION_NAME}
16COREBOOT_TARBALL="${COREBOOT_RELEASE_NAME}.tar.xz"
17COREBOOT_BLOBS_TARBALL="coreboot-blobs-${VERSION_NAME}.tar.xz"
18
Patrick Georgid198e2e2019-11-19 17:09:30 +010019if [ -z "$GPG_TTY" ]; then
Martin Rothd05ea792022-09-02 14:27:45 -060020 GPG_TTY=$(tty)
21 export GPG_TTY
Patrick Georgid198e2e2019-11-19 17:09:30 +010022fi
23
Alexander Couzens871da8e2016-09-09 00:05:54 +020024# set local + tz to be reproducible
25LC_ALL=C
26LANG=C
Paul Menzel38a906b2017-09-27 15:06:57 +020027TZ=UTC0
Alexander Couzens871da8e2016-09-09 00:05:54 +020028export LC_ALL LANG TZ
29
Martin Rothd05ea792022-09-02 14:27:45 -060030if [ -z "${VERSION_NAME}" ] || [ "${VERSION_NAME}" = "--help" ] || [ -z "${COMMIT_ID}" ]; then
Martin Roth7a00a632017-04-04 15:05:24 -060031 echo "usage: $0 <version> <commit id> [username] [gpg key id]"
Martin Rothdd78aa62016-10-04 16:45:17 -060032 echo "Tags a new coreboot version and creates a tar archive"
33 echo
34 echo "version: New version name to tag the tree with"
35 echo "commit id: check out this commit-id after cloning the coreboot tree"
Martin Rothdd78aa62016-10-04 16:45:17 -060036 echo "username: clone the tree using ssh://USERNAME - defaults to https://"
Martin Roth7a00a632017-04-04 15:05:24 -060037 echo "gpg key id: used to tag the version, and generate a gpg signature"
Patrick Georgif61c9e92015-07-13 22:48:46 +020038 exit 1
39fi
Martin Rothdd78aa62016-10-04 16:45:17 -060040
41# Verify that tar supports --sort
42if ! tar --sort=name -cf /dev/null /dev/null 2>/dev/null ; then
43 echo "Error: The installed version of tar does not support --sort"
44 echo " GNU tar version 1.28 or greater is required. Exiting."
45 exit 1
46fi
47
Martin Rothd05ea792022-09-02 14:27:45 -060048# Clone new copy of repo if needed
Martin Roth60f367a2023-01-10 20:17:22 -070049if [ ! -d "${COREBOOT_RELEASE_NAME}/.git" ]; then
50 rm -rf "${COREBOOT_RELEASE_NAME}"
Martin Rothb621d9b2022-09-02 14:23:25 -060051 declare -a GIT_REF_OPTS
Patrick Georgi54cabb92019-11-19 17:11:04 +010052 if [ -d .git ]; then
Martin Rothb621d9b2022-09-02 14:23:25 -060053 GIT_REF_OPTS=("--reference" "." "--dissociate")
Patrick Georgi54cabb92019-11-19 17:11:04 +010054 elif [ -d ../../.git ]; then
Martin Rothb621d9b2022-09-02 14:23:25 -060055 GIT_REF_OPTS=("--reference" "../.." "--dissociate")
Patrick Georgi54cabb92019-11-19 17:11:04 +010056 fi
Martin Roth7a00a632017-04-04 15:05:24 -060057 if [ -n "${USERNAME}" ]; then
Martin Roth60f367a2023-01-10 20:17:22 -070058 git clone "${GIT_REF_OPTS[@]}" "ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git" "${COREBOOT_RELEASE_NAME}" --
Martin Roth7a00a632017-04-04 15:05:24 -060059 else
Martin Roth60f367a2023-01-10 20:17:22 -070060 git clone "${GIT_REF_OPTS[@]}" https://review.coreboot.org/coreboot.git "${COREBOOT_RELEASE_NAME}" --
Martin Roth7a00a632017-04-04 15:05:24 -060061 fi
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020062fi
Martin Rothdd78aa62016-10-04 16:45:17 -060063
Martin Rothd05ea792022-09-02 14:27:45 -060064# Handle everything that needs to be done from inside the new coreboot
65# directory. Use requested version, update submodules, and get ready to
66# run from outside a git repository, and create a signed tag to push.
67(
Martin Roth60f367a2023-01-10 20:17:22 -070068 cd "${COREBOOT_RELEASE_NAME}" || exit 1
69 git reset --hard "${COMMIT_ID}"
Martin Rothdd78aa62016-10-04 16:45:17 -060070
Martin Rothd05ea792022-09-02 14:27:45 -060071 util/crossgcc/buildgcc -W > .crossgcc-version
Felix Singerff6416f2021-10-17 16:07:07 +020072
Martin Rothd05ea792022-09-02 14:27:45 -060073 git submodule update --init --checkout
74 if [ -n "${GPG_KEY_ID}" ]; then
75 git tag -a -s -u "$GPG_KEY_ID" --force "${VERSION_NAME}" -m "coreboot version ${VERSION_NAME}" --
76 else
77 git tag -a --force "${VERSION_NAME}" -m "coreboot version ${VERSION_NAME}" --
78 fi
Martin Rothdd78aa62016-10-04 16:45:17 -060079
Martin Rothd05ea792022-09-02 14:27:45 -060080 printf "%s-%s\n" "$VERSION_NAME" "$(git log --pretty=%h -1)" > .coreboot-version
Martin Roth60f367a2023-01-10 20:17:22 -070081 printf "%s\n" "$(git log --pretty=format:%ci -1)" > "${TIME_FILE}"
Martin Rothd05ea792022-09-02 14:27:45 -060082)
Martin Roth60f367a2023-01-10 20:17:22 -070083tstamp=$(cat "${TIME_FILE}" | sed 's/ +0000//')
Martin Rothd05ea792022-09-02 14:27:45 -060084
85# Create the two tarballs, source and blobs.
86exclude_paths="3rdparty/blobs 3rdparty/fsp 3rdparty/intel-microcode 3rdparty/amd_blobs 3rdparty/qc_blobs"
Martin Roth8da4bfe2022-06-02 19:56:23 -060087
Martin Rothb621d9b2022-09-02 14:23:25 -060088declare -a blobs_paths
89declare -a exclude_opts
Patrick Georgi85678b82019-11-19 17:12:05 +010090for i in ${exclude_paths}; do
Martin Roth60f367a2023-01-10 20:17:22 -070091 blobs_paths+=("${COREBOOT_RELEASE_NAME}/${i}")
92 exclude_opts+=("--exclude=${COREBOOT_RELEASE_NAME}/${i}")
Patrick Georgi85678b82019-11-19 17:12:05 +010093done
94
Martin Roth60f367a2023-01-10 20:17:22 -070095tar --sort=name --mtime="${tstamp}" --owner=coreboot:1000 --group=coreboot:1000 --exclude=*/.git --exclude=*/.gitignore --exclude=*/.gitreview --exclude=*/.mailmap --exclude=*/.gitmodules "${exclude_opts[@]}" -cvf - "${COREBOOT_RELEASE_NAME}" |xz -9 > "${COREBOOT_TARBALL}"
96tar --sort=name --mtime="${tstamp}" --owner=coreboot:1000 --group=coreboot:1000 --exclude=*/.git --exclude=*/.gitignore --exclude=*/.gitreview --exclude=*/.mailmap --exclude=*/.gitmodules -cvf - "${blobs_paths[@]}" |xz -9 > "${COREBOOT_BLOBS_TARBALL}"
Martin Rothdd78aa62016-10-04 16:45:17 -060097
Martin Rothd05ea792022-09-02 14:27:45 -060098# Sign the tarballs
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +020099if [ -n "${GPG_KEY_ID}" ]; then
Martin Roth60f367a2023-01-10 20:17:22 -0700100 gpg --armor --local-user "$GPG_KEY_ID" --output "${COREBOOT_TARBALL}.sig" --detach-sig "${COREBOOT_TARBALL}"
101 gpg --armor --local-user "$GPG_KEY_ID" --output "${COREBOOT_BLOBS_TARBALL}.sig" --detach-sig "${COREBOOT_BLOBS_TARBALL}"
Philipp Deppenwiese6e4204a2016-09-08 22:35:48 +0200102fi
Martin Roth60f367a2023-01-10 20:17:22 -0700103
104# Clean up
105rm -f "${TIME_FILE}"