Expanded on same-loop-handler-signature code, added staticgen.pl.
[xuni.git] / makedistar.sh
blob3226a7a39489f5ece1a2e99b3bd0287a5b9fd53f
1 #!/bin/sh
3 # Setup variables
4 mode=$1 ; shift
5 prefix=$1 ; shift
6 name=$1 ; shift
7 pwd=$(pwd)
8 output="$prefix-$name.tar.gz"
10 # Set up the temporary directory
11 tempdir=$(mktemp -d)
12 dir="$tempdir/$prefix"
13 mkdir $dir
15 echo -n "archive: "
17 # Copy the files specified in the remaining arguments to the temporary dir
18 cp --parents -l $* $dir
20 # Create the actual archive
21 if [ -f "$output" ]; then
22 if [ "$mode" = "--create" ]; then
23 rm $output
26 tar -C $tempdir -xzf $pwd/$output 2>/dev/null
29 tar -C $tempdir -czf $pwd/$output $prefix 2>/dev/null
31 # Print a message about the number of files that were added to the archive
32 printf '%-40s%4d extra %4d total\n' \
33 $output ${#*} $(find $tempdir -type f | wc -w)
35 # Remove temporary directory
36 if [ -n "$(echo $tempdir | grep ^/tmp)" ]; then
37 rm -rf $tempdir
38 else
39 echo Error: temporary directory not in /tmp: $tempdir