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.
17 if test $# -lt 1; then
18 error "Usage: $0 <output tarball>"
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"
40 } | grep -x -v $(for sm in $submodules; do echo "-e $sm"; done) > "$list_file"
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"