From 55d13e06fde97ddea41750e5afd7aa289a5b1960 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 19 Apr 2020 08:37:21 +0200 Subject: [PATCH] Make sysroot preparation & packaging overrideable package actions Signed-off-by: David Oberhollenzer --- mk.sh | 1 - util/build_package.sh | 17 ++---------- util/emptypkg.sh | 64 +++++++++++++++++++++++++++++++++++++++++++ util/misc.sh | 45 ------------------------------ util/pkgcmd.sh | 2 +- 5 files changed, 67 insertions(+), 62 deletions(-) delete mode 100644 util/misc.sh diff --git a/mk.sh b/mk.sh index 0302907..dc2135d 100755 --- a/mk.sh +++ b/mk.sh @@ -47,7 +47,6 @@ export BUILD_PATH_PREFIX_MAP="$PKGSRCDIR=src:$BUILDROOT=build" ############################# include utilities ############################## source "$SCRIPTDIR/util/pkgcmd.sh" -source "$SCRIPTDIR/util/misc.sh" source "$SCRIPTDIR/util/override.sh" source "$SCRIPTDIR/util/autotools.sh" source "$SCRIPTDIR/util/build_package.sh" diff --git a/util/build_package.sh b/util/build_package.sh index 252dc7e..bffa6e6 100644 --- a/util/build_package.sh +++ b/util/build_package.sh @@ -12,27 +12,14 @@ build_package() { return fi - for f in $SUBPKG; do - rm -f "$REPODIR/${f}.pkg" - done - rm -rf "$SYSROOT" "$PKGBUILDDIR" "$PKGDEPLOYDIR" mkdir -p "$SYSROOT" "$PKGBUILDDIR" "$PKGDEPLOYDIR" - if [ ! -z "$DEPENDS" ]; then - pkg install -omD $DEPENDS - fi - + run_pkg_command "set_scene" run_pkg_command "download" run_pkg_command "build" run_pkg_command "deploy" - deploy_dev_cleanup - strip_files ${PKGDEPLOYDIR}/{bin,lib} - - for f in $SUBPKG; do - pkg pack -d "$PKGDEPLOYDIR/${f}.desc" \ - -l "$PKGDEPLOYDIR/${f}.files" - done + run_pkg_command "package" rm -rf "$SYSROOT" "$PKGBUILDDIR" "$PKGDEPLOYDIR" } diff --git a/util/emptypkg.sh b/util/emptypkg.sh index 70b9aa4..f62fcaa 100644 --- a/util/emptypkg.sh +++ b/util/emptypkg.sh @@ -50,6 +50,52 @@ fetch_package() { fi } +strip_files() { + local f + + for f in $@; do + [ ! -L "$f" ] || continue; + + if [ -d "$f" ]; then + strip_files ${f}/* + fi + + [ -f "$f" ] || continue; + + if file -b $f | grep -q -i elf; then + ${TARGET}-strip --discard-all "$f" 2> /dev/null || true + fi + done +} + +deploy_dev_cleanup() { + local f + + if [ -d "$PKGDEPLOYDIR/share/pkgconfig" ]; then + mkdir -p "$PKGDEPLOYDIR/lib/pkgconfig" + mv $PKGDEPLOYDIR/share/pkgconfig/* "$PKGDEPLOYDIR/lib/pkgconfig" + rmdir "$PKGDEPLOYDIR/share/pkgconfig" + fi + + for f in $PKGDEPLOYDIR/lib/*.la; do + [ ! -e "$f" ] || rm "$f" + done +} + +unfuck_libtool() { + local libdir="$PKGDEPLOYDIR/lib" + local f + + for f in $(find $PKGBUILDDIR -type f -name '*.la' -o -name '*.lai'); do + sed -i "s#libdir='.*'#libdir='$libdir'#g" "$f" + done + + sed -i -r "s/(finish_cmds)=.*$/\1=\"\"/" "$PKGBUILDDIR/libtool" + sed -i -r "s/(hardcode_into_libs)=.*$/\1=no/" "$PKGBUILDDIR/libtool" + + sed -i "s#libdir='\$install_libdir'#libdir='$libdir'#g" "$PKGBUILDDIR/libtool" +} + download() { fetch_package } @@ -58,6 +104,12 @@ prepare() { apply_patches } +set_scene() { + if [ ! -z "$DEPENDS" ]; then + pkg install -omD $DEPENDS + fi +} + build() { return } @@ -66,6 +118,18 @@ deploy() { return } +package() { + deploy_dev_cleanup + strip_files ${PKGDEPLOYDIR}/{bin,lib} + + for f in $SUBPKG; do + rm -f "$REPODIR/${f}.pkg" + + pkg pack -d "$PKGDEPLOYDIR/${f}.desc" \ + -l "$PKGDEPLOYDIR/${f}.files" + done +} + check_update() { return } diff --git a/util/misc.sh b/util/misc.sh deleted file mode 100644 index 9ef510c..0000000 --- a/util/misc.sh +++ /dev/null @@ -1,45 +0,0 @@ -strip_files() { - local f - - for f in $@; do - [ ! -L "$f" ] || continue; - - if [ -d "$f" ]; then - strip_files ${f}/* - fi - - [ -f "$f" ] || continue; - - if file -b $f | grep -q -i elf; then - ${TARGET}-strip --discard-all "$f" 2> /dev/null || true - fi - done -} - -deploy_dev_cleanup() { - local f - - if [ -d "$PKGDEPLOYDIR/share/pkgconfig" ]; then - mkdir -p "$PKGDEPLOYDIR/lib/pkgconfig" - mv $PKGDEPLOYDIR/share/pkgconfig/* "$PKGDEPLOYDIR/lib/pkgconfig" - rmdir "$PKGDEPLOYDIR/share/pkgconfig" - fi - - for f in $PKGDEPLOYDIR/lib/*.la; do - [ ! -e "$f" ] || rm "$f" - done -} - -unfuck_libtool() { - local libdir="$PKGDEPLOYDIR/lib" - local f - - for f in $(find $PKGBUILDDIR -type f -name '*.la' -o -name '*.lai'); do - sed -i "s#libdir='.*'#libdir='$libdir'#g" "$f" - done - - sed -i -r "s/(finish_cmds)=.*$/\1=\"\"/" "$PKGBUILDDIR/libtool" - sed -i -r "s/(hardcode_into_libs)=.*$/\1=no/" "$PKGBUILDDIR/libtool" - - sed -i "s#libdir='\$install_libdir'#libdir='$libdir'#g" "$PKGBUILDDIR/libtool" -} diff --git a/util/pkgcmd.sh b/util/pkgcmd.sh index bfb053d..ea15731 100644 --- a/util/pkgcmd.sh +++ b/util/pkgcmd.sh @@ -1,7 +1,7 @@ include_pkg() { PKGNAME="$1" # globally visible package name - unset -f build deploy download prepare check_update + unset -f build deploy download prepare check_update package unset -v VERSION TARBALL URL SRCDIR SHA256SUM DEPENDS SUBPKG source "$SCRIPTDIR/util/emptypkg.sh" source "$SCRIPTDIR/pkg/$PKGNAME/build"