2011-06-17 17:11:16 +04:00
|
|
|
#!/bin/sh
|
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
# The first argument is the shell script that initializes the variables:
|
2013-05-09 05:38:10 +04:00
|
|
|
# addBuildCompatibilityLibDir
|
|
|
|
# mimeDB
|
2011-06-17 17:11:16 +04:00
|
|
|
# outputDir
|
2013-05-09 05:38:10 +04:00
|
|
|
# sourceDir
|
2011-06-17 17:11:16 +04:00
|
|
|
# tmpDir
|
2013-05-19 03:48:53 +04:00
|
|
|
# compressionLevel
|
2011-07-03 10:44:19 +04:00
|
|
|
# updateOnly
|
2011-06-17 17:11:16 +04:00
|
|
|
#
|
|
|
|
# addattr
|
|
|
|
# copyattr
|
2013-05-09 05:38:10 +04:00
|
|
|
# mimeset
|
2011-06-17 17:11:16 +04:00
|
|
|
# package
|
|
|
|
# rc
|
|
|
|
# rmAttrs
|
|
|
|
# unzip
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ $# -le 1 ]; then
|
|
|
|
echo "$0: Missing parameters!" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
packagePath="$1"
|
|
|
|
packageInfoPath="$2"
|
|
|
|
shift 2
|
|
|
|
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
. $1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
|
|
|
# this adds the build library dir to LD_LIBRARY_PATH
|
|
|
|
eval "$addBuildCompatibilityLibDir"
|
|
|
|
|
|
|
|
|
|
|
|
# make a clean contents dir
|
2013-06-01 00:45:06 +04:00
|
|
|
packageName=`basename "$packagePath"`
|
|
|
|
echo "$packageName: Removing and re-creating package contents dir ..."
|
2011-06-17 17:11:16 +04:00
|
|
|
contentsDir="$tmpDir/contents"
|
|
|
|
$rmAttrs -rf "$contentsDir"
|
|
|
|
mkdir -p "$contentsDir"
|
|
|
|
|
|
|
|
|
|
|
|
# map the shell commands
|
|
|
|
sPrefix=
|
|
|
|
tPrefix="$contentsDir/"
|
|
|
|
cd=cd
|
|
|
|
scd=:
|
|
|
|
cp="$copyattr -d"
|
|
|
|
copyAttrs="$copyattr"
|
|
|
|
ln=ln
|
|
|
|
mkdir=mkdir
|
|
|
|
rm=$rmAttrs
|
|
|
|
mkindex=mkindex
|
|
|
|
|
|
|
|
|
2013-06-01 00:37:13 +04:00
|
|
|
extractFile()
|
|
|
|
{
|
|
|
|
# extractFile <archive> <directory> <extractedSubDir> <stripDebugSymbols>
|
|
|
|
archiveFile=$1
|
|
|
|
targetExtractedDir=$2
|
|
|
|
extractedSubDir=$3
|
|
|
|
# Ignore stripDebugSymbols. It's not relevant here, since executables and
|
|
|
|
# libraries shouldn't come from zip files or other archives anymore.
|
|
|
|
|
|
|
|
extractDir=$tmpDir/extract
|
|
|
|
$rmAttrs -rf "$extractDir"
|
|
|
|
mkdir -p "$extractDir"
|
|
|
|
|
|
|
|
case "$archiveFile" in
|
|
|
|
*.zip)
|
|
|
|
$unzip -q -d "$extractDir" "$archiveFile"
|
|
|
|
;;
|
|
|
|
*.tgz|*.tar.gz)
|
|
|
|
tar -C "$extractDir" -xf "$archiveFile"
|
|
|
|
;;
|
|
|
|
*.hpkg)
|
|
|
|
if [ -n "$extractedSubDir" ]; then
|
|
|
|
$package extract -C "$extractDir" "$archiveFile" \
|
|
|
|
"$extractedSubDir"
|
|
|
|
else
|
|
|
|
$package extract -C "$extractDir" "$archiveFile"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unhandled archive extension in build_haiku_image" \
|
|
|
|
"extractFile()"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
$cp -r "${sPrefix}$extractDir/$extractedSubDir/." \
|
|
|
|
"${tPrefix}$targetExtractedDir"
|
|
|
|
|
|
|
|
$rmAttrs -rf "$extractDir"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 17:11:16 +04:00
|
|
|
# execute the scripts preparing the package contents
|
2013-06-01 00:45:06 +04:00
|
|
|
echo "$packageName: Collecting package contents ..."
|
2011-06-17 17:11:16 +04:00
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
. $1
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
|
2013-05-09 05:38:10 +04:00
|
|
|
# mimeset the whole package content
|
2013-06-01 00:45:06 +04:00
|
|
|
echo "$packageName: mimeset'ing package contents ..."
|
2013-05-09 05:38:10 +04:00
|
|
|
$mimeset --mimedb "$mimeDB" "$contentsDir"
|
|
|
|
|
|
|
|
|
2011-06-17 17:11:16 +04:00
|
|
|
# create the package
|
2011-07-03 10:44:19 +04:00
|
|
|
if [ ! $updateOnly ]; then
|
2013-06-01 00:45:06 +04:00
|
|
|
echo "$packageName: Creating the package ..."
|
2011-07-03 10:44:19 +04:00
|
|
|
rm -f "$packagePath"
|
2013-05-19 03:48:53 +04:00
|
|
|
$package create -q "-$compressionLevel" -i "$packageInfoPath" \
|
|
|
|
-C "$contentsDir" "$packagePath"
|
2011-07-03 10:44:19 +04:00
|
|
|
else
|
2013-06-01 00:45:06 +04:00
|
|
|
echo "$packageName: Updating the package ..."
|
2013-05-19 03:48:53 +04:00
|
|
|
$package add -q -f "-$compressionLevel" -i "$packageInfoPath" \
|
|
|
|
-C "$contentsDir" "$packagePath" .
|
2011-07-03 10:44:19 +04:00
|
|
|
fi
|