From b5e4f53357db10e63116f8b182653f7211cd8b7e Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 27 Dec 2020 21:19:32 +0100 Subject: [PATCH] factor out inject-json.sh --- dev/inject-json.sh | 34 ++++++++++++++++++++++++++++++++ dev/make-distribution.sh | 21 ++++---------------- dev/make-distribution.sh.exclude | 9 ++++++++- dev/make-standalone.sh | 19 +++++++++++++----- 4 files changed, 60 insertions(+), 23 deletions(-) create mode 100644 dev/inject-json.sh diff --git a/dev/inject-json.sh b/dev/inject-json.sh new file mode 100644 index 0000000..f02a58b --- /dev/null +++ b/dev/inject-json.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +############################################################## +# +# File: inject-json.sh +# +# Description: download and prepare JSON.sh and JSON.awk +# +# Usage: source inject-json.sh +# +#### $$VERSION$$ v1.21-dev-17-g8c9298d +############################################################## + +# download JSON.sh +JSONSHFILE="JSON.sh/JSON.sh" +if [ ! -r "${JSONSHFILE}" ]; then + printf "Inject JSON.sh ... " + mkdir "JSON.sh" 2>/dev/null + curl -sL -o "${JSONSHFILE}" "https://cdn.jsdelivr.net/gh/dominictarr/JSON.sh/JSON.sh" + chmod +x "${JSONSHFILE}" + printf "Done!\n" +fi + +# download JSON.awk +JSONSHFILE="JSON.sh/JSON.awk" +if [ ! -r "${JSONSHFILE}" ]; then + printf "Inject JSON.awk ... " + curl -sL -o "${JSONSHFILE}" "https://cdn.jsdelivr.net/gh/step-/JSON.awk/JSON.awk" + curl -sL -o "${JSONSHFILE%/*}/awk-patch.sh" "https://cdn.jsdelivr.net/gh/step-/JSON.awk/tool/patch-for-busybox-awk.sh" + printf "Done!\n" + bash "${JSONSHFILE%/*}/awk-patch.sh" "${JSONSHFILE%/*}/JSON.awk" +fi +# delete backup files +rm -f "${JSONSHFILE%/*}"/*.bak + diff --git a/dev/make-distribution.sh b/dev/make-distribution.sh index ed097a9..1e381e8 100755 --- a/dev/make-distribution.sh +++ b/dev/make-distribution.sh @@ -7,7 +7,7 @@ # # Options: --notest - skip tests # -#### $$VERSION$$ v1.21-dev-16-geedd0b3 +#### $$VERSION$$ v1.21-dev-17-g8c9298d ############################################################## # magic to ensure that we're always inside the root of our application, @@ -53,22 +53,9 @@ do mv "${file}" "${file}.dist" done -# dwonload JSON.sh -echo "Inject JSON.sh" -JSONSHFILE="JSON.sh/JSON.sh" -if [ ! -r "${JSONSHFILE}" ]; then - mkdir "JSON.sh" 2>/dev/null - curl -sL -o "${JSONSHFILE}" "https://cdn.jsdelivr.net/gh/dominictarr/JSON.sh/JSON.sh" - chmod +x "${JSONSHFILE}" -fi -echo "Inject JSON.awk" -JSONSHFILE="JSON.sh/JSON.awk" -if [ ! -r "${JSONSHFILE}" ]; then - curl -sL -o "${JSONSHFILE}" "https://cdn.jsdelivr.net/gh/step-/JSON.awk/JSON.awk" - curl -sL -o "${JSONSHFILE%/*}/awk-patch.sh" "https://cdn.jsdelivr.net/gh/step-/JSON.awk/tool/patch-for-busybox-awk.sh" - bash "${JSONSHFILE%/*}/awk-patch.sh" "${JSONSHFILE%/*}/JSON.awk" -fi -rm -f "${JSONSHFILE%/*}"/*.bak +# inject JSON.sh into distribution +# shellcheck disable=SC1090 +source "$GIT_DIR/../dev/inject-json.sh" # make html doc echo "Create html doc" diff --git a/dev/make-distribution.sh.exclude b/dev/make-distribution.sh.exclude index 0d04a17..2a35aa6 100644 --- a/dev/make-distribution.sh.exclude +++ b/dev/make-distribution.sh.exclude @@ -1,7 +1,14 @@ data-bot-bash/* -*.jssh +*.jssh* botacl *.flock *.log *.last *.ok +*.bad +*.bak +*.jpg +*.jpeg +*.png +*.zip +*.gz diff --git a/dev/make-standalone.sh b/dev/make-standalone.sh index 7e532f1..666928c 100755 --- a/dev/make-standalone.sh +++ b/dev/make-standalone.sh @@ -1,11 +1,16 @@ #!/usr/bin/env bash -# file: make-standalone.sh -# even after make-distribution.sh bashbot is not self contained as it was in the past. +################################################################### # -# If you your bot is finished you can use make-standalone.sh to create the -# the old all-in-one bashbot: bashbot.sh and commands.sh only! +# File: make-standalone.sh # -#### $$VERSION$$ v1.20-0-g2ab00a2 +# Description: +# even after make-distribution.sh bashbot is not self contained as it was in the past. +# +# If you your bot is finished you can use make-standalone.sh to create the +# the old all-in-one bashbot: bashbot.sh and commands.sh only! +# +#### $$VERSION$$ v1.21-dev-17-g8c9298d +################################################################### # magic to ensure that we're always inside the root of our application, # no matter from which directory we'll run script @@ -30,6 +35,10 @@ mkdir -p "${DISTDIR}" 2>/dev/null cp -r ${DISTFILES} "${DISTDIR}" 2>/dev/null cd "${DISTDIR}" || exit 1 +# inject JSON.sh into distribution +# shellcheck disable=SC1090 +source "$GIT_DIR/../dev/inject-json.sh" + ####################### # here the magic starts # create all in one bashbot.sh file