1#!/bin/bash
2#
3# mktarball: Make a release tarball (including xen, qemu, and qemu-traditional)
4#
5# Takes 2 arguments, the path to the dist directory and the version
6set -ex
7
8function git_archive_into {
9    mkdir -p "$2"
10
11    git --git-dir="$1"/.git \
12	archive --format=tar HEAD | \
13	tar Cxf "$2" -
14}
15
16if [[ -z "$1" || -z "$2" ]] ; then
17  echo "usage: $0 path-to-XEN_ROOT xen-version"
18  exit 1
19fi
20
21xen_root="$1"
22desc="$2"
23
24tdir="$xen_root/dist/tmp.src-tarball"
25
26rm -rf $tdir
27
28mkdir -p $tdir
29
30git_archive_into $xen_root $tdir/xen-$desc
31
32# We can't use git_archive_into with qemu upstream because it uses
33# git-submodules.  git-submodules are an inherently broken git feature
34# which should never be used in any circumstance.  Unfortunately, qemu
35# upstream uses them.  Relevantly for us, git archive does not work
36# properly when there are submodules.
37(
38    cd $xen_root/tools/qemu-xen-dir-remote
39    # if it's not clean, the qemu script will call `git stash' !
40    git --no-pager diff --stat HEAD
41    scripts/archive-source.sh $tdir/xen-$desc/tools/qemu-xen.tar
42    cd $tdir/xen-$desc/tools
43    mkdir qemu-xen
44    tar <qemu-xen.tar Cxf qemu-xen -
45    rm qemu-xen.tar
46)
47
48git_archive_into $xen_root/tools/qemu-xen-traditional-dir-remote $tdir/xen-$desc/tools/qemu-xen-traditional
49
50git_archive_into $xen_root/extras/mini-os-remote $tdir/xen-$desc/extras/mini-os
51
52GZIP=-9v tar cz -f $xen_root/dist/xen-$desc.tar.gz -C $tdir xen-$desc
53
54echo "Source tarball in $xen_root/dist/xen-$desc.tar.gz"
55