Linux (#52)
* copy asset when execute /bin/FreeKill * PKGBUILD test * ready to makepkg
This commit is contained in:
parent
b2dfd69a16
commit
4e1385fa6f
|
@ -0,0 +1,44 @@
|
||||||
|
# Maintainer: Notify-ctrl <notify-ctrl@qq.com>
|
||||||
|
|
||||||
|
pkgname=freekill
|
||||||
|
_upper_pkgname=FreeKill
|
||||||
|
pkgver=0.0.1
|
||||||
|
pkgrel=1
|
||||||
|
arch=('x86_64')
|
||||||
|
url='https://github.com/Notify-ctrl/FreeKill'
|
||||||
|
license=('GPL3')
|
||||||
|
pkgdesc='A Bang-like card game'
|
||||||
|
depends=('qt6-declarative' 'qt6-multimedia' 'qt6-5compat'
|
||||||
|
'qt6-shadertools' 'libgit2' 'lua' 'sqlite' 'openssl'
|
||||||
|
'readline' )
|
||||||
|
makedepends=('cmake' 'flex' 'bison' 'qt6-tools' 'swig')
|
||||||
|
# TODO: set source to release tarball
|
||||||
|
source=("file:///home/notify/develop/FreeKill-demo.tar.gz")
|
||||||
|
sha256sums=('SKIP')
|
||||||
|
|
||||||
|
prepare() {
|
||||||
|
cd ${srcdir}/${_upper_pkgname}
|
||||||
|
rm -rf build
|
||||||
|
}
|
||||||
|
|
||||||
|
build() {
|
||||||
|
cd ${srcdir}/${_upper_pkgname}
|
||||||
|
mkdir build && cd build
|
||||||
|
cmake ..
|
||||||
|
make
|
||||||
|
}
|
||||||
|
|
||||||
|
package() {
|
||||||
|
mkdir -p ${pkgdir}/usr/share/${_upper_pkgname}
|
||||||
|
mkdir -p ${pkgdir}/usr/share/icons
|
||||||
|
mkdir -p ${pkgdir}/usr/share/applications
|
||||||
|
mkdir -p ${pkgdir}/usr/bin
|
||||||
|
mkdir -p ${pkgdir}/usr/lib
|
||||||
|
cd ${srcdir}/${_upper_pkgname}
|
||||||
|
cmake --install build --prefix ${pkgdir}/usr --config Release
|
||||||
|
|
||||||
|
cp -r audio fonts image lua packages qml server build/zh_CN.qm \
|
||||||
|
${pkgdir}/usr/share/${_upper_pkgname}
|
||||||
|
install -Dm644 image/icon.png ${pkgdir}/usr/share/icons/freekill_logo.png
|
||||||
|
install -Dm644 freekill.desktop ${pkgdir}/usr/share/applications/freekill.desktop
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/usr/bin/env xdg-open
|
||||||
|
[Desktop Entry]
|
||||||
|
Name=FreeKill
|
||||||
|
Comment=A Bang!-like card game
|
||||||
|
Comment[zh_CN]=一款玩法类似Bang!的桌游
|
||||||
|
Icon=freekill_logo
|
||||||
|
Exec=/usr/bin/FreeKill
|
||||||
|
Type=Application
|
||||||
|
Terminal=false
|
|
@ -91,3 +91,6 @@ target_link_libraries(FreeKill PRIVATE
|
||||||
${QT_LIB}
|
${QT_LIB}
|
||||||
${GIT_LIB}
|
${GIT_LIB}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
install(TARGETS FreeKill DESTINATION bin)
|
||||||
|
install(TARGETS fkparse DESTINATION lib)
|
||||||
|
|
26
src/main.cpp
26
src/main.cpp
|
@ -49,6 +49,28 @@ static bool copyPath(const QString &srcFilePath, const QString &tgtFilePath)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
static void prepareForLinux() {
|
||||||
|
// if user executes /usr/bin/FreeKill, that means freekill is installed by
|
||||||
|
// package manager, and then we need to copy assets to ~/.local and change cwd
|
||||||
|
char buf[256] = {0};
|
||||||
|
int len = readlink("/proc/self/exe", buf, 256);
|
||||||
|
if (!strcmp(buf, "/usr/bin/FreeKill")) {
|
||||||
|
system("mkdir -p ~/.local/share/FreeKill");
|
||||||
|
system("cp -r /usr/share/FreeKill ~/.local/share");
|
||||||
|
chdir(getenv("HOME"));
|
||||||
|
chdir(".local/share/FreeKill");
|
||||||
|
} else if (!strcmp(buf, "/usr/local/bin/FreeKill")) {
|
||||||
|
system("mkdir -p ~/.local/share/FreeKill");
|
||||||
|
system("cp -r /usr/local/share/FreeKill ~/.local/share");
|
||||||
|
chdir(getenv("HOME"));
|
||||||
|
chdir(".local/share/FreeKill");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void fkMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
void fkMsgHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) {
|
||||||
fprintf(stderr, "\r[%s] ", QTime::currentTime().toString("hh:mm:ss").toLatin1().constData());
|
fprintf(stderr, "\r[%s] ", QTime::currentTime().toString("hh:mm:ss").toLatin1().constData());
|
||||||
auto localMsg = msg.toUtf8();
|
auto localMsg = msg.toUtf8();
|
||||||
|
@ -87,6 +109,10 @@ int main(int argc, char *argv[])
|
||||||
QCoreApplication::setApplicationName("FreeKill");
|
QCoreApplication::setApplicationName("FreeKill");
|
||||||
QCoreApplication::setApplicationVersion("Alpha 0.0.1");
|
QCoreApplication::setApplicationVersion("Alpha 0.0.1");
|
||||||
|
|
||||||
|
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
|
||||||
|
prepareForLinux();
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef Q_OS_WASM
|
#ifndef Q_OS_WASM
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.setApplicationDescription("FreeKill server");
|
parser.setApplicationDescription("FreeKill server");
|
||||||
|
|
Loading…
Reference in New Issue