diff options
author | Aaron Ball <nullspoon@oper.io> | 2018-02-05 22:04:42 -0700 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2018-02-05 22:04:42 -0700 |
commit | 71a27af77d1ef238a8a7a54289f739d5511588f9 (patch) | |
tree | a5e87fca440806d6f1a3cc4aa4b783c0cd7ce1e8 | |
parent | 0021b9976350a078e3efed10fc36031ac8f73d95 (diff) | |
download | pkgself-71a27af77d1ef238a8a7a54289f739d5511588f9.tar.gz pkgself-71a27af77d1ef238a8a7a54289f739d5511588f9.tar.xz |
More work on the install header
extract_chunk_index: Added support for stdout extraction via the '-'
destination.
Added support for NOCLEANUP variable. If set, the removal of TMP will
not occur.
Added argument passthrough for install-header arguments to the deploy
function.
Some more comments
Added exports and comments for global variables SELF, TMP, PAYLOAD, and
NOCLEANUP.
Added PAYLOAD variable for the installation package to easily referece
the absolute path to its own install files within the payload archive.
-rwxr-xr-x | install-header.sh | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/install-header.sh b/install-header.sh index 210691d..766ba0a 100755 --- a/install-header.sh +++ b/install-header.sh @@ -4,25 +4,29 @@ # DO NOT CHANGE THIS without great care - it will break header length # calculations LENS=( ) -export SELF -export TMP +export SELF # Absolute path to the installer script (me!) +export TMP # Path to tmp install staging directory +export PAYLOAD # Path to the extracted payload directory +export NOCLEANUP # Do not clean up deploy resources. Useful for debugging # Header: 0 # runscript: 1 # payload: 2 extract_chunk_index() { - local script="${1}" + local src="${1}" local dest="${2}" local index="${3}" - local skip=0 + local skip=0 # Byte count to skip into source + local of # Output path with 'of=' prefix. Only used if dest is not '-' for (( i = 0; i < index; i++ )); do skip=$(( skip + LENS[$i] )) done + [ "${dest}" != '-' ] && of="${dest}" # Extract the requested chunk index dd bs=1 count=${LENS[$index]} iflag=skip_bytes skip=${skip} \ - if=${script} of=${dest} 2>/dev/null + if=${src} ${of} 2>/dev/null } extract_header() { @@ -30,13 +34,12 @@ extract_header() { } extract_runscript() { - extract_chunk_index "${SELF}" "${TMP}/run.sh.xz" 1 - xz -d "${TMP}/run.sh.xz" + extract_chunk_index "${SELF}" '-' 1 | xz -d -c > "${TMP}/run.sh" } extract_payload() { - extract_chunk_index "${SELF}" "${TMP}/payload.tar.xz" 2 - tar -C "${TMP}" -x -f payload.tar.xz + extract_chunk_index "${SELF}" '-' 2 | xz -d -c | tar -C "${TMP}" -x + export PAYLOAD="${TMP}/pkg" } @@ -53,13 +56,13 @@ main() { # Function 'deploy' is provided by run.sh if [ "$(type -t deploy)" == 'function' ]; then - deploy + deploy ${@} else printf "ERROR: Deploy function not found.\n" fi # Cleanup - rm -rf "${TMP}" + [ -z "${NOCLEANUP:-}" ] && rm -rf "${TMP}" } main ${@} |