1
0
Fork 0
mirror of https://github.com/pygos/build.git synced 2024-11-25 04:20:41 +01:00

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 <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2020-04-12 03:25:37 +02:00
parent a646707dc0
commit 2dc8bd9cd6
5 changed files with 35 additions and 32 deletions

1
mk.sh
View file

@ -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"

View file

@ -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

View file

@ -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
}

View file

@ -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
}

View file

@ -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"