Improve patchExternalProjectGit

Add basic support for checking the version if it is assigned to a
variable.
This commit is contained in:
Ben Wolsieffer 2024-11-15 13:10:05 -05:00
parent 5d3c82695b
commit f556a34f39
4 changed files with 12 additions and 14 deletions

View file

@ -48,6 +48,7 @@
rev,
originalRev ? rev,
originalUrl ? url,
revVariable ? "",
file ? "CMakeLists.txt",
fetchgitArgs ? {}
}: pkg.overrideAttrs ({
@ -59,6 +60,7 @@
{ print "URL \"" path "\""; foundUrl=1; next } \
{ print }
$0 ~ "GIT_TAG[[:blank:]]+" originalRev { print; foundRev=1 }
$0 ~ "set\\(" revVariable "[[:blank:]]+\"?" originalRev "\"?\\)" { print; foundRev=1 }
END {
if (!foundUrl) print "patchExternalProjectGit: did not find URL: " originalUrl > "/dev/stderr"
if (!foundRev) print "patchExternalProjectGit: did not find revision: " originalRev > "/dev/stderr"
@ -69,6 +71,7 @@
awk -i inplace \
-v originalUrl=${lib.escapeShellArg originalUrl} \
-v originalRev=${lib.escapeShellArg originalRev} \
-v revVariable=${lib.escapeShellArg revVariable} \
-v path=${lib.escapeShellArg (self.fetchgit ({ inherit url rev; } // fetchgitArgs))} \
${lib.escapeShellArg script} \
${lib.escapeShellArg file}