Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building on NixOS returns "invalid system call" #406

Open
Whovian9369 opened this issue Mar 5, 2024 · 0 comments
Open

Building on NixOS returns "invalid system call" #406

Whovian9369 opened this issue Mar 5, 2024 · 0 comments

Comments

@Whovian9369
Copy link

Whovian9369 commented Mar 5, 2024

Building rom-properties on NixOS with CMake flags -DCMAKE_BUILD_TYPE=Release -DINSTALL_APPARMOR=OFF appears to build correctly, but running rpcli just errors instead.

Example:

$  nix run .#git-broken
[1]    36898 invalid system call  nix run .#git-broken

Working example, which is expected output:

$  nix run .#git
Usage: rpcli [-k] [-c] [-p] [-j] [-l lang] [[-xN outfile]... [-mN outfile]... [-a apngoutfile] filename]...
  -k:  Verify encryption keys in keys.conf.
  -c:  Print system region information.
  -p:  Print system path information.
  -d:  Skip ListData fields with more than 10 items. [text only]
  -j:  Use JSON output format.
  -l:  Retrieve the specified language from the ROM image.
  -xN: Extract image N to outfile in PNG format.
  -mN: Extract mipmap level N to outfile in PNG format.
  -a:  Extract the animated icon to outfile in APNG format.

Special options for devices:
  -is: Run a SCSI INQUIRY command.
  -ia: Run an ATA IDENTIFY DEVICE command.
  -ip: Run an ATA IDENTIFY PACKET DEVICE command.

Examples:
* rpcli s3.gen
         displays info about s3.gen
* rpcli -x0 icon.png pokeb2.nds
         extracts icon from pokeb2.nds

The fix (as previously troubleshot via Discord) at build time is adding getdents64 as an available system call. That can easily be done with the following substituteInPlace command:

  postPatch = ''
    substituteInPlace "src/librpsecure/os-secure_linux.c" \
      --replace "SCMP_SYS(write)," "SCMP_SYS(write), SCMP_SYS(getdents64),"
  '';

The following is a Nix evaluation that succeeds that building a working rpcli binary. If you want to test this issue yourself, remove the postPatch section, rebuild, and test the result/bin/rpcli binary.

{ lib, stdenv, fetchFromGitHub, cmake, gettext, curl, libjpeg, libpng, libseccomp, lz4, lzo, nettle, pkg-config, tinyxml2, zlib, zstd, glib }:

stdenv.mkDerivation {
  pname = "rom-properties";
  version = "git";

  src = fetchFromGitHub {
    owner = "GerbilSoft";
    repo = "rom-properties";
    rev = "205c81c885df9a4616e686f9318f9e8844e0cc7d";
    hash = "sha256-cKij/F4ni8zMGH6OMgt4dQmpsxQcY9sDaLhAC5FYwPY=";
  };

  nativeBuildInputs = [
    cmake
    nettle.dev
    pkg-config
    glib.dev
  ];

  buildInputs = [
    gettext
    curl.dev
    libjpeg.dev
    libpng.dev
    libseccomp.dev
    lz4.dev
    lzo
    tinyxml2
    zlib.dev
    zstd.dev
  ];

  cmakeFlags = [
    "-DCMAKE_BUILD_TYPE=Release"
    "-DINSTALL_APPARMOR=OFF"
  ];

  postPatch = ''
    substituteInPlace "src/librpsecure/os-secure_linux.c" \
      --replace "SCMP_SYS(write)," "SCMP_SYS(write), SCMP_SYS(getdents64),"
  '';

  meta = {
    description = "ROM Properties Page shell extension";
    homepage = "https://github.com/GerbilSoft/rom-properties";
    license = lib.licenses.gpl2Only;
    maintainers = with lib.maintainers; [ whovian9369 ];
    mainProgram = "rpcli";
    platforms = lib.platforms.all;
  };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant