From 9fac0bb00a6c1113015f96036eee812dd0969689 Mon Sep 17 00:00:00 2001 From: "T. Finch" <175355007+Taylor-Finch@users.noreply.github.com> Date: Wed, 24 Jul 2024 19:10:56 +0000 Subject: [PATCH 1/4] Fix 'discid' memset array bounds error Fixes compilation error by adjusting bounds of memset on 'discid'. --- pkg2zip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg2zip.c b/pkg2zip.c index fe852ae..7cf1976 100644 --- a/pkg2zip.c +++ b/pkg2zip.c @@ -256,7 +256,7 @@ static void find_psp_sfo(const aes128_key* key, const aes128_key* ps3_key, const static void find_pbp_sfo(const aes128_key* key, const aes128_key* ps3_key, const uint8_t* iv, sys_file pkg, uint64_t pkg_size, uint64_t enc_offset, uint64_t items_offset, uint32_t item_count, char* discid) { - memset(discid, 0x00, 0x10); + memset(discid, 0x00, 0x0A); for (uint32_t item_index = 0; item_index < item_count; item_index++) { uint8_t item[32]; From 699a5635eef5487a9d41c2c5954b8f8ab22aaa32 Mon Sep 17 00:00:00 2001 From: lakrestofer Date: Sat, 15 Feb 2025 13:52:09 +0100 Subject: [PATCH 2/4] add flake.nix --- .envrc | 3 +++ .gitignore | 1 + flake.nix | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 .envrc create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..7ceda50 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +use flake +export CC=clang +export LD_LIBRARY_PATH="/run/opengl-driver/lib:/run/opengl-driver-32/lib"; diff --git a/.gitignore b/.gitignore index b83e0c7..2dee4ff 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ pkg2zip.exe *.obj *.pdb *.zip +.direnv diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..8be536e --- /dev/null +++ b/flake.nix @@ -0,0 +1,49 @@ +{ + description = "A Nix-flake-based C/C++ development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + { self, nixpkgs }: + let + supportedSystems = [ "x86_64-linux" ]; + forEachSupportedSystem = + f: + nixpkgs.lib.genAttrs supportedSystems ( + system: + f { + pkgs = import nixpkgs { inherit system; }; + } + ); + in + { + devShells = forEachSupportedSystem ( + { pkgs }: + { + default = + pkgs.mkShell.override + { + # Override stdenv in order to change compiler: + stdenv = pkgs.clangStdenv; + } + { + packages = with pkgs; [ + glxinfo + cglm + glfw + blas + clang-tools + meson + ninja + gdb + typos + pkg-config + ]; + + }; + } + ); + }; +} From 3ee312cc9e6f99b2b173b5d8f1ebe76066e55f2a Mon Sep 17 00:00:00 2001 From: lakrestofer Date: Sat, 15 Feb 2025 14:11:00 +0100 Subject: [PATCH 3/4] update flake.nix --- .envrc | 2 -- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 14 +++++++------- 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 flake.lock diff --git a/.envrc b/.envrc index 7ceda50..3550a30 100644 --- a/.envrc +++ b/.envrc @@ -1,3 +1 @@ use flake -export CC=clang -export LD_LIBRARY_PATH="/run/opengl-driver/lib:/run/opengl-driver-32/lib"; diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..42c04dd --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1739446958, + "narHash": "sha256-+/bYK3DbPxMIvSL4zArkMX0LQvS7rzBKXnDXLfKyRVc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "2ff53fe64443980e139eaa286017f53f88336dd0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 8be536e..65baaeb 100644 --- a/flake.nix +++ b/flake.nix @@ -26,17 +26,17 @@ pkgs.mkShell.override { # Override stdenv in order to change compiler: - stdenv = pkgs.clangStdenv; + stdenv = pkgs.gccStdenv; } { packages = with pkgs; [ - glxinfo - cglm - glfw - blas + (python3.withPackages ( + p: with p; [ + + ] + )) + gcc clang-tools - meson - ninja gdb typos pkg-config From a86ee57638c9b50d3dd9b4f5c9e5d4fb90a273b1 Mon Sep 17 00:00:00 2001 From: lakrestofer Date: Sat, 15 Feb 2025 14:34:03 +0100 Subject: [PATCH 4/4] package pkg2zip nix derivation --- .gitignore | 1 + flake.nix | 38 ++++++++++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 2dee4ff..aabff09 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ pkg2zip.exe *.pdb *.zip .direnv +result diff --git a/flake.nix b/flake.nix index 65baaeb..1257c57 100644 --- a/flake.nix +++ b/flake.nix @@ -25,16 +25,11 @@ default = pkgs.mkShell.override { - # Override stdenv in order to change compiler: stdenv = pkgs.gccStdenv; } { packages = with pkgs; [ - (python3.withPackages ( - p: with p; [ - - ] - )) + python3 gcc clang-tools gdb @@ -45,5 +40,36 @@ }; } ); + + packages = forEachSupportedSystem ( + { pkgs }: + { + default = pkgs.stdenv.mkDerivation { + pname = "pkg2zip"; + version = "0.1"; + + src = ./.; + + # nativeBuildInputs = [ pkgs.makeWrapper ]; # If you need wrappers + buildInputs = [ ]; # Add dependencies like pkgs.openssl if needed + + buildPhase = '' + printenv + make + ''; + + installPhase = '' + mkdir -p $out/bin + cp ./pkg2zip $out/bin/ + ''; + + meta = { + description = "Decrypts PlayStation Vita pkg file and packages to zip archive"; + license = pkgs.lib.licenses.unlicense; + platforms = pkgs.lib.platforms.linux; + }; + }; + } + ); }; }