commit f498a516fe3c27b892bf873e99b65239bdfba60d
parent c6649bb39704ad5583a74c78286c09fff9ac2c75
Author: ccx <ccx@te2000.cz>
Date: Tue, 29 Oct 2024 11:01:19 +0000
cache/link generation, standardize on cache/link/file-sha256/
Diffstat:
7 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/command/pthbs-build b/command/pthbs-build
@@ -135,7 +135,7 @@ function at_git(commit_id, dstdir){
function at_untar(extra_opts, hash_type, file_hash, dstdir){
print "mkdir -p "q(dstdir)
- print "tar -x "extra_opts" -C "q(dstdir)" -f "qlink("files-"hash_type"/"file_hash)
+ print "tar -x "extra_opts" -C "q(dstdir)" -f "qlink("file-"hash_type"/"file_hash)
}
function at_filehash(hash_type, file_hash, dst, dstdir){
diff --git a/command/pthbs-download b/command/pthbs-download
@@ -1,4 +1,7 @@
#!/bin/sh
+if test -n "$pthbs_xtrace"; then
+ set -x
+fi
test $# -gt 3 || exit 2
checksum_format=$1
checksum=$2
diff --git a/command/pthbs-makegen b/command/pthbs-makegen
@@ -66,7 +66,7 @@ function fatal(msg) {
function have_file(hash_type, file_hash) {
if(((hash_type, file_hash) in linkable_hashes)) {
- deps[++dep_count] = "$(cache)/link/files-"hash_type"/.local"
+ deps[++dep_count] = "$(cache)/link/file-"hash_type"/.local"
return
}
if(((hash_type, file_hash) in downloadable_hashes)) {
@@ -75,6 +75,9 @@ function have_file(hash_type, file_hash) {
}
fatal("Could not determine source for file "hash_type":"file_hash)
}
+function have_git_commit(commit_id) {
+ deps[++dep_count] = "$(cache)/link/git-commit-sha1/.local"
+}
function have_envdep(package) {
if(match(package, "[.][0-9a-f]{64}$") == 0) {
@@ -130,7 +133,7 @@ function make_envfile( n, envfile, envhash) {
}
/^#@/ && !is_envfile {
if($1 == "#@git") {
- next
+ have_git_commit($2)
} else if($1 == "#@pragma") {
if($2 == "nosandbox") {
settings["sandbox"] = 0
diff --git a/pthbs.mk b/pthbs.mk
@@ -26,8 +26,11 @@ $(versions)/environment.%/.env:
touch '$@'
-$(cache)/link/files-%/.local: $(index)/filelist.% $(cache)/link/files-%/.exists
- pthbs-link-from-index '$(cache)/link/files-$*/' '$(index)/filelist.$*'
+$(cache)/link/file-%/.local: $(index)/filelist.% $(cache)/link/file-%/.exists
+ pthbs-link-from-index '$(cache)/link/file-$*/' '$(index)/filelist.$*'
+
+$(cache)/link/git-commit-%/.local: $(index)/commitlist.% $(cache)/link/git-commit-%/.exists
+ pthbs-link-from-index '$(cache)/link/git-commit-$*/' '$(index)/commitlist.$*'
$(cache)/make/package.%.mk: $(packages)/% $(cache)/make/.exists $(pthbs)/command/pthbs-makegen
pthbs-makegen '$(packages)/$*' >'$@.new'
diff --git a/util/gen-filelist-sha256 b/util/gen-filelist-sha256
@@ -1,2 +1,2 @@
#!/bin/sh
-busybox find "$@" -type f -print0 | busybox sort -z | busybox xargs -0 busybox sha256sum
+busybox find "$@" -type f -print0 | busybox sort -z | busybox xargs -0r busybox sha256sum
diff --git a/util/gen_git_commitlist b/util/gen_git_commitlist
@@ -0,0 +1,6 @@
+#!/bin/sh
+if test -n "$pthbs_xtrace"; then
+ set -x
+fi
+util_dir=$(dirname "$0")
+busybox find "$@" -type d -name .git -print0 | busybox sort -z | busybox xargs -0 -r -n 1 "$util_dir/gitdir_listrefs"
diff --git a/util/gitdir_listrefs b/util/gitdir_listrefs
@@ -0,0 +1,15 @@
+#!/bin/sh -e
+if test -n "$pthbs_xtrace"; then
+ set -x
+fi
+if test $# -ne 1; then
+ printf >&2 '%s: fatal: requires exactly one argument, got %s\n' "${0##*/}" $#
+ exit 2
+fi
+test -d "$1" || exit 2
+repo_dir=${1%/*}
+head=$( cd "$repo_dir" && git show -s --pretty=format:%H%n )
+printf '%s %s\n' "$head" "$repo_dir"
+( cd "$repo_dir" && git for-each-ref --format='%(objectname)' ) | while read commit; do
+ printf '%s %s\n' "$commit" "$repo_dir"
+done