| 1 |
#! /bin/bash |
| 2 |
set -e |
| 3 |
|
| 4 |
verbose="-q" |
| 5 |
screen="" |
| 6 |
web="" |
| 7 |
test="" |
| 8 |
target="" |
| 9 |
|
| 10 |
while true; do |
| 11 |
case "$1" in |
| 12 |
"") break ;; |
| 13 |
-s) screen=1 ;; |
| 14 |
-t) shift; test=$1 ;; |
| 15 |
-v) verbose="-v -v -v -v" ;; |
| 16 |
-w) web=1 ;; |
| 17 |
-*) |
| 18 |
echo "Error: unrecognized argument '$1'" |
| 19 |
exit 1 |
| 20 |
;; |
| 21 |
*) |
| 22 |
if [ -z "$target" ]; then |
| 23 |
target=$1 |
| 24 |
else |
| 25 |
echo "Error: invalid number of arguments" |
| 26 |
exit 1 |
| 27 |
fi |
| 28 |
;; |
| 29 |
esac |
| 30 |
shift |
| 31 |
done |
| 32 |
|
| 33 |
if [ -z "$screen" ]; then |
| 34 |
if [ -z "$target" ]; then |
| 35 |
echo "Error: target directory not specified" |
| 36 |
exit 1 |
| 37 |
fi |
| 38 |
|
| 39 |
mkdir -p $target |
| 40 |
if [ "$web" ]; then |
| 41 |
mkdir -p $target/thumbs |
| 42 |
else |
| 43 |
arch=$(dpkg --print-architecture) |
| 44 |
dist=$(apt-cache policy | \ |
| 45 |
sed -r "/^ [0-9]+ /N; s/^ ([0-9]+) .*a=([^,]*).*/\1 \2/" | \ |
| 46 |
grep "^[0-9]" | sort -nru | head -n1 | awk '{print $2}') |
| 47 |
if [ -z "$test" ]; then |
| 48 |
echo "Testset generated $(date -uR) on $arch/$dist" >$target/README |
| 49 |
fi |
| 50 |
fi |
| 51 |
fi |
| 52 |
|
| 53 |
gen_set() { |
| 54 |
count=1 |
| 55 |
for opt in "--no-versions --no-alternatives --no-recommends" \ |
| 56 |
"--no-versions --no-alternatives" \ |
| 57 |
"--no-versions --no-alternatives --with-suggests" \ |
| 58 |
"--no-versions" \ |
| 59 |
"" \ |
| 60 |
"--with-suggests" \ |
| 61 |
"--with-suggests --versioned-conflicts" \ |
| 62 |
"--rotate" |
| 63 |
do |
| 64 |
echo $1$count $1 $opt |
| 65 |
count=$(($count + 1)) |
| 66 |
done |
| 67 |
} |
| 68 |
|
| 69 |
testset="dpkg dpkg |
| 70 |
$(gen_set debconf) |
| 71 |
$(gen_set aptitude) |
| 72 |
usage1 dpkg -b --arch=all --no-recommends --no-conflicts |
| 73 |
usage2 clamav -I -S |
| 74 |
usage3.1 pidentd --max-providers=5 |
| 75 |
usage3.2 pidentd -I |
| 76 |
usage4 apt -I --rdeps-depth=3" |
| 77 |
|
| 78 |
if [ -z "$web" ]; then |
| 79 |
testset="$testset |
| 80 |
test1 tcpd --no-conflicts -I --rdeps-depth=2 --max-rdeps=3 |
| 81 |
test2 libcairo2 --no-conflicts -I --rdeps-depth=20 |
| 82 |
test3 debian-installer -b --arch=armel --no-recommends --no-conflicts |
| 83 |
test4 whiptail -R" |
| 84 |
fi |
| 85 |
|
| 86 |
echo "$testset" | while read outfile package opts; do |
| 87 |
if [ "$test" ] && [ $outfile != $test ]; then |
| 88 |
continue |
| 89 |
fi |
| 90 |
|
| 91 |
echo "Generating $outfile: $opts $package" >&2 |
| 92 |
if [ "$screen" ]; then |
| 93 |
./debtree $verbose $opts $package | dot -Tps | kghostview - & |
| 94 |
sleep 10 |
| 95 |
else |
| 96 |
./debtree $verbose $opts $package >$target/$outfile.dot |
| 97 |
if [ "$web" ]; then |
| 98 |
for format in ps png svg; do |
| 99 |
dot -T$format -o "$target/$outfile.$format" \ |
| 100 |
$target/$outfile.dot |
| 101 |
done |
| 102 |
# Generate thumbnail; from SVG gives best quality |
| 103 |
convert $target/$outfile.svg -thumbnail 400 \ |
| 104 |
$target/thumbs/$outfile.png |
| 105 |
|
| 106 |
# For dpkg we only need the thumbnail |
| 107 |
rm -f $target/dpkg.* |
| 108 |
# The following files are not wanted for the website |
| 109 |
# because of size restraints |
| 110 |
rm -f $target/aptitude[5678].png |
| 111 |
rm -f $target/debconf[678].png |
| 112 |
rm -f $target/usage[124].png |
| 113 |
rm -f $target/usage3.[12].png |
| 114 |
fi |
| 115 |
fi |
| 116 |
done |
| 117 |
|
| 118 |
# Also generate the comparison graphs from apt-cache |
| 119 |
if [ "$web" ]; then |
| 120 |
for package in debconf aptitude; do |
| 121 |
outfile=${package}0 |
| 122 |
apt-cache dotty $package >$target/$outfile.dot |
| 123 |
for format in ps png svg; do |
| 124 |
dot -T$format -o "$target/$outfile.$format" \ |
| 125 |
$target/$outfile.dot |
| 126 |
done |
| 127 |
# Generate thumbnail; from SVG gives best quality |
| 128 |
convert $target/$outfile.svg -thumbnail 400 \ |
| 129 |
$target/thumbs/$outfile.png |
| 130 |
done |
| 131 |
fi |