vpkedit: init at 4.4.2

Co-authored-by: HurricanePootis <53066639+HurricanePootis@users.noreply.github.com>
This commit is contained in:
Seraphim R. Pardee
2025-03-19 22:31:08 -04:00
committed by Gaetan Lepage
parent 2b582a07cc
commit 7a8f7eaaef
5 changed files with 371 additions and 0 deletions

View File

@@ -0,0 +1,141 @@
{
lib,
stdenv,
fetchgit,
fetchFromGitHub,
cmake,
openssl,
qt6,
zlib-ng,
bzip2,
xz,
zstd,
cryptopp,
pkg-config,
makeWrapper,
versionCheckHook,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "vpkedit";
version = "4.4.2";
src = fetchFromGitHub {
owner = "craftablescience";
repo = "VPKEdit";
tag = "v${finalAttrs.version}";
fetchSubmodules = true;
hash = "sha256-bxY190G12djkyfprrNt83+qzya44fnYV6Ij7D8SWelQ=";
};
# The following sources should be updated according to what was available
# at the time of VPKEdit's release, according to the vendored submodules
# and their nested submodules. These need to exist to avoid CMake's
# FetchContent trying to pull stuff over the network.
#
#
# v4.4.2
# |
# --> src/thirdparty/sourcepp @ 5bb0e05
# |
# --> ext/cryptopp (which is actually cryptopp-cmake) @ d2b07a
# | |
# | --> sources cryptopp (the actual one) from latest release tag of https://github.com/weidai11/cryptopp
# |
# --> ext/minizip-ng @ fe5fedc
# |
# --> sources zlib from stable branch of https://github.com/zlib-ng/zlib-ng (pinned to latest release tag)
# |
# --> sources bzip2 from master branch of https://sourceware.org/git/bzip
# |
# --> sources xz from master branch of https://github.com/tukaani-project/xz
# | (i used the most recent release tag. slightly newer than what would've been used, but only minor version changes)
# |
# --> sources zstd from release branch of https://github.com/facebook/zstd (pinned to latest release tag)
cryptopp-src = fetchgit {
url = "https://github.com/weidai11/cryptopp.git";
tag = "CRYPTOPP_8_9_0";
hash = "sha256-HV+afSFkiXdy840JbHBTR8lLL0GMwsN3QdwaoQmicpQ=";
};
zlib-src = fetchgit {
url = "https://github.com/zlib-ng/zlib-ng.git";
tag = "2.2.4";
hash = "sha256-NZgnctJ6nA8Pp+wQ70p6m01LwY3wyl4G5bnLhQZYfps=";
};
bzip2-src = fetchgit {
url = "git://sourceware.org/git/bzip2.git";
rev = "fbc4b11da543753b3b803e5546f56e26ec90c2a7";
hash = "sha256-kg/y9ZGbvaQd86tXxekxcv+h8nbNk3UvWad50fm5FtA=";
};
xz-src = fetchgit {
url = "https://github.com/tukaani-project/xz.git";
tag = "v5.8.0";
hash = "sha256-oH9aI5norOBIzyybYU3SnHJL8PXJ9lmZRX/RN0e+NXs=";
};
zstd-src = fetchgit {
url = "https://github.com/facebook/zstd.git";
tag = "v1.5.7";
hash = "sha256-tNFWIT9ydfozB8dWcmTMuZLCQmQudTFJIkSr0aG7S44=";
};
nativeBuildInputs = [
cmake
makeWrapper
qt6.wrapQtAppsHook
];
buildInputs = [
bzip2
cryptopp
openssl
pkg-config
qt6.qtbase
qt6.qttools
xz
zlib-ng
zstd
];
cmakeFlags = with finalAttrs; [
(lib.cmakeFeature "CRYPTOPP_SOURCES" "${cryptopp-src}")
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_ZLIB" "${zlib-src}")
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_BZIP2" "${bzip2-src}")
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_LIBLZMA" "${xz-src}")
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_ZSTD" "${zstd-src}")
(lib.cmakeBool "MZ_OPENSSL" true)
];
patches = [
./patches/fix-config-and-i18n-paths.patch
./patches/fix-installer-cmake.patch
./patches/fix-miniz-cmake-dirs.patch
];
postInstall = ''
mkdir -p $out/lib/vpkedit/i18n
mv *.qm $out/lib/vpkedit/i18n
substituteInPlace $out/share/applications/vpkedit.desktop \
--replace-fail "/opt/vpkedit/vpkedit" "vpkedit"
'';
nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgram = "${placeholder "out"}/bin/vpkeditcli";
doInstallCheck = true;
meta = {
description = "CLI/GUI tool to create, read, and write several pack file formats";
homepage = "https://github.com/craftablescience/VPKEdit";
mainProgram = "vpkeditcli";
license = lib.licenses.mit;
platforms = [ "x86_64-linux" ];
maintainers = with lib.maintainers; [ srp ];
changelog = "https://github.com/craftablescience/VPKEdit/releases/tag/v${finalAttrs.version}";
};
})

