Compare commits

...

22 Commits

Author SHA1 Message Date
Martin Scheidt 876c8907e5 Merge branch 'master' of github.com:railtoolkit/tikz-trackschematic 2022-03-11 11:47:13 +01:00
Martin Scheidt c0ad07f84e added fall back if development package is not installed 2022-03-11 11:46:59 +01:00
Martin Scheidt c9f5e7a7ba added fall back if development package is not installed 2022-03-11 11:31:08 +01:00
Martin Scheidt 9a7828e059 fixed PackageWarning Error in development mode 2022-03-11 11:28:36 +01:00
Martin Scheidt 7ed8411378 refactored log() function - part 2 2022-03-11 11:04:36 +01:00
Martin Scheidt 43c132a957 refactored log() function 2022-03-11 10:55:21 +01:00
Martin Scheidt 1dfb44feed refactored user interaction 2022-03-11 10:51:26 +01:00
Martin Scheidt 3d6030b43b combined if condition 2022-03-10 17:17:17 +01:00
Martin Scheidt f90b3a9b0d POSIX compatiblity 2022-03-10 17:14:02 +01:00
Martin Scheidt 44110223b6 minor changes 2022-03-10 15:41:17 +01:00
Martin Scheidt 90aebcda84 added silent and debug logging 2022-03-10 15:26:50 +01:00
Martin Scheidt 7dfad7eef5
Merge pull request #27 from apriljunge/run-tests-on-pullrequest
Run tests on pull request
2022-03-10 11:18:11 +01:00
Gregor 8d27ed80ad
Run tests on pullrequest 2022-03-10 10:34:17 +01:00
Martin Scheidt f5e79dedb2
Merge pull request #26 from apriljunge/small-pdftoppm-tweaks
Small pdftoppm tweaks
2022-03-10 10:18:55 +01:00
Gregor b4f1112448
Use singlefile transformation for ppm 2022-03-09 23:02:53 +01:00
Gregor 91b9b3631c
Use shorthand resultion parameter for pdftoppm 2022-03-09 22:58:59 +01:00
Martin Scheidt 42773fc910 testing for file not for directory 2022-03-09 22:48:55 +01:00
Martin Scheidt 6a73b502e2 Merge branch 'master' of github.com:railtoolkit/tikz-trackschematic 2022-03-09 22:30:08 +01:00
Martin Scheidt 9f72df2b64 reduced resolution for pdftoppm conversion and fixed array handling for POSIX shell 2022-03-09 22:29:53 +01:00
Gregor 540813a062
Fix small typo in build script 2022-03-09 20:03:26 +01:00
Martin Scheidt c44553d7ad removed unnecessary line in help message 2022-03-09 18:34:23 +01:00
Martin Scheidt beb481d2a7 enhanced path check in build script 2022-03-09 18:32:29 +01:00
7 changed files with 195 additions and 273 deletions

View File

@ -2,7 +2,6 @@
latex-bin latex-bin
## -- direct dependencies ## -- direct dependencies
tikz-trackschematic
pgf pgf
xkeyval xkeyval
etoolbox etoolbox

View File

@ -52,10 +52,10 @@ jobs:
packages-path: ${{ github.workspace }}/.github/tex/packages.test.txt packages-path: ${{ github.workspace }}/.github/tex/packages.test.txt
# - name: "install tikz-trackschematic" # - name: "install tikz-trackschematic"
# run: ./build.sh --noninteractive --install-dev # run: ./build.sh --non-interactive --install-dev
# - name: "test tikz-trackschematic" # - name: "test tikz-trackschematic"
# run: ./build.sh --noninteractive --test --verbose # run: ./build.sh --non-interactive --test --verbose
# ## create varibale ${{ steps.tag.outputs.tag }} # ## create varibale ${{ steps.tag.outputs.tag }}
# - name: "get tag" # - name: "get tag"
@ -66,7 +66,7 @@ jobs:
# strip_v: false # strip_v: false
# - name: "create tikz-trackschematic package" # - name: "create tikz-trackschematic package"
# run: ./build.sh --noninteractive --release ${{ steps.tag.outputs.tag }} # run: ./build.sh --non-interactive --release ${{ steps.tag.outputs.tag }}
## opening a debug console ## opening a debug console
- name: Setup upterm session - name: Setup upterm session

View File

@ -27,7 +27,7 @@ jobs:
strip_v: false strip_v: false
- name: "create tikz-trackschematic package" - name: "create tikz-trackschematic package"
run: ./build.sh --noninteractive --release ${{ steps.tag.outputs.tag }} run: ./build.sh --non-interactive --release ${{ steps.tag.outputs.tag }}
- name: "create release" - name: "create release"
id: create_release id: create_release

View File

