commit 325f0477adddcf02c0e53338e142ef5267e29233 Author: Leon Date: Mon May 25 21:39:33 2020 +0200 Initial commit diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 00000000000..4d55b416877 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,36 @@ +pkgbase = karaokemugen + pkgdesc = Karaoke playlist manager/player app used in parties or events. + pkgver = 3.2.2 + pkgrel = 1 + url = https://mugen.karaokes.moe/ + install = karaokemugen.install + arch = any + license = MIT + makedepends = git + makedepends = npm + makedepends = typescript + makedepends = yarn + makedepends = nodejs>=12 + makedepends = python2 + depends = mpv + depends = ffmpeg + depends = postgresql + depends = electron + optdepends = sudo: for using karaokemugen-install script + provides = karaokemugen + conflicts = karaokemugen + source = karaokemugen::git+https://lab.shelter.moe/karaokemugen/karaokemugen-app.git#tag=v3.2.2 + source = karaokemugen-lib::git+https://lab.shelter.moe/karaokemugen/lib.git + source = install.sh + source = run.sh + source = icon256.png + source = karaokemugen.desktop + md5sums = SKIP + md5sums = SKIP + md5sums = 4ad5390b139dc5b5e78e6eef8411e90b + md5sums = 0d0d432f35c56a962f9d386f391c6036 + md5sums = 5e9a33a42fef7572b7e0fa504c586f32 + md5sums = 10561eed906a5efeed427f90501b4f49 + +pkgname = karaokemugen + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 00000000000..967dc0e11f1 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,86 @@ +# Maintainer: leonekmi +pkgname=karaokemugen +pkgver=3.2.2 +pkgrel=1 +pkgdesc="Karaoke playlist manager/player app used in parties or events." +arch=('any') +url="https://mugen.karaokes.moe/" +license=('MIT') +groups=() +depends=('mpv' 'ffmpeg' 'postgresql' 'electron') # Warning : to be replaced with electron8 when Electron 9 will be pushed to [community] +makedepends=('git' 'npm' 'typescript' 'yarn' 'nodejs>=12' 'python2') +optdepends=('sudo: for using karaokemugen-install script') +provides=("${pkgname%-git}") +conflicts=("${pkgname%-git}") +replaces=() +backup=() +options=() +install=${pkgname%-git}.install +source=('karaokemugen::git+https://lab.shelter.moe/karaokemugen/karaokemugen-app.git#tag=v3.2.2' + 'karaokemugen-lib::git+https://lab.shelter.moe/karaokemugen/lib.git' + 'install.sh' + 'run.sh' + 'icon256.png' + 'karaokemugen.desktop') +noextract=() +md5sums=('SKIP' + 'SKIP' + '4ad5390b139dc5b5e78e6eef8411e90b' + '0d0d432f35c56a962f9d386f391c6036' + '5e9a33a42fef7572b7e0fa504c586f32' + '10561eed906a5efeed427f90501b4f49') + +prepare() { + cd "$srcdir/${pkgname}" + git submodule init + git config submodule.src/lib.url $srcdir/${pkgname}-lib + git submodule update +} + +build() { + cd "$srcdir/${pkgname}" + + # Prepare dependencies + export HOME="$srcdir/$pkgname-home" + export XDG_CACHE_HOME="$srcdir/$pkgname-cache" + export npm_config_devdir="$srcdir/$pkgname-npm-dev" + export npm_config_cache="$srcdir/$pkgname-npm-cache" + yarn global add electron-builder + yarn install + yarn installFrontend + yarn installSystemPanel + # Build and package with electron-builder + export NODE_ENV='production' + electronDist=$(dirname $(realpath $(which electron))) + electronVer=$(electron --version | tail -c +2) + yarn build + yarn buildFrontend + yarn buildSystemPanel + "$(yarn global dir)/node_modules/.bin/electron-builder" --linux --x64 -c.electronDist=$electronDist -c.electronVersion=$electronVer --dir +} + +package() { + cd "$srcdir/${pkgname}" + + # Application itself + install -dm755 "$pkgdir/usr/lib/${pkgname}" + cp -dr --no-preserve=ownership packages/linux-unpacked/resources/* "$pkgdir/usr/lib/${pkgname}/" + install -dm 755 "$pkgdir/usr/lib/${pkgname}/asar" + mv "$pkgdir/usr/lib/${pkgname}/app.asar" "$pkgdir/usr/lib/${pkgname}/asar" + chmod -R 755 "$pkgdir/usr/lib/${pkgname}/" + + # License + install -dm755 "$pkgdir/usr/share/licenses/${pkgname}" + install -m644 LICENSE.md "$pkgdir/usr/share/licenses/${pkgname}/LICENSE" + + # Runtimes + install -dm755 "$pkgdir/usr/bin/" + install -m755 "$srcdir/run.sh" "$pkgdir/usr/bin/karaokemugen" + install -m755 "$srcdir/install.sh" "$pkgdir/usr/bin/karaokemugen-install" + + # .desktop entry + install -dm755 "$pkgdir/usr/share/pixmaps/" + install -dm755 "$pkgdir/usr/share/applications/" + install -m644 "$srcdir/icon256.png" "$pkgdir/usr/share/pixmaps/${pkgname}.png" + install -m644 "$srcdir/${pkgname}.desktop" "$pkgdir/usr/share/applications/${pkgname}.desktop" +} \ No newline at end of file diff --git a/icon256.png b/icon256.png new file mode 100644 index 00000000000..134c7b1f42f Binary files /dev/null and b/icon256.png differ diff --git a/install.sh b/install.sh new file mode 100755 index 00000000000..03dd52470cd --- /dev/null +++ b/install.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash + +# _ __ _ __ __ +# | |/ /__ _ _ _ __ _ ___| |_____ | \/ |_ _ __ _ ___ _ _ +# | ' /dev/null + EXIT_STATUS=$? + if [ $EXIT_STATUS -eq 4 ]; then + echo -e "${_COL_YELLOW_}Postgres is not initialized, initializing..." + sudo -H -u postgres -g postgres initdb -D /var/lib/postgres/data + check_postgres + elif [ $EXIT_STATUS -eq 3 ]; then + echo -e "${_COL_YELLOW_}Postgres is not running, starting..." + sudo systemctl restart postgresql + check_postgres + else + echo -e "${_COL_GREEN_}Postgres seems OK." + fi +} + +check_mugen() { + if [ -f "/opt/karaokemugen/karaokemugen" ]; then + echo -e "${_COL_GREEN_}Karaoke Mugen is installed in /opt/karaokemugen." + else + echo -e "${_COL_BRED_}Karaoke Mugen is not installed in /opt/karaokemugen. Exiting." + exit 1 + fi +} + +setup_postgres() { + echo -e "${_BEGIN_}Creating the karaokemugen_app database..." + # Create the DB for Mugen + # Check if the DB already exists + sudo -u postgres -g postgres -H -- psql -d karaokemugen_app -c "" + if [ $? -eq 0 ]; then + echo -e "${_COL_YELLOW_}karaokemugen_app database is existing, do you want to keep its content or reset it?" + select dbch in "Keep data" "Reset database"; do + case $dbch in + "Keep data" ) echo -e "${_COL_GREEN_}karaokemugen_app database will be used." ; return 0;; # TODO : maybe do some integrity checks + "Reset database" ) sudo -u postgres -g postgres -H -- psql -c "DROP DATABASE karaokemugen_app;"; sudo -u postgres -g postgres -H -- psql -c "DROP ROLE IF EXISTS karaokemugen_app;";; + esac + done + fi + # Creating the database + sudo -u postgres -g postgres -H -- psql -c "CREATE DATABASE karaokemugen_app ENCODING 'UTF8';" + sudo -u postgres -g postgres -H -- psql -c "CREATE USER karaokemugen_app WITH ENCRYPTED PASSWORD 'musubi'; GRANT ALL PRIVILEGES ON DATABASE karaokemugen_app TO karaokemugen_app;" + sudo -u postgres -g postgres -H -- psql -d karaokemugen_app -c "CREATE EXTENSION unaccent;" + echo -e "${_COL_GREEN_}karaokemugen_app database created!" +} + +# use colors only if we have them +if [[ $(which tput > /dev/null 2>&1 && tput -T "${TERM}" colors || echo -n '0') -ge 8 ]] ; then + _COL_YELLOW_='\e[0;33m' + _COL_GREEN_='\e[0;32m' + _COL_LIGHTGREY_='\e[0;37m' + _COL_BRED_='\e[1;31m' + _COL_BBLUE_='\e[1;34m' + _COL_BWHITE_='\e[1;37m' + _COL_DEFAULT_='\e[0m' + _BEGIN_="${_COL_BRED_}-> ${_COL_BBLUE_}" +fi + +while getopts ":g" opt; do + case ${opt} in + g ) + #target=$OPTARG + echo -e "${_COL_YELLOW_}You may have to enter your sudo password" + add_user_to_group + echo -e "${_BEGIN_}Done! You need to restart your session to apply these changes." + exit 0 + ;; + \? ) + echo "Invalid option: $OPTARG" 1>&2 + exit 1 + ;; + esac +done +shift $((OPTIND -1)) + +echo -e "${_BEGIN_}Welcome to the Karaoke Mugen installer!" +echo -e "${_COL_YELLOW_}⚠️ You may have to enter your sudo password a couple times during this installation." +echo -e "${_COL_YELLOW_}This script may not work if you tweaked your PostgreSQL configuration." +echo -e "${_COL_YELLOW_}If you encounter any problems during installation, contact the package maintainer." +echo -e "${_COL_YELLOW_}The installation will begin in 5 seconds." +sleep 5 + +echo -e "${_BEGIN_}Doing some initial checks..." +check_postgres +check_mugen + +setup_postgres + +echo -e "${_BEGIN_}Done! Go ahead and launch Karaoke Mugen using the desktop entry" + diff --git a/karaokemugen.desktop b/karaokemugen.desktop new file mode 100644 index 00000000000..4aaa3d3da36 --- /dev/null +++ b/karaokemugen.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Name=Karaoke Mugen +Comment=Karaoke playlist manager/player app used in parties or events. +Exec=karaokemugen +Icon=karaokemugen +Terminal=false +Type=Application +Categories=AudioVideo;Video \ No newline at end of file diff --git a/karaokemugen.install b/karaokemugen.install new file mode 100644 index 00000000000..76aeede9d7c --- /dev/null +++ b/karaokemugen.install @@ -0,0 +1,14 @@ +post_install() { + echo "TIP: This package ships with tools to help you with Karaoke Mugen installation" + echo "- karaokemugen-install interactively creates the initial configuration and helps you with database setup." + echo "- karaokemugen launches the app with Electron UI." +} + +post_upgrade() { + echo "You may need to run karaokemugen-install again. Keep that in mind." +} + +post_remove() { + echo "The media files downloaded are still in the directory you set (~/KaraokeMugen/ by default)." + echo "Delete them to free space if you want." +} \ No newline at end of file diff --git a/run.sh b/run.sh new file mode 100755 index 00000000000..07de3a7a7d7 --- /dev/null +++ b/run.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# _ __ _ __ __ +# | |/ /__ _ _ _ __ _ ___| |_____ | \/ |_ _ __ _ ___ _ _ +# | ' /dev/null 2>&1 && tput -T "${TERM}" colors || echo -n '0') -ge 8 ]] ; then + _COL_YELLOW_='\e[0;33m' + _COL_BLUE_='\e[0;34m' + _COL_DEFAULT_='\e[0m' +fi + +# Check if postgres is running +if systemctl is-active postgresql -q ; then + echo "Starting Karaoke Mugen..." +else + echo -e "${_COL_YELLOW_}⚠️ Postgres seems down... Trying to start PostgreSQL before Karaoke Mugen.${_COL_DEFAULT_}" + echo -e "${_COL_BLUE_}You may want to start PostgreSQL at boot with `systemctl enable postgresql`.${_COL_DEFAULT_}" + systemctl start postgresql +fi +# Launch Karaoke Mugen +exec electron /usr/lib/karaokemugen/asar/app.asar "$@"