pkgit: init at 0.0.11 (#518355)
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
From 366607d5e2bc8a7e067105f1c0d0e6c2c235c131 Mon Sep 17 00:00:00 2001
|
||||
From: Philip Taron <philip.taron@gmail.com>
|
||||
Date: Mon, 29 Jun 2026 10:04:36 -0700
|
||||
Subject: [PATCH] main: handle --version/--help before loading the Lua config
|
||||
|
||||
main() loads the Lua configuration before parsing arguments, and the
|
||||
loader exits when no config file exists. That makes `pkgit --version`
|
||||
and `pkgit --help` fail on a fresh install. Answer those informational
|
||||
flags first so they work without a config.
|
||||
---
|
||||
src/main.c | 13 +++++++++++++
|
||||
1 file changed, 13 insertions(+)
|
||||
|
||||
diff --git a/src/main.c b/src/main.c
|
||||
index 9010d3e..4c45b8a 100644
|
||||
--- a/src/main.c
|
||||
+++ b/src/main.c
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <stdio.h>
|
||||
+#include <string.h>
|
||||
|
||||
#include "cla_parse.h"
|
||||
#include "lua_state.h"
|
||||
@@ -7,6 +8,18 @@
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
init_vars();
|
||||
+
|
||||
+ /* Respond to informational flags before loading the Lua config, which aborts
|
||||
+ when no config file (~/.config/pkgit/init.lua) exists. This keeps
|
||||
+ `pkgit --version` and `pkgit --help` usable on a fresh install. */
|
||||
+ for (int i = 1; i < argc; i++) {
|
||||
+ if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--version") ||
|
||||
+ !strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
|
||||
+ cla_parse(argc, argv);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
init_lua_state();
|
||||
setup_pkgit();
|
||||
cache_repos();
|
||||
--
|
||||
2.54.0
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchgit,
|
||||
pkg-config,
|
||||
luajit,
|
||||
git,
|
||||
makeWrapper,
|
||||
nix-update-script,
|
||||
versionCheckHook,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "pkgit";
|
||||
version = "1.1.3";
|
||||
|
||||
src = fetchgit {
|
||||
url = "https://git.symlinx.net/pkgit";
|
||||
tag = finalAttrs.version;
|
||||
hash = "sha256-xGrhkVA5H/expArfUbfJ8p1odUAeJiL/vbsPedd92EE=";
|
||||
};
|
||||
|
||||
__structuredAttrs = true;
|
||||
|
||||
patches = [
|
||||
# main() loads the Lua config (which requires ~/.config/pkgit/init.lua)
|
||||
# before parsing arguments, so `pkgit --version` and `--help` abort without
|
||||
# a config. Answer those informational flags first so they work standalone
|
||||
# and can be used by versionCheckHook.
|
||||
./0001-main-handle-version-help-before-loading-the-Lua-config.patch
|
||||
];
|
||||
|
||||
strictDeps = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs = [ luajit ];
|
||||
|
||||
# The Makefile defaults CC to clang via `?=`; stdenv exports CC, which wins.
|
||||
makeFlags = [ "PREFIX=${placeholder "out"}" ];
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
# pkgit shells out to git at runtime (src/fetch_git.c execvp's "git").
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/pkgit \
|
||||
--prefix PATH : ${lib.makeBinPath [ git ]}
|
||||
'';
|
||||
|
||||
doInstallCheck = true;
|
||||
nativeInstallCheckInputs = [ versionCheckHook ];
|
||||
|
||||
passthru.updateScript = nix-update-script { };
|
||||
|
||||
meta = {
|
||||
description = "Unconventional package manager that compiles and installs packages directly from Git repositories";
|
||||
homepage = "https://git.symlinx.net/pkgit";
|
||||
license = lib.licenses.gpl3Plus;
|
||||
maintainers = with lib.maintainers; [ Ra77a3l3-jar ];
|
||||
mainProgram = "pkgit";
|
||||
platforms = lib.platforms.unix;
|
||||
};
|
||||
})
|
||||
Reference in New Issue
Block a user