View File

@@ -0,0 +1,21 @@
--- a/src/gui/Main.cpp
+++ b/src/gui/Main.cpp
@@ -28,7 +28,8 @@
std::unique_ptr<QSettings> options;
if (Options::isStandalone()) {
- auto configPath = QApplication::applicationDirPath() + "/config.ini";
+ QString defaultConfigPath = qEnvironmentVariable("HOME") + "/.config/vpkedit";
+ auto configPath = qEnvironmentVariable("XDG_CONFIG_HOME", defaultConfigPath) + "/vpkedit/config.ini";
options = std::make_unique<QSettings>(configPath, QSettings::Format::IniFormat);
} else {
options = std::make_unique<QSettings>();
@@ -42,7 +43,7 @@
QCoreApplication::installTranslator(&translatorQtBase);
}
QTranslator translator;
- if (translator.load(locale, PROJECT_NAME.data(), "_", ":/i18n")) {
+ if (translator.load(locale, PROJECT_NAME.data(), "_", QApplication::applicationDirPath() + "/../lib/vpkedit/i18n")) {
QCoreApplication::installTranslator(&translator);
}

View File

@@ -0,0 +1,162 @@
--- a/src/installer/_installer.cmake
+++ b/src/installer/_installer.cmake
@@ -1,120 +1,40 @@
# Set up install rules
install(TARGETS ${PROJECT_NAME}cli
- DESTINATION .)
+ DESTINATION "bin")
install(TARGETS ${PROJECT_NAME}
- DESTINATION .)
+ DESTINATION "bin")
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/CREDITS.md"
"${CMAKE_CURRENT_SOURCE_DIR}/LICENSE"
- "${CMAKE_CURRENT_LIST_DIR}/.nonportable"
- DESTINATION .)
+ DESTINATION "share/licenses/${PROJECT_NAME}")
foreach(${PROJECT_NAME}_QTBASE_TRANSLATION IN LISTS ${PROJECT_NAME}_QTBASE_TRANSLATIONS)
install(FILES "${${PROJECT_NAME}_QTBASE_TRANSLATION}"
- DESTINATION i18n)
+ DESTINATION "lib/${PROJECT_NAME}/i18n")
endforeach()
-if(WIN32)
- install(IMPORTED_RUNTIME_ARTIFACTS
- Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Network Qt6::OpenGL Qt6::OpenGLWidgets Qt6::Svg
- RUNTIME DESTINATION .
- LIBRARY DESTINATION .)
-
- install(FILES "${QT_BASEDIR}/bin/opengl32sw.dll"
- DESTINATION .)
-
- install(FILES "${QT_BASEDIR}/plugins/imageformats/qwebp${QT_LIB_SUFFIX}.dll"
- DESTINATION imageformats)
-
- install(FILES "${QT_BASEDIR}/plugins/platforms/qwindows${QT_LIB_SUFFIX}.dll"
- DESTINATION platforms)
-
- install(FILES "${QT_BASEDIR}/plugins/styles/qwindowsvistastyle${QT_LIB_SUFFIX}.dll"
- DESTINATION styles)
-
- install(FILES
- "${QT_BASEDIR}/plugins/tls/qcertonlybackend${QT_LIB_SUFFIX}.dll"
- "${QT_BASEDIR}/plugins/tls/qschannelbackend${QT_LIB_SUFFIX}.dll"
- DESTINATION tls)
-
- # NSIS install commands
- configure_file(
- "${CMAKE_CURRENT_LIST_DIR}/win/InstallCommands.nsh.in"
- "${CMAKE_CURRENT_LIST_DIR}/win/generated/InstallCommands.nsh"
- @ONLY)
-
- # NSIS uninstall commands
- configure_file(
- "${CMAKE_CURRENT_LIST_DIR}/win/UninstallCommands.nsh.in"
- "${CMAKE_CURRENT_LIST_DIR}/win/generated/UninstallCommands.nsh"
- @ONLY)
-elseif(UNIX)
- if (DEFINED QT_BASEDIR)
- # If this is a custom install, we've copied the Qt libraries to the build directory and done special fixups
- install(FILES
- "${CMAKE_BINARY_DIR}/libQt6Core.so.6"
- "${CMAKE_BINARY_DIR}/libQt6Gui.so.6"
- "${CMAKE_BINARY_DIR}/libQt6Widgets.so.6"
- "${CMAKE_BINARY_DIR}/libQt6Network.so.6"
- "${CMAKE_BINARY_DIR}/libQt6OpenGL.so.6"
- "${CMAKE_BINARY_DIR}/libQt6OpenGLWidgets.so.6"
- "${CMAKE_BINARY_DIR}/libQt6Svg.so.6"
-
- # Required by plugins
- "${CMAKE_BINARY_DIR}/libicudata.so.56"
- "${CMAKE_BINARY_DIR}/libicui18n.so.56"
- "${CMAKE_BINARY_DIR}/libicuuc.so.56"
- "${CMAKE_BINARY_DIR}/libQt6DBus.so.6"
- "${CMAKE_BINARY_DIR}/libQt6EglFSDeviceIntegration.so.6"
- "${CMAKE_BINARY_DIR}/libQt6EglFsKmsSupport.so.6"
- "${CMAKE_BINARY_DIR}/libQt6WaylandClient.so.6"
- "${CMAKE_BINARY_DIR}/libQt6WaylandEglClientHwIntegration.so.6"
- "${CMAKE_BINARY_DIR}/libQt6WlShellIntegration.so.6"
- "${CMAKE_BINARY_DIR}/libQt6XcbQpa.so.6"
- DESTINATION .)
-
- install(DIRECTORY
- "${CMAKE_BINARY_DIR}/egldeviceintegrations"
- "${CMAKE_BINARY_DIR}/imageformats"
- "${CMAKE_BINARY_DIR}/platforminputcontexts"
- "${CMAKE_BINARY_DIR}/platforms"
- "${CMAKE_BINARY_DIR}/platformthemes"
- "${CMAKE_BINARY_DIR}/tls"
- "${CMAKE_BINARY_DIR}/wayland-decoration-client"
- "${CMAKE_BINARY_DIR}/wayland-graphics-integration-client"
- "${CMAKE_BINARY_DIR}/wayland-shell-integration"
- "${CMAKE_BINARY_DIR}/xcbglintegrations"
- DESTINATION .)
- else()
- install(IMPORTED_RUNTIME_ARTIFACTS
- Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Network Qt6::OpenGL Qt6::OpenGLWidgets Qt6::Svg
- RUNTIME DESTINATION .
- LIBRARY DESTINATION .)
- endif()
-
- # Desktop file
- configure_file(
- "${CMAKE_CURRENT_LIST_DIR}/linux/desktop.in"
- "${CMAKE_CURRENT_LIST_DIR}/linux/generated/${PROJECT_NAME}.desktop")
- install(FILES "${CMAKE_CURRENT_LIST_DIR}/linux/generated/${PROJECT_NAME}.desktop"
- DESTINATION "/usr/share/applications/")
- install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/branding/logo.png"
- DESTINATION "/usr/share/pixmaps/"
- RENAME "${PROJECT_NAME}.png")
-
- # MIME type info
- configure_file(
- "${CMAKE_CURRENT_LIST_DIR}/linux/mime-type.xml.in"
- "${CMAKE_CURRENT_LIST_DIR}/linux/generated/mime-type.xml")
- install(FILES "${CMAKE_CURRENT_LIST_DIR}/linux/generated/mime-type.xml"
- DESTINATION "/usr/share/mime/packages/"
- RENAME "${PROJECT_NAME}.xml")
- install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/branding/logo.png"
- DESTINATION "/usr/share/icons/hicolor/128x128/mimetypes/"
- RENAME "application-x-vpkedit.png")
-endif()
+# Desktop file
+configure_file(
+ "${CMAKE_CURRENT_LIST_DIR}/linux/desktop.in"
+ "${CMAKE_CURRENT_LIST_DIR}/linux/generated/${PROJECT_NAME}.desktop")
+install(FILES "${CMAKE_CURRENT_LIST_DIR}/linux/generated/${PROJECT_NAME}.desktop"
+ DESTINATION "share/applications/")
+install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/branding/logo.png"
+ DESTINATION "share/pixmaps/"
+ RENAME "${PROJECT_NAME}.png")
+
+# MIME type info
+configure_file(
+ "${CMAKE_CURRENT_LIST_DIR}/linux/mime-type.xml.in"
+ "${CMAKE_CURRENT_LIST_DIR}/linux/generated/mime-type.xml")
+install(FILES "${CMAKE_CURRENT_LIST_DIR}/linux/generated/mime-type.xml"
+ DESTINATION "share/mime/packages/"
+ RENAME "${PROJECT_NAME}.xml")
+install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/branding/logo.png"
+ DESTINATION "share/icons/hicolor/128x128/mimetypes/"
+ RENAME "application-x-vpkedit.png")
# CPack stuff
set(CPACK_PACKAGE_NAME ${PROJECT_NAME_PRETTY})
@@ -154,14 +74,5 @@
set(CPACK_PACKAGING_INSTALL_PREFIX "/opt/${PROJECT_NAME}")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libxcb-cursor0")
set(CPACK_DEBIAN_COMPRESSION_TYPE "zstd")
-
- # Add symlinks so it can be ran from anywhere
- install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink /opt/${PROJECT_NAME}/${PROJECT_NAME}cli ${CMAKE_CURRENT_LIST_DIR}/linux/generated/${PROJECT_NAME}cli)")
- install(FILES "${CMAKE_CURRENT_LIST_DIR}/linux/generated/${PROJECT_NAME}cli"
- DESTINATION "/usr/bin")
-
- install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink /opt/${PROJECT_NAME}/${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/linux/generated/${PROJECT_NAME})")
- install(FILES "${CMAKE_CURRENT_LIST_DIR}/linux/generated/${PROJECT_NAME}"
- DESTINATION "/usr/bin")
endif()
include(CPack)

