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 |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 4 | # ${COMMIT_ID}: commit id for new version |
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 | |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 14 | TIME_FILE="$(mktemp -d)/.coreboot-time" |
| 15 | COREBOOT_RELEASE_NAME=coreboot-${VERSION_NAME} |
| 16 | COREBOOT_TARBALL="${COREBOOT_RELEASE_NAME}.tar.xz" |
| 17 | COREBOOT_BLOBS_TARBALL="coreboot-blobs-${VERSION_NAME}.tar.xz" |
| 18 | |
Patrick Georgi | d198e2e | 2019-11-19 17:09:30 +0100 | [diff] [blame] | 19 | if [ -z "$GPG_TTY" ]; then |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 20 | GPG_TTY=$(tty) |
| 21 | export GPG_TTY |
Patrick Georgi | d198e2e | 2019-11-19 17:09:30 +0100 | [diff] [blame] | 22 | fi |
| 23 | |
Alexander Couzens | 871da8e | 2016-09-09 00:05:54 +0200 | [diff] [blame] | 24 | # set local + tz to be reproducible |
| 25 | LC_ALL=C |
| 26 | LANG=C |
Paul Menzel | 38a906b | 2017-09-27 15:06:57 +0200 | [diff] [blame] | 27 | TZ=UTC0 |
Alexander Couzens | 871da8e | 2016-09-09 00:05:54 +0200 | [diff] [blame] | 28 | export LC_ALL LANG TZ |
| 29 | |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 30 | if [ -z "${VERSION_NAME}" ] || [ "${VERSION_NAME}" = "--help" ] || [ -z "${COMMIT_ID}" ]; then |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 31 | echo "usage: $0 <version> <commit id> [username] [gpg key id]" |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 32 | 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 Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 36 | echo "username: clone the tree using ssh://USERNAME - defaults to https://" |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 37 | 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] | 38 | exit 1 |
| 39 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 40 | |
Martin Roth | 52354ea | 2023-08-21 15:10:01 -0600 | [diff] [blame] | 41 | pause() { |
| 42 | local text=$1 |
| 43 | |
| 44 | echo |
| 45 | if [ -n "$text" ]; then |
| 46 | echo "$text" |
| 47 | fi |
| 48 | read -r -p "Press [Enter] key to continue..." |
| 49 | } |
| 50 | |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 51 | # Verify that tar supports --sort |
| 52 | if ! tar --sort=name -cf /dev/null /dev/null 2>/dev/null ; then |
| 53 | echo "Error: The installed version of tar does not support --sort" |
| 54 | echo " GNU tar version 1.28 or greater is required. Exiting." |
| 55 | exit 1 |
| 56 | fi |
| 57 | |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 58 | # Clone new copy of repo if needed |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 59 | if [ ! -d "${COREBOOT_RELEASE_NAME}/.git" ]; then |
| 60 | rm -rf "${COREBOOT_RELEASE_NAME}" |
Martin Roth | b621d9b | 2022-09-02 14:23:25 -0600 | [diff] [blame] | 61 | declare -a GIT_REF_OPTS |
Patrick Georgi | 54cabb9 | 2019-11-19 17:11:04 +0100 | [diff] [blame] | 62 | if [ -d .git ]; then |
Martin Roth | b621d9b | 2022-09-02 14:23:25 -0600 | [diff] [blame] | 63 | GIT_REF_OPTS=("--reference" "." "--dissociate") |
Patrick Georgi | 54cabb9 | 2019-11-19 17:11:04 +0100 | [diff] [blame] | 64 | elif [ -d ../../.git ]; then |
Martin Roth | b621d9b | 2022-09-02 14:23:25 -0600 | [diff] [blame] | 65 | GIT_REF_OPTS=("--reference" "../.." "--dissociate") |
Patrick Georgi | 54cabb9 | 2019-11-19 17:11:04 +0100 | [diff] [blame] | 66 | fi |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 67 | if [ -n "${USERNAME}" ]; then |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 68 | git clone "${GIT_REF_OPTS[@]}" "ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git" "${COREBOOT_RELEASE_NAME}" -- |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 69 | else |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 70 | git clone "${GIT_REF_OPTS[@]}" https://review.coreboot.org/coreboot.git "${COREBOOT_RELEASE_NAME}" -- |
Martin Roth | 7a00a63 | 2017-04-04 15:05:24 -0600 | [diff] [blame] | 71 | fi |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 72 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 73 | |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 74 | # Handle everything that needs to be done from inside the new coreboot |
| 75 | # directory. Use requested version, update submodules, and get ready to |
| 76 | # run from outside a git repository, and create a signed tag to push. |
| 77 | ( |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 78 | cd "${COREBOOT_RELEASE_NAME}" || exit 1 |
| 79 | git reset --hard "${COMMIT_ID}" |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 80 | |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 81 | util/crossgcc/buildgcc -W > .crossgcc-version |
Felix Singer | ff6416f | 2021-10-17 16:07:07 +0200 | [diff] [blame] | 82 | |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 83 | if [ -n "${GPG_KEY_ID}" ]; then |
Martin Roth | 52354ea | 2023-08-21 15:10:01 -0600 | [diff] [blame] | 84 | pause "The next step will need your PGP key's passphrase, so be ready." |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 85 | git tag -a -s -u "$GPG_KEY_ID" --force "${VERSION_NAME}" -m "coreboot version ${VERSION_NAME}" -- |
| 86 | else |
| 87 | git tag -a --force "${VERSION_NAME}" -m "coreboot version ${VERSION_NAME}" -- |
| 88 | fi |
Martin Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 89 | |
Martin Roth | 52354ea | 2023-08-21 15:10:01 -0600 | [diff] [blame] | 90 | git submodule update --init --checkout |
| 91 | |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 92 | printf "%s-%s\n" "$VERSION_NAME" "$(git log --pretty=%h -1)" > .coreboot-version |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 93 | printf "%s\n" "$(git log --pretty=format:%ci -1)" > "${TIME_FILE}" |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 94 | ) |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 95 | tstamp=$(cat "${TIME_FILE}" | sed 's/ +0000//') |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 96 | |
| 97 | # Create the two tarballs, source and blobs. |
| 98 | exclude_paths="3rdparty/blobs 3rdparty/fsp 3rdparty/intel-microcode 3rdparty/amd_blobs 3rdparty/qc_blobs" |
Martin Roth | 8da4bfe | 2022-06-02 19:56:23 -0600 | [diff] [blame] | 99 | |
Martin Roth | b621d9b | 2022-09-02 14:23:25 -0600 | [diff] [blame] | 100 | declare -a blobs_paths |
| 101 | declare -a exclude_opts |
Patrick Georgi | 85678b8 | 2019-11-19 17:12:05 +0100 | [diff] [blame] | 102 | for i in ${exclude_paths}; do |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 103 | blobs_paths+=("${COREBOOT_RELEASE_NAME}/${i}") |
| 104 | exclude_opts+=("--exclude=${COREBOOT_RELEASE_NAME}/${i}") |
Patrick Georgi | 85678b8 | 2019-11-19 17:12:05 +0100 | [diff] [blame] | 105 | done |
| 106 | |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 107 | tar --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}" |
| 108 | tar --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 Roth | dd78aa6 | 2016-10-04 16:45:17 -0600 | [diff] [blame] | 109 | |
Martin Roth | d05ea79 | 2022-09-02 14:27:45 -0600 | [diff] [blame] | 110 | # Sign the tarballs |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 111 | if [ -n "${GPG_KEY_ID}" ]; then |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 112 | gpg --armor --local-user "$GPG_KEY_ID" --output "${COREBOOT_TARBALL}.sig" --detach-sig "${COREBOOT_TARBALL}" |
| 113 | gpg --armor --local-user "$GPG_KEY_ID" --output "${COREBOOT_BLOBS_TARBALL}.sig" --detach-sig "${COREBOOT_BLOBS_TARBALL}" |
Philipp Deppenwiese | 6e4204a | 2016-09-08 22:35:48 +0200 | [diff] [blame] | 114 | fi |
Martin Roth | 60f367a | 2023-01-10 20:17:22 -0700 | [diff] [blame] | 115 | |
| 116 | # Clean up |
| 117 | rm -f "${TIME_FILE}" |