diff options
author | Aaron Ball <nullspoon@oper.io> | 2017-06-23 10:57:36 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2017-06-23 10:57:36 -0600 |
commit | a268ade6a60ab9912849f63b115c523f3f168626 (patch) | |
tree | eba82bfb5e140879e4fb1c21ff77a810e67d4273 | |
parent | 3b1cef0bbb1fb8ae4c97bc38f6878e2b7f5316a0 (diff) | |
parent | bbbf011bad8b227c74d95ff332c3616f2e6a8d4f (diff) | |
download | portimg-a268ade6a60ab9912849f63b115c523f3f168626.tar.gz portimg-a268ade6a60ab9912849f63b115c523f3f168626.tar.xz |
Merge branch 'pkgmk-cleanup'
-rwxr-xr-x | bin/pkgimg.sh | 39 | ||||
-rw-r--r-- | lib/pkg.sh | 32 |
2 files changed, 42 insertions, 29 deletions
diff --git a/bin/pkgimg.sh b/bin/pkgimg.sh index 25afe11..462c0e1 100755 --- a/bin/pkgimg.sh +++ b/bin/pkgimg.sh @@ -32,48 +32,53 @@ export KEEP_BUILD=${KEEP_BUILD:-0} function main { local manifest=${1:-} - local installbase='' + local _installbase # Path to the temporary image working directory + local _porttmp # Path to the temporary package working directory - if [[ -z ${manifest} ]]; then - lerror "Please provide a port manifest." + if [[ -z "${manifest}" ]]; then + lerror "Please specify a port manifest." return 1 fi + if [[ ! -f "${manifest}" ]]; then + lerror "Path '${manifest}' does not exist or is not a manifest" + return 2 + fi # Convert portsdir to absolute path PORTSDIR="$(cd ${PORTSDIR} && pwd)" - installbase=$(mktemp -d /tmp/pkgimg-install.XXXX) + _installbase=$(mktemp -d /tmp/pkgimg-install.XXXX) # Loop over each port in the manifest for port in $(grep -v '^#' ${manifest} | grep -v '^[ ]*$'); do # Call pkgmk to build the port - pkgmk ${port} + pkgmk ${port} '_porttmp' [ $? -gt 0 ] && return 1 # Move the package contents to the install base - linfo "Synchronizing ${port} build to install base ${installbase}" - rsync -a ${PORTTMP}/pkg/ ${installbase}/ + linfo "Synchronizing ${port} build to install base ${_installbase}" + rsync -a ${_porttmp}/pkg/ ${_installbase}/ # Cleanup if [ "${KEEP_BUILD}" = 0 ]; then - rm -rf ${PORTTMP} + rm -rf ${_porttmp} else linfo "KEEP_BUILD is set. Skipping cleanup of ${port}." fi done - linfo "Generating footprint file for ${installbase}" - footprint_dir ${installbase} > ${installbase}.footprint + linfo "Generating footprint file for ${_installbase}" + footprint_dir ${_installbase} > ${_installbase}.footprint - linfo "Creating deployment tarball from ${installbase}" - tar -cf ${installbase}.tar -C ${installbase} ./* + linfo "Creating deployment tarball from ${_installbase}" + tar -cf ${_installbase}.tar -C ${_installbase} ./* - linfo "Compressing ${installbase}.tar" - xz -v ${installbase}.tar + linfo "Compressing ${_installbase}.tar" + xz -v ${_installbase}.tar - linfo "Fakeroot filesystem: ${installbase}" - linfo "Deployment tarball: ${installbase}.tar.xz" - linfo "Tarball footprint: ${installbase}.footprint" + linfo "Fakeroot filesystem: ${_installbase}" + linfo "Deployment tarball: ${_installbase}.tar.xz" + linfo "Tarball footprint: ${_installbase}.footprint" } main ${@} @@ -53,37 +53,45 @@ function pkg_download_src { # TODO: Describe this # function pkgmk { - local port=${1:-} + local _port=${1:-} + local _ref_porttmp=${2:-} - local PKG='' # Path to the port pkg dir (binary install dest) - local PKGSRC='' # Path to the port src dir + local _retval # Return value variable + local _tmpdir # Temporary working directory to build the pkg + # NOTE: These are "global", so the Pkgfile can access them + local PKG # Path to the port pkg dir (binary install dest) + local PKGSRC # Path to the port src dir # Change context to port dir - cd ${PORTSDIR}/${port} + cd ${PORTSDIR}/${_port} # Include the port Pkgfile source Pkgfile # Create the port build and install directory structure - PORTTMP=$(mktemp -d /tmp/pkgmk-${port}.XXXX) - PKGSRC=${PORTTMP}/src - PKG=${PORTTMP}/pkg + _tmpdir=$(mktemp -d /tmp/pkgmk-${_port}.XXXX) + PKGSRC=${_tmpdir}/src + PKG=${_tmpdir}/pkg mkdir -p {${PKGSRC},${PKG}} # Download the package source files - pkg_download_src "${PORTSDIR}/${port}" "${PKGSRC}" "${source[@]}" + pkg_download_src "${PORTSDIR}/${_port}" "${PKGSRC}" "${source[@]}" cd ${PKGSRC} # Call the build process if defined if [[ $(type -t pkgbuild) == 'function' ]]; then - linfo "Running ${port} build process" + linfo "Running ${_port} build process" pkgbuild - return $? + _retval=$? + + # Set the pkg temp dir (this is our return value) + eval "${_ref_porttmp}=${_tmpdir}" + return ${_retval} else - lerror "Port ${port} has no pkgbuild function. Aborting." + lerror "Port ${_port} has no pkgbuild function. Aborting." return 1 fi - return 0 + return 1 } |