block: Remove wrong bdrv_set_aio_context() calls
[qemu/ar7.git] / scripts / archive-source.sh
blob8b899482600053276d13e1ff7515259277178b83
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=$(realpath "$1")
22 list_file="${tar_file}.list"
23 vroot_dir="${tar_file}.vroot"
25 # We want a predictable list of submodules for builds, that is
26 # independent of what the developer currently has initialized
27 # in their checkout, because the build environment is completely
28 # different to the host OS.
29 submodules="dtc slirp ui/keycodemapdb tests/fp/berkeley-softfloat-3 tests/fp/berkeley-testfloat-3"
31 trap "status=$?; rm -rf \"$list_file\" \"$vroot_dir\"; exit \$status" 0 1 2 3 15
33 if git diff-index --quiet HEAD -- &>/dev/null
34 then
35 HEAD=HEAD
36 else
37 HEAD=$(git stash create)
39 git clone --shared . "$vroot_dir"
40 test $? -ne 0 && error "failed to clone into '$vroot_dir'"
41 for sm in $submodules; do
42 if test -d "$sm/.git"
43 then
44 git clone --shared "$sm" "$vroot_dir/$sm"
45 test $? -ne 0 && error "failed to clone submodule $sm"
47 done
49 cd "$vroot_dir"
50 test $? -ne 0 && error "failed to change into '$vroot_dir'"
52 git checkout $HEAD
53 test $? -ne 0 && error "failed to checkout $HEAD revision"
55 for sm in $submodules; do
56 git submodule update --init $sm
57 test $? -ne 0 && error "failed to init submodule $sm"
58 done
60 if test -n "$submodules"; then
62 git ls-files || error "git ls-files failed"
63 for sm in $submodules; do
64 (cd $sm; git ls-files) | sed "s:^:$sm/:"
65 if test "${PIPESTATUS[*]}" != "0 0"; then
66 error "git ls-files in submodule $sm failed"
68 done
69 } | grep -x -v $(for sm in $submodules; do echo "-e $sm"; done) > "$list_file"
70 else
71 git ls-files > "$list_file"
74 if test $? -ne 0; then
75 error "failed to generate list file"
78 tar -cf "$tar_file" -T "$list_file" || error "failed to create tar file"
80 exit 0