-
Notifications
You must be signed in to change notification settings - Fork 0
Useful variables for recipes
For a list of all variables and where to use them, check Haikuporter Guidelines and Haikuporter Build-Recipes
Some sources ship with licenses not provided by default in Haiku, when they do you have to put them together with your recipe
create a `licenses` directory next to your `recipe`
copy the existing license from source to the licenses directory
rename the license appropriate and add this to your recipe in LICENSES=""
For a non standard $portversion like this: 1.5.4~pl02
you need to adjust the SOURCE_URI
and sometimes the SOURCE_DIR
:
`SOURCE_URI="https://www.gnu.org/software/xorriso/xorriso-${portVersion/\~/.}.tar.gz"`
SOURCE_DIR = xorriso-1.5.4 then:
SOURCE_DIR="xorriso-${portVersion/\~pl02/}"
A bit more complex for slunkcrypt-2022_04_24.recipe, we need to change the _
to -
in the recipe, the archive doesn't provide a top-levell directory so we need to leave SOURCE_DIR empty, gitLabDir
and SLUNKCRYPT_VERSION
are custom variables:
gitLabDir="da63740f538e552708ae712bcc157142"
SLUNKCRYPT_VERSION=`echo $portVersion | sed 's/\_/-/g'`
SOURCE_URI="$HOMEPAGE/uploads/$gitLabDir/slunkcrypt.$SLUNKCRYPT_VERSION.source.tar.gz"
CHECKSUM_SHA256="599be4f4a6767992731a671d534fdaa74919dc8c83a8204b0f92439b90f7b658"
SOURCE_DIR=""
On x86_gcc2 if primary doesn't build (!x86_gcc2) then move binaries to $prefix/bin
instead of $binDir
($prefix/bin/x86)
needs the adjustment in BUILD()
and PROVIDES
too:
commandBinDir=$binDir
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]; then
commandSuffix=
commandBinDir=$prefix/bin
fi
PROVIDES="
projectx$secondaryArchSuffix
cmd:projectx$commandSuffix
"
BUILD()
runConfigure --omit-dirs binDir ./configure \
--bindir=$commandBinDir
for cmake:
BUILD()
cmake -B build -S . \
$cmakeDirArgs \
-DCMAKE_INSTALL_BINDIR=$commandBinDir
readelf -d /system/lib/libgit2.so.1.5.0 | grep SONAME
If libraries provide sonames declare them here and in PROVIDES=""
:
libVersion="0.1.1"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"
PROVIDES="
fribidi$secondaryArchSuffix = $portVersion
lib:libfribidi$secondaryArchSuffix = $libVersionCompat
"
In packages with multiple libraries and different sonames you could use a bit more complex variant:
libcdioLibs="
libcdio
libcdioxx
libiso9660
libiso9660xx
libudf
"
libcdioVersion=18.0.0
libcdioxxVersion=1.0.0
libiso9660Version=11.0.0
libiso9660xxVersion=0.0.0
libudfVersion=0.0.0
for i in lib $libcdioLibs; do
eval "${i}VersionCompat=\"\$${i}Version compat >= \${${i}Version%%.*}\""
done
PROVIDES="
libcdio$secondaryArchSuffix = $portVersion
lib:libcdio$secondaryArchSuffix = $libcdioVersionCompat
lib:libcdio++$secondaryArchSuffix = $libcdioxxVersionCompat
lib:libiso9660$secondaryArchSuffix = $libiso9660VersionCompat
lib:libiso9660++$secondaryArchSuffix = $libiso9660xxVersionCompat
lib:libudf$secondaryArchSuffix = $libudfVersionCompat
"
If a package builds for both gcc2 and gcc8 you might want to skip the commands for SECONDARY_ARCHITECTURE=""
:
if [ -z "$secondaryArchSuffix" ]; then
PROVIDES="$PROVIDES
cmd:cdda_player = $portVersion
cmd:cd_drive = $portVersion
cmd:cd_info = $portVersion
cmd:cd_read = $portVersion
cmd:iso_info = $portVersion
cmd:iso_read = $portVersion
cmd:mmc_tool = $portVersion
"
fi
Also needs adjusting in INSTALL():
INSTALL()
if [ -z "$secondaryArchSuffix" ]; then
packageEntries tools \
"$commandBinDir"
fi
if [ -n "$secondaryArchSuffix" ]; then
rm -rf "$documentationDir" "$binDir"
fi
Sometimes you want the tools (commands in a subpackage, use $commandSuffix
or $secondaryArchSuffix
as needed:
PROVIDES_tools="
fribidi${secondaryArchSuffix}_tools = $portVersion
cmd:fribidi$commandSuffix = $portVersion
"
REQUIRES_tools="
fribidi$secondaryArchSuffix == $portVersion base
"
Also needs adjustment in INSTALL(), use $commandBinDir
or $binDir
where needed
packageEntries tools \
"$commandBinDir"
Check in Terminal with readelf -S $libname | grep debug
for debug info
If they are provided move them into a debug package:
defineDebugInfoPackage roaraudio$secondaryArchSuffix \
$libDir/libroar.so.$libVersion \
$commandBinDir/roarbidir
defineDebugInfoPackage libde265$secondaryArchSuffix \
$libDir/libde265.so.$libVersion \
"$(getPackagePrefix tools)"/bin/acceleration_speed \
Sometimes ports don't provide pkgconfig
files, these can be added to the INSTALL()
part:
# Add pkgconfig file
mkdir -p $developLibDir/pkgconfig
cat > $developLibDir/pkgconfig/libargon2.pc << EOF
bindir=$prefix/bin
exec_prefix=$prefix
libdir=$libDir
includedir=$includeDir
Name: libargon2
Description: $SUMMARY
Version: $portVersion
Libs: -L$developLibDir -largon2
Cflags: -I$includeDir
EOF
Sometimes fixPkgconfig
alters the paths for the pkgconfig
files, this is a fix for those:
INSTALL()
# fixPkgconfig
if [ -n "$secondaryArchSuffix" ]; then
sed -i 's,\/headers/x86,\/headers/x86/sunpinyin-2.0,g' \
$prefix/$relativeDevelopLibDir/pkgconfig/sunpinyin-2.0.pc
else
sed -i 's,\/headers,\/headers/sunpinyin-2.0,g' \
$prefix/$relativeDevelopLibDir/pkgconfig/sunpinyin-2.0.pc
fi
Or:
fixPkgconfig strict
sed -e 's,^includedir=\(.*\)include,includedir=${prefix}/'${relativeIncludeDir}',' \
-i $developLibDir/pkgconfig/libinstpatch-1.0.pc
Some more information on using sed: https://www.geeksforgeeks.org/sed-command-in-linux-unix-with-examples/
find "$libDir" -name '*.la' -delete
If you need to do some post install actions you can do this in a post-install script that will be executed when the package is installed
ADDITIONAL_FILES="fontconfig-reload-cache.sh"
POST_INSTALL_SCRIPTS="$relativePostInstallDir/fontconfig-reload-cache.sh"
mkdir -p $postInstallDir
cp -f $portDir/additional-files/fontconfig-reload-cache.sh $postInstallDir
In the script you can do a check if fc-cache is available and if so reload the fontconfig's chache (save this file as fontconfig-reload-cache.sh
in additional-files):
#!sh
command -v fc-cache && fc-cache -f
If you need to point to a certain path, check finddir -l
for available paths:
$(finddir B_SYSTEM_DEVELOP_DIRECTORY)/lib$secondaryArchSubDir
This points to /boot/system/develop/lib/x86
(secondary architecture on 32bit)
You can open your applications with FileTypes and get additional information like version number ... For resource vector_icon information you can create a new icon or edit a provided svg icon in Icon-O-Matic and export the icon as *.rdef file. Edit the *.rdef.in file in your port directory next to the recipes, below some information what's needed:
additional-files/mednaffe.rdef.in
resource app_flags B_SINGLE_LAUNCH;
resource app_version {
major = @MAJOR@,
middle = @MIDDLE@,
minor = @MINOR@,
variety = B_APPV_FINAL,
internal = 0,
short_info = "@APP_NAME@",
long_info = "@LONG_INFO@"
};
resource app_signature "@APP_SIGNATURE@";
resource vector_icon {
$"6E63696604020112020000003B1906BDCE9B00000049D2014B20D10000FFFF00"
$"00020106020000003DEC56BDEC5100000049E13F480189008FB1DCFF3465A403"
$"204A870200120239F37D3E5955BE595539F37D4465034BBA6100FFFFFFFF0004"
$"0606FF07CB4FC6F1CB4FC6F1CB4FC9ABBF2DCBE1C5E1CBE1B879CBE1B30AC6F1"
$"B30AC9ABB30AC437BF2DC201B879C201C5E1C201CB4FC6F1CB4FC437CB4FC6F1"
$"C6F10606FF07C9F0BF59C9F0BF59C9F0C530BF5EC9EBC534C9EBB987C9EBB4CB"
$"BF59B4CBC530B4CBB983BF5EB4C7B987B4C7C534B4C7C9F0BF59C9F0B983C9F0"
$"BF59BF590606FF07C9F0BF59C9F0BF59C9F0C530BF5EC9EBC534C9EBB987C9EB"
$"B4CBBF59B4CBC530B4CBB983BF5EB4C7B987B4C7C534B4C7C9F0BF59C9F0B983"
$"C9F0BF59BF590606FF07C95BBF59C95BBF59C95BC4DDBF5EC956C4E2C956B9D9"
$"C956B560BF59B560C4DDB560B9D5BF5EB55CB9D9B55CC4E2B55CC95BBF59C95B"
$"B9D5C95BBF59BF59040A000100000A010101000A0201021001178100040A0301"
$"03100117810004"
};
In the recipe (games-emulation/mednaffe-0.9.2.recipe)
ADDITIONAL_FILES="mednaffe.rdef.in"
...
local MAJOR="`echo "$portVersion" | cut -d. -f1`"
local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
local MINOR="`echo "$portVersion" | cut -d. -f3`"
local APP_NAME="Mednaffe"
local LONG_INFO="$SUMMARY"
local APP_SIGNATURE="application/x-vnd.mednaffe"
sed \
-e "s|@MAJOR@|$MAJOR|" \
-e "s|@MIDDLE@|$MIDDLE|" \
-e "s|@MINOR@|$MINOR|" \
-e "s|@LONG_INFO@|$LONG_INFO|" \
-e "s|@APP_NAME@|$APP_NAME|" \
-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
$portDir/additional-files/mednaffe.rdef.in > mednaffe.rdef
addResourcesToBinaries mednaffe.rdef $appsDir/Mednaffe
If you need to add a link in the Deskbar
addAppDeskbarSymlink $appsDir/Mednaffe
or
addAppDeskbarSymlink $prefix/bin/solarus-launcher Solarus