View File

@@ -0,0 +1,28 @@
--- a/src/shared/thirdparty/sourcepp/ext/miniz/miniz.pc.in
+++ b/src/shared/thirdparty/sourcepp/ext/miniz/miniz.pc.in
@@ -1,13 +1,12 @@
-prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@
-
-Name: @PROJECT_NAME@
-Description: @PROJECT_DESCRIPTION@
-Version: @MINIZ_VERSION@
-URL: @PROJECT_HOMEPAGE_URL@
-
-Requires:
-Libs: -L${libdir} -lminiz
-Cflags: -I${includedir}
+prefix=@CMAKE_INSTALL_PREFIX@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@/@PROJECT_NAME@
+
+Name: @PROJECT_NAME@
+Description: @PROJECT_DESCRIPTION@
+Version: @MINIZ_VERSION@
+URL: @PROJECT_HOMEPAGE_URL@
+
+Requires:
+Libs: -L${libdir} -lminiz
+Cflags: -I${includedir}

View File

@@ -0,0 +1,19 @@
--- a/src/gui/utility/Options.cpp
+++ b/src/gui/utility/Options.cpp
@@ -13,15 +13,7 @@
QSettings* opts = nullptr;
bool Options::isStandalone() {
-#ifdef VPKEDIT_BUILD_FOR_STRATA_SOURCE
- // Standalone mode is only used to check if we should write a physical config file.
- // If we're building for a Strata Source game, we should just use the system registry.
- // No need to pollute the bin folder!
- return false;
-#else
- QFileInfo nonportable(QApplication::applicationDirPath() + "/.nonportable");
- return !(nonportable.exists() && nonportable.isFile());
-#endif
+ return true;
}
void Options::setupOptions(QSettings& options) {