libroot/posix/stdio: Remove unused portions.
[haiku.git] / build / scripts / build_haiku_package
blob46c1a20a0a07a0b8177bb5c3e13e0fea2eede810
1 #!/bin/sh
2 set -o errexit
4 # The first argument is the shell script that initializes the variables:
5 # addBuildCompatibilityLibDir
6 # mimeDB
7 # outputDir
8 # sourceDir
9 # tmpDir
10 # compressionLevel
11 # updateOnly
12 # cc
14 # addattr
15 # copyattr
16 # mimeset
17 # package
18 # rc
19 # rmAttrs
20 # unzip
23 if [ $# -le 1 ]; then
24 echo "$0: Missing parameters!" >&2
25 exit 1
28 packagePath="$1"
29 packageInfoPath="$2"
30 shift 2
32 if [ $# -gt 0 ]; then
33 . $1
34 shift
37 # this adds the build library dir to LD_LIBRARY_PATH
38 eval "$addBuildCompatibilityLibDir"
41 # make a clean contents dir
42 packageName=`basename "$packagePath"`
43 echo "$packageName: Removing and re-creating package contents dir ..."
44 contentsDir="$tmpDir/contents"
45 $rmAttrs -rf "$contentsDir"
46 mkdir -p "$contentsDir"
49 # map the shell commands
50 sPrefix=
51 tPrefix="$contentsDir/"
52 cd=cd
53 scd=:
54 cp="$copyattr -d"
55 copyAttrs="$copyattr"
56 ln=ln
57 mkdir=mkdir
58 rm=$rmAttrs
59 mkindex=mkindex
62 extractFile()
64 # extractFile <archive> <directory> <extractedSubDir>
65 archiveFile=$1
66 targetExtractedDir=$2
67 extractedSubDir=$3
69 extractDir=$tmpDir/extract
70 $rmAttrs -rf "$extractDir"
71 mkdir -p "$extractDir"
73 case "$archiveFile" in
74 *.zip)
75 $unzip -q -d "$extractDir" "$archiveFile"
77 *.tgz|*.tar.gz)
78 tar -C "$extractDir" -xf "$archiveFile"
80 *.hpkg)
81 if [ -n "$extractedSubDir" ]; then
82 $package extract -C "$extractDir" "$archiveFile" \
83 "$extractedSubDir"
84 else
85 $package extract -C "$extractDir" "$archiveFile"
89 echo "Unhandled archive extension in build_haiku_image" \
90 "extractFile()"
91 exit 1
93 esac
95 $cp -r "${sPrefix}$extractDir/$extractedSubDir/." \
96 "${tPrefix}$targetExtractedDir"
98 $rmAttrs -rf "$extractDir"
102 # execute the scripts preparing the package contents
103 echo "$packageName: Collecting package contents ..."
104 while [ $# -gt 0 ]; do
105 . $1
106 shift
107 done
110 # mimeset the whole package content
111 echo "$packageName: mimeset'ing package contents ..."
112 $mimeset --mimedb "$mimeDB" "$contentsDir"
115 # create the package
116 if [ ! $updateOnly ]; then
117 echo "$packageName: Creating the package ..."
118 rm -f "$packagePath"
119 $package create -q "-$compressionLevel" -i "$packageInfoPath" \
120 -C "$contentsDir" "$packagePath"
121 else
122 echo "$packageName: Updating the package ..."
123 $package add -q -f "-$compressionLevel" -i "$packageInfoPath" \
124 -C "$contentsDir" "$packagePath" .