2022-03-07 01:20:18 +01:00
#!/usr/bin/env sh
# Copyright (c) 2018 - 2022, Martin Scheidt (ISC license)
# Permission to use, copy, modify, and/or distribute this file for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
#
# Variables in upper case, e.g.: $VARIABLE
# Functions in lower case as action with underscore, e.g.: do_something
#
# Halt on error
set -e
## -- print usage
print_usage( ) {
cat << EOF
Usage: ./build.sh [ OPTIONS]
install, test or release a package for tikz-trackschematic
2022-03-10 15:26:50 +01:00
-h, --help Display this help message.
-s, --silent Run script in silent mode.
The -s option overrides any previous -v or -d options.
2022-03-07 01:20:18 +01:00
-v, --verbose Run script in verbose mode.
2022-03-10 15:26:50 +01:00
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.
2022-03-07 01:20:18 +01:00
2022-03-09 13:09:03 +01:00
-m, --messy Do not clean up afterwards.
2022-03-10 15:41:17 +01:00
-n, --non-interactive Run script with no interaction.
2022-03-07 01:20:18 +01:00
2022-03-10 15:26:50 +01:00
-i, --install-dev Install as dev-package in local TeX Live environment.
The -i option overrides any previous -u option.
2022-03-09 18:01:10 +01:00
2022-03-10 15:26:50 +01:00
-u, --uninstall-dev Deinstall dev-package from local TeX Live environment.
The -u option overrides any previous -i option.
2022-03-07 01:20:18 +01:00
2022-03-24 14:58:28 +01:00
-x, --memory-increase Increase available TeX memory.
2022-03-10 15:26:50 +01:00
-t, --test Tests the current src/ against the test/.
2022-03-07 01:20:18 +01:00
2022-03-22 18:27:29 +01:00
-c, --compile-doc Compile documentation sources.
-y, --compile-symbology Compile symbology sources.
2022-03-10 15:26:50 +01:00
-r, --release VERSION Creates a .zip with the release for given VERSION in
2022-03-07 01:20:18 +01:00
Semantic Versioning with leading 'v' , e.g: v1.0.0
2022-04-05 14:28:09 +02:00
-z, --update-cite DOI Updates the CITATION.cff with the current version in
CHANGELOG.md and a given DOI
2022-03-07 01:20:18 +01:00
EOF
}
## -- processes getopts
2022-03-10 15:26:50 +01:00
VERBOSITY = 2 # set by cli argument
2022-03-09 16:40:25 +01:00
NOINTERACT = 0 # set by cli argument
INSTALL = 0 # set by cli argument
2022-03-24 14:58:28 +01:00
TEXMEMORY = 0 # set by cli argument
2022-03-09 16:40:25 +01:00
TESTING = 0 # set by cli argument
2022-03-22 18:27:29 +01:00
COMPILE = 0 # set by cli argument
SYMBOLOGY = 0 # set by cli argument
2022-03-09 16:40:25 +01:00
RELEASE = 0 # set by cli argument
2022-04-05 14:28:09 +02:00
CITATION = 0 # set by cli argument
2022-03-09 16:40:25 +01:00
CLEANUP = 1 # set by cli argument
2022-03-07 01:20:18 +01:00
process_arguments( ) {
while true; do
2022-03-07 11:13:49 +01:00
# loop condition - test for empty string:
2022-03-10 15:41:17 +01:00
if [ -z " $1 " ] ; then break; fi
2022-03-07 11:13:49 +01:00
# loop test
2022-03-07 01:20:18 +01:00
case $1 in
-h| --help)
print_usage
exit 0
; ;
2022-03-10 15:26:50 +01:00
-s| --silent)
VERBOSITY = 0
; ;
2022-03-07 01:20:18 +01:00
-v| --verbose)
2022-03-10 15:26:50 +01:00
VERBOSITY = 3
; ;
-d| --debug)
VERBOSITY = 4
2022-03-07 01:20:18 +01:00
; ;
2022-03-09 13:09:03 +01:00
-m| --messy)
CLEANUP = 0
; ;
2022-03-10 15:41:17 +01:00
-n| --non-interactive)
2022-03-09 16:40:25 +01:00
NOINTERACT = 1
; ;
2022-03-09 13:46:47 +01:00
-i| --install-dev)
2022-03-07 01:20:18 +01:00
INSTALL = 1
; ;
2022-03-09 18:01:10 +01:00
-u| --uninstall-dev)
INSTALL = 2
; ;
2022-03-24 14:58:28 +01:00
-x| --memory-increase)
TEXMEMORY = 1
; ;
2022-03-07 01:20:18 +01:00
-t| --test)
TESTING = 1
; ;
2022-03-22 18:27:29 +01:00
-c| --compile-doc)
COMPILE = 1
; ;
-y| --compile-symbology)
SYMBOLOGY = 1
; ;
2022-03-07 01:20:18 +01:00
-r| --release)
RELEASE = 1
shift
2022-03-29 14:33:03 +02:00
if [ -z " $1 " ] || [ " `echo $1 | cut -c1-1` " = "-" ] ; then
2022-03-07 11:39:28 +01:00
print_usage
exit 1
fi
2022-03-07 01:20:18 +01:00
VERSION_STR = $1
; ;
2022-04-05 14:28:09 +02:00
-z| --update-cite)
CITATION = 1
shift
if [ -z " $1 " ] || [ " `echo $1 | cut -c1-1` " = "-" ] ; then
print_usage
exit 1
fi
DOI = $1
; ;
2022-03-07 01:20:18 +01:00
*)
print_usage
exit 1
; ;
esac
shift
done
}
2022-03-09 13:09:03 +01:00
## -- run variables
#
2022-03-09 13:17:43 +01:00
PDFTOPPM_CONVERT = 0 # set by check_pdftoppm
POLICY_MOD = 0 # set by check_imagemagick_policy
2022-03-09 13:09:03 +01:00
#
ERROR_OCCURRED = 0
2022-03-10 15:26:50 +01:00
## -- logging functions
## colors
2022-03-07 01:20:18 +01:00
RED = "\033[0;31m"
GREEN = "\033[0;32m"
2022-03-10 15:26:50 +01:00
YELLOW = "\033[0;33m"
2022-03-07 01:20:18 +01:00
COLOR_RESET = "\033[0;m"
2022-03-10 15:26:50 +01:00
## cross platform echo option
2022-03-07 13:49:44 +01:00
if [ "`echo -n`" = "-n" ] ; then
2022-03-07 01:20:18 +01:00
n = "" ; c = "\c"
else
n = "-n" ; c = ""
fi
2022-03-10 15:26:50 +01:00
log( ) {
NO_LINE_BREAK = 0
2022-03-11 11:04:36 +01:00
case $2 in
-n) NO_LINE_BREAK = 1; ;
esac
2022-03-11 10:55:21 +01:00
2022-03-11 11:04:36 +01:00
COLOR = ${ COLOR_RESET }
2022-03-11 10:55:21 +01:00
case $1 in
1) COLOR = ${ RED } ; ;
2) COLOR = ${ GREEN } ; ;
4) COLOR = ${ YELLOW } ; ;
esac
2022-03-10 15:26:50 +01:00
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
2022-03-07 01:20:18 +01:00
}
2022-03-10 15:26:50 +01:00
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
2022-03-07 01:20:18 +01:00
2022-03-11 10:51:26 +01:00
## -- 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
}
2022-03-07 01:20:18 +01:00
## -- commands
check_path( ) {
2022-03-09 18:32:29 +01:00
# test for project specific files
STATUS = 0
2022-03-09 22:29:53 +01:00
set -- doc/tikz-trackschematic-documentation.sty src/tikz-trackschematic.sty test/turnout.tex
for FILE in " $@ " ; do
2022-03-09 18:32:29 +01:00
if [ ! -e $FILE ] ; then
STATUS = 1
fi
done
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note "Build script is within the project folder."
2022-03-09 18:32:29 +01:00
return 0
2022-03-07 01:20:18 +01:00
fi
2022-03-09 18:32:29 +01:00
2022-03-10 15:26:50 +01:00
log_error "Please run this script from inside the project folder!"
2022-03-09 18:32:29 +01:00
exit 1
2022-03-07 01:20:18 +01:00
}
2022-03-09 13:43:36 +01:00
## checks for installed software
2022-03-10 15:26:50 +01:00
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 "" " $@ "
}
2022-03-07 01:20:18 +01:00
check_zip( ) {
# check for zip
STATUS = 0
command -v zip >/dev/null 2>& 1 || STATUS = 1
2022-03-07 13:49:44 +01:00
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note "zip found"
2022-03-07 01:20:18 +01:00
return 0
fi
2022-03-10 15:26:50 +01:00
log_error "Program 'zip' not found. Be sure to have zip installed!"
2022-03-07 01:20:18 +01:00
exit 1
}
2022-03-09 13:43:36 +01:00
check_sudo( ) {
# checks if sudo is available
2022-03-10 15:26:50 +01:00
STATUS = 0
2022-03-09 13:43:36 +01:00
rootrun = ""
# If we are root, we do note require sudo
if [ " $EUID " = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note "you are root"
2022-03-09 13:43:36 +01:00
return 0
fi
2022-03-10 15:26:50 +01:00
command -v sudo >/dev/null 2>& 1 || STATUS = 1
if [ $STATUS = 0 ] ; then
log_note "sudo found"
2022-03-09 13:43:36 +01:00
rootrun = "sudo"
2022-03-10 15:26:50 +01:00
return 0
2022-03-09 13:43:36 +01:00
else
2022-03-10 15:26:50 +01:00
log_debug "sudo failed."
2022-03-09 13:43:36 +01:00
fi
2022-03-10 15:26:50 +01:00
log_error "This script must be run as root!"
exit 1
2022-03-09 13:43:36 +01:00
}
check_texlive( ) {
# check for kpsewhich (and mktexlsr)
STATUS = 0
command -v kpsewhich >/dev/null 2>& 1 || STATUS = 1
command -v mktexlsr >/dev/null 2>& 1 || STATUS = 1
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note "kpsewhich and mktexlsr found"
2022-03-09 13:43:36 +01:00
TEXMFLOCAL = $( kpsewhich --var-value TEXMFLOCAL)
return 0
fi
2022-03-10 15:26:50 +01:00
log_error "Program 'kpsewhich' or 'mktexlsr' not found. Be sure to use texlive or mactex!"
2022-03-09 13:43:36 +01:00
exit 1
}
2022-03-22 18:27:29 +01:00
check_latexmk( ) {
# check for latexmk
STATUS = 0
command -v latexmk >/dev/null 2>& 1 || STATUS = 1
if [ $STATUS = 0 ] ; then
log_note "latexmk found"
return 0
fi
log_error "Program 'latexmk' not found. Be sure to have texlive or mactex installed!"
exit 1
}
2022-03-09 13:43:36 +01:00
check_pdflatex( ) {
# check for pdflatex
STATUS = 0
command -v pdflatex >/dev/null 2>& 1 || STATUS = 1
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note "pdflatex found"
2022-03-09 13:43:36 +01:00
return 0
fi
2022-03-10 15:26:50 +01:00
log_error "Program 'pdflatex' not found. Be sure to have texlive or mactex installed!"
2022-03-09 13:43:36 +01:00
exit 1
}
check_imagemagick( ) {
# check for ImageMagick/compare
STATUS = 0
command -v compare >/dev/null 2>& 1 || STATUS = 1
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note "compare found"
2022-03-09 13:43:36 +01:00
return 0
fi
2022-03-10 15:26:50 +01:00
log_error "Program 'compare' not found. Be sure to have ImageMagick installed!"
2022-03-09 13:43:36 +01:00
exit 1
}
check_pdftoppm( ) {
# check for poppler/pdftoppm
STATUS = 0
command -v pdftoppm >/dev/null 2>& 1 || STATUS = 1
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note "pdftoppm found"
2022-03-09 13:43:36 +01:00
PDFTOPPM_CONVERT = 1
return 0
fi
2022-03-11 10:51:26 +01:00
log_note "Program 'pdftoppm' not found."
2022-03-10 15:26:50 +01:00
# no # exit 1 ## can still modify ImageMagick policy!
2022-03-09 13:43:36 +01:00
}
2022-03-22 18:27:29 +01:00
check_pdf2svg( ) {
2022-03-24 22:18:50 +01:00
# check for pdf2svg
2022-03-22 18:27:29 +01:00
STATUS = 0
command -v pdf2svg >/dev/null 2>& 1 || STATUS = 1
if [ $STATUS = 0 ] ; then
log_note "pdf2svg found"
2022-03-24 22:18:50 +01:00
svg_convert = "pdf2svg"
return 0
fi
# check for poppler/pdftocairo
STATUS = 0
command -v pdftocairo >/dev/null 2>& 1 || STATUS = 1
if [ $STATUS = 0 ] ; then
log_note "pdftocairo found"
svg_convert = "pdftocairo -svg"
2022-03-22 18:27:29 +01:00
return 0
fi
2022-03-24 22:18:50 +01:00
log_note "Program 'pdf2svg' or 'pdftocairo' not found."
2022-03-22 18:27:29 +01:00
exit 1
}
2022-03-09 13:43:36 +01:00
check_imagemagick_policy( ) {
STATUS = 1
2022-03-09 14:25:20 +01:00
convert -list policy | grep -q "pattern: PDF" || STATUS = 0
2022-03-09 13:43:36 +01:00
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note "ImageMagick allows to convert PDFs. Great!"
2022-03-09 13:43:36 +01:00
return 0
else
2022-03-10 15:26:50 +01:00
log_note "ImageMagick does not allow to convert PDFs."
2022-03-09 13:43:36 +01:00
## check for alternative
check_pdftoppm # if pdftoppm is available, then PDFTOPPM_CONVERT=1
if [ $PDFTOPPM_CONVERT = 0 ] ; then
## modify ImageMagick-6/policy.xml
2022-03-11 10:51:26 +01:00
user_confirmation " Be sure to have either poppler(-utils) installed or an ImageMagick \
policy which allows for PDF conversion! Do you wish to temporaly remove \
the policy preventing ImageMagick from converting PDFs?"
2022-03-09 14:38:54 +01:00
2022-03-09 13:43:36 +01:00
check_sudo
2022-03-09 14:38:54 +01:00
2022-03-09 16:22:18 +01:00
POLICY_PATH = $( convert -list policy | grep "Path" | awk "NR==1" | cut -d " " -f2) # default /etc/ImageMagick-*/policy.xml
2022-03-09 22:48:55 +01:00
if [ ! -e $POLICY_PATH ] ; then
2022-03-09 14:25:20 +01:00
VERSION = $( convert --version | grep "Version" | cut -d " " -f3 | cut -d "." -f1 )
POLICY_PATH = " /etc/ImageMagick- ${ VERSION } /policy.xml "
2022-03-09 22:48:55 +01:00
if [ ! -e $POLICY_PATH ] ; then
2022-03-10 15:26:50 +01:00
log_error " ImageMagick policy is preventing converting PDFs to PNGs and program \
'pdftoppm' was not found. Modifying the policy temporaly failed! Be sure \
to have either poppler( -utils) installed or an ImageMagick policy which \
allows for PDF conversion!"
2022-03-09 14:25:20 +01:00
exit 1
fi
fi
2022-03-09 14:53:39 +01:00
2022-03-09 13:43:36 +01:00
POLICY_MOD = 1
$rootrun sed -i".backup" 's/^.*policy.*coder.*none.*PDF.*//' $POLICY_PATH
2022-03-10 15:26:50 +01:00
log_note " Modified ${ POLICY_PATH } ! "
2022-03-09 13:43:36 +01:00
fi
fi
}
check_trackschematic( ) {
# check for tikz-trackschematic
STATUS = 0
TEXMFLOCAL = $( kpsewhich --var-value TEXMFLOCAL)
2022-03-09 18:01:10 +01:00
DEVDIR = $( find $TEXMFLOCAL -name 'tikz-trackschematic-dev' )
2022-03-09 13:43:36 +01:00
2022-03-09 18:01:10 +01:00
ls $DEVDIR /tikz-trackschematic-dev.sty >> /dev/null 2>& 1 || STATUS = 1
2022-03-09 13:43:36 +01:00
if [ $STATUS = 0 ] ; then
2022-03-11 11:31:08 +01:00
log_note "Package tikz-trackschematic-dev found."
2022-03-09 13:43:36 +01:00
return 0
fi
2022-03-11 11:31:08 +01:00
log_note "Package 'tikz-trackschematic-dev' not found - using project src/."
2022-03-22 18:27:29 +01:00
export TEXINPUTS = .:$( pwd ) /src/:$TEXINPUTS
2022-03-09 13:43:36 +01:00
}
## checks for updated repository
2022-03-07 01:20:18 +01:00
check_version_number( ) {
2022-03-07 11:13:49 +01:00
while true; do
# loop condition - test format of $VERSION_STR:
echo " $VERSION_STR " | egrep -q "v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)?" && break;
# loop test
2022-03-09 16:40:25 +01:00
if [ $NOINTERACT = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_error " Your version ' $VERSION_STR ' has not the correct format! "
log_show -n "Please specify as Semantic Versioning ( e.g. v1.0.0 ): "
2022-03-07 01:20:18 +01:00
read VERSION_STR
else
2022-03-10 15:26:50 +01:00
log_error " Your version ' $VERSION_STR ' has not the correct format! \
Please use Semantic Versioning with leading 'v' "
2022-03-07 01:20:18 +01:00
exit 1
fi
done
# remove leading 'v'
VERSION_NUM = $( echo $VERSION_STR | cut -c 2-)
}
check_versionhistory( ) {
# check if $VERSION is present in doc/versionhistory.tex
STATUS = 0
grep -qs " vhEntry{ $VERSION_NUM " doc/versionhistory.tex || STATUS = 1
2022-03-07 13:49:44 +01:00
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note " Version $VERSION_NUM is present in versionhistory.tex. "
2022-03-07 01:20:18 +01:00
return 0
fi
2022-03-10 15:26:50 +01:00
log_error " Version $VERSION_NUM not found in versionhistory.tex. \
Be sure to edit versionhistory.tex and specify current version!"
2022-03-07 01:20:18 +01:00
exit 1
}
check_changelog( ) {
# check if $VERSION is present in CHANGELOG.md
STATUS = 0
grep -qs " Version \[ $VERSION_NUM \] " CHANGELOG.md || STATUS = 1
2022-03-07 13:49:44 +01:00
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note " Version $VERSION_NUM is present in CHANGELOG.md. "
2022-03-07 01:20:18 +01:00
return 0
fi
2022-03-10 15:26:50 +01:00
log_error " Version $VERSION_NUM not found in CHANGELOG.md. \
Be sure to edit CHANGELOG.md and specify current version!"
2022-03-07 01:20:18 +01:00
exit 1
}
check_date( ) {
2022-04-04 11:01:51 +02:00
## extract DATE from versionhistory.tex, CHANGELOG.md, and CITATION.cff
# fallback: DATE=$(date "+%Y-%m-%d")
#
STATUS = 0
#
2022-03-07 01:20:18 +01:00
LINE_1 = $( grep " vhEntry{ $VERSION_NUM " doc/versionhistory.tex)
LINE_2 = $( grep " Version \[ $VERSION_NUM \] " CHANGELOG.md)
2022-04-05 14:28:09 +02:00
# LINE_3=$(grep "date-released:" CITATION.cff)
2022-03-07 01:20:18 +01:00
DATEISO_1 = $( echo $LINE_1 | egrep -o '[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])' )
DATEISO_2 = $( echo $LINE_2 | egrep -o '[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])' )
2022-04-05 14:28:09 +02:00
# DATEISO_3=$(echo $LINE_3 | egrep -o '[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])')
2022-04-04 11:01:51 +02:00
if [ $DATEISO_1 != $DATEISO_2 ] ; then
STATUS = 1
fi
2022-04-05 14:28:09 +02:00
# if [ $DATEISO_1 != $DATEISO_3 ]; then
# STATUS=1
# fi
2022-03-07 01:20:18 +01:00
2022-04-04 11:01:51 +02:00
if [ $STATUS = 0 ] ; then
2022-03-07 01:20:18 +01:00
DATE = " $DATEISO_1 "
2022-03-10 15:26:50 +01:00
log_note " The date $DATE was extracted from versionhistory.tex and CHANGELOG.md. "
2022-03-07 01:20:18 +01:00
return 0
fi
2022-04-04 11:01:51 +02:00
log_error " The date in versionhistory.tex, CHANGELOG.md, and CITATION.cff did not match.\
Be sure to edit versionhistory.tex, CHANGELOG.md, or CITATION.cff and modifiy the date!"
2022-03-07 01:20:18 +01:00
exit 1
}
2022-04-04 11:01:51 +02:00
check_changelog_url1( ) {
2022-03-07 01:20:18 +01:00
## extract urls from CHANGELOG.md
STATUS = 0
LINE = $( grep " \[ $VERSION_NUM \]: https:// " CHANGELOG.md)
echo $LINE | grep -qs " ... $VERSION_STR " || STATUS = 1
2022-03-07 13:49:44 +01:00
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note " Version $VERSION_NUM URL is present in CHANGELOG.md. "
2022-03-07 01:20:18 +01:00
return 0
fi
2022-03-10 15:26:50 +01:00
log_error " Version $VERSION_NUM URL was not found in CHANGELOG.md. \
Be sure to edit CHANGELOG.md and specify a URL for the current version!"
2022-03-07 01:20:18 +01:00
exit 1
}
2022-04-04 11:01:51 +02:00
check_changelog_url2( ) {
2022-03-07 01:20:18 +01:00
## extract urls from CHANGELOG.md
STATUS = 0
LINE = $( grep "\[Unreleased\]: https://" CHANGELOG.md)
echo $LINE | grep -qs " / $VERSION_STR ... " || STATUS = 1
2022-03-07 13:49:44 +01:00
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_note "The URL for [Unreleased] was also updated in CHANGELOG.md! Thx!"
2022-03-07 01:20:18 +01:00
return 0
fi
2022-03-10 15:26:50 +01:00
log_show " WARNING: URL for [Unreleased] in CHANGELOG.md does not reflect the current version $VERSION_NUM . "
log_show "WARNING: Be sure to edit CHANGELOG.md and specify current version!"
2022-03-11 10:51:26 +01:00
user_confirmation "Do you wish to continue without updated URL for [Unreleased]?"
2022-03-07 01:20:18 +01:00
2022-03-11 10:51:26 +01:00
if [ $NOINTERACT = 1 ] ; then
2022-03-10 15:26:50 +01:00
log_error "Aborting in batch mode!"
2022-03-07 01:20:18 +01:00
exit 1
fi
}
2022-03-09 13:43:36 +01:00
## functionality
2022-03-07 01:20:18 +01:00
create_release( ) {
2022-03-09 13:09:03 +01:00
####
# This function produces a .zip-file in accordance to the requirements for CTAN.
# For more information see https://ctan.org/help/upload-pkg.
####
2022-03-11 10:51:26 +01:00
user_confirmation " Do you wish to create a release for the version $VERSION_NUM ? "
2022-03-07 01:20:18 +01:00
## create backup-file und update VERSIONDATE in tikz-trackschematic.sty
sed -i".backup" -e" s/%\[VERSIONDATE/\[ $DATE $VERSION_STR /g " src/tikz-trackschematic.sty
sedi "/%%\[SCRIPT\]/d" src/tikz-trackschematic.sty
2022-03-10 15:26:50 +01:00
log_note "Updated version in src/tikz-trackschematic.sty"
2022-03-07 01:20:18 +01:00
## -- create zip-archive
# create temporary folder
2022-03-08 14:42:27 +01:00
TMP = " tikz-trackschematic- $VERSION_STR "
2022-03-07 01:20:18 +01:00
mkdir -p $TMP
# copy README, CHANGELOG, LICENSE and CITATION
cp README.md $TMP /README.md
cp CHANGELOG.md $TMP /CHANGELOG.md
cp LICENSE $TMP /LICENSE
cp CITATION.cff $TMP /CITATION.cff
# copy and rename documentation
cp doc/tikz-trackschematic-documentation.sty $TMP /
cp doc/manual.pdf $TMP /tikz-trackschematic.pdf
cp doc/manual.tex $TMP /tikz-trackschematic.tex
cp doc/snippets.pdf $TMP /tikz-trackschematic-snippets.pdf
cp doc/snippets.tex $TMP /tikz-trackschematic-snippets.tex
cp doc/symbology-table.pdf $TMP /tikz-trackschematic-symbology-table.pdf
cp doc/symbology-table.tex $TMP /tikz-trackschematic-symbology-table.tex
mkdir $TMP /tikz-trackschematic-examples
mkdir $TMP /tikz-trackschematic-snippets
cp -R doc/examples/* $TMP /tikz-trackschematic-examples/
cp -R doc/snippets/* $TMP /tikz-trackschematic-snippets/
2022-03-10 15:26:50 +01:00
log_note "copied documentation"
2022-03-07 01:20:18 +01:00
# copy src-files
for SRC in src/*; do
EXT = ${ SRC ##*. }
# do not copy backup created by sed
if [ $EXT != "backup" ] ; then
cp $SRC $TMP /
fi
done
2022-03-10 15:26:50 +01:00
log_note "copied src-files"
2022-03-07 01:20:18 +01:00
# zip package
2022-03-10 15:26:50 +01:00
zip -r $TMP .zip $TMP /* >/dev/null 2>& 1
log_note " compressed the release in $TMP .zip "
2022-03-07 01:20:18 +01:00
}
create_release_notes( ) {
2022-03-11 10:51:26 +01:00
user_confirmation " Do you wish to create a release notes for the version $VERSION_NUM ? "
2022-03-07 01:20:18 +01:00
## -- create release note as excerpt from CHANGELOG.md
# determine beginning and end in CHANGELOG.md
TOP = $( grep -n " Version \[ $VERSION_NUM \] " CHANGELOG.md | cut -d: -f1)
2022-03-29 23:55:43 +02:00
awk " NR> $TOP " CHANGELOG.md > release-note.tmp.md
2022-04-15 13:39:43 +02:00
BOTTOM = $( grep -n -m 1 "## Version\|[Unreleased]:" release-note.tmp.md | cut -d: -f1)
2022-03-07 01:20:18 +01:00
BOTTOM = $(( $TOP + $BOTTOM ))
BOTTOM = $(( $BOTTOM - 2 ))
TOP = $(( $TOP + 1 ))
# extract the excerpt
awk " NR> $TOP &&NR< $BOTTOM " CHANGELOG.md > release-note-$VERSION_STR .md
sedi "s/###/##/g" release-note-$VERSION_STR .md
}
2022-03-29 23:55:43 +02:00
create_ctan_configuration( ) {
# modify the file .github/tex/tikz-trackschematic.pkg for ctan-o-mat
# 1. replace \version{}%%[SCRIPT]
sed -i".backup" -e" s/version{}%%\[SCRIPT\]/version{ $DATE $VERSION_STR }/g " .github/tex/tikz-trackschematic.pkg
# 2. replace \file{}%%[SCRIPT]
sedi " s/file{}%%\[SCRIPT\]/file{tikz-trackschematic- $VERSION_STR .zip}/g " .github/tex/tikz-trackschematic.pkg
# 3. replace %RELEASE-NOTES%%[SCRIPT]
awk '/%RELEASE-NOTES%%\[SCRIPT\]/{system("cat release-note-*.md");next}1' .github/tex/tikz-trackschematic.pkg > .github/tex/tikz-trackschematic.tmp.pkg
mv .github/tex/tikz-trackschematic.tmp.pkg .github/tex/tikz-trackschematic.pkg
}
2022-04-01 21:36:25 +02:00
create_zenodo_metadata( ) {
# modify the file .github/zenodo/metadata.json for zenodo upload
# 1. replace "version": "%%[SCRIPT]"
2022-04-15 14:58:42 +02:00
sed -i".backup" -e" s/\"version\": \"%%\[SCRIPT\]\"/\"version\": \" $VERSION_NUM \"/g " .github/zenodo/metadata.json
2022-04-01 21:36:25 +02:00
# 2. replace "publication_date": "%%[SCRIPT]"
2022-04-05 14:28:09 +02:00
sedi " s/\"publication_date\": \"%%\[SCRIPT\]\"/\"publication_date\": \" $DATE \"/g " .github/zenodo/metadata.json
2022-04-01 21:36:25 +02:00
}
2022-03-22 19:09:33 +01:00
run_compile_documentation( ) {
2022-03-22 18:27:29 +01:00
## compile order
# 1. manual, symbology-table, snippets
# 2. examples
# 3. symbology
cd doc/
mkdir -p .tex
log_debug "entered documentation dir"
## 1. main documentation
set -- manual symbology-table snippets
for NAME in " $@ " ; do
log_info -n " compiling $NAME : "
#
## TeX build
EXIT_CODE = 0
/usr/bin/time -p -o .tex/${ NAME } .time \
latexmk -pdf -f -g -emulate-aux-dir -auxdir= .tex -outdir= .tex $NAME .tex >> /dev/null 2>& 1 || EXIT_CODE = 1
#
TIME = $( awk "NR==2" .tex/${ NAME } .time | cut -d " " -f2)
# understanding TeX statistics:
# -> https://tex.stackexchange.com/questions/26208/components-of-latexs-memory-usage
MEMORY_USAGE = $( grep "words of memory out of" .tex/${ NAME } .log | cut -d " " -f2)
MEMORY_USAGE = $(( $MEMORY_USAGE / 1000 ))
#
if [ $EXIT_CODE = 0 ] ; then
log_info " - build successful in ${ TIME } s and with ${ MEMORY_USAGE } k memory. "
#
mv .tex/$NAME .pdf $NAME .pdf
log_debug " copied $NAME to doc/ "
else
ERROR_OCCURRED = 1
log_error " - build failed."
fi
done
## 2. examples
cd examples/
mkdir -p .tex
EXAMPLEDIR = "../examples"
for EXAMPLE in ` ls $EXAMPLEDIR /*.tex` ; do
FILE = $( basename " $EXAMPLE " ) # remove path
NAME = ${ FILE %.* } # remove extension
#
log_info -n " compiling $FILE : "
#
## TeX build
EXIT_CODE = 0
/usr/bin/time -p -o .tex/${ NAME } .time \
latexmk -pdf -f -g -emulate-aux-dir -auxdir= .tex -outdir= .tex $NAME .tex >> /dev/null 2>& 1 || EXIT_CODE = 1
#
TIME = $( awk "NR==2" .tex/${ NAME } .time | cut -d " " -f2)
# understanding TeX statistics:
# -> https://tex.stackexchange.com/questions/26208/components-of-latexs-memory-usage
MEMORY_USAGE = $( grep "words of memory out of" .tex/${ NAME } .log | cut -d " " -f2)
MEMORY_USAGE = $(( $MEMORY_USAGE / 1000 ))
#
if [ $EXIT_CODE = 0 ] ; then
log_info " - build successful in ${ TIME } s and with ${ MEMORY_USAGE } k memory. "
#
mv .tex/$NAME .pdf $NAME .pdf
log_debug " copied $NAME to doc/examples/ "
#
if [ $PDFTOPPM_CONVERT = 0 ] ; then
# 'compare' will convert the pdf to png
# -> this reasonably fast!
convert -density 300 ${ NAME } .pdf ${ NAME } .png >> /dev/null 2>& 1
else
# use 'pdftoppm' convert the pdf to png
# -> this is slower!
pdftoppm -png -r 300 -singlefile ${ NAME } .pdf ${ NAME } .png
fi
log_debug " converted $NAME .pdf to PNG "
else
ERROR_OCCURRED = 1
log_error " - build failed."
fi
done
cd ..
## 3. symbology
cd ..
}
2022-03-22 19:09:33 +01:00
run_compile_symbology( ) {
2022-03-22 18:27:29 +01:00
cd doc/symbology/
mkdir -p .tex
for FILE in symbols_tikz/*.tikz; do
SYMBOL = $( basename $FILE .tikz)
log_note " converting: $SYMBOL "
## -- header tex file
echo '\\documentclass[tikz,border=0]{standalone}' > tmp.tex
echo '\\usepackage[dev]{tikz-trackschematic}' >> tmp.tex
echo '\\begin{document}' >> tmp.tex
echo '\\begin{tikzpicture}[font=\\sffamily]' >> tmp.tex
## -- input symbol
echo '\\input{' $FILE '}' >> tmp.tex
## -- footer tex file
echo '\\end{tikzpicture}' >> tmp.tex
echo '\\end{document}' >> tmp.tex
# echo "---------------"
# cat tmp.tex
# echo "---------------"
## -- compile tmp.tex
# pdflatex -output-directory=.tex tmp.tex
pdflatex -output-directory= .tex -interaction= batchmode tmp.tex 2>& 1 > /dev/null
## -- copy and convert symbols
2022-03-24 22:18:50 +01:00
## SVG
$svg_convert .tex/tmp.pdf symbols_svg/$SYMBOL .svg
#
## PNG
2022-03-22 18:27:29 +01:00
if [ $PDFTOPPM_CONVERT = 0 ] ; then
# 'compare' will convert the pdf to png
# -> this reasonably fast!
convert -density 600 .tex/tmp.pdf symbols_png/$SYMBOL .png >> /dev/null 2>& 1
else
# use 'pdftoppm' convert the pdf to png
# -> this is slower!
pdftoppm -png -r 600 -singlefile .tex/tmp.pdf symbols_png/$SYMBOL .png
fi
#
mv .tex/tmp.pdf symbols_pdf/$SYMBOL .pdf
done
cd ../..
}
2022-03-07 01:20:18 +01:00
run_test_cases( ) {
cd test/
TESTDIR = "../test"
mkdir -p .tex
STATUS = 0
# Start with an empty List:
FAILED = ""
for TEST in ` ls $TESTDIR /*.tex` ; do
# setup
FILE = $( basename " $TEST " ) # remove path
NAME = ${ FILE %.* } # remove extension
ADD_TO_LIST = 0
#
2022-03-10 15:26:50 +01:00
log_info " $NAME test: "
2022-03-07 01:20:18 +01:00
#
#
## TeX build
#
2022-03-07 13:44:34 +01:00
EXIT_CODE = 0
/usr/bin/time -p -o .tex/${ NAME } .time \
2022-03-09 16:40:25 +01:00
pdflatex -output-directory= .tex -interaction= NOINTERACT -halt-on-error ${ NAME } .tex >> /dev/null 2>& 1 || EXIT_CODE = 1
2022-03-07 13:44:34 +01:00
#
TIME = $( awk "NR==2" .tex/${ NAME } .time | cut -d " " -f2)
2022-03-07 01:20:18 +01:00
# understanding TeX statistics:
# -> https://tex.stackexchange.com/questions/26208/components-of-latexs-memory-usage
2022-03-07 13:44:34 +01:00
MEMORY_USAGE = $( grep "words of memory out of" .tex/${ NAME } .log | cut -d " " -f2)
MEMORY_USAGE = $(( $MEMORY_USAGE / 1000 ))
2022-03-07 13:49:44 +01:00
#
if [ $EXIT_CODE = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_info " - build successful in ${ TIME } s and with ${ MEMORY_USAGE } k memory. "
2022-03-07 01:20:18 +01:00
else
STATUS = 1
ADD_TO_LIST = 1
2022-03-10 15:26:50 +01:00
log_error " - build failed."
2022-03-07 01:20:18 +01:00
fi
#
#
## compare images with following compare metrics
# AE: absolute error count, number of different pixels (-fuzz affected)
# DSSIM: structural dissimilarity index
# FUZZ: mean color distance
# MAE: mean absolute error (normalized), average channel error distance
# MEPP: mean error per pixel (normalized mean error, normalized peak error)
# MSE: mean error squared, average of the channel error squared
# NCC: normalized cross correlation
# PAE: peak absolute (normalized peak absolute)
# PHASH: perceptual hash for the sRGB and HCLp colorspaces.
# PSNR: peak signal to noise ratio
# RMSE: root mean squared (normalized root mean squared)
# SSIM: structural similarity index
#
EXIT_CODE = 0
2022-03-09 13:17:43 +01:00
if [ $PDFTOPPM_CONVERT = 0 ] ; then
# 'compare' will convert the pdf to png
2022-03-09 13:56:35 +01:00
# unless the policy of ImageMagick prevents it
2022-03-09 13:17:43 +01:00
# -> this reasonably fast!
compare -metric RMSE -colorspace RGB .tex/${ NAME } .pdf ${ NAME } _expected.pdf NULL: >> /dev/null 2>& 1 || EXIT_CODE = 1
else
# use 'pdftoppm' convert the pdf to png
# then use 'compare' for comparison without converting
# -> this is slower!
2022-03-09 23:02:53 +01:00
pdftoppm -png -r 144 -singlefile .tex/${ NAME } .pdf .tex/${ NAME }
pdftoppm -png -r 144 -singlefile ${ NAME } _expected.pdf .tex/${ NAME } _expected
compare -metric RMSE -colorspace RGB .tex/${ NAME } .png .tex/${ NAME } _expected.png NULL: >> /dev/null 2>& 1 || EXIT_CODE = 1
2022-03-09 13:17:43 +01:00
fi
2022-03-07 13:49:44 +01:00
if [ $EXIT_CODE = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_info " - comparison successful."
2022-03-07 01:20:18 +01:00
else
STATUS = 1
ADD_TO_LIST = 1
2022-03-10 15:26:50 +01:00
log_error " - comparison failed."
2022-03-07 01:20:18 +01:00
fi
## if a test failed add to list
2022-03-07 13:49:44 +01:00
if [ $ADD_TO_LIST = 1 ] ; then
2022-03-07 01:20:18 +01:00
if [ -z " $FAILED " ] ; then
# first item
FAILED = " $NAME "
else
FAILED = " $FAILED , $NAME "
fi
fi
done
2022-03-07 13:49:44 +01:00
if [ $STATUS = 0 ] ; then
2022-03-10 15:26:50 +01:00
log_info "\n=> All tests passed!\n"
2022-03-07 01:20:18 +01:00
else
2022-03-10 15:26:50 +01:00
log_error "\n=> Some or all tests failed!"
log_debug " The following tests failed: ${ FAILED } ! "
2022-03-08 14:42:27 +01:00
ERROR_OCCURRED = 1
2022-03-07 01:20:18 +01:00
fi
2022-03-08 14:42:27 +01:00
cd ..
2022-03-07 01:20:18 +01:00
}
link_dev_files( ) {
# destination folder inside the TeX Live installation
2022-03-09 18:01:10 +01:00
TEXMFLOCAL = $( kpsewhich --var-value TEXMFLOCAL)
DEVDIR = " $TEXMFLOCAL /tex/latex/tikz-trackschematic-dev "
2022-03-07 01:20:18 +01:00
PROJECTDIR = $( pwd -P)
2022-03-11 10:51:26 +01:00
user_confirmation " Do you wish to install this package for development to $DEVDIR ? "
2022-03-07 01:20:18 +01:00
# make sure that destination folder exists
2022-03-09 18:01:10 +01:00
if [ ! -d " $DEVDIR " ] ; then
$rootrun mkdir -p $DEVDIR
2022-03-07 01:20:18 +01:00
fi
# link every file in src/ and rename it
for SRC in src/*; do
FILE = $( basename " $SRC " ) # remove path
NAME = ${ FILE %.* } # remove extension
PREFIX = ${ NAME %%.* }
POSTFIX = ${ NAME #*. }
EXT = ${ SRC ##*. }
2022-03-07 13:49:44 +01:00
if [ " $PREFIX " = " $POSTFIX " ] ; then
2022-03-07 01:20:18 +01:00
DST = " $PREFIX -dev. $EXT "
else
DST = " $PREFIX -dev. $POSTFIX . $EXT "
fi
2022-03-09 18:01:10 +01:00
$rootrun ln -sfn $PROJECTDIR /$SRC $DEVDIR /$DST
2022-03-07 01:20:18 +01:00
2022-03-10 15:26:50 +01:00
if [ $VERBOSITY = 1 ] ; then
2022-03-07 01:20:18 +01:00
echo " linked ' $DST ' "
fi
done
# update TeX Live installation
TEXlsr = ` which mktexlsr`
2022-03-10 15:26:50 +01:00
if [ $VERBOSITY -ge 3 ] ; then
2022-03-07 01:20:18 +01:00
$rootrun $TEXlsr
else
$rootrun $TEXlsr --quiet
fi
}
2022-03-09 18:01:10 +01:00
remove_dev_files( ) {
# destination folder inside the TeX Live installation
cd $DEVDIR # from check_trackschematic
2022-03-11 10:51:26 +01:00
user_confirmation " Do you wish to remove the package ' $DEVDIR '? "
2022-03-10 15:26:50 +01:00
log_note " removing $DEVDIR ! "
2022-03-09 18:01:10 +01:00
$rootrun rm -f *
cd ..
$rootrun rmdir tikz-trackschematic-dev
# update TeX Live installation
TEXlsr = ` which mktexlsr`
2022-03-10 15:26:50 +01:00
if [ $VERBOSITY -ge 3 ] ; then
2022-03-09 18:01:10 +01:00
$rootrun $TEXlsr
else
$rootrun $TEXlsr --quiet
fi
}
2022-03-24 14:58:28 +01:00
change_tex_memory( ) {
## compiling snipptes.tex may run out of memory!
## to increase available memory find local texmf.cnf:
TEXMF_PATH = $( kpsewhich -a texmf.cnf | awk "NR==1" ) # default .../texlive/YYYY/texmf.cnf
log_note " Found local texmf.cnf at $TEXMF_PATH "
##
## check for already made changes
STATUS = 0
grep -qs '%% \[tikz-trackschematic\] increase available memory' $TEXMF_PATH || STATUS = 1
if [ $STATUS = 0 ] ; then
log_note " $TEXMF_PATH has already been modified! "
return 0
fi
##
user_confirmation " Do you wish to increase TeX memory by modifying the file $TEXMF_PATH ? "
## increase available memory
echo '%% [tikz-trackschematic] increase available memory' | $rootrun tee -a $TEXMF_PATH >> /dev/null 2>& 1
echo 'main_memory = 12000000' | $rootrun tee -a $TEXMF_PATH >> /dev/null 2>& 1
echo 'extra_mem_bot = 12000000' | $rootrun tee -a $TEXMF_PATH >> /dev/null 2>& 1
echo 'font_mem_size = 12000000' | $rootrun tee -a $TEXMF_PATH >> /dev/null 2>& 1
echo 'pool_size = 12000000' | $rootrun tee -a $TEXMF_PATH >> /dev/null 2>& 1
echo 'buf_size = 12000000' | $rootrun tee -a $TEXMF_PATH >> /dev/null 2>& 1
## update TeX Live installation
TEXlsr = ` which mktexlsr`
if [ $VERBOSITY -ge 3 ] ; then
$rootrun $TEXlsr
else
$rootrun $TEXlsr --quiet
fi
}
2022-04-05 14:28:09 +02:00
update_citation( ) {
## use CHANGELOG.md as source for $VERSION and $DATE
CHANGELOG_LINE = $( grep "Version \[" CHANGELOG.md | awk "NR==1" )
VERSION = $( echo $CHANGELOG_LINE | egrep -o '(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)?' )
DATE = $( echo $CHANGELOG_LINE | egrep -o '[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])' )
## check for already made changes
STATUS = 0
grep -qs " version: v $VERSION " CITATION.cff || STATUS = 1
if [ $STATUS = 0 ] ; then
log_note "CITATION.cff is already up to date!"
return 0
fi
## find lines in CITATION.cff
VERSION_LINE = $( grep -n 'version: v' CITATION.cff | cut -d: -f1)
DATE_LINE = $( grep -n 'date-released:' CITATION.cff | cut -d: -f1)
# select the second DOI
DOI_LINE = $( grep -n 'type: doi' CITATION.cff | cut -d: -f1 | awk "NR==2" )
DOI_LINE = $(( $DOI_LINE + 1 ))
## update CITATION.cff
sedi " ${ VERSION_LINE } s|.*|version: v ${ VERSION } | " CITATION.cff
sedi " ${ DATE_LINE } s|.*|date-released: ${ DATE } | " CITATION.cff
sedi " ${ DOI_LINE } s|.*| value: ${ DOI } | " CITATION.cff
}
2022-03-08 14:42:27 +01:00
cleanup( ) {
## -- cleanup
## from create_release
2022-03-09 13:09:03 +01:00
if [ $CLEANUP = 1 ] ; then
2022-03-29 23:55:43 +02:00
## from run_test_cases
if [ $TESTING = 1 ] ; then
2022-03-09 13:09:03 +01:00
# remove TMP-folder
2022-03-29 23:55:43 +02:00
rm -rf test/.tex
2022-03-09 13:09:03 +01:00
fi
2022-03-08 14:42:27 +01:00
2022-03-09 13:09:03 +01:00
## from check_imagemagick_policy
if [ $POLICY_MOD = 1 ] ; then
# undo changes to /etc/ImageMagick-6/policy.xml by sed
$rootrun mv ${ POLICY_PATH } .backup $POLICY_PATH
fi
2022-03-08 14:42:27 +01:00
2022-03-22 18:27:29 +01:00
## from run_compile
if [ $COMPILE = 1 ] ; then
# remove TMP-folder
rm -rf doc/examples/.tex
rm -rf doc/.tex
fi
## from run_symbology
if [ $SYMBOLOGY = 1 ] ; then
# remove TMP-folder
rm -rf doc/symbology/.tex/
rm doc/symbology/tmp.tex
fi
2022-03-29 23:55:43 +02:00
## from create_release(_notes)
if [ $RELEASE = 1 ] ; then
2022-03-09 13:09:03 +01:00
# remove TMP-folder
2022-03-29 23:55:43 +02:00
rm -rf $TMP
# undo changes to tikz-trackschematic.sty by sed
mv src/tikz-trackschematic.sty.backup src/tikz-trackschematic.sty
# remove TMP-release-note
rm release-note.tmp.md
# # undo changes to .github/tex/tikz-trackschematic.pkg by sed
# mv .github/tex/tikz-trackschematic.pkg.backup .github/tex/tikz-trackschematic.pkg
2022-04-01 21:36:25 +02:00
# # undo changes to .github/zenodo/metadata.json by sed
# mv .github/zenodo/metadata.json.backup .github/zenodo/metadata.json
2022-03-09 13:09:03 +01:00
fi
##
2022-03-10 15:26:50 +01:00
log_note "Clean up done!"
2022-03-08 14:42:27 +01:00
fi
}
2022-03-07 01:20:18 +01:00
## -- execution
## Process user arguments
process_arguments $@
2022-03-09 13:09:03 +01:00
check_path
2022-03-07 01:20:18 +01:00
## do what is requested
2022-03-07 13:49:44 +01:00
if [ $INSTALL = 1 ] ; then
2022-03-09 18:01:10 +01:00
## install package
2022-03-07 01:20:18 +01:00
check_texlive
check_sudo
##
link_dev_files
fi
2022-03-09 18:01:10 +01:00
if [ $INSTALL = 2 ] ; then
## deinstall package
check_texlive
check_trackschematic
check_sudo
##
remove_dev_files
fi
2022-03-24 14:58:28 +01:00
if [ $TEXMEMORY = 1 ] ; then
##
check_texlive
check_sudo
##
change_tex_memory
fi
2022-03-07 13:49:44 +01:00
if [ $TESTING = 1 ] ; then
2022-03-07 01:20:18 +01:00
##
check_pdflatex
check_trackschematic
check_imagemagick
2022-03-09 13:09:03 +01:00
check_imagemagick_policy
2022-03-07 01:20:18 +01:00
##
run_test_cases
fi
2022-03-22 18:27:29 +01:00
if [ $COMPILE = 1 ] ; then
##
check_latexmk
check_trackschematic
check_imagemagick
check_imagemagick_policy
##
2022-03-22 19:09:33 +01:00
run_compile_documentation
2022-03-22 18:27:29 +01:00
fi
if [ $SYMBOLOGY = 1 ] ; then
##
check_pdflatex
check_trackschematic
check_imagemagick
check_imagemagick_policy
check_pdf2svg
##
2022-03-22 19:09:33 +01:00
run_compile_symbology
2022-03-22 18:27:29 +01:00
fi
2022-03-07 13:49:44 +01:00
if [ $RELEASE = 1 ] ; then
2022-03-07 01:20:18 +01:00
## check if version ist in the correct format
check_version_number
2022-04-04 11:01:51 +02:00
## check if $VERSION is present in CHANGELOG.md, versionhistory.tex, and CITATION.cff
2022-03-07 01:20:18 +01:00
check_versionhistory
check_changelog
2022-04-04 11:01:51 +02:00
check_changelog_url1
check_changelog_url2
2022-03-07 01:20:18 +01:00
check_date
## check for installed software
check_zip
##
create_release
create_release_notes
2022-03-29 23:55:43 +02:00
create_ctan_configuration
2022-04-01 21:36:25 +02:00
create_zenodo_metadata
2022-03-07 01:20:18 +01:00
fi
2022-04-05 14:28:09 +02:00
if [ $CITATION = 1 ] ; then
##
update_citation
fi
2022-03-08 14:42:27 +01:00
##
cleanup
##
if [ $ERROR_OCCURRED = 0 ] ; then
exit 0
else
exit 1
fi
2022-03-07 01:20:18 +01:00
#EOF