2019-04-22 20:34:43 +02:00
|
|
|
#!/usr/bin/env bash
|
2020-12-27 17:27:04 +01:00
|
|
|
##############################################################
|
2019-05-11 12:17:38 +02:00
|
|
|
#
|
2020-12-27 17:27:04 +01:00
|
|
|
# File: make-distribution.sh
|
|
|
|
#
|
|
|
|
# Description: creates files and arcchives to distribute bashbot
|
|
|
|
#
|
|
|
|
# Options: --notest - skip tests
|
|
|
|
#
|
2021-03-10 08:39:17 +01:00
|
|
|
#### $$VERSION$$ v1.5-0-g8adca9b
|
2020-12-27 17:27:04 +01:00
|
|
|
##############################################################
|
2019-04-22 20:34:43 +02:00
|
|
|
|
2021-01-15 14:23:19 +01:00
|
|
|
#shellcheck disable=SC1090
|
|
|
|
source "${0%/*}/dev.inc.sh"
|
2019-04-22 20:34:43 +02:00
|
|
|
|
2019-04-30 14:21:24 +02:00
|
|
|
VERSION="$(git describe --tags | sed -e 's/-[0-9].*//' -e 's/v//')"
|
2019-04-22 20:34:43 +02:00
|
|
|
|
|
|
|
DISTNAME="telegram-bot-bash"
|
2019-05-26 16:55:02 +02:00
|
|
|
DISTDIR="./DIST/${DISTNAME}"
|
2021-01-05 13:27:20 +01:00
|
|
|
DISTMKDIR="data-bot-bash logs bin bin/logs addons"
|
|
|
|
|
2021-01-08 15:18:58 +01:00
|
|
|
DISTFILES="bashbot.sh commands.sh mycommands.sh.clean bin doc examples scripts modules LICENSE README.md README.txt README.html"
|
2021-03-08 08:06:35 +01:00
|
|
|
DISTFILESDEV="dev/make-standalone.sh dev/inject-json.sh dev/make-html.sh dev/obfuscate.sh"
|
2021-01-09 08:10:52 +01:00
|
|
|
DISTFILESDIST="mycommands.sh mycommands.conf bashbot.rc $(echo "addons/"*.sh)"
|
2019-04-22 20:34:43 +02:00
|
|
|
|
|
|
|
# run tests first!
|
2020-12-27 17:27:04 +01:00
|
|
|
for test in $1 dev/all-test*.sh
|
2019-04-22 20:34:43 +02:00
|
|
|
do
|
2020-12-27 17:27:04 +01:00
|
|
|
[[ "${test}" == "--notest"* ]] && break
|
2020-05-31 11:04:38 +02:00
|
|
|
[ ! -x "${test}" ] && continue
|
2019-04-22 20:34:43 +02:00
|
|
|
if ! "${test}" ; then
|
2021-01-01 19:25:25 +01:00
|
|
|
printf "ERROR: Test %s failed, can't create dist!\n" "${test}"
|
2019-04-22 20:34:43 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2019-04-28 10:32:06 +02:00
|
|
|
# create dir for distribution and copy files
|
2019-04-22 20:34:43 +02:00
|
|
|
mkdir -p "${DISTDIR}" 2>/dev/null
|
2020-12-29 13:59:31 +01:00
|
|
|
|
2021-01-01 11:27:54 +01:00
|
|
|
printf "Copy files\n"
|
2020-06-20 17:30:03 +02:00
|
|
|
# shellcheck disable=SC2086
|
2019-04-22 20:34:43 +02:00
|
|
|
cp -r ${DISTFILES} "${DISTDIR}"
|
2021-03-07 09:09:48 +01:00
|
|
|
mkdir -p "${DISTDIR}/dev"
|
2021-03-05 20:12:30 +01:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
cp ${DISTFILESDEV} "${DISTDIR}/dev"
|
2019-04-22 20:34:43 +02:00
|
|
|
cd "${DISTDIR}" || exit 1
|
|
|
|
|
2021-01-01 11:27:54 +01:00
|
|
|
printf "Create directories\n"
|
2021-01-05 11:40:28 +01:00
|
|
|
# shellcheck disable=SC2250
|
2020-12-29 13:59:31 +01:00
|
|
|
for dir in $DISTMKDIR
|
|
|
|
do
|
|
|
|
[ ! -d "${dir}" ] && mkdir "${dir}"
|
|
|
|
done
|
|
|
|
|
2019-05-25 17:02:25 +02:00
|
|
|
# do not overwrite on update
|
2021-01-01 11:27:54 +01:00
|
|
|
printf "Create .dist files\n"
|
2021-01-05 13:27:20 +01:00
|
|
|
for file in ${DISTFILESDIST}
|
2019-05-25 17:02:25 +02:00
|
|
|
do
|
|
|
|
[ "${file}" = "addons/*.sh" ] && continue
|
2021-01-15 14:23:19 +01:00
|
|
|
cp "${BASE_DIR}/${file}" "${file}.dist"
|
2019-05-25 17:02:25 +02:00
|
|
|
done
|
2019-04-22 20:34:43 +02:00
|
|
|
|
2020-12-27 21:19:32 +01:00
|
|
|
# inject JSON.sh into distribution
|
|
|
|
# shellcheck disable=SC1090
|
2021-01-15 14:23:19 +01:00
|
|
|
source "${BASE_DIR}/dev/inject-json.sh"
|
2019-04-22 20:34:43 +02:00
|
|
|
|
2019-04-28 10:32:06 +02:00
|
|
|
# make html doc
|
2021-01-01 11:27:54 +01:00
|
|
|
printf "Create html doc\n"
|
2020-11-29 17:44:20 +01:00
|
|
|
# shellcheck disable=SC1090,SC1091
|
|
|
|
source "../../dev/make-html.sh"
|
2019-04-28 10:32:06 +02:00
|
|
|
|
2019-04-22 20:34:43 +02:00
|
|
|
# create archive
|
|
|
|
cd .. || exit 1
|
2021-01-01 11:27:54 +01:00
|
|
|
printf "Create dist archives\n"
|
2020-12-18 17:26:05 +01:00
|
|
|
# shellcheck disable=SC2046
|
2021-01-15 14:23:19 +01:00
|
|
|
zip -rq - "${DISTNAME}" --exclude $(cat "${BASE_DIR}/dev/${0##*/}.exclude") >"${DISTNAME}-${VERSION}.zip"
|
|
|
|
tar --exclude-ignore="${BASE_DIR}/dev/${0##*/}.exclude" -czf "${DISTNAME}-${VERSION}.tar.gz" "${DISTNAME}"
|
2019-04-22 20:34:43 +02:00
|
|
|
|
2021-01-01 11:27:54 +01:00
|
|
|
printf "%s Done!\n" "$0"
|
2019-04-22 20:34:43 +02:00
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
2021-01-05 11:40:28 +01:00
|
|
|
ls -ld "${DISTNAME}-${VERSION}".*
|
2019-04-22 20:34:43 +02:00
|
|
|
|
2021-01-03 12:06:39 +01:00
|
|
|
# an empty DEBUG.log is created ... :-(
|
2021-01-15 14:23:19 +01:00
|
|
|
rm -f "${BASE_DIR}/test/"*.log
|