@ -5,6 +5,8 @@ name: test
# Controls when the workflow will run # Controls when the workflow will run
on: on:
# Triggers the workflow on push or pull request events but only for the master branch # Triggers the workflow on push or pull request events but only for the master branch
pull_request:
branches: [ master ]
push: push:
branches: [ master ] branches: [ master ]
@ -33,8 +35,5 @@ jobs:
profile-path: ${{ github.workspace }}/.github/tex/profile.minimal.txt profile-path: ${{ github.workspace }}/.github/tex/profile.minimal.txt
packages-path: ${{ github.workspace }}/.github/tex/packages.test.txt packages-path: ${{ github.workspace }}/.github/tex/packages.test.txt
- name: "install tikz-trackschematic"
run: ./build.sh --noninteractive --install-dev
- name: "test tikz-trackschematic" - name: "test tikz-trackschematic"
run: ./build.sh --noninteractive --test --verbose run: ./build.sh --non-interactive --test --verbose

View File

@ -23,6 +23,7 @@ Categories: Added, Changed, Deprecated, Removed, Fixed, and Security.
* wrong option for labels in vehicles * wrong option for labels in vehicles
* foreground of sidetrack (alias) * foreground of sidetrack (alias)
* PackageWarning Error in development mode
## Version [0.6.3] - 2022-02-15 ## Version [0.6.3] - 2022-02-15

446
build.sh
View File

