RepositoryRules: RepositoryConfig does not need/use URL now.
[haiku.git] / build / scripts / build_archive
blob350ffe5f4f4a3fdb9b580b87f5c53487229e5b88
1 #!/bin/sh
2 set -o errexit
4 if [ $# -lt 2 ]; then
5 echo "Usage: $0 <archive> <scripts> ..."
6 fi
8 # get the archive name
9 archive=$1
10 shift
12 # The second argument is the shell script that initializes the variables:
13 # tmpDir
14 # addBuildCompatibilityLibDir
16 # copyattr
17 # rmAttrs
18 # zip
19 # NOTE: rmAttrs and zip are only passed in when building zip
21 . $1
22 shift
24 outputDir=$tmpDir/archive
26 # this adds the build library dir to LD_LIBRARY_PATH
27 eval "$addBuildCompatibilityLibDir"
29 # map the shell commands
30 sPrefix=
31 tPrefix="$outputDir/"
32 cd=cd
33 scd=:
34 cp="$copyattr -d"
35 ln=ln
36 mkdir=mkdir
37 rm=rm
40 cleanDir()
42 # clearDir <directory>
43 if [ $rmAttrs ] ; then
44 $rmAttrs -rf $1
45 else
46 $rm -rf $1
51 # clean output dir
52 cleanDir $outputDir
53 $mkdir -p $outputDir
55 # populate output dir
56 echo "Preparing contents of archive $archive ..."
57 while [ $# -gt 0 ]; do
58 . $1
59 shift
60 done
62 # get an absolute path for the archive
63 cwd=$(pwd)
64 cd $(dirname $archive)
65 archive=$(pwd)/$(basename $archive)
66 cd $cwd
68 # build the archive
69 echo "Building archive $archive ..."
70 $rm -f $archive
71 cd $outputDir
72 case "$archive" in
73 *.zip)
74 $zip -ryq $archive .
76 *.tgz)
77 contents=$(ls)
78 tar --format ustar -czf $archive $contents
81 echo "Unhandled archive format in build_archive"
82 exit 1
84 esac
85 cd ..
87 # clean up
88 cleanDir $outputDir