ympd/mkrelease.sh

81 lines
1.9 KiB
Bash
Raw Normal View History

2019-01-24 05:11:31 +00:00
#!/bin/bash
2019-01-21 20:27:27 +00:00
JAVABIN=$(which java 2> /dev/null)
HASJAVA="$?"
2019-01-21 20:27:27 +00:00
function minify {
TYPE="$1"
SRC="$2"
DST="$3"
ERROR="1"
2018-07-11 00:01:04 +00:00
2019-01-21 20:51:24 +00:00
if [ "$DST" -nt "$SRC" ]
then
return
fi
2019-01-21 20:27:27 +00:00
2019-01-21 21:01:25 +00:00
if [ "$TYPE" = "html" ]
2019-01-21 20:27:27 +00:00
then
perl -pe 's/^\s*//gm; s/\s*$//gm' $SRC > $DST
ERROR="$?"
2019-01-24 05:11:31 +00:00
elif [ "$TYPE" = "js" ] && [ "$HASJAVA" = "0" ]
2019-01-21 20:27:27 +00:00
then
$JAVABIN -jar dist/buildtools/closure-compiler.jar $SRC > $DST
ERROR="$?"
2019-01-24 05:11:31 +00:00
elif [ "$TYPE" = "css" ] && [ "$HASJAVA" = "0" ]
2019-01-21 20:27:27 +00:00
then
$JAVABIN -jar dist/buildtools/closure-stylesheets.jar --allow-unrecognized-properties $SRC > $DST
ERROR="$?"
elif [ "$TYPE" = "cp" ]
then
cp $SRC $DST
ERROR="$?"
else
ERROR="1"
fi
if [ "$ERROR" = "1" ]
then
echo "Error minifying $SRC, copy $SRC to $DST"
cp $SRC $DST
fi
}
echo "Minifying javascript"
minify js htdocs/js/player.js dist/htdocs/js/player.min.js
minify js htdocs/js/mympd.js dist/htdocs/js/mympd.min.js
minify js htdocs/sw.js dist/htdocs/sw.min.js
minify js htdocs/js/keymap.js dist/htdocs/js/keymap.min.js
minify js htdocs/js/keymap.js dist/htdocs/js/keymap.min.js
minify js dist/htdocs/js/bootstrap-native-v4.js dist/htdocs/js/bootstrap-native-v4.min.js
echo "Minifying stylesheets"
minify css htdocs/css/mympd.css dist/htdocs/css/mympd.min.css
echo "Minifying html"
2019-01-21 20:27:27 +00:00
minify html htdocs/index.html dist/htdocs/index.html
minify html htdocs/player.html dist/htdocs/player.html
2018-07-11 00:01:04 +00:00
echo "Compiling and installing mympd"
2019-01-21 20:51:24 +00:00
install -d release
cd release
2019-01-24 05:11:31 +00:00
INSTALL_PREFIX="${MYMPD_INSTALL_PREFIX:-/usr}"
cmake -DCMAKE_INSTALL_PREFIX:PATH=$INSTALL_PREFIX -DCMAKE_BUILD_TYPE=RELEASE ..
make
2019-01-24 05:11:31 +00:00
if [ $INSTALL_PREFIX = "/usr" ]
then
sudo make install
cd ..
sudo debian/postinst
else
# Container build implied when $INSTALL_PREFIX != /usr
make install
cd ..
fi
2018-09-20 22:22:44 +00:00
2018-09-25 23:27:17 +00:00
if [ -x /usr/bin/cppcheck ]
then
echo "Running cppcheck"
cppcheck --enable=warning --inconclusive --force --inline-suppr src/*.c src/*.h
fi