diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 00000000..02ea4229 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,44 @@ +# Maintainer: Notify-ctrl + +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 +} diff --git a/freekill.desktop b/freekill.desktop new file mode 100755 index 00000000..74c28f31 --- /dev/null +++ b/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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a2d0fd8..a8ff8518 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -91,3 +91,6 @@ target_link_libraries(FreeKill PRIVATE ${QT_LIB} ${GIT_LIB} ) + +install(TARGETS FreeKill DESTINATION bin) +install(TARGETS fkparse DESTINATION lib) diff --git a/src/main.cpp b/src/main.cpp index 9a3979f0..63326195 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -49,6 +49,28 @@ static bool copyPath(const QString &srcFilePath, const QString &tgtFilePath) } #endif +#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) +#include +#include +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) { fprintf(stderr, "\r[%s] ", QTime::currentTime().toString("hh:mm:ss").toLatin1().constData()); auto localMsg = msg.toUtf8(); @@ -87,6 +109,10 @@ int main(int argc, char *argv[]) QCoreApplication::setApplicationName("FreeKill"); QCoreApplication::setApplicationVersion("Alpha 0.0.1"); +#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) + prepareForLinux(); +#endif + #ifndef Q_OS_WASM QCommandLineParser parser; parser.setApplicationDescription("FreeKill server");