From 2dc8bd9cd6cdb34fbbd6307e1f8303798bf43dfe Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 12 Apr 2020 03:25:37 +0200 Subject: [PATCH] Make "download" a package function This commit moves the "fetch_package" utility function to the package skeleton and turns it into an overrideable function called "download". Signed-off-by: David Oberhollenzer --- mk.sh | 1 - util/build_package.sh | 3 +-- util/download.sh | 28 ---------------------------- util/emptypkg.sh | 33 +++++++++++++++++++++++++++++++++ util/pkgcmd.sh | 2 +- 5 files changed, 35 insertions(+), 32 deletions(-) delete mode 100755 util/download.sh diff --git a/mk.sh b/mk.sh index 09e70a0..0302907 100755 --- a/mk.sh +++ b/mk.sh @@ -46,7 +46,6 @@ popd > /dev/null export BUILD_PATH_PREFIX_MAP="$PKGSRCDIR=src:$BUILDROOT=build" ############################# include utilities ############################## -source "$SCRIPTDIR/util/download.sh" source "$SCRIPTDIR/util/pkgcmd.sh" source "$SCRIPTDIR/util/misc.sh" source "$SCRIPTDIR/util/override.sh" diff --git a/util/build_package.sh b/util/build_package.sh index f0f8127..252dc7e 100644 --- a/util/build_package.sh +++ b/util/build_package.sh @@ -16,8 +16,6 @@ build_package() { rm -f "$REPODIR/${f}.pkg" done - fetch_package - rm -rf "$SYSROOT" "$PKGBUILDDIR" "$PKGDEPLOYDIR" mkdir -p "$SYSROOT" "$PKGBUILDDIR" "$PKGDEPLOYDIR" @@ -25,6 +23,7 @@ build_package() { pkg install -omD $DEPENDS fi + run_pkg_command "download" run_pkg_command "build" run_pkg_command "deploy" deploy_dev_cleanup diff --git a/util/download.sh b/util/download.sh deleted file mode 100755 index c31b5a9..0000000 --- a/util/download.sh +++ /dev/null @@ -1,28 +0,0 @@ -fetch_package() { - echo "$PKGNAME - download" - - if [ -z "$TARBALL" ]; then - return - fi - - if [ ! -e "$PKGDOWNLOADDIR/$TARBALL" ]; then - curl -o "$PKGDOWNLOADDIR/$TARBALL" --silent --show-error \ - -L "$URL/$TARBALL" - fi - - echo "$SHA256SUM $PKGDOWNLOADDIR/${TARBALL}" | sha256sum -c --quiet "-" - - if [ ! -e "$PKGSRCDIR/$SRCDIR" ]; then - local LOGFILE="$PKGLOGDIR/${PKGNAME}-prepare.log" - - echo "$PKGNAME - unpack" - tar -C "$PKGSRCDIR" -xf "$PKGDOWNLOADDIR/$TARBALL" - - pushd "$PKGSRCDIR/$SRCDIR" > /dev/null - echo "$PKGNAME - prepare" - prepare "$SCRIPTDIR/pkg/$PKGNAME" &>> "$LOGFILE" < /dev/null - popd > /dev/null - - gzip -f "$LOGFILE" - fi -} diff --git a/util/emptypkg.sh b/util/emptypkg.sh index 25ce6a5..0ed3f7a 100644 --- a/util/emptypkg.sh +++ b/util/emptypkg.sh @@ -14,6 +14,39 @@ pkg_scan_dir() { find -H "$1" -type f -printf "file \"%p\" 0%m 0 0\\n" } +fetch_package() { + echo "$PKGNAME - download" + + if [ -z "$TARBALL" ]; then + return + fi + + if [ ! -e "$PKGDOWNLOADDIR/$TARBALL" ]; then + curl -o "$PKGDOWNLOADDIR/$TARBALL" --silent --show-error \ + -L "$URL/$TARBALL" + fi + + echo "$SHA256SUM $PKGDOWNLOADDIR/${TARBALL}" | sha256sum -c --quiet "-" + + if [ ! -e "$PKGSRCDIR/$SRCDIR" ]; then + local LOGFILE="$PKGLOGDIR/${PKGNAME}-prepare.log" + + echo "$PKGNAME - unpack" + tar -C "$PKGSRCDIR" -xf "$PKGDOWNLOADDIR/$TARBALL" + + pushd "$PKGSRCDIR/$SRCDIR" > /dev/null + echo "$PKGNAME - prepare" + prepare "$SCRIPTDIR/pkg/$PKGNAME" &>> "$LOGFILE" < /dev/null + popd > /dev/null + + gzip -f "$LOGFILE" + fi +} + +download() { + fetch_package +} + prepare() { apply_patches } diff --git a/util/pkgcmd.sh b/util/pkgcmd.sh index cd21340..bfb053d 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 prepare check_update + unset -f build deploy download prepare check_update unset -v VERSION TARBALL URL SRCDIR SHA256SUM DEPENDS SUBPKG source "$SCRIPTDIR/util/emptypkg.sh" source "$SCRIPTDIR/pkg/$PKGNAME/build"