oasislinux / oasis

a small statically-linked linux system
Other
2.75k stars 84 forks source link

update git to 2.42.0 and consider config.prefix #69

Closed rnpnr closed 9 months ago

rnpnr commented 9 months ago

First commit simply updates git to 2.42.0.

Second commit makes config.prefix apply to some of compiled in paths. It makes git built here usable if its installed to config.prefix rather than /.

I omitted the ETC_* paths for now but they could also be modified.

Note: GIT_LOCALE_PATH isn't actually used anywhere so it was dropped.

See #15.

michaelforney commented 9 months ago

Thanks for the PR!

Update to 2.42 looks great, nice job. git is one of the more involved packages to update, too. I pushed with two tiny changes:

Regarding config.prefix, I think there may be a simpler approach. It looks like all of those paths (GIT_*_PATH, DEFAULT_GIT_TEMPLATE_DIR) are used with the system_path() function, which prefixes them with system_prefix().

system_prefix() works in one of two ways, depending on whether RUNTIME_PREFIX is defined. If it is, it looks of the executable path using /proc/self/exe, finding the prefix dynamically similar to a relocatable gcc toolchain, otherwise it uses FALLBACK_RUNTIME_PREFIX. So I think we could do the following:

diff --git a/pkg/git/gen.lua b/pkg/git/gen.lua
index ff45e4333..89239fa90 100644
--- a/pkg/git/gen.lua
+++ b/pkg/git/gen.lua
@@ -31,7 +31,7 @@ build('hooklist', '$outdir/hook-list.h', {
    '|', '$srcdir/generate-hooklist.sh', '$srcdir/Documentation/githooks.txt'
 })

-cc('exec-cmd.c', nil, {cflags=[[$cflags '-DFALLBACK_RUNTIME_PREFIX=""']]})
+cc('exec-cmd.c', nil, {cflags=string.format([[$cflags '-DFALLBACK_RUNTIME_PREFIX="%s"']], config.prefix)})
 cc('common-main.c')
 cc('http.c')
 cc('compat/regex/regex.c', nil, {cflags='$cflags -DGAWK -DNO_MBSUPPORT'})

Perhaps you could test this and see if it works for you? Alternatively, we could enable runtime prefix detection by defining RUNTIME_PREFIX and PROCFS_EXECUTABLE_PATH. What do you think?

rnpnr commented 9 months ago

pkg/git/.gitignore & pkg/git/ver

Sorry I definitely thought I included those.

As for config.prefix I can confirm your approach works. I rebased and pushed this branch with only that fix. Feel free to use it or write your own commit if you prefer.

I think FALLBACK_RUNTIME_PREFIX is fine. Since you can't just copy the git binary to another location and expect it to work I think that runtime detection of the prefix is unnecessary. If you didn't need all the files in libexec/git-core to have fully functional git it might be a different story.

michaelforney commented 9 months ago

Thanks, pushed.