summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/pkgmk.sh49
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 ${@}

Generated by cgit