BuildSystem: Cleanup port building script

All dependencies are now installed only ones. If a port depends on for
examle zlib and one of its other dependencies depends on zlib, zlib will
now get installe only once.

Accept .tgz archives as the main download file
This commit is contained in:
Bananymous 2025-11-11 16:07:39 +02:00
parent f3beee9874
commit 6f8d850726
2 changed files with 48 additions and 18 deletions

1
ports/.gitignore vendored
View File

@ -1,3 +1,4 @@
*/* */*
!*/patches/ !*/patches/
!*/build.sh !*/build.sh
.installed_ports

View File

@ -11,6 +11,12 @@ fi
source "$BANAN_ROOT_DIR/script/config.sh" source "$BANAN_ROOT_DIR/script/config.sh"
installed_file="$BANAN_PORT_DIR/.installed_ports"
if [ -z $DONT_REMOVE_INSTALLED ]; then
export DONT_REMOVE_INSTALLED=1
rm -f "$installed_file"
fi
export PATH="$BANAN_TOOLCHAIN_PREFIX/bin:$PATH" export PATH="$BANAN_TOOLCHAIN_PREFIX/bin:$PATH"
export PKG_CONFIG_DIR='' export PKG_CONFIG_DIR=''
@ -29,10 +35,6 @@ export OBJDUMP="$BANAN_TOOLCHAIN_TRIPLE-objdump"
export STRIP="$BANAN_TOOLCHAIN_TRIPLE-strip" export STRIP="$BANAN_TOOLCHAIN_TRIPLE-strip"
export CXXFILT="$BANAN_TOOLCHAIN_TRIPLE-c++filt" export CXXFILT="$BANAN_TOOLCHAIN_TRIPLE-c++filt"
pushd "$BANAN_ROOT_DIR" >/dev/null
./bos all && ./bos install || exit 1
popd >/dev/null
if [ "$BANAN_ARCH" = "i686" ]; then if [ "$BANAN_ARCH" = "i686" ]; then
export LDFLAGS="-shared-libgcc" export LDFLAGS="-shared-libgcc"
fi fi
@ -78,13 +80,17 @@ post_configure() {
} }
configure() { configure() {
pre_configure
configure_options=("--host=$BANAN_ARCH-pc-banan_os" '--prefix=/usr') configure_options=("--host=$BANAN_ARCH-pc-banan_os" '--prefix=/usr')
configure_options+=("${CONFIGURE_OPTIONS[@]}") configure_options+=("${CONFIGURE_OPTIONS[@]}")
./configure "${configure_options[@]}" || exit 1 ./configure "${configure_options[@]}" || exit 1
}
post_configure pre_build() {
:
}
post_build() {
:
} }
build() { build() {
@ -102,13 +108,9 @@ post_install() {
} }
install() { install() {
pre_install
for target in "${MAKE_INSTALL_TARGETS[@]}"; do for target in "${MAKE_INSTALL_TARGETS[@]}"; do
make $target "DESTDIR=$BANAN_SYSROOT" || exit 1 make $target "DESTDIR=$BANAN_SYSROOT" || exit 1
done done
post_install
} }
source $1 source $1
@ -118,7 +120,30 @@ if [ -z $NAME ] || [ -z $VERSION ] || [ -z $DOWNLOAD_URL ]; then
exit 1 exit 1
fi fi
build_dir="$NAME-$VERSION-$BANAN_ARCH"
if [ ! -d "$build_dir" ]; then
rm -f '.compile_hash'
fi
if [ ! -f '.compile_hash' ] && [ -f "$installed_file" ]; then
sed -i "/^$NAME-$VERSION$/d" "$installed_file"
fi
if grep -qsxF "$NAME-$VERSION" "$installed_file"; then
exit 0
fi
pushd "$BANAN_ROOT_DIR" >/dev/null
./bos all && ./bos install || exit 1
popd >/dev/null
for dependency in "${DEPENDENCIES[@]}"; do for dependency in "${DEPENDENCIES[@]}"; do
if [ ! -d "../$dependency" ]; then
echo "Could not find dependency '$dependency' or port '$NAME'"
exit 1
fi
pushd "../$dependency" >/dev/null pushd "../$dependency" >/dev/null
pwd pwd
if ! ./build.sh; then if ! ./build.sh; then
@ -128,12 +153,6 @@ for dependency in "${DEPENDENCIES[@]}"; do
popd >/dev/null popd >/dev/null
done done
build_dir="$NAME-$VERSION-$BANAN_ARCH"
if [ ! -d "$build_dir" ]; then
rm -f ".compile_hash"
fi
if [ "$VERSION" = "git" ]; then if [ "$VERSION" = "git" ]; then
regex="(.*/.*\.git)#(.*)" regex="(.*/.*\.git)#(.*)"
@ -186,7 +205,7 @@ else
exit 1 exit 1
fi fi
regex='(.*\.tar\..*)' regex='(.*\.tar\..*|.*\.tgz)'
if [[ $FILE_NAME =~ $regex ]] && [ ! -d "$build_dir" ]; then if [[ $FILE_NAME =~ $regex ]] && [ ! -d "$build_dir" ]; then
tar xf "$FILE_NAME" || exit 1 tar xf "$FILE_NAME" || exit 1
@ -219,9 +238,19 @@ cd "$build_dir"
if (( $needs_compile )); then if (( $needs_compile )); then
config_sub_update config_sub_update
pre_configure
configure configure
post_configure
pre_build
build build
post_build
sha256sum "$BANAN_SYSROOT/usr/lib/libc.a" > "../.compile_hash" sha256sum "$BANAN_SYSROOT/usr/lib/libc.a" > "../.compile_hash"
fi fi
pre_install
install install
grep -qsxF "$NAME-$VERSION" "$installed_file" || echo "$NAME-$VERSION" >> "$installed_file"
post_install