xref: /openbmc/qemu/scripts/make-release (revision 4cfe9edb1b1961af9cda74351f73b0abb3159b67)
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
43d0f0cd5bSPaolo Bonzini  berkeley-testfloat-3 arbitrary-int-1-rs bilge-0.2-rs
44*4cfe9edbSPaolo Bonzini  bilge-impl-0.2-rs either-1-rs itertools-0.11-rs libc-0.2-rs proc-macro2-1-rs
45d0f0cd5bSPaolo Bonzini  proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs
462b74dd91SManos Pitsidianakis  syn-2-rs unicode-ident-1-rs"
472019cabfSPaolo Bonzini
4834bb443eSAnthony Liguorisrc="$1"
4934bb443eSAnthony Liguoriversion="$2"
5034bb443eSAnthony Liguoridestination=qemu-${version}
5134bb443eSAnthony Liguori
52aa4609dcSThomas Huthgit clone --single-branch -b "v${version}" -c advice.detachedHead=false \
53aa4609dcSThomas Huth    "${src}" ${destination}
54aa4609dcSThomas Huth
5534bb443eSAnthony Liguoripushd ${destination}
56aa4609dcSThomas Huth
57aa4609dcSThomas Huthgit submodule update --init --single-branch
582019cabfSPaolo Bonzinimeson subprojects download $SUBPROJECTS
592019cabfSPaolo Bonzini
608648fcd5SAndreas Färber(cd roms/seabios && git describe --tags --long --dirty > .version)
613fccd3f2SMichael Roth(cd roms/skiboot && ./make_version.sh > .version)
6245c61c6cSMichael Roth# Fetch edk2 submodule's submodules, since it won't have access to them via
6345c61c6cSMichael Roth# the tarball later.
6445c61c6cSMichael Roth#
6545c61c6cSMichael Roth# A more uniform way to handle this sort of situation would be nice, but we
6645c61c6cSMichael Roth# don't necessarily have much control over how a submodule handles its
6745c61c6cSMichael Roth# submodule dependencies, so we continue to handle these on a case-by-case
6845c61c6cSMichael Roth# basis for now.
69bd0da3a3SPhilippe Mathieu-Daudé(cd roms/edk2 && \
70aa4609dcSThomas Huth    git submodule update --init --depth 1 -- \
71bd0da3a3SPhilippe Mathieu-Daudé        ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 \
72bd0da3a3SPhilippe Mathieu-Daudé        BaseTools/Source/C/BrotliCompress/brotli \
73bd0da3a3SPhilippe Mathieu-Daudé        CryptoPkg/Library/OpensslLib/openssl \
74bd0da3a3SPhilippe Mathieu-Daudé        MdeModulePkg/Library/BrotliCustomDecompressLib/brotli)
7534bb443eSAnthony Liguoripopd
76be27b514SPaolo Bonzini
77be27b514SPaolo Bonziniexclude=(--exclude=.git)
78be27b514SPaolo Bonzini# include the tarballs in subprojects/packagecache but not their expansion
79be27b514SPaolo Bonzinifor sp in $SUBPROJECTS; do
80b79b05d1SMichael Roth    if grep -xqF "[wrap-file]" $src/subprojects/$sp.wrap; then
81be27b514SPaolo Bonzini      exclude+=(--exclude=subprojects/"$(subproject_dir $sp)")
82be27b514SPaolo Bonzini    fi
83be27b514SPaolo Bonzinidone
84be27b514SPaolo Bonzinitar "${exclude[@]}" -cJf ${destination}.tar.xz ${destination}
8534bb443eSAnthony Liguorirm -rf ${destination}
86