mirror of
https://review.haiku-os.org/haiku
synced 2025-01-31 10:47:14 +01:00
ba96552b6a
* BuildHaikuPackage rule: Create the script that contains the extraction commands. * build_haiku_package: Add extractFile() function (stripped down version from build_haiku_image). In build_haiku_image the functionality was mainly used to extract the optional packages, which is no longer done. We still need it e.g. for the Wifi firmware packages that want to be extracted.
124 lines
2.3 KiB
Bash
Executable File
124 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
set -o errexit
|
|
|
|
# The first argument is the shell script that initializes the variables:
|
|
# addBuildCompatibilityLibDir
|
|
# mimeDB
|
|
# outputDir
|
|
# sourceDir
|
|
# tmpDir
|
|
# compressionLevel
|
|
# updateOnly
|
|
#
|
|
# addattr
|
|
# copyattr
|
|
# mimeset
|
|
# 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
|
|
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
|
|
|
|
|
|
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)
|
|
echo "Extracting $archiveFile ..."
|
|
$unzip -q -d "$extractDir" "$archiveFile"
|
|
;;
|
|
*.tgz|*.tar.gz)
|
|
echo "Extracting $archiveFile ..."
|
|
tar -C "$extractDir" -xf "$archiveFile"
|
|
;;
|
|
*.hpkg)
|
|
echo "Extracting $archiveFile ..."
|
|
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"
|
|
}
|
|
|
|
|
|
# execute the scripts preparing the package contents
|
|
while [ $# -gt 0 ]; do
|
|
. $1
|
|
shift
|
|
done
|
|
|
|
|
|
# mimeset the whole package content
|
|
$mimeset --mimedb "$mimeDB" "$contentsDir"
|
|
|
|
|
|
# create the package
|
|
if [ ! $updateOnly ]; then
|
|
rm -f "$packagePath"
|
|
$package create -q "-$compressionLevel" -i "$packageInfoPath" \
|
|
-C "$contentsDir" "$packagePath"
|
|
else
|
|
$package add -q -f "-$compressionLevel" -i "$packageInfoPath" \
|
|
-C "$contentsDir" "$packagePath" .
|
|
fi
|