util/release/build-release: Use short git hash for .coreboot-version
[coreboot2.git] / util / release / build-release
blobd4a9a1f5b8d54aea26b72128afae774a3c0a32e1
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: GPL-2.0-only
3 # ${VERSION_NAME}: new version name
4 # ${COMMIT_ID}: commit id (if not master)
5 # ${USERNAME}: username (if not default to https)
6 # ${GPG_KEY_ID}: gpg key id (if not don't sign)
7 VERSION_NAME=$1
8 COMMIT_ID=$2
9 USERNAME=$3
10 GPG_KEY_ID=$4
12 set -e
14 if [ -z "$GPG_TTY" ]; then
15 export GPG_TTY=$(tty)
18 # set local + tz to be reproducible
19 LC_ALL=C
20 LANG=C
21 TZ=UTC0
22 export LC_ALL LANG TZ
24 if [ -z "$VERSION_NAME" ] || [ "$VERSION_NAME" = "--help" ] || [ -z "$COMMIT_ID" ]; then
25 echo "usage: $0 <version> <commit id> [username] [gpg key id]"
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"
30 echo "username: clone the tree using ssh://USERNAME - defaults to https://"
31 echo "gpg key id: used to tag the version, and generate a gpg signature"
32 exit 1
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
42 if [ ! -d "coreboot-${VERSION_NAME}" ]; then
43 if [ -d .git ]; then
44 GIT_REF_OPTS="--reference . --dissociate"
45 elif [ -d ../../.git ]; then
46 GIT_REF_OPTS="--reference ../.. --dissociate"
48 if [ -n "${USERNAME}" ]; then
49 git clone ${GIT_REF_OPTS} "ssh://${USERNAME}@review.coreboot.org:29418/coreboot.git" "coreboot-${VERSION_NAME}"
50 else
51 git clone ${GIT_REF_OPTS} https://review.coreboot.org/coreboot.git "coreboot-${VERSION_NAME}"
55 cd "coreboot-${VERSION_NAME}" || exit 1
56 if [ -n "$COMMIT_ID" ]; then
57 git reset --hard "$COMMIT_ID"
60 util/crossgcc/buildgcc -W > .crossgcc-version
62 git submodule update --init --checkout
63 if [ -n "$GPG_KEY_ID" ]; then
64 git tag -a -s -u "$GPG_KEY_ID" --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
65 else
66 git tag -a --force "$VERSION_NAME" -m "coreboot version $VERSION_NAME"
69 printf "%s-%s\n" "$VERSION_NAME" "$(git log --pretty=%h|head -1)" > .coreboot-version
70 tstamp=$(git log --pretty=format:%ci -1)
71 cd ..
73 exclude_paths="3rdparty/blobs "
74 exclude_paths+="3rdparty/fsp "
75 exclude_paths+="3rdparty/intel-microcode "
76 exclude_paths+="3rdparty/amd_blobs "
77 exclude_paths+="3rdparty/qc_blobs "
79 for i in ${exclude_paths}; do
80 blobs_paths+="coreboot-${VERSION_NAME}/${i} "
81 exclude_opts+="--exclude=coreboot-${VERSION_NAME}/${i} "
82 done
84 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"
85 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"
87 if [ -n "${GPG_KEY_ID}" ]; then
88 gpg --armor --local-user "$GPG_KEY_ID" --output "coreboot-${VERSION_NAME}.tar.xz.sig" --detach-sig "coreboot-${VERSION_NAME}.tar.xz"
89 gpg --armor --local-user "$GPG_KEY_ID" --output "coreboot-blobs-${VERSION_NAME}.tar.xz.sig" --detach-sig "coreboot-blobs-${VERSION_NAME}.tar.xz"