diff options
author | merakor <cem@ckyln.com> | 2020-10-05 07:32:45 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-10-05 07:32:45 +0000 |
commit | 756b2c8fcc5e4bb07921132985253234c6b32eab (patch) | |
tree | f10fdf8364b170621601f8d8ecc616ef1b9d29b5 | |
parent | 3a3944019a79fd171be19bfe8a56c3dca2fcfd76 (diff) | |
download | cpt-756b2c8fcc5e4bb07921132985253234c6b32eab.tar.gz |
cpt-orphans: add tool to print orphaned packages.
FossilOrigin-Name: 3addfbbb6f53df7ca63443c15e0a253bd760b7c75409d9196bf82ca5a090f796
-rwxr-xr-x | contrib/cpt-orphans | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/contrib/cpt-orphans b/contrib/cpt-orphans new file mode 100755 index 0000000..f42c49e --- /dev/null +++ b/contrib/cpt-orphans @@ -0,0 +1,27 @@ +#!/bin/sh -e +# Print orphaned packages. + +trap 'rm -f $CPT_TMPDIR/packages-$$' EXIT + +cd "$CPT_ROOT/var/db/cpt/installed" + +# Get base packages. +[ -f "$CPT_ROOT/etc/cpt-base" ] && while read -r pkg _; do + case "$pkg" in ''|\#*) continue; esac + base=" $pkg $base" +done < "$CPT_ROOT/etc/cpt-base" + +# Make a list of packages, but remove the base. +for pkg in *; do + case "$base" in *" $pkg "*) continue; esac + printf '%s\n' "$pkg" +done > "${CPT_TMPDIR:=/tmp}/packages-$$" + +# List dependencies. +cat ./*/depends | + +# Remove make dependencies. +while read -r dep make; do [ "$make" ] || printf '%s\n' "$dep"; done | sort -u | + +# Remove dependencies from the list and print. +comm -23 "$CPT_TMPDIR/packages-$$" - |