ppc/mac: More rework of the DBDMA emulation
[qemu/kevin.git] / scripts / archive-source.sh
blobc4e7d98f4dab7bbd5d759ac989d66c01ba7e945f
1 #!/bin/bash
3 # Author: Fam Zheng <famz@redhat.com>
5 # Archive source tree, including submodules. This is created for test code to
6 # export the source files, in order to be built in a different environment,
7 # such as in a docker instance or VM.
9 # This code is licensed under the GPL version 2 or later. See
10 # the COPYING file in the top-level directory.
12 error() {
13 printf %s\\n "$*" >&2
14 exit 1
17 if test $# -lt 1; then
18 error "Usage: $0 <output tarball>"
21 tar_file="$1"
22 list_file="$1.list"
23 submodules=$(git submodule foreach --recursive --quiet 'echo $name')
25 if test $? -ne 0; then
26 error "git submodule command failed"
29 trap "status=$?; rm -f \"$list_file\"; exit \$status" 0 1 2 3 15
31 if test -n "$submodules"; then
33 git ls-files || error "git ls-files failed"
34 for sm in $submodules; do
35 (cd $sm; git ls-files) | sed "s:^:$sm/:"
36 if test "${PIPESTATUS[*]}" != "0 0"; then
37 error "git ls-files in submodule $sm failed"
39 done
40 } | grep -x -v $(for sm in $submodules; do echo "-e $sm"; done) > "$list_file"
41 else
42 git ls-files > "$list_file"
45 if test $? -ne 0; then
46 error "failed to generate list file"
49 tar -cf "$tar_file" -T "$list_file" || error "failed to create tar file"
51 exit 0