diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:03:49 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:03:49 -0800 |
commit | dcc08f073b6873c69ab891d4f69f7c568e282df7 (patch) | |
tree | cbaa218be3f46078555b6bfb36c48659096a747a /tools/mktarball.sh | |
parent | d3aa4000e42fd1036e0e3286843c5132f905d754 (diff) | |
download | build-dcc08f073b6873c69ab891d4f69f7c568e282df7.zip build-dcc08f073b6873c69ab891d4f69f7c568e282df7.tar.gz build-dcc08f073b6873c69ab891d4f69f7c568e282df7.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'tools/mktarball.sh')
-rwxr-xr-x | tools/mktarball.sh | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tools/mktarball.sh b/tools/mktarball.sh new file mode 100755 index 0000000..ea1a8ed --- /dev/null +++ b/tools/mktarball.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# $1: path to fs_get_stats program +# $2: start dir +# $3: subdir to tar up (from $2) +# $4: target tar name +# $5: target tarball name (usually $(3).bz2) + +if [ $# -ne 5 ]; then + echo "Error: wrong number of arguments in cmd: $0 $* " + exit 1 +fi + +fs_get_stats=`readlink -f $1` +start_dir=`readlink -f $2` +dir_to_tar=$3 +target_tar=`readlink -f $4` +target_tarball=`readlink -f $5` + +cd $2 + +#tar --no-recursion -cvf ${target_tar} ${dir_to_tar} +rm ${target_tar} > /dev/null 2>&1 + +# do dirs first +subdirs=`find ${dir_to_tar} -type d -print` +files=`find ${dir_to_tar} \! -type d -print` +for f in ${subdirs} ${files} ; do + curr_perms=`stat -c 0%a $f` + [ -d "$f" ] && is_dir=1 || is_dir=0 + new_info=`${fs_get_stats} ${curr_perms} ${is_dir} ${f}` + new_uid=`echo ${new_info} | awk '{print $1;}'` + new_gid=`echo ${new_info} | awk '{print $2;}'` + new_perms=`echo ${new_info} | awk '{print $3;}'` +# echo "$f: dir: $is_dir curr: $curr_perms uid: $new_uid gid: $new_gid "\ +# "perms: $new_perms" + tar --no-recursion --numeric-owner --owner $new_uid \ + --group $new_gid --mode $new_perms -p -rf ${target_tar} ${f} +done + +if [ $? -eq 0 ] ; then + bzip2 -c ${target_tar} > ${target_tarball} + success=$? + [ $success -eq 0 ] || rm -f ${target_tarball} + rm -f ${target_tar} + exit $success +fi + +rm -f ${target_tar} +exit 1 |