From ee8fb4208642e6085cef8089fc175d645029d796 Mon Sep 17 00:00:00 2001 From: Aaron Ball Date: Mon, 26 Jun 2017 19:45:17 -0600 Subject: pkgmk.sh:Added complete support Previously, pkgmk.sh was committed in an incomplete state. This adds complete support for current project capabilities. Not pkgmk can read a Pkgfile, build it in a working directory, and convert the built product into a package file, saving the binary package to the port directory. It also now cleans up after itself, provided the KEEP_BUILD variable is set to 0. --- bin/pkgmk.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/bin/pkgmk.sh b/bin/pkgmk.sh index 8b88e0d..e0f3d4f 100755 --- a/bin/pkgmk.sh +++ b/bin/pkgmk.sh @@ -24,13 +24,58 @@ export LIBDIR="${BASEDIR}/lib" source ${LIBDIR}/log.sh source ${LIBDIR}/template.sh source ${LIBDIR}/port.sh +source ${LIBDIR}/pkg.sh +source ${LIBDIR}/common.sh export PORTSDIR=${PORTSDIR:-${BASEDIR}/ports} +export KEEP_BUILD=${KEEP_BUILD:-0} function main { - local port=${1:-} - [[ -z ${port} ]] && lerror "A port name is required." && return 1 + local _pkg=${1:-} + [[ -z ${_pkg} ]] && lerror "A port name is required." && return 1 + local _porttmp # Path to the port build working directory + local _pkgfile # Path to the port's Pkgfile + + _pkgfile="${PORTSDIR}/${_pkg}/Pkgfile" + + if [ ! -f ${_pkgfile} ]; then + lerror "Could not find Pkgfile at ${_pkgfile}." + return 1 + fi + + source ${_pkgfile} + + # Set all these variables as the same variables will be set later by port + # files + _pkgname=${name} && unset 'name' + _pkgdepends=("${depends[@]}") && unset 'depends[@]' + _pkgversion=${version} && unset 'version' + _pkgrelease=${release} && unset 'release' + _pkgbuildname="${_pkgname}#${_pkgversion}_${_pkgrelease}" + + pkgmk ${_pkg} '_porttmp' + [ $? -gt 0 ] && return 1 + + linfo "Generating footprint file for ${_pkg}" + footprint_dir ${_porttmp}/pkg > ${_porttmp}/pkg.footprint + + # linfo "Creating deployment tarball from ${_installbase}" + tar -cf ${_porttmp}/pkg.tar -C ${_porttmp}/pkg . + + # linfo "Compressing ${_installbase}.tar" + xz -v ${_porttmp}/pkg.tar + + # # Move the package and footprint to current directory + mv ${_porttmp}/pkg.tar.xz ${PORTSDIR}/${_pkg}/${_pkgbuildname}.tar.xz + mv ${_porttmp}/pkg.footprint ${PORTSDIR}/${_pkg}/${_pkgbuildname}.footprint + + # Cleanup if allowed + if [ "${KEEP_BUILD}" = 0 ]; then + rm -rf ${_porttmp} + else + linfo "KEEP_BUILD is set. Skipping cleanup of ${port}." + fi } main ${@} -- cgit v1.2.3