diff options
-rwxr-xr-x | bin/pkgimg.sh | 16 | ||||
-rw-r--r-- | lib/common.sh | 48 |
2 files changed, 61 insertions, 3 deletions
diff --git a/bin/pkgimg.sh b/bin/pkgimg.sh index fdece5a..d5b2718 100755 --- a/bin/pkgimg.sh +++ b/bin/pkgimg.sh @@ -16,7 +16,7 @@ # 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 +set -u export BASEDIR="$(cd $(dirname ${0})/../ && pwd)" export LIBDIR="${BASEDIR}/lib" @@ -24,6 +24,7 @@ export LIBDIR="${BASEDIR}/lib" source ${LIBDIR}/log.sh source ${LIBDIR}/pkg.sh source ${LIBDIR}/config.sh +source ${LIBDIR}/common.sh export PORTSDIR=${PORTSDIR:-${BASEDIR}/ports} @@ -52,9 +53,18 @@ function main { rm -rf ${PORTTMP} done - dump_configs + linfo "Generating footprint file for ${installbase}" + footprint_dir ${installbase} > ${installbase}.footprint - linfo "Fakeroot filesystem available at ${installbase}" + linfo "Creating deployment tarball from ${installbase}" + tar -cf ${installbase}.tar -C ${installbase} ./* + + linfo "Compressing ${installbase}.tar" + xz -v ${installbase}.tar + + linfo "Fakeroot filesystem: ${installbase}" + linfo "Deployment tarball: ${installbase}.tar.xz" + linfo "Tarball footprint: ${installbase}.footprint" } main ${@} diff --git a/lib/common.sh b/lib/common.sh new file mode 100644 index 0000000..edcc8f9 --- /dev/null +++ b/lib/common.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# +# Portimg uses Crux port-like system for creating software deployment images. +# Copyright (C) 2017 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/>. +# + + +# +# Footprints the specified path in the format +# Outputs footprint to stdout. +# +# @path Path to the directory to recursively footprint +# +function footprint_dir { + local path=${1:-} + + if [[ -z ${path} ]]; then + echo "Please specify a directory to checksum." + return 1 + fi + + cd ${path} + + # Generate a file and directory list + local file_list=$(find) + + # Stat each file + for i in ${file_list[@]}; do + # Skip . and .. + [[ ${i} == '.' || ${i} == '..' ]] && continue + + # Get file stats for "permissions owner:group filename" + stat -c '%A %U:%G %n' "${i#*/}" + done +} |