summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2017-06-26 19:23:43 -0600
committerAaron Ball <nullspoon@oper.io>2017-06-26 19:23:43 -0600
commitb26135c8f99cf6afacc204294a531399b968ea85 (patch)
treecc7a0ed402bdf99534fac8956bb7575935d9d5b2
parentf9645ec8dfd2cc11df9b2588eb4b50c6041d6c13 (diff)
parent595093e51de1ae78b8a6f0454f9f5bdc8d03a5df (diff)
downloadportimg-b26135c8f99cf6afacc204294a531399b968ea85.tar.gz
portimg-b26135c8f99cf6afacc204294a531399b968ea85.tar.xz
Merge branch 'impl-pkgadd'
-rwxr-xr-xbin/pkgadd.sh39
-rw-r--r--lib/pkg.sh40
2 files changed, 79 insertions, 0 deletions
diff --git a/bin/pkgadd.sh b/bin/pkgadd.sh
new file mode 100755
index 0000000..a5622a9
--- /dev/null
+++ b/bin/pkgadd.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+#
+# Portimg uses Crux port-like system for creating software deployment images.
+# Copyright (C) 2016 Aaron Ball <nullspoon@oper.io>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+set -eu
+
+export BASEDIR="$(cd $(dirname ${0})/../ && pwd)"
+export LIBDIR="${BASEDIR}/lib"
+
+source ${LIBDIR}/log.sh
+source ${LIBDIR}/pkg.sh
+
+export PORTSDIR=${PORTSDIR:-${BASEDIR}/ports}
+
+function main {
+ local _pkg=${1:-}
+ local _dest=${2:-}
+
+ [ -z "${_pkg}" ] && lerror "A port name is required." && return 1
+ [ -z "${_dest}" ] && lerror "An install destination is required." && return 1
+
+ pkgadd "${_pkg}" "${_dest}"
+}
+
+main ${@}
diff --git a/lib/pkg.sh b/lib/pkg.sh
index aa6063e..cc11ee0 100644
--- a/lib/pkg.sh
+++ b/lib/pkg.sh
@@ -95,3 +95,43 @@ function pkgmk {
return 1
}
+
+
+#
+# Installs the specified port's compiled package to the specified destination.
+#
+# @param _port Name of the port (contained in PORTSDIR) to be installed
+# @param _dest Path to install the port to
+#
+function pkgadd {
+ local _port=${1:-}
+ local _dest=${2:-}
+
+ local _pkgname # Pkgfile value for 'name'
+ local _pkgversion # Pkgfile value for 'version'
+ local _pkgrelease # Pkgfile value for 'release'
+ local _pkgbuildname # Pkgfile composite of name, version, and release
+
+ # Ensure Pkgfile exists (we can't assemble the package filename without this)
+ if [ ! -f ${PORTSDIR}/${_port}/Pkgfile ]; then
+ lerror "Could not find Pkgfile for port ${_port}"
+ return 1
+ fi
+
+ # Import the Pkgfile values
+ source ${PORTSDIR}/${_port}/Pkgfile
+ _pkgname=${name} && unset 'name'
+ _pkgversion=${version} && unset 'version'
+ _pkgrelease=${release} && unset 'release'
+ _pkgbuildname="${_pkgname}#${_pkgversion}_${_pkgrelease}"
+
+ # Ensure the built package exists
+ if [ ! -f "${PORTSDIR}/${_port}/${_pkgbuildname}.tar.xz" ]; then
+ lerror "Could not find compiled package for ${_port}"
+ return 1
+ fi
+
+ # Extract the package to the destination directory
+ cd ${_dest}
+ tar -xf ${PORTSDIR}/${_port}/${_pkgbuildname}.tar.xz
+}

Generated by cgit