From 3f55a70f6e2329aa8bf3b91c6f916d0a87db5372 Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 8 Aug 2023 19:46:04 +0200 Subject: [PATCH] ports: Auto-strip binaries, remove libtool .la files, add dependencies --- ports/README.md | 3 +++ ports/binutils/PACKAGE | 9 +-------- tools/install-package.sh | 13 ++++++++++--- tools/make-package.sh | 12 ++++++++++++ tools/uninstall-package.sh | 2 ++ 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/ports/README.md b/ports/README.md index 33d25a27..101378f9 100644 --- a/ports/README.md +++ b/ports/README.md @@ -48,10 +48,13 @@ The `name` variable should be set to the name of the ported program. The `version` variable should be set to the currently ported version of the program. +If the program has dependencies on any other library/program, the `dependencies` field should be set to a list of those. Note that these dependencies must also be ported to Luna! Thus, when porting programs, you'll have to start with porting their dependencies (unless those have already been ported). + Example: ``` name="example" version="1.0.0" +dependencies=(foo bar) ``` #### Download options diff --git a/ports/binutils/PACKAGE b/ports/binutils/PACKAGE index a84adcd9..de56d904 100644 --- a/ports/binutils/PACKAGE +++ b/ports/binutils/PACKAGE @@ -10,6 +10,7 @@ sha256sum="d12ea6f239f1ffe3533ea11ad6e224ffcb89eb5d01bbea589e9158780fa11f10" # Build instructions default_build_make=true +default_install_make=true do_patch() { @@ -20,11 +21,3 @@ do_configure() { $srcdir/configure --host=$LUNA_ARCH-luna --disable-nls --disable-werror --enable-warn-rwx-segments=no --prefix=/usr --enable-gold=no --enable-ld=yes --enable-gprofng=no } - -do_install() -{ - make install - - cd $installdir/usr/bin - $LUNA_ARCH-luna-strip size objdump ar strings ranlib objcopy addr2line readelf elfedit nm strip c++filt as gprof ld.bfd ld -} diff --git a/tools/install-package.sh b/tools/install-package.sh index f87c8265..f9033005 100755 --- a/tools/install-package.sh +++ b/tools/install-package.sh @@ -15,16 +15,23 @@ fi source ports/$PORT_NAME/PACKAGE +IS_NEW_VERSION=0 + if ! [ -f ports/out/$name-$version.tar.gz ]; then tools/make-package.sh $PORT_NAME + IS_NEW_VERSION=1 fi -PORT_FILES=$LUNA_BASE/usr/share/pkgdb/$PORT_NAME.files +PORT_FILES=$LUNA_BASE/usr/share/pkgdb/$name.files if [ -f $PORT_FILES ] then - echo "Package $PORT_NAME is already installed! Updating." - tools/uninstall-package.sh $PORT_NAME + if [ "$IS_NEW_VERSION" -eq "0" ]; then + echo "Package $PORT_NAME version $version is already installed!" + exit 0 + fi + echo "Package $PORT_NAME is already installed! Updating to version $version." + tools/uninstall-package.sh $name fi mkdir -p $LUNA_BASE/usr/share/pkgdb/ diff --git a/tools/make-package.sh b/tools/make-package.sh index 9b69bb75..20a9f051 100755 --- a/tools/make-package.sh +++ b/tools/make-package.sh @@ -28,6 +28,13 @@ source ports/$PORT_NAME/PACKAGE [ -z ${format+x} ] && show_error "error: The port's PACKAGE file does not have a 'format' key." [ -z ${url+x} ] && show_error "error: The port's PACKAGE file does not have a 'url' key." +if ! [ -z ${dependencies+x} ]; then + echo "Installing dependencies of $name: ($dependencies)" + for dep in ${dependencies[@]}; do + tools/install-package.sh $dep + done +fi + export portdir=$LUNA_ROOT/ports/$name/ export srcdir=${srcdir:-$WORKDIR/$name-$version} export builddir=$WORKDIR/build-$name @@ -109,6 +116,11 @@ else do_install fi +rm -f $installdir/usr/lib/*.la # remove all libtool .la files, as they use host stuff which we don't want at all +set +e +$LUNA_ARCH-luna-strip $installdir/usr/bin/* # strip all binaries +set -e + cd $installdir tar czf $LUNA_ROOT/ports/out/$name-$version.tar.gz * diff --git a/tools/uninstall-package.sh b/tools/uninstall-package.sh index e347d4f5..fbb14208 100755 --- a/tools/uninstall-package.sh +++ b/tools/uninstall-package.sh @@ -14,5 +14,7 @@ then exit 1 fi +set +e + rm -v $(cat $LUNA_BASE/usr/share/pkgdb/$PORT_NAME.files) rm -v $LUNA_BASE/usr/share/pkgdb/$PORT_NAME.files