master
text 82 lines 2.58 KB
Raw
1 #!/bin/bash -e
2 #
3 # QEMU Release Script
4 #
5 # Copyright IBM, Corp. 2012
6 #
7 # Authors:
8 # Anthony Liguori <aliguori@us.ibm.com>
9 #
10 # This work is licensed under the terms of the GNU GPLv2 or later.
11 # See the COPYING file in the top-level directory.
12
13 function subproject_dir() {
14 if test ! -f "$src/subprojects/$1.wrap"; then
15 echo "scripts/archive-source.sh should only process wrap subprojects"
16 exit 1
17 fi
18
19 # Print the directory key of the wrap file, defaulting to the
20 # subproject name. The wrap file is in ini format and should
21 # have a single section only. There should be only one section
22 # named "[wrap-*]", which helps keeping the script simple.
23 local dir
24 dir=$(sed -n \
25 -e '/^\[wrap-[a-z][a-z]*\]$/,/^\[/{' \
26 -e '/^directory *= */!b' \
27 -e 's///p' \
28 -e 'q' \
29 -e '}' \
30 "$src/subprojects/$1.wrap")
31
32 echo "${dir:-$1}"
33 }
34
35 if [ $# -ne 2 ]; then
36 echo "Usage:"
37 echo " $0 gitrepo version"
38 exit 0
39 fi
40
41 # Only include wraps that are invoked with subproject()
42 SUBPROJECTS="libvfio-user keycodemapdb berkeley-softfloat-3
43 berkeley-testfloat-3 anyhow-1-rs arbitrary-int-1-rs attrs-0.2-rs bilge-0.2-rs
44 bitfield-0.9-rs foreign-0.3-rs libc-0.2-rs probe-0.5-rs proc-macro2-1-rs quote-1-rs
45 syn-2-rs unicode-ident-1-rs"
46
47 src="$1"
48 version="$2"
49 destination=qemu-${version}
50
51 git clone --single-branch -b "v${version}" -c advice.detachedHead=false \
52 "${src}" ${destination}
53
54 pushd ${destination}
55
56 git submodule update --init --single-branch
57 meson subprojects download $SUBPROJECTS
58
59 (cd roms/seabios && git describe --tags --long --dirty > .version)
60 (cd roms/skiboot && ./make_version.sh > .version)
61 # Fetch edk2 submodule's submodules, since it won't have access to them via
62 # the tarball later.
63
64 # As recommended by the EDK2 readme, we don't use --recursive here.
65 # EDK2 won't use any code or feature from a submodule of a submodule,
66 # so we don't need to add them to the tarball.
67 # Although we don't necessarily need all of the submodules that EDK2
68 # has, we clone them all, to avoid running into problems where EDK2
69 # adds a new submodule or changes its use of an existing one and
70 # the sources we ship in the tarball then fail to build.
71 (cd roms/edk2 && git submodule update --init --depth 1)
72 popd
73
74 exclude=(--exclude=.git)
75 # include the tarballs in subprojects/packagecache but not their expansion
76 for sp in $SUBPROJECTS; do
77 if grep -xqF "[wrap-file]" $src/subprojects/$sp.wrap; then
78 exclude+=(--exclude=subprojects/"$(subproject_dir $sp)")
79 fi
80 done
81 tar "${exclude[@]}" -cJf ${destination}.tar.xz ${destination}
82 rm -rf ${destination}