From 95bdef1d645b3032372c9519ec3e7c0b3df94922 Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sun, 8 Apr 2012 21:47:40 -0500 Subject: [PATCH] script/gentree: add script support to gentree --- script/gentree | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/script/gentree b/script/gentree index bb5938c..a5338fd 100755 --- a/script/gentree +++ b/script/gentree @@ -7,7 +7,7 @@ _root="$(dirname "${0}")" # Load needed modules want root ansi log ask -targets="prepwork admin overlay packages patch whiteout prepboot preptmp prepetc imgboot imgconf imgetc imgall custom" +targets="prepwork admin overlay packages patch whiteout scripts prepboot preptmp prepetc imgboot imgconf imgetc imgall custom" pebkac() { [ "${*}" ] && printf "${*}\n\n" @@ -23,6 +23,7 @@ pebkac() { echo ' -i pkgsdir Directory holding packages to install (${target}/pkg)' echo ' -p patchdir Directory holding patches to apply (${target}/config/patch)' echo ' -w whiteout Listfile of paths to remove (${target}/config/whiteout.lst)' + echo ' -s scriptdir Directory holding scripts to apply (${target}/config/script)' echo ' -d confdir Conf md_size files and old cpios (${target}/config/conf)' echo ' -l logfile File to hold stderr spam (${stage}/gentree.log' echo ' -h Hello! >^-^<' @@ -35,7 +36,7 @@ pebkac() { exit 1 } -while getopts "a:c:b:t:r:o:i:p:w:l:h" opt +while getopts "a:c:b:t:r:o:i:p:w:s:l:h" opt do case "${opt}" in a) arch="${OPTARG}" ;; @@ -47,6 +48,7 @@ do i) pkgs="${OPTARG}" ;; p) ptch="${OPTARG}" ;; w) rmrf="${OPTARG}" ;; + s) scpt="${OPTARG}" ;; d) cnfd="${OPTARG}" ;; l) logf="${OPTARG}" ;; h) pebkac ;; @@ -71,6 +73,7 @@ ovly="${ovly:-${target}/config/overlay}" pkgs="${pkgs:-${target}/pkg}" ptch="${ptch:-${target}/config/patch}" rmrf="${rmrf:-${target}/config/whiteout.lst}" +scpt="${scpt:-${target}/config/script}" cnfd="${cnfd:-${target}/config/conf}" logf="${logf:-${tree}/gentree.log}" @@ -200,6 +203,21 @@ do_whiteout() { done } +# Run arbitrary user scripts to perform additional functions prior to carving and packaging +# Warning! These run as root and no chroot is performed! BE CAREFUL HERE! +do_scripts() { + [ -d "${scpt}" ] && ls -1 "${scpt}" | grep -q '.' || return + log Run user scripts from "${scpt##${base}/}" + ls -1 "${scpt}" | LANG=C sort | while read file + do + [ -f "${scpt}/${file}" ] || continue + log "... ${file}" + ( cd "${sroot}" + . "${scpt}/${file}" + ) || chk + done +} + do_prepboot() { log Prepare /boot chk mv "${sroot}/boot/boot" "${sroot}/boot/boot.blk" -- 2.42.0