Last active
September 12, 2022 17:39
-
-
Save oguz-ismail/7d7a11d0ecf653cf10e934fdb161608a to your computer and use it in GitHub Desktop.
awk -f deptab.gawk /var/lib/dpkg/status
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN { | |
FS = ": " | |
} | |
$1 == "Package" { | |
pkg = $2 | |
tab[pkg][""] | |
} | |
$1 == "Status" { | |
ok = $2 ~ / installed$/ | |
} | |
$1 == "Provides" && ok { | |
gsub(/ \([^)]*)/, "", $2) | |
split($2, pkgs, ", ") | |
for (i in pkgs) { | |
v[pkgs[i]] | |
tab[pkg][pkgs[i]] | |
} | |
} | |
$1 == "Depends" && ok { | |
gsub(/ \([^)]*)/, "", $2) | |
split($2, deps, /, | \| /) | |
for (i in deps) | |
tab[deps[i]][pkg] | |
} | |
END { | |
do { | |
cont = 0 | |
for (dep in tab) | |
for (pkg1 in tab[dep]) { | |
if (!(pkg1 in tab)) | |
continue | |
for (pkg2 in tab[pkg1]) { | |
if (pkg2 in tab[dep]) | |
continue | |
tab[dep][pkg2] | |
cont = 1 | |
} | |
} | |
} while (cont) | |
PROCINFO["sorted_in"] = "@ind_str_asc" | |
for (dep in tab) { | |
delete tab[dep][""] | |
printf "%s", dep | |
for (pkg in tab[dep]) { | |
if (pkg in v) | |
continue | |
printf " %s", pkg | |
} | |
print "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment