summaryrefslogtreecommitdiff
path: root/lib/pkg.sh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pkg.sh')
-rw-r--r--lib/pkg.sh71
1 files changed, 30 insertions, 41 deletions
diff --git a/lib/pkg.sh b/lib/pkg.sh
index cc11ee0..680ccb6 100644
--- a/lib/pkg.sh
+++ b/lib/pkg.sh
@@ -24,27 +24,32 @@ source ${LIBDIR}/port.sh # Basic port functions
export PORTSDIR=${PORTSDIR:-/usr/ports} # Path to port store
export PORTTMP='' # Path to the port temp dir
-function pkg_download_src {
- local _port=${1:-}
- local _pkgsrc=${2:-}
- shift && shift
- local _src=${@}
+#
+# @param _port_path Path to the port Pkgfile directory
+# @param _port_src_path Path to the port's working src directory for building
+# @param _src Ref to the source array for the given package
+#
+function pkg_setup_src {
+ local _port_path=${1:-}
+ local _port_src_path=${2:-}
+ local _ref_src=${3:-}
+
+ local _file_path
# Download from Pkgfile src spec
for file in ${_src[@]}; do
- if [[ -f ${file} ]]; then
- # If the source file exists locally, just copy from here
- cp -p ${file} ${_pkgsrc}
- else
- if [ -f $(basename ${file}) ]; then
- linfo "Source '${file}' already downloaded"
- else
- linfo "Downloading ${file}"
- download_src ${file} ${_port}
- fi
- linfo "Extracting $(basename ${file}) to ${_pkgsrc}"
- archive_extract ${_port}/$(basename ${file}) ${_pkgsrc}
+ if [ -f "${_port_path}/${file}" ]; then
+ # The referenced source file is a local path, so use that verbatim
+ _file_path="${_port_path}/${file}"
+ elif [ -f "${_port_path}/$(basename ${file})" ]; then
+ # The verbatim referenced source file path does not exist locally, so it
+ # is probably a uri. Get the basename of the path, and try to extract
+ # that.
+ _file_path="${_port_path}/$(basename ${file})"
fi
+ # Extract any local files to the pkg src path
+ linfo "Extracting $(basename ${file}) to ${_port_src_path}"
+ archive_extract "${_file_path}" "${_port_src_path}"
done
}
@@ -53,44 +58,28 @@ function pkg_download_src {
# TODO: Describe this
#
function pkgmk {
- local _port=${1:-}
- local _ref_porttmp=${2:-}
+ local _name=${1:-}
+ local _ref_source=${2:-}
+ local _porttmp=${3:-}
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}
-
- # Include the port Pkgfile
- source Pkgfile
# Create the port build and install directory structure
- _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[@]}"
+ PKGSRC=${_porttmp}/src
+ PKG=${_porttmp}/pkg
cd ${PKGSRC}
# Call the build process if defined
if [[ $(type -t pkgbuild) == 'function' ]]; then
- linfo "Running ${_port} build process"
+ linfo "Running ${_name} build process"
pkgbuild
- _retval=$?
-
- # Set the pkg temp dir (this is our return value)
- eval "${_ref_porttmp}=${_tmpdir}"
- return ${_retval}
+ return $?
else
- lerror "Port ${_port} has no pkgbuild function. Aborting."
- return 1
+ lerror "Port ${_name} has no pkgbuild function. Aborting."
fi
return 1

Generated by cgit