From bd1120a2cbd402325ec6572a03798456d37c594c Mon Sep 17 00:00:00 2001 From: Whovian9369 Date: Tue, 4 Jun 2024 05:24:03 -0400 Subject: [PATCH] Add fully working `rom-properties` evaluation! --- home/packages/rom-properties/package.nix | 92 ++++++++++--------- .../patches/fix_debug_paths.diff | 34 +++++++ .../patches/fix_getdents64_build.diff | 12 +++ .../patches/fix_rp-stub_symlink.diff | 13 +++ home/pkgs_and_programs.nix | 4 +- 5 files changed, 113 insertions(+), 42 deletions(-) create mode 100644 home/packages/rom-properties/patches/fix_debug_paths.diff create mode 100644 home/packages/rom-properties/patches/fix_getdents64_build.diff create mode 100644 home/packages/rom-properties/patches/fix_rp-stub_symlink.diff diff --git a/home/packages/rom-properties/package.nix b/home/packages/rom-properties/package.nix index b3fac63..e2e850e 100644 --- a/home/packages/rom-properties/package.nix +++ b/home/packages/rom-properties/package.nix @@ -15,7 +15,15 @@ tinyxml2, zlib, zstd, - glib + glib, + + # Use "Ninja" for the build. + useNinja ? false, + ninja, + + # Enable GNOME "Tracker". + useTracker ? false, + tracker }: stdenv.mkDerivation { @@ -25,8 +33,8 @@ stdenv.mkDerivation { src = fetchFromGitHub { owner = "GerbilSoft"; repo = "rom-properties"; - rev = "1df55be31d5aab88db1ba722267255389a812802"; - hash = "sha256-e2K2XRPLLSXM+lWv5aFiU3PwotuUT0V8INAFc9QKmYY="; + rev = "10c20ccc3b5550e7950e036a56b0a34714edb263"; + hash = "sha256-uoyD2xuPkdoKidyG1Dlckk5ImKnGw/rk8G27IS1cTes="; }; nativeBuildInputs = [ @@ -34,7 +42,9 @@ stdenv.mkDerivation { nettle.dev pkg-config glib.dev - ]; + tinyxml2 + ] + ++ lib.optionals useNinja [ ninja ]; buildInputs = [ gettext @@ -44,21 +54,45 @@ stdenv.mkDerivation { libseccomp.dev lz4.dev lzo - tinyxml2 zlib.dev zstd.dev - ]; + tinyxml2 + ] + ++ lib.optionals useTracker [ tracker ]; cmakeFlags = [ - "-DCMAKE_BUILD_TYPE=Release" - "-DINSTALL_APPARMOR=OFF" + (lib.cmakeBool "INSTALL_APPARMOR" false) + (lib.cmakeBool "ENABLE_DECRYPTION" true) + (lib.cmakeBool "ENABLE_EXTRA_SECURITY" true) + (lib.cmakeBool "ENABLE_JPEG" true) + (lib.cmakeBool "ENABLE_XML" true) + (lib.cmakeBool "ENABLE_UNICE68" true) + (lib.cmakeBool "ENABLE_LIBMSPACK" true) + (lib.cmakeBool "ENABLE_PVRTC" true) + (lib.cmakeBool "ENABLE_ZSTD" true) + (lib.cmakeBool "ENABLE_LZ4" true) + (lib.cmakeBool "ENABLE_LZO" true) + (lib.cmakeBool "ENABLE_NLS" true) + (lib.cmakeBool "ENABLE_OPENMP" true) + ] ++ lib.optionals useTracker [ (lib.cmakeFeature "TRACKER_INSTALL_API_VERSION" "3") ]; + + patches = [ + ./patches/fix_debug_paths.diff + ./patches/fix_getdents64_build.diff + ./patches/fix_rp-stub_symlink.diff ]; /* - About "postPatch"... patches. - "src/librpsecure/os-secure_linux.c" change is needed to complete the - build as it's not being detected automatically. (WSL Issue????) - "src/rp-stub/CMakeLists.txt" change is needed to properly symlink + About "patches": + "fix_debug_paths.diff" is needed to properly have some correct debug + paths, due to "cmake"'s weird path issues. + (See below references for "fix_rp-stub_symlink.diff".) + + "fix_getdents64_build.diff" is needed to properly complete and then run + the build as it's not being detected automatically. + (Maybe it's an issue with WSL?) + + "fix_rp-stub_symlink.diff" is needed to properly symlink `result/libexec/rp-thumbnail` to `result/bin/rp-stub` due to the odd double-path bug as described in https://github.com/NixOS/nixpkgs/issues/144170 @@ -68,13 +102,6 @@ stdenv.mkDerivation { https://github.com/NixOS/nixpkgs/pull/247474 # cmake: make check-pc-files hook also check .cmake files */ - postPatch = '' - substituteInPlace "src/librpsecure/os-secure_linux.c" \ - --replace-fail "SCMP_SYS(write)," \ - "SCMP_SYS(write), SCMP_SYS(getdents64)," - substituteInPlace "src/rp-stub/CMakeLists.txt" \ - --replace-fail "{CMAKE_INSTALL_PREFIX}/\$" "" - ''; meta = { description = "ROM Properties Page shell extension"; @@ -86,29 +113,12 @@ stdenv.mkDerivation { }; } +################################################################### -/* +/* NOTES - Notes: - - "$STORE_PATH" in these notes reference "nix/store/pnyxqz1vi124i18zdbl8ad1vypai73yg-rom-properties-git" - "$CMAKE_INSTALL_BINDIR" matches variable in Cmake flags - "$CMAKE_INSTALL_LIBDIR" matches variable in Cmake flags - "$CMAKE_INSTALL_LIBEXECDIR" matches variable in Cmake flags - ============================================================= - /$CMAKE_INSTALL_LIBDIR/debug/$STORE_PATH/$CMAKE_INSTALL_LIBEXECDIR/rp-download.debug - /$CMAKE_INSTALL_LIBDIR/debug/$STORE_PATH/$CMAKE_INSTALL_LIBDIR/libromdata.debug - /$CMAKE_INSTALL_LIBDIR/debug/$STORE_PATH/$CMAKE_INSTALL_BINDIR/rpcli.debug - /$CMAKE_INSTALL_LIBDIR/debug/$STORE_PATH/$CMAKE_INSTALL_BINDIR/rp-thumbnail.debug - /$CMAKE_INSTALL_LIBDIR/debug/$STORE_PATH/$CMAKE_INSTALL_BINDIR/rp-config.debug - - What I think I want the debug paths to end up as: - $CMAKE_INSTALL_LIBDIR/debug/libexec/rp-download.debug - $CMAKE_INSTALL_LIBDIR/debug/lib/libromdata.debug - $CMAKE_INSTALL_LIBDIR/debug/bin/rpcli.debug - $CMAKE_INSTALL_LIBDIR/debug/bin/rp-thumbnail.debug - $CMAKE_INSTALL_LIBDIR/debug/bin/rp-config.debug - - ... Do I even need to build the debug executables anyway? + Package 'libpcre2-8', required by 'glib-2.0', not found + Package libpcre2-8 was not found in the pkg-config search path. + Perhaps you should add the directory containing `libpcre2-8.pc' */ diff --git a/home/packages/rom-properties/patches/fix_debug_paths.diff b/home/packages/rom-properties/patches/fix_debug_paths.diff new file mode 100644 index 0000000..96b6766 --- /dev/null +++ b/home/packages/rom-properties/patches/fix_debug_paths.diff @@ -0,0 +1,34 @@ +diff --git a/cmake/macros/DirInstallPaths.cmake b/cmake/macros/DirInstallPaths.cmake +index 7aefd5de6..1b180e3d2 100644 +--- a/cmake/macros/DirInstallPaths.cmake ++++ b/cmake/macros/DirInstallPaths.cmake +@@ -65,10 +65,10 @@ IF(UNIX AND NOT APPLE) + SET(DIR_INSTALL_XDG_MIME "share/mime") + SET(DIR_INSTALL_XDG_DESKTOP "share/applications") + SET(DIR_INSTALL_XDG_APPSTREAM "share/metainfo") +- SET(DIR_INSTALL_EXE_DEBUG "lib/debug/${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_EXE}") +- SET(DIR_INSTALL_DLL_DEBUG "lib/debug/${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_DLL}") +- SET(DIR_INSTALL_LIB_DEBUG "lib/debug/${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_LIB}") +- SET(DIR_INSTALL_LIBEXEC_DEBUG "lib/debug/${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_LIBEXEC}") ++ SET(DIR_INSTALL_EXE_DEBUG "lib/debug/bin") ++ SET(DIR_INSTALL_DLL_DEBUG "lib/debug/lib") ++ SET(DIR_INSTALL_LIB_DEBUG "lib/debug/lib") ++ SET(DIR_INSTALL_LIBEXEC_DEBUG "lib/debug/libexec") + + # AppArmor profile directory + SET(DIR_INSTALL_APPARMOR "/etc/apparmor.d") +@@ -88,10 +88,10 @@ ELSEIF(APPLE) + UNSET(DIR_INSTALL_XDG_MIME) + UNSET(DIR_INSTALL_XDG_DESKTOP) + UNSET(DIR_INSTALL_XDG_APPSTREAM) +- SET(DIR_INSTALL_EXE_DEBUG "lib/debug/${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_EXE}") +- SET(DIR_INSTALL_DLL_DEBUG "lib/debug/${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_DLL}") +- SET(DIR_INSTALL_LIB_DEBUG "lib/debug/${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_LIB}") +- SET(DIR_INSTALL_LIBEXEC_DEBUG "lib/debug/${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_LIBEXEC}") ++ SET(DIR_INSTALL_EXE_DEBUG "lib/debug/bin") ++ SET(DIR_INSTALL_DLL_DEBUG "lib/debug/lib") ++ SET(DIR_INSTALL_LIB_DEBUG "lib/debug/lib") ++ SET(DIR_INSTALL_LIBEXEC_DEBUG "lib/debug/libexec") + ELSEIF(WIN32) + # Win32-style install paths. + # Files are installed relative to root, since the diff --git a/home/packages/rom-properties/patches/fix_getdents64_build.diff b/home/packages/rom-properties/patches/fix_getdents64_build.diff new file mode 100644 index 0000000..f4b2867 --- /dev/null +++ b/home/packages/rom-properties/patches/fix_getdents64_build.diff @@ -0,0 +1,12 @@ +diff --git a/src/librpsecure/os-secure_linux.c b/src/librpsecure/os-secure_linux.c +index bd245ff40..0a4c7159f 100644 +--- a/src/librpsecure/os-secure_linux.c ++++ b/src/librpsecure/os-secure_linux.c +@@ -71,6 +71,7 @@ int rp_secure_enable(rp_secure_param_t param) + SCMP_SYS(read), + SCMP_SYS(rt_sigreturn), + SCMP_SYS(write), ++ SCMP_SYS(getdents64), + + SCMP_SYS(access), + SCMP_SYS(faccessat), // Linux on aarch64 does not have an access() syscall diff --git a/home/packages/rom-properties/patches/fix_rp-stub_symlink.diff b/home/packages/rom-properties/patches/fix_rp-stub_symlink.diff new file mode 100644 index 0000000..19ad012 --- /dev/null +++ b/home/packages/rom-properties/patches/fix_rp-stub_symlink.diff @@ -0,0 +1,13 @@ +diff --git a/src/rp-stub/CMakeLists.txt b/src/rp-stub/CMakeLists.txt +index acad9bdcd..d611b38cf 100644 +--- a/src/rp-stub/CMakeLists.txt ++++ b/src/rp-stub/CMakeLists.txt +@@ -39,7 +39,7 @@ INCLUDE(DirInstallPaths) + # Create symlinks for rp-thumbnail and rp-config. + # Reference: https://stackoverflow.com/questions/34578362/how-can-i-package-a-symlink-with-cpack + ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD +- COMMAND ln -sf "${CMAKE_INSTALL_PREFIX}/${DIR_INSTALL_EXE}/${PROJECT_NAME}" rp-thumbnail ++ COMMAND ln -sf "${DIR_INSTALL_EXE}/${PROJECT_NAME}" rp-thumbnail + WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + VERBATIM + ) diff --git a/home/pkgs_and_programs.nix b/home/pkgs_and_programs.nix index 24419a8..5d7c2f3 100644 --- a/home/pkgs_and_programs.nix +++ b/home/pkgs_and_programs.nix @@ -15,6 +15,9 @@ let ps3dec = pkgs.callPackage ./packages/ps3dec/package.nix {}; sabretools = pkgs.callPackage ./packages/sabretools/package.nix {}; rom-properties = pkgs.callPackage ./packages/rom-properties/package.nix {}; + # rom-properties_ninja = pkgs.callPackage ./package.nix { useNinja = true; }; + # rom-properties_gtracker = pkgs.callPackage ./package.nix { useTracker = true; }; + # rom-properties_ninja_gtracker = pkgs.callPackage ./package.nix { useNinja = true; useTracker = true; }; new_rclone = pkgs.rclone.overrideAttrs (oldAttrs: rec { patches = [ ./packages/new_rclone/patches/rclone_8ffe3e462cbf5688c37c54009db09d8dcb486860.diff ]; } @@ -147,7 +150,6 @@ in # Not needed on WSL, even though I'd like it on WSL sometimes. pkgs.yt-dlp # Not needed on WSL - my_packages.hactoolnet-bin # Not needed on WSL as I currently use the Windows version. */