Skip to content

Commit

Permalink
Refactor debian-packager.sh, rename launcher scripts (#303)
Browse files Browse the repository at this point in the history
* Improve windows-bundler.sh

* Overhaul debian-packager.sh. Rename base package name to tachidesk-server

* Add -electron-launcher-debian.sh
  • Loading branch information
mahor1221 authored Mar 3, 2022
1 parent 454de23 commit 291a239
Show file tree
Hide file tree
Showing 17 changed files with 68 additions and 74 deletions.
67 changes: 35 additions & 32 deletions scripts/debian-packager.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,46 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

echo "creating debian package"
echo "Creating DEB Package"
pkgname="tachidesk-server"
PkgName="Tachidesk-Server"
jar=$(ls ../server/build/*.jar | tail -n1)
release_ver=$(tmp="${jar%-*}" && echo "${tmp##*-}" | tr -d v)
orig_dir="tachidesk-$release_ver" # dir uses hyphen "-"
orig_tar_gz="tachidesk_$release_ver.orig.tar.gz" # orig file uses underscore "_"
package_name="tachidesk_$release_ver-1_all.deb"

# copy artifacts
mkdir "$orig_dir"
cp "$jar" "$orig_dir/Tachidesk.jar"
cp -r "resources/debian" "$orig_dir"
cp "resources/tachidesk-browser-launcher-standalone.sh" "$orig_dir/debian"
cp "resources/tachidesk-debug-launcher-standalone.sh" "$orig_dir/debian"
cp "resources/tachidesk-electron-launcher-standalone.sh" "$orig_dir/debian"
cp "resources/tachidesk.desktop" "$orig_dir/debian"
cp "../server/src/main/resources/icon/faviconlogo.png" "$orig_dir/debian/tachidesk.png"

# prepare
tar cvzf "$orig_tar_gz" "$orig_dir/Tachidesk.jar"
sed -i "s/\${version}/$release_ver/" "$orig_dir/debian/changelog"

# build
mkdir "build"
mv $orig_dir $orig_tar_gz "build/"
cd "build/$orig_dir/debian"
pkgver="$(tmp="${jar%-*}" && echo "${tmp##*-}" | tr -d v)"
pkgrel=1

srcdir="$pkgname-$pkgver" # uses hyphen "-"
srctgz="${pkgname}_$pkgver.orig.tar.gz" # uses underscore "_"
deb="${pkgname}_$pkgver-${pkgrel}_all.deb"
Deb="${PkgName}_$pkgver-${pkgrel}_all.deb"

# Prepare
mkdir "$srcdir/"
cp "$jar" "$srcdir/$pkgname.jar"
cp "resources/$pkgname-browser-launcher.sh" "$srcdir/"
cp "resources/$pkgname-debug-launcher.sh" "$srcdir/"
cp "resources/$pkgname-electron-launcher-debian.sh" "$srcdir/$pkgname-electron-launcher.sh"
cp "resources/$pkgname.desktop" "$srcdir/"
cp "../server/src/main/resources/icon/faviconlogo.png" "$srcdir/$pkgname.png"

GZIP=-9 tar -cvzf "$srctgz" "$srcdir/"

cp -r "resources/debian" "$srcdir/"
sed -i "s/\${pkgver}/$pkgver/" "$srcdir/debian/changelog"
sed -i "s/\${pkgrel}/$pkgrel/" "$srcdir/debian/changelog"

# Build
mkdir "debuild/"
mv "$srctgz" "$srcdir/" "debuild/"
sudo apt install devscripts build-essential dh-exec
# --lintian-opts --profile debian: build Debian packages on Ubuntu
# --lintian-opts --profile are for building Debian packages on Ubuntu
cd "debuild/$srcdir/debian"
debuild -uc -us --lintian-opts --profile debian
cd -

# clean build directory
mv "build/$package_name" "./"
rm -rf "build"

# clean up from possible previous runs
if [ -f "../server/build/$package_name" ]; then
rm "../server/build/$package_name"
if [ -f "../server/build/$Deb" ]; then
rm "../server/build/$Deb"
fi

mv "$package_name" "../server/build/"
mv "debuild/$deb" "../server/build/$Deb"
rm -rf "debuild/"
2 changes: 1 addition & 1 deletion scripts/resources/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tachidesk (${version}-1) unstable; urgency=medium
tachidesk-server (${pkgver}-${pkgrel}) unstable; urgency=medium

* See CHANGELOG.md on https://github.com/Suwayomi/Tachidesk-Server

Expand Down
4 changes: 2 additions & 2 deletions scripts/resources/debian/control
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Source: tachidesk
Source: tachidesk-server
Section: web
Priority: optional
Maintainer: Mahor Foruzesh <[email protected]>
Build-Depends: debhelper-compat (= 12), dh-exec
Standards-Version: 4.5.1
Homepage: https://github.com/Suwayomi/Tachidesk-Server

Package: tachidesk
Package: tachidesk-server
Architecture: all
Depends: ${misc:Depends}, default-jre-headless (>= 8)
Description: Manga Reader
Expand Down
2 changes: 1 addition & 1 deletion scripts/resources/debian/copyright
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: tachidesk
Upstream-Name: tachidesk-server
Upstream-Contact: https://discord.gg/DDZdqZWaHA
Source: https://github.com/Suwayomi/Tachidesk-Server

Expand Down
13 changes: 6 additions & 7 deletions scripts/resources/debian/install
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/dh-exec

debian/tachidesk-browser-launcher-standalone.sh => usr/bin/tachidesk
debian/tachidesk-browser-launcher-standalone.sh => usr/bin/tachidesk-browser
debian/tachidesk-debug-launcher-standalone.sh => usr/bin/tachidesk-debug
debian/tachidesk-electron-launcher-standalone.sh => usr/bin/tachidesk-electron
Tachidesk.jar => usr/share/java/tachidesk/tachidesk.jar
debian/tachidesk.png usr/share/pixmaps/
debian/tachidesk.desktop usr/share/applications/
tachidesk-server-browser-launcher.sh => usr/bin/tachidesk-server-browser
tachidesk-server-debug-launcher.sh => usr/bin/tachidesk-server-debug
tachidesk-server-electron-launcher.sh => usr/bin/tachidesk-server-electron
tachidesk-server.jar usr/share/java/tachidesk-server/
tachidesk-server.png usr/share/pixmaps/
tachidesk-server.desktop usr/share/applications/
2 changes: 1 addition & 1 deletion scripts/resources/debian/source/include-binaries
Original file line number Diff line number Diff line change
@@ -1 +1 @@
debian/tachidesk.png
tachidesk-server.png
2 changes: 0 additions & 2 deletions scripts/resources/tachidesk-browser-launcher-standalone.sh

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/resources/tachidesk-browser-launcher.sh

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/resources/tachidesk-debug-launcher.sh

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/resources/tachidesk-electron-launcher.sh

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/resources/tachidesk-server-browser-launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/sh
exec /usr/bin/java -jar /usr/share/java/tachidesk-server/tachidesk-server.jar
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
exec /usr/bin/java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar /usr/share/java/tachidesk/tachidesk.jar
exec /usr/bin/java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar /usr/share/java/tachidesk-server/tachidesk-server.jar
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#!/bin/sh

if [ ! -f /usr/bin/electron ]; then
echo "Electron executable was not found!
echo "Electron executable was not found
In order to run this launcher, you need Electron installed.
You can install it with these commands:
sudo apt install npm
sudo npm install electron -g
"
exit 1
sudo npm install electron -g"
exit 1
fi

exec /usr/bin/java -Dsuwayomi.tachidesk.config.server.webUIInterface=electron -Dsuwayomi.tachidesk.config.server.electronPath=/usr/bin/electron -jar /usr/share/java/tachidesk/tachidesk.jar
exec /usr/bin/java -Dsuwayomi.tachidesk.config.server.webUIInterface=electron -Dsuwayomi.tachidesk.config.server.electronPath=/usr/bin/electron -jar /usr/share/java/tachidesk-server/tachidesk-server.jar
3 changes: 3 additions & 0 deletions scripts/resources/tachidesk-server-electron-launcher.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

exec /usr/bin/java -Dsuwayomi.tachidesk.config.server.webUIInterface=electron -Dsuwayomi.tachidesk.config.server.electronPath=/usr/bin/electron -jar /usr/share/java/tachidesk-server/tachidesk-server.jar
8 changes: 8 additions & 0 deletions scripts/resources/tachidesk-server.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Name=Tachidesk-Server
Comment=Manga Reader
Exec=/usr/bin/java -jar /usr/share/java/tachidesk-server/tachidesk-server.jar "\\$@"
Icon=tachidesk-server
Terminal=false
Categories=Network;
8 changes: 0 additions & 8 deletions scripts/resources/tachidesk.desktop

This file was deleted.

8 changes: 4 additions & 4 deletions scripts/unix-bundler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ fi
unzip $electron -d $release_name/electron

# copy artifacts
cp $jar $release_name/Tachidesk.jar
cp $jar $release_name/Tachidesk-Server.jar
if [ $os = linux ]; then
cp "resources/tachidesk-browser-launcher.sh" $release_name
cp "resources/tachidesk-debug-launcher.sh" $release_name
cp "resources/tachidesk-electron-launcher.sh" $release_name
cp "resources/tachidesk-server-browser-launcher.sh" $release_name
cp "resources/tachidesk-server-debug-launcher.sh" $release_name
cp "resources/tachidesk-server-electron-launcher.sh" $release_name
elif [ $os = macOS ]; then
cp "resources/Tachidesk Browser Launcher.command" $release_name
cp "resources/Tachidesk Debug Launcher.command" $release_name
Expand Down

0 comments on commit 291a239

Please sign in to comment.