summaryrefslogtreecommitdiff
path: root/bin/pkgmk.sh
diff options
context:
space:
mode:
Diffstat (limited to 'bin/pkgmk.sh')
-rwxr-xr-xbin/pkgmk.sh63
1 files changed, 42 insertions, 21 deletions
diff --git a/bin/pkgmk.sh b/bin/pkgmk.sh
index e0f3d4f..3e7e091 100755
--- a/bin/pkgmk.sh
+++ b/bin/pkgmk.sh
@@ -31,33 +31,54 @@ export PORTSDIR=${PORTSDIR:-${BASEDIR}/ports}
export KEEP_BUILD=${KEEP_BUILD:-0}
function main {
- 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}."
+ local _porttmp # Path to the port build working directory
+ local _portdir # Path to the port dir that contains the Pkgfile
+
+ local _pkgname # Pkgfile value for 'name'
+ local _pkgsource # Pkgfile value for 'source'
+ local _pkgversion # Pkgfile value for 'version'
+ local _pkgrelease # Pkgfile value for 'release'
+ local _pkgbuildname # Pkgfile composite of name, version, and release
+ local _porttmp # Temporary working directory to build the pkg
+
+ if [ ! -f Pkgfile ]; then
+ lerror "Could not find Pkgfile."
return 1
fi
- source ${_pkgfile}
+ _portdir="$(pwd)"
- # 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'
+ # Include the port Pkgfile
+ source Pkgfile
+
+ # Set all these variables to local versions, to avoid possible overrides,
+ # conflicts, etc. when these are used later on.
+ _pkgname=${name}
+ _pkgsource=("${source[@]}")
+ _pkgversion=${version}
+ _pkgrelease=${release}
_pkgbuildname="${_pkgname}#${_pkgversion}_${_pkgrelease}"
- pkgmk ${_pkg} '_porttmp'
+
+ for _src in ${_pkgsource[@]}; do
+ # Download the package source files
+ port_download_src "_pkgsource[@]"
+ done
+
+
+ # Create the temporary build and packaging location
+ _porttmp=$(mktemp -d /tmp/pkgmk-${_pkgname}.XXXX)
+ mkdir -p ${_porttmp}/{pkg,src}
+
+ # Copy the sources into the build and packaging location
+ for _src in ${_pkgsource[@]}; do
+ pkg_setup_src "./" "${_porttmp}/src" "_pkgsource[@]"
+ done
+
+ pkgmk ${_pkgname} '_pkgsource[@]' "${_porttmp}"
[ $? -gt 0 ] && return 1
- linfo "Generating footprint file for ${_pkg}"
+ linfo "Generating footprint file for ${_pkgname}"
footprint_dir ${_porttmp}/pkg > ${_porttmp}/pkg.footprint
# linfo "Creating deployment tarball from ${_installbase}"
@@ -67,8 +88,8 @@ function main {
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
+ mv -v ${_porttmp}/pkg.tar.xz ${_portdir}/${_pkgbuildname}.tar.xz
+ mv -v ${_porttmp}/pkg.footprint ${_portdir}/${_pkgbuildname}.footprint
# Cleanup if allowed
if [ "${KEEP_BUILD}" = 0 ]; then

Generated by cgit