Skip to content

Commit

Permalink
build.sh without temp files
Browse files Browse the repository at this point in the history
  • Loading branch information
doZennn committed May 16, 2024
1 parent 18ffe74 commit 98928ce
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 30 deletions.
31 changes: 31 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
set -e

cd "$(dirname "$0")"

INPUT=$1
INNOBIN=$2

SCRIPT=$(cat "$INPUT")

# Add licences to header
HASHEDLIC=$(sed 's/^/# /' < LICENSE)
INNOLIC='###
# This script uses a fork of "innoextract" licensed under the zlib/libpng license.
#
# Original innoextract (c) Daniel Scharrer <daniel@constexpr.org> https://constexpr.org/innoextract/
# Fork by Jozen Blue Martinez for ZOOM Platform https://github.com/doZennn/innoextract
###'
SCRIPT=$(printf "%s" "$SCRIPT" | awk -v r="###\n$HASHEDLIC\n###\n\n$INNOLIC" '{gsub(/#__LICENSE_HERE__/,r)}1')

# set version to either release tag or commit hash
VERSION=$(git tag --points-at HEAD)
[ -z "$VERSION" ] && VERSION="git-$(git rev-parse --short=7 HEAD)"
SCRIPT=$(printf "%s" "$SCRIPT" | sed "s/INSTALLER_VERSION=\"DEV\"/INSTALLER_VERSION=\"$VERSION\"/")

# Add innoextract binary between comments
START=$(printf "%s" "$SCRIPT" | sed -n '1,/^#__INNOEXTRACT_BINARY_START__/p')
# shellcheck disable=SC2016
END=$(printf "%s" "$SCRIPT" | sed -n '/^#__INNOEXTRACT_BINARY_END__$/,${p;}')
INNOB64=$(base64 -w 0 "$INNOBIN")
printf '%s\nINNOEXTRACT_BINARY_B64=%s\n%s' "$START" "$INNOB64" "$END"
31 changes: 2 additions & 29 deletions dist.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,9 @@
#!/bin/sh

set -e

cd "$(dirname "$0")"
FINAL_FILE="zoom-platform.sh"

cp "src.sh" "$FINAL_FILE"

# Add licences to header
HASHEDLIC=$(sed 's/^/# /' < LICENSE)
INNOLIC='###
# This script uses a fork of "innoextract" licensed under the zlib/libpng license.
#
# Original innoextract (c) Daniel Scharrer <daniel@constexpr.org> https://constexpr.org/innoextract/
#
# Fork by Jozen Blue Martinez for ZOOM Platform https://github.com/doZennn/innoextract
###'

awk -i inplace -v r="###\n$HASHEDLIC\n###\n\n$INNOLIC" '{gsub(/#__LICENSE_HERE__/,r)}1' "$FINAL_FILE"

# set version to either release tag or commit hash
VERSION=$(git tag --points-at HEAD)
if [ -z "$VERSION" ]; then VERSION="git-$(git rev-parse --short HEAD)"; fi
sed -i "s/INSTALLER_VERSION=\"DEV\"/INSTALLER_VERSION=\"$VERSION\"/" "$FINAL_FILE"

# Download innoextract binaries
rm -f innoextract.tar.gz innoextract-upx.tar.gz
INNOEXT_URLS=$(curl -s "https://api.github.com/repos/doZennn/innoextract/releases/latest" | grep '"browser_download_url":.*innoextract.*.tar.gz' | sed -E 's/.*"([^"]+)".*/\1/')
Expand All @@ -31,12 +12,4 @@ echo "$INNOEXT_URLS" | wget -nv -i -
# Extract binaries
tar -xzf innoextract-upx.tar.gz

# Add innoextract binary between comments
START="$(sed -n '1,/^#__INNOEXTRACT_BINARY_START__/p' "$FINAL_FILE")"
# shellcheck disable=SC2016
END="$(sed -n '/^#__INNOEXTRACT_BINARY_END__$/,${p;}' "$FINAL_FILE")"
printf '%s\nINNOEXTRACT_BINARY_B64=' "$START" > "$FINAL_FILE"
base64 -w 0 innoextract-upx >> "$FINAL_FILE"
printf '\n%s' "$END" >> "$FINAL_FILE"

chmod +x "$FINAL_FILE"
./build.sh "src.sh" "innoextract-upx" > "$FINAL_FILE"
2 changes: 1 addition & 1 deletion src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dialog_installer_select() {
zenity --file-selection --title="Select a ZOOM Platform installer"
return $?
else
kdialog --getopenfilename . "ZOOM Platform Windows installer (*.exe)" --title "Select a ZOOM Platform installer"
kdialog --getopenfilename . "ZOOM Platform Windows installer(*.exe)" --title "Select a ZOOM Platform installer"
return $?
fi
}
Expand Down

0 comments on commit 98928ce

Please sign in to comment.