mirror of
https://github.com/SuperBFG7/ympd
synced 2025-01-27 01:14:53 +00:00
Feat: add archlinux PKGBUILD
This commit is contained in:
parent
4959e95513
commit
a11224da57
87
PKGBUILD
Normal file
87
PKGBUILD
Normal file
@ -0,0 +1,87 @@
|
||||
# Maintainer: K. Loz <cultofrobots [at] protonmail [dot] com>
|
||||
# Based on jcorporation's myMPD mkrelease.sh
|
||||
# Website: https://github.com/jcorporation/myMPD
|
||||
# PKGBUILD Based on mympd-archphile by Mike Andonov <info [at] archphile [dot] org>
|
||||
|
||||
pkgname=mympd
|
||||
_pkgname=myMPD
|
||||
pkgver=4.1.1
|
||||
pkgrel=1
|
||||
pkgdesc="A standalone MPD Web GUI based on YMPD - Default port set to 80"
|
||||
arch=('x86_64' 'armv7h' 'aarch64')
|
||||
url="http://github.org/jcorporation/myMpd"
|
||||
license=('GPL')
|
||||
depends=('libmpdclient' 'openssl')
|
||||
makedepends=('cmake' 'git')
|
||||
optdepends=()
|
||||
provides=()
|
||||
conflicts=()
|
||||
replaces=()
|
||||
install=contrib/archlinux.install
|
||||
source=("https://github.com/jcorporation/${_pkgname}/archive/v${pkgver}.tar.gz"
|
||||
'mympd.install')
|
||||
sha256sums=('ec776fa76b2623f27e147abbb0e182d54fb8b80917a35533e58d95ca9f0571d1'
|
||||
'b01671a1153764d96655069f0a9ddf8ab2f7370f60a3789f6f1b4f370474df67')
|
||||
|
||||
prepare() {
|
||||
export java=$(which java 2> /dev/null)
|
||||
|
||||
if [ -f ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar ] && [ "$java" != "$NULL" ]
|
||||
then
|
||||
echo "Minifying javascript"
|
||||
[ ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/player.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/player.min.js ] && \
|
||||
java -jar ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/player.js > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/player.min.js
|
||||
[ ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/mympd.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js ] && \
|
||||
java -jar ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/mympd.js > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js
|
||||
[ ${srcdir}/${_pkgname}-${pkgver}/htdocs/sw.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js ] && \
|
||||
java -jar ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar ${srcdir}/${_pkgname}-${pkgver}/htdocs/sw.js > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js
|
||||
else
|
||||
echo "${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-compiler.jar not found, using non-minified files"
|
||||
[ ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/player.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/player.min.js ] && \
|
||||
cp ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/player.js ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/player.min.js
|
||||
[ ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/mympd.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js ] && \
|
||||
cp ${srcdir}/${_pkgname}-${pkgver}/htdocs/js/mympd.js ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js
|
||||
[ ${srcdir}/${_pkgname}-${pkgver}/htdocs/sw.js -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js ] && \
|
||||
cp ${srcdir}/${_pkgname}-${pkgver}/htdocs/sw.js ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js
|
||||
fi
|
||||
|
||||
if [ -f ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-stylesheets.jar ] && [ "$java" != "$NULL" ]
|
||||
then
|
||||
echo "Minifying stylesheets"
|
||||
[ ${srcdir}/${_pkgname}-${pkgver}/htdocs/css/mympd.css -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/css/mympd.min.css ] && \
|
||||
java -jar ${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-stylesheets.jar --allow-unrecognized-properties ${srcdir}/${_pkgname}-${pkgver}/htdocs/css/mympd.css > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/css/mympd.min.css
|
||||
else
|
||||
echo "${srcdir}/${_pkgname}-${pkgver}/dist/buildtools/closure-stylesheets.jar not found, using non-minified files"
|
||||
[ ${srcdir}/${_pkgname}-${pkgver}/htdocs/css/mympd.css -nt ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/css/mympd.min.css ] && \
|
||||
cp ${srcdir}/${_pkgname}-${pkgver}/htdocs/css/mympd.css ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/css/mympd.min.css
|
||||
fi
|
||||
|
||||
echo "Replacing javascript and stylesheets with minified files"
|
||||
sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' ${srcdir}/${_pkgname}-${pkgver}/htdocs/index.html > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/index.html
|
||||
sed -e 's/mympd\.css/mympd\.min\.css/' -e 's/player\.js/player\.min\.js/' ${srcdir}/${_pkgname}-${pkgver}/htdocs/player.html > ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/player.html
|
||||
sed -i -e 's/mympd\.css/mympd\.min\.css/' -e 's/mympd\.js/mympd\.min\.js/' -e 's/player\.js/player\.min\.js/' ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/sw.min.js
|
||||
sed -i -e 's/\/sw\.js/\/sw\.min\.js/' ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/js/mympd.min.js
|
||||
echo "Minifying html"
|
||||
perl -i -pe 's/^\s*//gm; s/\s*$//gm' ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/index.html
|
||||
perl -i -pe 's/^\s*//gm; s/\s*$//gm' ${srcdir}/${_pkgname}-${pkgver}/dist/htdocs/player.html
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "${srcdir}/${_pkgname}-${pkgver}"
|
||||
|
||||
[ -d release ] || mkdir release
|
||||
cd release
|
||||
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=RELEASE ..
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "${srcdir}/${_pkgname}-${pkgver}/release"
|
||||
make DESTDIR="$pkgdir/" install
|
||||
|
||||
### DON'T OVERWRITE CURRENT CONFIG ###
|
||||
mv "${pkgdir}/etc/mympd/mympd.conf" "${pkgdir}/etc/mympd/mympd.conf.dist"
|
||||
|
||||
install -Dm644 "${srcdir}/${_pkgname}-${pkgver}/contrib/mympd.service" "$pkgdir/usr/lib/systemd/system/mympd.service"
|
||||
}
|
||||
|
105
contrib/archlinux.install
Normal file
105
contrib/archlinux.install
Normal file
@ -0,0 +1,105 @@
|
||||
post_install() {
|
||||
post_upgrade;
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
# create mympd user, group if not already existing
|
||||
echo "INFO: Checking status of mympd system user and group"
|
||||
getent group mympd > /dev/null
|
||||
[ "$?" = "2" ] && groupadd --system mympd
|
||||
getent passwd mympd > /dev/null
|
||||
[ "$?" = "2" ] && useradd --system -d /var/lib/mympd -s /usr/sbin/nologin -g mympd mympd
|
||||
|
||||
# fix ownership of /var/lib/mympd
|
||||
if ! [ $(stat -c '%U:%G' /var/lib/mympd/) == 'mympd:mympd' ]
|
||||
then
|
||||
echo "INFO: Fixing ownership of /var/lib/mympd"
|
||||
chown -R mympd.mympd /var/lib/mympd
|
||||
fi
|
||||
|
||||
# link music directory to mympd if not already exising
|
||||
echo "INFO: Trying to link musicdir to library"
|
||||
if [ -f /etc/mpd.conf ]
|
||||
then
|
||||
LIBRARY=$(grep ^music_directory /etc/mpd.conf | awk {'print $2'} | sed -e 's/"//g')
|
||||
[ "$LIBRARY" != "" ] && [ ! -e /usr/share/mympd/htdocs/library ] && ln -s "$LIBRARY" /usr/share/mympd/htdocs/library
|
||||
else
|
||||
echo "/etc/mpd.conf not found, you must link your musicdir manually to /usr/share/mympd/htdocs/library"
|
||||
fi
|
||||
|
||||
# install systemd service
|
||||
echo "INFO: Installing systemd service"
|
||||
if [ -d /etc/systemd/system ]
|
||||
then
|
||||
echo "INFO: reloading systemd"
|
||||
systemctl daemon-reload
|
||||
if [ ! -f /etc/systemd/system/multi-user.target.wants/mympd.service ]
|
||||
then
|
||||
echo "INFO: enabling mympd.service"
|
||||
systemctl enable mympd
|
||||
fi
|
||||
fi
|
||||
|
||||
# create ssl certificates unless already existing
|
||||
if [ -d /etc/mympd/ssl ]
|
||||
then
|
||||
echo "INFO: Certificates already created"
|
||||
else
|
||||
echo "INFO: Creating certificates"
|
||||
/usr/share/mympd/crcert.sh
|
||||
fi
|
||||
|
||||
# disable ssl by default on mympd.conf.dist (chrome hates localhost.localdomain)
|
||||
echo "INFO: Disabling SSL by default in dist config"
|
||||
sed '/^ssl = true/c ssl = false' -i "/etc/mympd/mympd.conf.dist"
|
||||
|
||||
# move config into place unless already existing
|
||||
if [ ! -f /etc/mympd/mympd.conf ]
|
||||
then
|
||||
mv /etc/mympd/mympd.conf.dist /etc/mympd/mympd.conf
|
||||
echo -e "\e[93mWARNING\e[0m: \e[1mSSL Disabled by default! You must enable SSL in /etc/mympd/mympd.conf if you wish to use SSL\e[0m"
|
||||
else
|
||||
echo -e "\e[93mWARNING\e[0m: \e[1mmympd.conf \e[0minstalled as \e[1mmympd.conf.dist\e[0m"
|
||||
fi
|
||||
|
||||
# installation complete
|
||||
echo -e "\e[93mWARNING\e[0m: Edit \e[1m/etc/mympd/mympd.conf \e[0mbefore starting myMPD"
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
# stop and remove systemd service
|
||||
systemctl daemon-reload
|
||||
if `systemctl is-active --quiet mympd`
|
||||
then
|
||||
echo "stopping mympd.service" && systemctl stop mympd
|
||||
fi
|
||||
echo "disabling mympd.service" && systemctl disable mympd
|
||||
|
||||
# backup config
|
||||
if [ -f /etc/mympd/mympd.conf ]
|
||||
then
|
||||
mv /etc/mympd/mympd.conf /etc/mympd/mympd.conf.pacsave
|
||||
echo -e "\e[93mINFO\e[0m: /etc/mympd/mympd.conf backed up to /etc/mympd/mympd.conf.pacsave"
|
||||
fi
|
||||
|
||||
# unlink music dir
|
||||
echo "unlinking musicdir to library"
|
||||
if [ -f /etc/mpd.conf ]
|
||||
then
|
||||
LIBRARY=$(grep ^music_directory /etc/mpd.conf | awk {'print $2'} | sed -e 's/"//g')
|
||||
[ "$LIBRARY" != "" ] && [ -e /usr/share/mympd/htdocs/library ] && rm /usr/share/mympd/htdocs/library
|
||||
else
|
||||
echo -e "\e[93mWARNING\e[0m: /etc/mpd.conf not found, you must unlink your musicdir manually from \e[1m/usr/share/mympd/htdocs/library\e[0m"
|
||||
fi
|
||||
|
||||
# remove mympd user and group
|
||||
getent passwd mympd > /dev/null
|
||||
echo -e "\e[93mWARNING\e[0m: Removing \e[1mmympd \e[0muser and group!"
|
||||
[ "$?" != "2" ] && userdel -r mympd
|
||||
getent group mympd > /dev/null
|
||||
[ "$?" != "2" ] && groupdel mympd
|
||||
|
||||
# remove leftover directories
|
||||
rmdir -v /usr/share/{mympd/htdocs/,mympd/}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user