File: show-deps.sh

package info (click to toggle)
sagemath 8.6-6
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 113,052 kB
  • sloc: python: 996,064; cpp: 6,208; sh: 3,252; ansic: 3,226; objc: 1,407; makefile: 1,087; lisp: 5
file content (51 lines) | stat: -rwxr-xr-x 1,464 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/sh
# Show sagemath's build dependencies. (You should run `mk-build-deps` first.)
#
# Usage: [pkg=$pkg] ./$0 [by-size|by-date] [extra aptitude filter]
#
# e.g. give ~i to only list packages installed on your system.
# Set pkg=XXX to show other packages, e.g. `pkg=r-base-core ./$0 by-date`
#
pkg="${pkg:-~Rsagemath-build-deps}"
d=~R
r=~Rrecommends:

case "$1" in
by-size|by-date) subcmd="$1"; shift;;
*) subcmd="";;
esac
# 2 more levels of depends/recommends should be enough
pattern="($pkg|$d$pkg|$r$pkg|$d$d$pkg|$d$r$pkg|$r$d$pkg|$r$r$pkg) $1"

last_updated() {
	local pkg="$1"
	local pkgname="${pkg%:*}"
	if [ -f "/usr/share/doc/$pkgname/changelog.Debian.gz" ]; then
		local changelog="/usr/share/doc/$pkgname/changelog.Debian.gz"
	else
		local changelog="/usr/share/doc/$pkgname/changelog.gz"
	fi
	echo "$(zcat "$changelog" | dpkg-parsechangelog -l- -STimestamp) $pkgname"
}

case "$subcmd" in
by-size)
LC_ALL=C aptitude search "$pattern" --disable-columns -F '%I %p' \
  | sed -e 's/ kB / KB /g' \
  | LC_ALL=C sort -k2,2 -k1n,1n \
  | sed -e 's/ KB / kB /g'
;;
by-date)
echo >&2 "by-date selected; restricting to installed packages"
LC_ALL=C aptitude search "$pattern ~i" --disable-columns -F '%p' \
  | {
	while read pkg; do
		printf >&2 "reading changelogs: $pkg                            \r"
		last_updated "$pkg"
	done
  } | sort -n | { while read t pkg; do printf "$(date -d@$t) $pkg\n"; done; }
;;
*)
LC_ALL=C aptitude search "$pattern"
;;
esac