xref: /openbmc/qemu/scripts/make-release (revision be27b5149c86f81531f8fc609baf3480fc4d9ca0)
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
13*be27b514SPaolo Bonzinifunction subproject_dir() {
14*be27b514SPaolo Bonzini    if test ! -f "subprojects/$1.wrap"; then
15*be27b514SPaolo Bonzini      error "scripts/archive-source.sh should only process wrap subprojects"
16*be27b514SPaolo Bonzini    fi
17*be27b514SPaolo Bonzini
18*be27b514SPaolo Bonzini    # Print the directory key of the wrap file, defaulting to the
19*be27b514SPaolo Bonzini    # subproject name.  The wrap file is in ini format and should
20*be27b514SPaolo Bonzini    # have a single section only.  There should be only one section
21*be27b514SPaolo Bonzini    # named "[wrap-*]", which helps keeping the script simple.
22*be27b514SPaolo Bonzini    local dir
23*be27b514SPaolo Bonzini    dir=$(sed -n \
24*be27b514SPaolo Bonzini      -e '/^\[wrap-[a-z][a-z]*\]$/,/^\[/{' \
25*be27b514SPaolo Bonzini      -e    '/^directory *= */!b' \
26*be27b514SPaolo Bonzini      -e    's///p' \
27*be27b514SPaolo Bonzini      -e    'q' \
28*be27b514SPaolo Bonzini      -e '}' \
29*be27b514SPaolo Bonzini      "subprojects/$1.wrap")
30*be27b514SPaolo Bonzini
31*be27b514SPaolo Bonzini    echo "${dir:-$1}"
32*be27b514SPaolo Bonzini}
33*be27b514SPaolo Bonzini
349bd0bcc3SThomas Huthif [ $# -ne 2 ]; then
359bd0bcc3SThomas Huth    echo "Usage:"
369bd0bcc3SThomas Huth    echo " $0 gitrepo version"
379bd0bcc3SThomas Huth    exit 0
389bd0bcc3SThomas Huthfi
399bd0bcc3SThomas Huth
402019cabfSPaolo Bonzini# Only include wraps that are invoked with subproject()
412b74dd91SManos PitsidianakisSUBPROJECTS="libvfio-user keycodemapdb berkeley-softfloat-3
42d0f0cd5bSPaolo Bonzini  berkeley-testfloat-3 arbitrary-int-1-rs bilge-0.2-rs
43d0f0cd5bSPaolo Bonzini  bilge-impl-0.2-rs either-1-rs itertools-0.11-rs proc-macro2-1-rs
44d0f0cd5bSPaolo Bonzini  proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs
452b74dd91SManos Pitsidianakis  syn-2-rs unicode-ident-1-rs"
462019cabfSPaolo Bonzini
4734bb443eSAnthony Liguorisrc="$1"
4834bb443eSAnthony Liguoriversion="$2"
4934bb443eSAnthony Liguoridestination=qemu-${version}
5034bb443eSAnthony Liguori
51aa4609dcSThomas Huthgit clone --single-branch -b "v${version}" -c advice.detachedHead=false \
52aa4609dcSThomas Huth    "${src}" ${destination}
53aa4609dcSThomas Huth
5434bb443eSAnthony Liguoripushd ${destination}
55aa4609dcSThomas Huth
56aa4609dcSThomas Huthgit submodule update --init --single-branch
572019cabfSPaolo Bonzinimeson subprojects download $SUBPROJECTS
582019cabfSPaolo Bonzini
598648fcd5SAndreas Färber(cd roms/seabios && git describe --tags --long --dirty > .version)
603fccd3f2SMichael Roth(cd roms/skiboot && ./make_version.sh > .version)
6145c61c6cSMichael Roth# Fetch edk2 submodule's submodules, since it won't have access to them via
6245c61c6cSMichael Roth# the tarball later.
6345c61c6cSMichael Roth#
6445c61c6cSMichael Roth# A more uniform way to handle this sort of situation would be nice, but we
6545c61c6cSMichael Roth# don't necessarily have much control over how a submodule handles its
6645c61c6cSMichael Roth# submodule dependencies, so we continue to handle these on a case-by-case
6745c61c6cSMichael Roth# basis for now.
68bd0da3a3SPhilippe Mathieu-Daudé(cd roms/edk2 && \
69aa4609dcSThomas Huth    git submodule update --init --depth 1 -- \
70bd0da3a3SPhilippe Mathieu-Daudé        ArmPkg/Library/ArmSoftFloatLib/berkeley-softfloat-3 \
71bd0da3a3SPhilippe Mathieu-Daudé        BaseTools/Source/C/BrotliCompress/brotli \
72bd0da3a3SPhilippe Mathieu-Daudé        CryptoPkg/Library/OpensslLib/openssl \
73bd0da3a3SPhilippe Mathieu-Daudé        MdeModulePkg/Library/BrotliCustomDecompressLib/brotli)
7434bb443eSAnthony Liguoripopd
75*be27b514SPaolo Bonzini
76*be27b514SPaolo Bonziniexclude=(--exclude=.git)
77*be27b514SPaolo Bonzini# include the tarballs in subprojects/packagecache but not their expansion
78*be27b514SPaolo Bonzinifor sp in $SUBPROJECTS; do
79*be27b514SPaolo Bonzini    if grep -xqF "[wrap-file]" subprojects/$sp.wrap; then
80*be27b514SPaolo Bonzini      exclude+=(--exclude=subprojects/"$(subproject_dir $sp)")
81*be27b514SPaolo Bonzini    fi
82*be27b514SPaolo Bonzinidone
83*be27b514SPaolo Bonzinitar "${exclude[@]}" -cJf ${destination}.tar.xz ${destination}
8434bb443eSAnthony Liguorirm -rf ${destination}
85