summaryrefslogtreecommitdiff
path: root/install-header.sh
diff options
context:
space:
mode:
Diffstat (limited to 'install-header.sh')
-rwxr-xr-xinstall-header.sh25
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 ${@}

Generated by cgit