aboutsummaryrefslogtreecommitdiff
path: root/contrib/cpt-orphans
blob: 728f5111f7f35b70b8cb8020cdb8d230cdaee6ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh -e
# Print orphaned packages

## SYNOPSIS:
## .Nm
## DESCRIPTION:
## .Nm
## prints a list of all packages that are not required by other packages. It
## also reads the file
## .Pa /etc/cpt-base
## to determine base packages, and will keep those packages out of this printed
## list.

trap 'rm -f $CPT_TMPDIR/packages-$$' EXIT

cd "$CPT_ROOT/var/db/cpt/installed"

# Get base packages.
base=" $(cpt-lib pkg_get_base nonl)"

# 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-$$" -