pthbs

Packaging Through Hashed Build Scripts
git clone https://ccx.te2000.cz/git/pthbs
Log | Files | Refs | Submodules | README

commit fa0a5d15560d24c885e5ca0001a5505abdbe31c9
parent 82c4755a063edf3f2347cb2ca92266d24ff8e12a
Author: Jan Pobrislo <ccx@te2000.cz>
Date:   Fri,  9 May 2025 22:48:22 +0000

print unused packages

Diffstat:
Mutil/_verify-external-resources.awk | 62++++++++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 52 insertions(+), 10 deletions(-)

diff --git a/util/_verify-external-resources.awk b/util/_verify-external-resources.awk @@ -4,10 +4,6 @@ BEGIN { dep_count = 0 env_count = 0 - is_envfile = ENVIRON["script"] ~ /\.environment$/ - if(is_envfile) { - envname = substr(ENVIRON["scriptname"], 1, length(ENVIRON["scriptname"])-12) - } FS="[ /]" } @@ -92,17 +88,19 @@ function load_commitlist(commitlist_path, n) { } /^[0-9a-f]+ .*\/[-_:.0-9a-zA-Z]+\/[-_:.0-9a-zA-Z]+/ { + pfile = substr($0, length($1) + 3) + pvariant = $(NF-1) pname = $NF sub(/:.*/, "", pname) if(pname ~ /\.environment$/) { + namedenv_name[pfile] = pvariant"/"pname pname = "env" } pname = $(NF-1)"/"pname"."$1 - pfile = substr($0, length($1) + 3) - pvariant = $(NF-1) dbgprint_pkg() package_names[pname] = 0 + package_files[pname] = pfile package_variants[pfile] = pvariant next } @@ -117,8 +115,19 @@ function record_failure(dep_type, dep_value, msg) { failed[pfile] = failed[pfile] pfile ":" pline " [" dep_type "] '" dep_value "'\t" msg "\n" } +function find_namedenvs(pfile, rdeps, rdep_count, n, result) { + if (pfile ~ /\.environment$/) { + return pfile + } + rdep_count = split(package_rdeps[pfile], rdeps, " ") + for(n=1; n<=rdep_count; n++) { + result = spacemerge(result, find_namedenvs(rdeps[n])) + } + return result +} + END { - delete pname + pname="" for(pfile in package_variants) { read_package(pfile) } @@ -152,6 +161,17 @@ END { } printf "downloads: %4d unused: %4d\n", count, unused + # for(pfile in package_rdeps) { + for(pfile in package_variants) { + dbgprint("'" pfile "' <- '" package_rdeps[pfile] "'") + nes = find_namedenvs(pfile) + if(length(nes)){ + dbgprint("'" pfile "' <= '" nes "'") + } else { + vprint("unused package: " pfile) + } + } + failed_files = 0 for(pfile in failed) { failed_files += 1 @@ -191,7 +211,7 @@ function read_package(f, line, seen_shebang) { if(!seen_shebang) { fatal("did not encounter expected shebang line in package") } - delete pline + pline="" } function depend_git(commit_id) { @@ -230,16 +250,38 @@ function at_filehash(hash_type, file_hash, dst, dstdir){ depend_file(hash_type, file_hash) } -function hash_plus(line, dep) { +function spacejoin(a, b) { + return (length(a) ? a " " : "") b +} + +function spacemerge(a, b, arr, cnt, n, marr, merged) { + cnt = split(a, arr, " ") + for(n=1; n<=cnt; n++) { + marr[arr[n]]=1 + } + cnt = split(b, arr, " ") + for(n=1; n<=cnt; n++) { + marr[arr[n]]=1 + } + for(n in marr) { + merged = spacejoin(merged, n) + } + return merged +} + +function hash_plus(line, dep, depfile) { if(line == "#+*") { # settings["sandbox"] = 0 - } else if(!length(ENVIRON["envdir"])) { + } else { dep = pvariant "/" substr(line, 3) if(!(dep in package_names)) { fatal("could not resolve '"dep"' to package file in") } else { dbgprint_dep("pkg", dep) package_names[dep] += 1 + depfile = package_files[dep] + package_deps[pfile] = spacejoin(package_deps[pfile], depfile) + package_rdeps[depfile] = spacejoin(package_rdeps[depfile], pfile) } } }