summaryrefslogtreecommitdiff
path: root/install-header.sh
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2018-02-05 08:50:27 -0700
committerAaron Ball <nullspoon@oper.io>2018-02-05 08:56:11 -0700
commit0021b9976350a078e3efed10fc36031ac8f73d95 (patch)
treeeb60452a9966e988a29161170e30f259bc4bffdf /install-header.sh
downloadpkgself-0021b9976350a078e3efed10fc36031ac8f73d95.tar.gz
pkgself-0021b9976350a078e3efed10fc36031ac8f73d95.tar.xz
Initial commit
Currently packages binary, creates payload index, etc. Installer executes specified run script and cleans itself up after run. NOTE: installer-header.sh is not released under any license at this time, as it is packaged with other people's code. Pkgself.sh is however GPLv3.
Diffstat (limited to 'install-header.sh')
-rwxr-xr-xinstall-header.sh67
1 files changed, 67 insertions, 0 deletions
diff --git a/install-header.sh b/install-header.sh
new file mode 100755
index 0000000..210691d
--- /dev/null
+++ b/install-header.sh
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+
+# This is a pre-allocated string of 30 chars of whitespace
+# DO NOT CHANGE THIS without great care - it will break header length
+# calculations
+LENS=( )
+export SELF
+export TMP
+
+# Header: 0
+# runscript: 1
+# payload: 2
+extract_chunk_index() {
+ local script="${1}"
+ local dest="${2}"
+ local index="${3}"
+ local skip=0
+
+ for (( i = 0; i < index; i++ )); do
+ skip=$(( skip + LENS[$i] ))
+ done
+
+ # Extract the requested chunk index
+ dd bs=1 count=${LENS[$index]} iflag=skip_bytes skip=${skip} \
+ if=${script} of=${dest} 2>/dev/null
+}
+
+extract_header() {
+ extract_chunk_index "${SELF}" "${TMP}/header.sh" 0
+}
+
+extract_runscript() {
+ extract_chunk_index "${SELF}" "${TMP}/run.sh.xz" 1
+ xz -d "${TMP}/run.sh.xz"
+}
+
+extract_payload() {
+ extract_chunk_index "${SELF}" "${TMP}/payload.tar.xz" 2
+ tar -C "${TMP}" -x -f payload.tar.xz
+}
+
+
+main() {
+ SELF="$(cd $(dirname ${0}) && pwd)/$(basename ${0})"
+ TMP="$(mktemp -d /tmp/installer-XXXXXXX)"
+
+ extract_header
+ extract_runscript
+ #extract_chunks "${self}" "${tmp}"
+
+ cd "${TMP}"
+ source run.sh
+
+ # Function 'deploy' is provided by run.sh
+ if [ "$(type -t deploy)" == 'function' ]; then
+ deploy
+ else
+ printf "ERROR: Deploy function not found.\n"
+ fi
+
+ # Cleanup
+ rm -rf "${TMP}"
+}
+
+main ${@}
+exit 0
+

Generated by cgit