xref: /openbmc/qemu/scripts/make-release (revision bfe0f6b02a4d76bcdc05f50e03667447f6069445)
134bb443eSAnthony Liguori#!/bin/bash -e
234bb443eSAnthony Liguori#
334bb443eSAnthony Liguori# QEMU Release Script
434bb443eSAnthony Liguori#
534bb443eSAnthony Liguori# Copyright IBM, Corp. 2012
634bb443eSAnthony Liguori#
734bb443eSAnthony Liguori# Authors:
834bb443eSAnthony Liguori#  Anthony Liguori <aliguori@us.ibm.com>
934bb443eSAnthony Liguori#
1034bb443eSAnthony Liguori# This work is licensed under the terms of the GNU GPLv2 or later.
1134bb443eSAnthony Liguori# See the COPYING file in the top-level directory.
1234bb443eSAnthony Liguori
13be27b514SPaolo Bonzinifunction subproject_dir() {
14b79b05d1SMichael Roth    if test ! -f "$src/subprojects/$1.wrap"; then
15b79b05d1SMichael Roth      echo "scripts/archive-source.sh should only process wrap subprojects"
16b79b05d1SMichael Roth      exit 1
17be27b514SPaolo Bonzini    fi
18be27b514SPaolo Bonzini
19be27b514SPaolo Bonzini    # Print the directory key of the wrap file, defaulting to the
20be27b514SPaolo Bonzini    # subproject name.  The wrap file is in ini format and should
21be27b514SPaolo Bonzini    # have a single section only.  There should be only one section
22be27b514SPaolo Bonzini    # named "[wrap-*]", which helps keeping the script simple.
23be27b514SPaolo Bonzini    local dir
24be27b514SPaolo Bonzini    dir=$(sed -n \
25be27b514SPaolo Bonzini      -e '/^\[wrap-[a-z][a-z]*\]$/,/^\[/{' \
26be27b514SPaolo Bonzini      -e    '/^directory *= */!b' \
27be27b514SPaolo Bonzini      -e    's///p' \
28be27b514SPaolo Bonzini      -e    'q' \
29be27b514SPaolo Bonzini      -e '}' \
30b79b05d1SMichael Roth      "$src/subprojects/$1.wrap")
31be27b514SPaolo Bonzini
32be27b514SPaolo Bonzini    echo "${dir:-$1}"
33be27b514SPaolo Bonzini}
34be27b514SPaolo Bonzini
359bd0bcc3SThomas Huthif [ $# -ne 2 ]; then
369bd0bcc3SThomas Huth    echo "Usage:"
379bd0bcc3SThomas Huth    echo " $0 gitrepo version"
389bd0bcc3SThomas Huth    exit 0
399bd0bcc3SThomas Huthfi
409bd0bcc3SThomas Huth
412019cabfSPaolo Bonzini# Only include wraps that are invoked with subproject()
422b74dd91SManos PitsidianakisSUBPROJECTS="libvfio-user keycodemapdb berkeley-softfloat-3
43a95ad49bSPaolo Bonzini  berkeley-testfloat-3 anyhow-1-rs arbitrary-int-1-rs bilge-0.2-rs
44*bfe0f6b0SPaolo Bonzini  bilge-impl-0.2-rs either-1-rs foreign-0.3-rs itertools-0.11-rs
45*bfe0f6b0SPaolo Bonzini  libc-0.2-rs proc-macro2-1-rs
46d0f0cd5bSPaolo Bonzini  proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs
472b74dd91SManos Pitsidianakis  syn-2-rs unicode-ident-1-rs"
482019cabfSPaolo Bonzini
4934bb443eSAnthony Liguorisrc="$1"
5034bb443eSAnthony Liguoriversion="$2"
5134bb443eSAnthony Liguoridestination=qemu-${version}
5234bb443eSAnthony Liguori
53aa4609dcSThomas Huthgit clone --single-branch -b "v${version}" -c advice.detachedHead=false \
54aa4609dcSThomas Huth    "${src}" ${destination}
55aa4609dcSThomas Huth
5634bb443eSAnthony Liguoripushd ${destination}
57aa4609dcSThomas Huth
58aa4609dcSThomas Huthgit submodule update --init --single-branch
592019cabfSPaolo Bonzinimeson subprojects download $SUBPROJECTS
602019cabfSPaolo Bonzini
618648fcd5SAndreas Färber(cd roms/seabios && git describe --tags --long --dirty > .version)
623fccd3f2SMichael Roth(cd roms/skiboot && ./make_version.sh > .version)
6345c61c6cSMichael Roth# Fetch edk2 submodule's submodules, since it won't have access to them via
6445c61c6cSMichael Roth# the tarball later.
6545c61c6cSMichael Roth#
6645c61c6cSMichael Roth# A more uniform way to handle this sort of situation would be nice, but we
6745c61c6cSMichael Roth# don't necessarily have much control over how a submodule handles its
6845c61c6cSMichael Roth# submodule dependencies, so we continue to handle these on a case-by-case
6945c61c6cSMichael Roth# basis for now.
70bd0da3a3SPhilippe Mathieu-Daudé(cd roms/edk2 && \
71aa4609dcSThomas Huth    git submodule update --init --depth 1 -- \
72bd0da3a3SPhilippe Mathieu-Daudé        ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 \
73bd0da3a3SPhilippe Mathieu-Daudé        BaseTools/Source/C/BrotliCompress/brotli \
74bd0da3a3SPhilippe Mathieu-Daudé        CryptoPkg/Library/OpensslLib/openssl \
75bd0da3a3SPhilippe Mathieu-Daudé        MdeModulePkg/Library/BrotliCustomDecompressLib/brotli)
7634bb443eSAnthony Liguoripopd
77be27b514SPaolo Bonzini
78be27b514SPaolo Bonziniexclude=(--exclude=.git)
79be27b514SPaolo Bonzini# include the tarballs in subprojects/packagecache but not their expansion
80be27b514SPaolo Bonzinifor sp in $SUBPROJECTS; do
81b79b05d1SMichael Roth    if grep -xqF "[wrap-file]" $src/subprojects/$sp.wrap; then
82be27b514SPaolo Bonzini      exclude+=(--exclude=subprojects/"$(subproject_dir $sp)")
83be27b514SPaolo Bonzini    fi
84be27b514SPaolo Bonzinidone
85be27b514SPaolo Bonzinitar "${exclude[@]}" -cJf ${destination}.tar.xz ${destination}
8634bb443eSAnthony Liguorirm -rf ${destination}
87