diff options
author | Aaron Ball <nullspoon@oper.io> | 2017-06-26 19:46:35 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2017-06-26 19:46:35 -0600 |
commit | f7c43650c0942ee69851213e6e8dc296da23585e (patch) | |
tree | e349c12d51cdf93d1c226d7544dcfe684b890762 | |
parent | b26135c8f99cf6afacc204294a531399b968ea85 (diff) | |
parent | ee8fb4208642e6085cef8089fc175d645029d796 (diff) | |
download | portimg-f7c43650c0942ee69851213e6e8dc296da23585e.tar.gz portimg-f7c43650c0942ee69851213e6e8dc296da23585e.tar.xz |
Merge branch 'improve-pkgmk'
-rwxr-xr-x | bin/pkgmk.sh | 49 |
1 files 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 ${@} |