@ -16,32 +16,37 @@ cat << EOF
Usage: ./build.sh [OPTIONS] Usage: ./build.sh [OPTIONS]
install, test or release a package for tikz-trackschematic install, test or release a package for tikz-trackschematic
-h, --help Display help -h, --help Display this help message.
-s, --silent Run script in silent mode.
The -s option overrides any previous -v or -d options.
-v, --verbose Run script in verbose mode. -v, --verbose Run script in verbose mode.
The -v option overrides any previous -s or -d options.
-d, --debug Run script in debug mode.
The -d option overrides any previous -s or -v options.
-m, --messy Do not clean up afterwards. -m, --messy Do not clean up afterwards.
-n, --noninteractive Run script with no interaction. -n, --non-interactive Run script with no interaction.
-i, --install-dev Install as dev-package in local TeX Live environment -i, --install-dev Install as dev-package in local TeX Live environment.
The -i option overrides any previous -u options. The -i option overrides any previous -u option.
-u, --uninstall-dev Deinstall dev-package from local TeX Live environment -u, --uninstall-dev Deinstall dev-package from local TeX Live environment.
The -u option overrides any previous -i options. The -u option overrides any previous -i option.
-u, --uninstall-dev Deinstall dev-package from local TeX Live environment -t, --test Tests the current src/ against the test/.
-t, --test Tests the current src/ against the test/ -r, --release VERSION Creates a .zip with the release for given VERSION in
-r, --release VERSION Creates a .zip with the release for given VERSION
Semantic Versioning with leading 'v', e.g: v1.0.0 Semantic Versioning with leading 'v', e.g: v1.0.0
EOF EOF
} }
## -- processes getopts ## -- processes getopts
VERBOSE=0 # set by cli argument VERBOSITY=2 # set by cli argument
NOINTERACT=0 # set by cli argument NOINTERACT=0 # set by cli argument
INSTALL=0 # set by cli argument INSTALL=0 # set by cli argument
TESTING=0 # set by cli argument TESTING=0 # set by cli argument
@ -51,22 +56,26 @@ CLEANUP=1 # set by cli argument
process_arguments() { process_arguments() {
while true; do while true; do
# loop condition - test for empty string: # loop condition - test for empty string:
if [ -z "$1" ]; then if [ -z "$1" ]; then break; fi
break;
fi
# loop test # loop test
case $1 in case $1 in
-h|--help) -h|--help)
print_usage print_usage
exit 0 exit 0
;; ;;
-s|--silent)
VERBOSITY=0
;;
-v|--verbose) -v|--verbose)
VERBOSE=1 VERBOSITY=3
;;
-d|--debug)
VERBOSITY=4
;; ;;
-m|--messy) -m|--messy)
CLEANUP=0 CLEANUP=0
;; ;;
-n|--noninteractive) -n|--non-interactive)
NOINTERACT=1 NOINTERACT=1
;; ;;
-i|--install-dev) -i|--install-dev)
@ -81,11 +90,7 @@ process_arguments() {
-r|--release) -r|--release)
RELEASE=1 RELEASE=1
shift shift
if [ -z "$1" ]; then if [ -z "$1" ] || [ "${1:0:1}" = "-" ]; then
print_usage
exit 1
fi
if [ ${1:0:1} = "-" ]; then
print_usage print_usage
exit 1 exit 1
fi fi
@ -107,75 +112,130 @@ POLICY_MOD=0 # set by check_imagemagick_policy
# #
ERROR_OCCURRED=0 ERROR_OCCURRED=0
## -- colors ## -- logging functions
## colors
RED="\033[0;31m" RED="\033[0;31m"
GREEN="\033[0;32m" GREEN="\033[0;32m"
YELLOW="\033[0;33m"
COLOR_RESET="\033[0;m" COLOR_RESET="\033[0;m"
## -- cross platform helpers ## cross platform echo option
if [ "`echo -n`" = "-n" ]; then if [ "`echo -n`" = "-n" ]; then
n=""; c="\c" n=""; c="\c"
else else
n="-n"; c="" n="-n"; c=""
fi fi
# https://stackoverflow.com/questions/2320564/sed-i-command-for-in-place-editing-to-work-with-both-gnu-sed-and-bsd-osx log() {
sedi () { NO_LINE_BREAK=0
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@" case $2 in
-n) NO_LINE_BREAK=1;;
esac
COLOR=${COLOR_RESET}
case $1 in
1) COLOR=${RED};;
2) COLOR=${GREEN};;
4) COLOR=${YELLOW};;
esac
if [ $VERBOSITY -ge $1 ]; then
shift
if [ $NO_LINE_BREAK = 0 ]; then
echo "${COLOR}$@${COLOR_RESET}" | fold -s
else
shift
echo $n "${COLOR}$@ $c${COLOR_RESET}" | fold -s
fi
fi
}
log_show() { log 0 $@; } # will always show
log_error() { log 1 $@; } # print message in RED ; but not when --silent
log_info() { log 2 $@; } # print message in GREEN ; but not when --silent
log_note() { log 3 $@; } # print message ; with --verbose and --debug
log_debug() { log 4 $@; } # print message in YELLOW; only with --debug
## -- user interaction
user_confirmation () {
if [ ! $NOINTERACT = 1 ]; then
log_show $@
log_show -n "(y/n)"
while true; do
read -p "" answer
case $answer in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) log_show "Please answer yes or no.";;
esac
done
fi
} }
## -- commands ## -- commands
check_path() { check_path() {
if [ ! -d ../tikz-trackschematic ]; then # test for project specific files
echo "${RED}Please run this script from inside the project folder!${COLOR_RESET}" STATUS=0
exit 1 set -- doc/tikz-trackschematic-documentation.sty src/tikz-trackschematic.sty test/turnout.tex
for FILE in "$@"; do
if [ ! -e $FILE ]; then
STATUS=1
fi
done
if [ $STATUS = 0 ]; then
log_note "Build script is within the project folder."
return 0
fi fi
log_error "Please run this script from inside the project folder!"
exit 1
} }
## checks for installed software ## checks for installed software
sedi () {
## cross platform sed -i option without a backup file name
# https://stackoverflow.com/questions/2320564/sed-i-command-for-in-place-editing-to-work-with-both-gnu-sed-and-bsd-osx
sed --version >/dev/null 2>&1 && sed -i -- "$@" || sed -i "" "$@"
}
check_zip() { check_zip() {
# check for zip # check for zip
STATUS=0 STATUS=0
command -v zip >/dev/null 2>&1 || STATUS=1 command -v zip >/dev/null 2>&1 || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "zip found"
echo "zip found"
fi
return 0 return 0
fi fi
echo "Program 'zip' not found." log_error "Program 'zip' not found. Be sure to have zip installed!"
echo "Be sure to have zip installed!"
exit 1 exit 1
} }
check_sudo() { check_sudo() {
# checks if sudo is available # checks if sudo is available
STATUS=0
rootrun="" rootrun=""
# If we are root, we do note require sudo # If we are root, we do note require sudo
if [ "$EUID" = 0 ]; then if [ "$EUID" = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "you are root"
echo "you are root"
fi
return 0 return 0
fi fi
if sudo -v >/dev/null 2>&1; then command -v sudo >/dev/null 2>&1 || STATUS=1
if [ $VERBOSE = 1 ]; then if [ $STATUS = 0 ]; then
echo "sudo ok" log_note "sudo found"
fi
rootrun="sudo" rootrun="sudo"
return 0
else else
echo "sudo failed" log_debug "sudo failed."
# Check if user is root (might be unnecessary)
if ! [ $(id -u) = 0 ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
fi fi
log_error "This script must be run as root!"
exit 1
} }
check_texlive() { check_texlive() {
@ -184,15 +244,12 @@ check_texlive() {
command -v kpsewhich >/dev/null 2>&1 || STATUS=1 command -v kpsewhich >/dev/null 2>&1 || STATUS=1
command -v mktexlsr >/dev/null 2>&1 || STATUS=1 command -v mktexlsr >/dev/null 2>&1 || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "kpsewhich and mktexlsr found"
echo "kpsewhich and mktexlsr found"
fi
TEXMFLOCAL=$(kpsewhich --var-value TEXMFLOCAL) TEXMFLOCAL=$(kpsewhich --var-value TEXMFLOCAL)
return 0 return 0
fi fi
echo "Program 'kpsewhich' not found." log_error "Program 'kpsewhich' or 'mktexlsr' not found. Be sure to use texlive or mactex!"
echo "Be sure to use texlive or mactex!"
exit 1 exit 1
} }
@ -201,14 +258,11 @@ check_pdflatex() {
STATUS=0 STATUS=0
command -v pdflatex >/dev/null 2>&1 || STATUS=1 command -v pdflatex >/dev/null 2>&1 || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "pdflatex found"
echo "pdflatex found"
fi
return 0 return 0
fi fi
echo "Program 'pdflatex' not found." log_error "Program 'pdflatex' not found. Be sure to have texlive or mactex installed!"
echo "Be sure to have texlive or mactex installed!"
exit 1 exit 1
} }
@ -217,14 +271,11 @@ check_imagemagick() {
STATUS=0 STATUS=0
command -v compare >/dev/null 2>&1 || STATUS=1 command -v compare >/dev/null 2>&1 || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "compare found"
echo "compare found"
fi
return 0 return 0
fi fi
echo "Program 'compare' not found." log_error "Program 'compare' not found. Be sure to have ImageMagick installed!"
echo "Be sure to have ImageMagick installed!"
exit 1 exit 1
} }
@ -233,69 +284,51 @@ check_pdftoppm() {
STATUS=0 STATUS=0
command -v pdftoppm >/dev/null 2>&1 || STATUS=1 command -v pdftoppm >/dev/null 2>&1 || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "pdftoppm found"
echo "pdftoppm found"
fi
PDFTOPPM_CONVERT=1 PDFTOPPM_CONVERT=1
return 0 return 0
fi fi
echo "Program 'pdftoppm' not found." log_note "Program 'pdftoppm' not found."
# exit 1 # no # exit 1 ## can still modify ImageMagick policy!
} }
check_imagemagick_policy() { check_imagemagick_policy() {
STATUS=1 STATUS=1
convert -list policy | grep -q "pattern: PDF" || STATUS=0 convert -list policy | grep -q "pattern: PDF" || STATUS=0
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "ImageMagick allows to convert PDFs. Great!"
echo "ImageMagick allows to convert PDFs. Great!"
fi
return 0 return 0
else else
if [ $VERBOSE = 1 ]; then log_note "ImageMagick does not allow to convert PDFs."
echo "ImageMagick does not allow to convert PDFs."
fi
## check for alternative ## check for alternative
check_pdftoppm # if pdftoppm is available, then PDFTOPPM_CONVERT=1 check_pdftoppm # if pdftoppm is available, then PDFTOPPM_CONVERT=1
if [ $PDFTOPPM_CONVERT = 0 ]; then if [ $PDFTOPPM_CONVERT = 0 ]; then
## modify ImageMagick-6/policy.xml ## modify ImageMagick-6/policy.xml
if [ $NOINTERACT = 0 ]; then user_confirmation "Be sure to have either poppler(-utils) installed or an ImageMagick \
echo "" policy which allows for PDF conversion! Do you wish to temporaly remove \
echo "Be sure to have either poppler(-utils) installed or an ImageMagick policy which allows for PDF conversion!" the policy preventing ImageMagick from converting PDFs?"
echo "Do you wish to temporaly remove the policy preventing ImageMagick from converting PDFs?"
echo $n "(y/n) $c"
while true; do
read -p "" answer
case $answer in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
fi
check_sudo check_sudo
POLICY_PATH=$(convert -list policy | grep "Path" | awk "NR==1" | cut -d " " -f2) # default /etc/ImageMagick-*/policy.xml POLICY_PATH=$(convert -list policy | grep "Path" | awk "NR==1" | cut -d " " -f2) # default /etc/ImageMagick-*/policy.xml
if [ ! -d $POLICY_PATH ]; then if [ ! -e $POLICY_PATH ]; then
VERSION=$(convert --version | grep "Version" | cut -d " " -f3 | cut -d "." -f1 ) VERSION=$(convert --version | grep "Version" | cut -d " " -f3 | cut -d "." -f1 )
POLICY_PATH="/etc/ImageMagick-${VERSION}/policy.xml" POLICY_PATH="/etc/ImageMagick-${VERSION}/policy.xml"
if [ ! -d $POLICY_PATH ]; then if [ ! -e $POLICY_PATH ]; then
echo "${RED}ImageMagick policy is preventing converting PDFs to PNGs and${COLOR_RESET}" log_error "ImageMagick policy is preventing converting PDFs to PNGs and program \
echo "${RED}program 'pdftoppm' was not found.${COLOR_RESET}" 'pdftoppm' was not found. Modifying the policy temporaly failed! Be sure \
echo "${RED}Modifying the policy temporaly failed!${COLOR_RESET}" to have either poppler(-utils) installed or an ImageMagick policy which \
echo "${RED}Be sure to have either poppler(-utils) installed or${COLOR_RESET}" allows for PDF conversion!"
echo "${RED}an ImageMagick policy which allows for PDF conversion!${COLOR_RESET}"
exit 1 exit 1
fi fi
fi fi
POLICY_MOD=1 POLICY_MOD=1
$rootrun sed -i".backup" 's/^.*policy.*coder.*none.*PDF.*//' $POLICY_PATH $rootrun sed -i".backup" 's/^.*policy.*coder.*none.*PDF.*//' $POLICY_PATH
echo "Modified ${POLICY_PATH}!" log_note "Modified ${POLICY_PATH}!"
fi fi
fi fi
} }
@ -308,15 +341,13 @@ check_trackschematic() {
ls $DEVDIR/tikz-trackschematic-dev.sty >> /dev/null 2>&1 || STATUS=1 ls $DEVDIR/tikz-trackschematic-dev.sty >> /dev/null 2>&1 || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "Package tikz-trackschematic-dev found."
echo "tikz-trackschematic-dev found"
fi
return 0 return 0
fi fi
echo "Library 'tikz-trackschematic-dev' not found." log_note "Package 'tikz-trackschematic-dev' not found - using project src/."
echo "Be sure to have tikz-trackschematic-dev installed!"
exit 1 export TEXINPUTS=.:../src/:$TEXINPUTS
} }
## checks for updated repository ## checks for updated repository
@ -327,12 +358,12 @@ check_version_number() {
echo "$VERSION_STR" | egrep -q "v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)?" && break; echo "$VERSION_STR" | egrep -q "v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)?" && break;
# loop test # loop test
if [ $NOINTERACT = 0 ]; then if [ $NOINTERACT = 0 ]; then
echo "${RED}Your version '$VERSION_STR' has not the correct format!${COLOR_RESET}" log_error "Your version '$VERSION_STR' has not the correct format!"
echo $n "Please specify as Semantic Versioning ( e.g. v1.0.0 ): $c" log_show -n "Please specify as Semantic Versioning ( e.g. v1.0.0 ): "
read VERSION_STR read VERSION_STR
else else
echo "${RED}Your version '$VERSION_STR' has not the correct format!${COLOR_RESET}" log_error "Your version '$VERSION_STR' has not the correct format! \
echo "Please use Semantic Versioning with leading 'v'" Please use Semantic Versioning with leading 'v'"
exit 1 exit 1
fi fi
done done
@ -345,14 +376,12 @@ check_versionhistory() {
STATUS=0 STATUS=0
grep -qs "vhEntry{$VERSION_NUM" doc/versionhistory.tex || STATUS=1 grep -qs "vhEntry{$VERSION_NUM" doc/versionhistory.tex || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "Version $VERSION_NUM is present in versionhistory.tex."
echo "Version $VERSION_NUM is present in versionhistory.tex."
fi
return 0 return 0
fi fi
echo "Version $VERSION_NUM not found in versionhistory.tex." log_error "Version $VERSION_NUM not found in versionhistory.tex. \
echo "Be sure to edit versionhistory.tex and specify current version!" Be sure to edit versionhistory.tex and specify current version!"
exit 1 exit 1
} }
@ -361,14 +390,12 @@ check_changelog() {
STATUS=0 STATUS=0
grep -qs "Version \[$VERSION_NUM\]" CHANGELOG.md || STATUS=1 grep -qs "Version \[$VERSION_NUM\]" CHANGELOG.md || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "Version $VERSION_NUM is present in CHANGELOG.md."
echo "Version $VERSION_NUM is present in CHANGELOG.md."
fi
return 0 return 0
fi fi
echo "Version $VERSION_NUM not found in CHANGELOG.md." log_error "Version $VERSION_NUM not found in CHANGELOG.md. \
echo "Be sure to edit CHANGELOG.md and specify current version!" Be sure to edit CHANGELOG.md and specify current version!"
exit 1 exit 1
} }
@ -382,14 +409,12 @@ check_date() {
if [ $DATEISO_1 = $DATEISO_2 ]; then if [ $DATEISO_1 = $DATEISO_2 ]; then
# DATE=$(date "+%Y-%m-%d") # DATE=$(date "+%Y-%m-%d")
DATE="$DATEISO_1" DATE="$DATEISO_1"
if [ $VERBOSE = 1 ]; then log_note "The date $DATE was extracted from versionhistory.tex and CHANGELOG.md."
echo "The date $DATE was extracted from versionhistory.tex and CHANGELOG.md."
fi
return 0 return 0
fi fi
echo "The date in versionhistory.tex and CHANGELOG.md did not match." log_error "The date in versionhistory.tex and CHANGELOG.md did not match.\
echo "Be sure to edit versionhistory.tex or CHANGELOG.md and modifiy the date!" Be sure to edit versionhistory.tex or CHANGELOG.md and modifiy the date!"
exit 1 exit 1
} }
@ -399,14 +424,12 @@ check_url1() {
LINE=$(grep "\[$VERSION_NUM\]: https://" CHANGELOG.md) LINE=$(grep "\[$VERSION_NUM\]: https://" CHANGELOG.md)
echo $LINE | grep -qs "...$VERSION_STR" || STATUS=1 echo $LINE | grep -qs "...$VERSION_STR" || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "Version $VERSION_NUM URL is present in CHANGELOG.md."
echo "Version $VERSION_NUM URL is present in CHANGELOG.md."
fi
return 0 return 0
fi fi
echo "Version $VERSION_NUM URL was not found in CHANGELOG.md." log_error "Version $VERSION_NUM URL was not found in CHANGELOG.md. \
echo "Be sure to edit CHANGELOG.md and specify a URL for the current version!" Be sure to edit CHANGELOG.md and specify a URL for the current version!"
exit 1 exit 1
} }
@ -416,28 +439,17 @@ check_url2() {
LINE=$(grep "\[Unreleased\]: https://" CHANGELOG.md) LINE=$(grep "\[Unreleased\]: https://" CHANGELOG.md)
echo $LINE | grep -qs "/$VERSION_STR..." || STATUS=1 echo $LINE | grep -qs "/$VERSION_STR..." || STATUS=1
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_note "The URL for [Unreleased] was also updated in CHANGELOG.md! Thx!"
echo "The URL for [Unreleased] was also updated in CHANGELOG.md! Thx!"
fi
return 0 return 0
fi fi
echo "WARNING: URL for [Unreleased] in CHANGELOG.md does not reflect the current version $VERSION_NUM." log_show "WARNING: URL for [Unreleased] in CHANGELOG.md does not reflect the current version $VERSION_NUM."
echo "WARNING: Be sure to edit CHANGELOG.md and specify current version!" log_show "WARNING: Be sure to edit CHANGELOG.md and specify current version!"
user_confirmation "Do you wish to continue without updated URL for [Unreleased]?"
if [ $NOINTERACT = 0 ]; then if [ $NOINTERACT = 1 ]; then
echo "Do you wish to continue without updated URL for [Unreleased]?" log_error "Aborting in batch mode!"
echo $n "(y/n) $c"
while true; do
read -p "" answer
case $answer in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
else
echo "ERROR: Aborting in batch mode!"
exit 1 exit 1
fi fi
} }
@ -449,26 +461,12 @@ create_release() {
# This function produces a .zip-file in accordance to the requirements for CTAN. # This function produces a .zip-file in accordance to the requirements for CTAN.
# For more information see https://ctan.org/help/upload-pkg. # For more information see https://ctan.org/help/upload-pkg.
#### ####
if [ $NOINTERACT = 0 ]; then user_confirmation "Do you wish to create a release for the version $VERSION_NUM?"
echo ""
echo "Do you wish to create a release for the version $VERSION_NUM?"
echo $n "(y/n) $c"
while true; do
read -p "" answer
case $answer in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
fi
## create backup-file und update VERSIONDATE in tikz-trackschematic.sty ## create backup-file und update VERSIONDATE in tikz-trackschematic.sty
sed -i".backup" -e"s/%\[VERSIONDATE/\[$DATE $VERSION_STR/g" src/tikz-trackschematic.sty sed -i".backup" -e"s/%\[VERSIONDATE/\[$DATE $VERSION_STR/g" src/tikz-trackschematic.sty
sedi "/%%\[SCRIPT\]/d" src/tikz-trackschematic.sty sedi "/%%\[SCRIPT\]/d" src/tikz-trackschematic.sty
if [ $VERBOSE = 1 ]; then log_note "Updated version in src/tikz-trackschematic.sty"
echo "Updated version in src/tikz-trackschematic.sty"
fi
## -- create zip-archive ## -- create zip-archive
# create temporary folder # create temporary folder
@ -493,9 +491,7 @@ create_release() {
mkdir $TMP/tikz-trackschematic-snippets mkdir $TMP/tikz-trackschematic-snippets
cp -R doc/examples/* $TMP/tikz-trackschematic-examples/ cp -R doc/examples/* $TMP/tikz-trackschematic-examples/
cp -R doc/snippets/* $TMP/tikz-trackschematic-snippets/ cp -R doc/snippets/* $TMP/tikz-trackschematic-snippets/
if [ $VERBOSE = 1 ]; then log_note "copied documentation"
echo "copied documentation"
fi
# copy src-files # copy src-files
for SRC in src/*; do for SRC in src/*; do
@ -505,33 +501,16 @@ create_release() {
cp $SRC $TMP/ cp $SRC $TMP/
fi fi
done done
if [ $VERBOSE = 1 ]; then log_note "copied src-files"
echo "copied src-files"
fi
# zip package # zip package
if [ $VERBOSE = 1 ]; then zip -r $TMP.zip $TMP/* >/dev/null 2>&1
zip -r $TMP.zip $TMP/* log_note "compressed the release in $TMP.zip"
echo "compressed the release in $TMP.zip"
else
zip -r $TMP.zip $TMP/* >/dev/null 2>&1
fi
} }
create_release_notes() { create_release_notes() {
if [ $NOINTERACT = 0 ]; then user_confirmation "Do you wish to create a release notes for the version $VERSION_NUM?"
echo ""
echo "Do you wish to create a release notes for the version $VERSION_NUM?"
echo $n "(y/n) $c"
while true; do
read -p "" answer
case $answer in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
fi
## -- create release note as excerpt from CHANGELOG.md ## -- create release note as excerpt from CHANGELOG.md
# determine beginning and end in CHANGELOG.md # determine beginning and end in CHANGELOG.md
TOP=$(grep -n "Version \[$VERSION_NUM\]" CHANGELOG.md | cut -d: -f1) TOP=$(grep -n "Version \[$VERSION_NUM\]" CHANGELOG.md | cut -d: -f1)
@ -556,21 +535,13 @@ run_test_cases() {
# Start with an empty List: # Start with an empty List:
FAILED="" FAILED=""
if [ $VERBOSE = 1 ]; then
echo "==========="
echo "Comparison of the expected appearance with the freshly created."
echo "-----------"
fi
for TEST in `ls $TESTDIR/*.tex`; do for TEST in `ls $TESTDIR/*.tex`; do
# setup # setup
FILE=$(basename "$TEST") # remove path FILE=$(basename "$TEST") # remove path
NAME=${FILE%.*} # remove extension NAME=${FILE%.*} # remove extension
ADD_TO_LIST=0 ADD_TO_LIST=0
# #
if [ $VERBOSE = 1 ]; then log_info "$NAME test:"
echo "$NAME test:"
fi
# #
# #
## TeX build ## TeX build
@ -582,26 +553,15 @@ run_test_cases() {
TIME=$(awk "NR==2" .tex/${NAME}.time | cut -d " " -f2) TIME=$(awk "NR==2" .tex/${NAME}.time | cut -d " " -f2)
# understanding TeX statistics: # understanding TeX statistics:
# -> https://tex.stackexchange.com/questions/26208/components-of-latexs-memory-usage # -> https://tex.stackexchange.com/questions/26208/components-of-latexs-memory-usage
# TOP=$(grep -n "Here is how much of TeX's memory you used:" .tex/${NAME}.log | cut -d: -f1)
# BOTTOM=$(($(grep -n "stack positions out of" .tex/${NAME}.log | cut -d: -f1) + 1))
# awk "NR>$TOP&&NR<$BOTTOM" .tex/${NAME}.log > .tex/${NAME}.statistics.log
MEMORY_USAGE=$(grep "words of memory out of" .tex/${NAME}.log | cut -d " " -f2) MEMORY_USAGE=$(grep "words of memory out of" .tex/${NAME}.log | cut -d " " -f2)
MEMORY_USAGE=$(($MEMORY_USAGE/1000)) MEMORY_USAGE=$(($MEMORY_USAGE/1000))
# #
if [ $EXIT_CODE = 0 ]; then if [ $EXIT_CODE = 0 ]; then
if [ $VERBOSE = 1 ]; then log_info " - build successful in ${TIME}s and with ${MEMORY_USAGE}k memory."
echo $n " - ${GREEN}build succesful${COLOR_RESET}: $c"
echo $n "in ${TIME}s $c"
echo $n "and with $c"
echo "${MEMORY_USAGE}k of memory used."
# cat .tex/${NAME}.statistics.log
fi
else else
STATUS=1 STATUS=1
ADD_TO_LIST=1 ADD_TO_LIST=1
if [ $VERBOSE = 1 ]; then log_error " - build failed."
echo " - ${RED}build failed${COLOR_RESET}."
fi
fi fi
# #
# #
@ -629,21 +589,17 @@ run_test_cases() {
# use 'pdftoppm' convert the pdf to png # use 'pdftoppm' convert the pdf to png
# then use 'compare' for comparison without converting # then use 'compare' for comparison without converting
# -> this is slower! # -> this is slower!
pdftoppm -png -rx 600 -ry 600 .tex/${NAME}.pdf .tex/${NAME} pdftoppm -png -r 144 -singlefile .tex/${NAME}.pdf .tex/${NAME}
pdftoppm -png -rx 600 -ry 600 ${NAME}_expected.pdf .tex/${NAME}_expected pdftoppm -png -r 144 -singlefile ${NAME}_expected.pdf .tex/${NAME}_expected
compare -metric RMSE -colorspace RGB .tex/${NAME}-1.png .tex/${NAME}_expected-1.png NULL: >> /dev/null 2>&1 || EXIT_CODE=1 compare -metric RMSE -colorspace RGB .tex/${NAME}.png .tex/${NAME}_expected.png NULL: >> /dev/null 2>&1 || EXIT_CODE=1
fi fi
if [ $EXIT_CODE = 0 ]; then if [ $EXIT_CODE = 0 ]; then
if [ $VERBOSE = 1 ]; then log_info " - comparison successful."
echo " - ${GREEN}comparison succesful${COLOR_RESET}."
fi
else else
STATUS=1 STATUS=1
ADD_TO_LIST=1 ADD_TO_LIST=1
if [ $VERBOSE = 1 ]; then log_error " - comparison failed."
echo " - ${RED}comparison failed${COLOR_RESET}."
fi
fi fi
## if a test failed add to list ## if a test failed add to list
if [ $ADD_TO_LIST = 1 ]; then if [ $ADD_TO_LIST = 1 ]; then
@ -657,17 +613,10 @@ run_test_cases() {
done done
if [ $STATUS = 0 ]; then if [ $STATUS = 0 ]; then
if [ $VERBOSE = 1 ]; then log_info "\n=> All tests passed!\n"
echo "-----------"
echo "${GREEN}All tests passed!${COLOR_RESET}"
fi
else else
if [ $VERBOSE = 1 ]; then log_error "\n=> Some or all tests failed!"
echo "-----------" log_debug "The following tests failed: ${FAILED}!"
echo "${RED}The following tests failed: ${FAILED}!${COLOR_RESET}"
else
echo "${RED}Some or all tests failed!${COLOR_RESET}"
fi
ERROR_OCCURRED=1 ERROR_OCCURRED=1
fi fi
@ -679,20 +628,8 @@ link_dev_files() {
TEXMFLOCAL=$(kpsewhich --var-value TEXMFLOCAL) TEXMFLOCAL=$(kpsewhich --var-value TEXMFLOCAL)
DEVDIR="$TEXMFLOCAL/tex/latex/tikz-trackschematic-dev" DEVDIR="$TEXMFLOCAL/tex/latex/tikz-trackschematic-dev"
PROJECTDIR=$(pwd -P) PROJECTDIR=$(pwd -P)
if [ $NOINTERACT = 0 ]; then
echo "" user_confirmation "Do you wish to install this package for development to $DEVDIR?"
echo "Do you wish to install this package for development to"
echo "$DEVDIR?"
echo $n "(y/n) $c"
while true; do
read -p "" answer
case $answer in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
fi
# make sure that destination folder exists # make sure that destination folder exists
if [ ! -d "$DEVDIR" ]; then if [ ! -d "$DEVDIR" ]; then
@ -715,14 +652,14 @@ link_dev_files() {
$rootrun ln -sfn $PROJECTDIR/$SRC $DEVDIR/$DST $rootrun ln -sfn $PROJECTDIR/$SRC $DEVDIR/$DST
if [ $VERBOSE = 1 ]; then if [ $VERBOSITY = 1 ]; then
echo "linked '$DST'" echo "linked '$DST'"
fi fi
done done
# update TeX Live installation # update TeX Live installation
TEXlsr=`which mktexlsr` TEXlsr=`which mktexlsr`
if [ $VERBOSE = 1 ]; then if [ $VERBOSITY -ge 3 ]; then
$rootrun $TEXlsr $rootrun $TEXlsr
else else
$rootrun $TEXlsr --quiet $rootrun $TEXlsr --quiet
@ -732,29 +669,16 @@ link_dev_files() {
remove_dev_files() { remove_dev_files() {
# destination folder inside the TeX Live installation # destination folder inside the TeX Live installation
cd $DEVDIR # from check_trackschematic cd $DEVDIR # from check_trackschematic
if [ $NOINTERACT = 0 ]; then user_confirmation "Do you wish to remove the package '$DEVDIR'?"
echo ""
echo "Do you wish to remove the package '$DEVDIR'?" log_note "removing $DEVDIR!"
echo $n "(y/n) $c"
while true; do
read -p "" answer
case $answer in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
fi
if [ $VERBOSE = 1 ]; then
echo "removing $DEVDIR!"
fi
$rootrun rm -f * $rootrun rm -f *
cd .. cd ..
$rootrun rmdir tikz-trackschematic-dev $rootrun rmdir tikz-trackschematic-dev
# update TeX Live installation # update TeX Live installation
TEXlsr=`which mktexlsr` TEXlsr=`which mktexlsr`
if [ $VERBOSE = 1 ]; then if [ $VERBOSITY -ge 3 ]; then
$rootrun $TEXlsr $rootrun $TEXlsr
else else
$rootrun $TEXlsr --quiet $rootrun $TEXlsr --quiet
@ -787,9 +711,7 @@ cleanup() {
fi fi
## ##
if [ $VERBOSE = 1 ]; then log_note "Clean up done!"
echo "Clean up done!"
fi
fi fi
} }

View File

@ -29,8 +29,9 @@
\usetikzlibrary{trackschematic-dev.symbology}% \usetikzlibrary{trackschematic-dev.symbology}%
\usetikzlibrary{trackschematic-dev}% \usetikzlibrary{trackschematic-dev}%
}{% }{%
\PackageWarning{tikz-trackschematic}{development mode not available}{execute the dev-install.sh script provided by the package repository}% \PackageWarning{tikz-trackschematic}{development mode not available}%
\PackageWarning{tikz-trackschematic}{development mode not available}{continuing in normal mode}% \PackageWarning{tikz-trackschematic}{execute the script './build.sh --install-dev' provided by the package repository}%
\PackageWarning{tikz-trackschematic}{continuing in normal mode}%
\usetikzlibrary{trackschematic.topology}% \usetikzlibrary{trackschematic.topology}%
\usetikzlibrary{trackschematic.trafficcontrol}% \usetikzlibrary{trackschematic.trafficcontrol}%
\usetikzlibrary{trackschematic.vehicles}% \usetikzlibrary{trackschematic.vehicles}%