diff options
author | Aaron Ball <nullspoon@oper.io> | 2018-02-14 11:26:22 -0700 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2018-02-14 11:26:22 -0700 |
commit | e2eefee7a83b19b6012ff9b093e71d93f66cf3f2 (patch) | |
tree | 129e0c1e610440ed0691ceb3d4d6e61274e8a0a9 /pkgself.sh | |
parent | 59173296aba560377f55dcc0527f2ddbb6c8d2ac (diff) | |
download | pkgself-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.
Diffstat (limited to 'pkgself.sh')
-rwxr-xr-x | pkgself.sh | 32 |
1 files changed, 21 insertions, 11 deletions
@@ -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} |