summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@oper.io>2018-02-14 11:26:22 -0700
committerAaron Ball <nullspoon@oper.io>2018-02-14 11:26:22 -0700
commite2eefee7a83b19b6012ff9b093e71d93f66cf3f2 (patch)
tree129e0c1e610440ed0691ceb3d4d6e61274e8a0a9
parent59173296aba560377f55dcc0527f2ddbb6c8d2ac (diff)
downloadpkgself-e2eefee7a83b19b6012ff9b093e71d93f66cf3f2.tar.gz
pkgself-e2eefee7a83b19b6012ff9b093e71d93f66cf3f2.tar.xz
Added compress and decompress variables
Install header now has a {{ DECOMPRESS }} variable that is interpolated on run of pkgself with pkgself's value for ${DECOMPRESS}. Also added DECOMPRESS, COMPRESS, and COMPRESSEXT variables to pkgself to standardize compression tools and command calls across the script. This will also make it easier to make compress tools selectable in the future (eg: --gzip or --bzip2 will set the variables differently). Moved install header size calculation after all interpolations with a note that all interpolations need to occur before that line so the size counts are accurate.
-rwxr-xr-xinstall-header.sh17
-rwxr-xr-xpkgself.sh32
2 files changed, 29 insertions, 20 deletions
diff --git a/install-header.sh b/install-header.sh
index b54a0ec..1d36f2a 100755
--- a/install-header.sh
+++ b/install-header.sh
@@ -4,12 +4,11 @@
# DO NOT CHANGE THIS without great care - it will break header length
# calculations
LENS=( )
-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
-export COMPRESS # Command to compress data
-export DECOMPRESS # Command to decompress data
+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
+export DECOMPRESS='{{ DECOMPRESS }}' # Command to decompress data
# Header: 0
# runscript: 1
@@ -36,15 +35,15 @@ extract_header() {
}
extract_libinstall() {
- extract_chunk_index "${SELF}" '-' 1 | xz -d -c | tar -C "${TMP}" -x
+ extract_chunk_index "${SELF}" '-' 1 | ${DECOMPRESS} | tar -C "${TMP}" -x
}
extract_runscript() {
- extract_chunk_index "${SELF}" '-' 2 | xz -d -c > "${TMP}/run.sh"
+ extract_chunk_index "${SELF}" '-' 2 | ${DECOMPRESS} > "${TMP}/run.sh"
}
extract_payload() {
- extract_chunk_index "${SELF}" '-' 3 | xz -d -c | tar -C "${TMP}" -x
+ extract_chunk_index "${SELF}" '-' 3 | ${DECOMPRESS} | tar -C "${TMP}" -x
export PAYLOAD="${TMP}/pkg"
}
diff --git a/pkgself.sh b/pkgself.sh
index 6e75b33..6811dbf 100755
--- a/pkgself.sh
+++ b/pkgself.sh
@@ -17,6 +17,10 @@
set -e
+export COMPRESS='xz -z -c -T 0' # Command to compress data
+export DECOMPRESS='xz -d -c' # Command to decompress data
+export COMPRESSEXT='xz' # File extension for compressed data
+
download_src() {
local file
@@ -126,20 +130,26 @@ main() {
printf "Reticulating splines...\n"
- headsize=$(wc -c < ${output})
-
# Package up the libinstall libraries
- tar -C "${tmp}" -c libinstall | xz -c > ${tmp}/libinstall.tar.xz
- libinstallsize=$(wc -c < ${tmp}/libinstall.tar.xz)
+ tar -C "${tmp}" -c libinstall \
+ | ${COMPRESS} > ${tmp}/libinstall.tar.${COMPRESSEXT}
+ libinstallsize=$(wc -c < ${tmp}/libinstall.tar.${COMPRESSEXT})
# Compress and calculate byte size for run.sh
- xz -c ${PKGSRC}/run.sh > ${tmp}/run.sh.xz
- runsize="$(wc -c < ${tmp}/run.sh.xz)"
+ ${COMPRESS} ${PKGSRC}/run.sh > ${tmp}/run.sh.${COMPRESSEXT}
+ runsize="$(wc -c < ${tmp}/run.sh.${COMPRESSEXT})"
# Compress and calculate byte size for payload
- tar -c "$(basename ${PKG})" | xz -v > ${PKG}.tar.xz
- payloadsize="$(wc -c < ${PKG}.tar.xz)"
+ tar -c "$(basename ${PKG})" \
+ | ${COMPRESS} -v > ${PKG}.tar.${COMPRESSEXT}
+ payloadsize="$(wc -c < ${PKG}.tar.${COMPRESSEXT})"
+ # Replace compress and decompress command variables
+ sed -i "s/{{ DECOMPRESS }}/${DECOMPRESS}/g" "${output}"
+
+ # NOTE: All variable interpolations in the header MUST occur before this line.
+ # This solely exclides the 'lens' array interpolation
+ headsize=$(wc -c < ${output})
# Print space padded values to meet expected character length.
# Expected length: 8 + 8 + 12 + 2 == 30
@@ -154,9 +164,9 @@ main() {
sed -i "s/LENS=(.*)/LENS=(${lens})/g" "${output}"
# Append chunks to output file
- cat "${tmp}/libinstall.tar.xz" >> "${output}"
- cat "${tmp}/run.sh.xz" >> "${output}"
- cat "${PKG}.tar.xz" >> "${output}"
+ cat "${tmp}/libinstall.tar.${COMPRESSEXT}" >> "${output}"
+ cat "${tmp}/run.sh.${COMPRESSEXT}" >> "${output}"
+ cat "${PKG}.tar.${COMPRESSEXT}" >> "${output}"
# Cleanup
rm -rf ${tmp}

Generated by cgit