summaryrefslogtreecommitdiffstats
path: root/run-tests
blob: d18ac9d24959ae32b0d86a13a5aa6e2079b28c3a (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#! /bin/bash
set -e

verbose="-q"
screen=""
web=""
test=""
target=""

while true; do
	case "$1" in
	    "")	break ;;
	    -s)	screen=1 ;;
	    -t)	shift; test=$1 ;;
	    -v) verbose="-v -v -v -v" ;;
	    -w)	web=1 ;;
	    -*)
		echo "Error: unrecognized argument '$1'"
		exit 1
		;;
	     *)
		if [ -z "$target" ]; then
			target=$1
		else
			echo "Error: invalid number of arguments"
			exit 1
		fi
		;;
	esac
	shift
done

if [ -z "$screen" ]; then
	if [ -z "$target" ]; then
		echo "Error: target directory not specified"
		exit 1
	fi

	mkdir -p $target
	if [ "$web" ]; then
		mkdir -p $target/thumbs
	else
		arch=$(dpkg --print-architecture)
		dist=$(apt-cache policy | \
		       sed -r "/^ [0-9]+ /N; s/^ ([0-9]+) .*a=([^,]*).*/\1 \2/" | \
		       grep "^[0-9]" | sort -nru | head -n1 | awk '{print $2}')
		if [ -z "$test" ]; then
			echo "Testset generated $(date -uR) on $arch/$dist" >$target/README
		fi
	fi
fi

gen_set() {
	count=1
	for opt in "--no-versions --no-alternatives --no-recommends" \
		   "--no-versions --no-alternatives" \
		   "--no-versions --no-alternatives --with-suggests" \
		   "--no-versions" \
		   "" \
		   "--with-suggests" \
		   "--with-suggests --versioned-conflicts" \
		   "--rotate"
	    do
		echo $1$count $1 $opt
		count=$(($count + 1))
	done
}

testset="dpkg dpkg
$(gen_set debconf)
$(gen_set aptitude)
usage1 dpkg -b --arch=all --no-recommends --no-conflicts
usage2 clamav -I -S
usage3.1 pidentd --max-providers=5
usage3.2 pidentd -I
usage4 apt -I --rdeps-depth=3"

if [ -z "$web" ]; then
testset="$testset
test1 tcpd --no-conflicts -I --rdeps-depth=2 --max-rdeps=3
test2 libcairo2 --no-conflicts -I --rdeps-depth=20
test3 debian-installer -b --arch=armel --no-recommends --no-conflicts
test4 whiptail -R"
fi

echo "$testset" | while read outfile package opts; do
	if [ "$test" ] && [ $outfile != $test ]; then
		continue
	fi

	echo "Generating $outfile: $opts $package" >&2
	if [ "$screen" ]; then
		./debtree $verbose $opts $package | dot -Tps | kghostview - &
		sleep 10
	else
        	./debtree $verbose $opts $package >$target/$outfile.dot
		if [ "$web" ]; then
			for format in ps png svg; do
				dot -T$format -o "$target/$outfile.$format" \
					$target/$outfile.dot
			done
			# Generate thumbnail; from SVG gives best quality
			convert $target/$outfile.svg -thumbnail 400 \
				$target/thumbs/$outfile.png

			# For dpkg we only need the thumbnail
			rm -f $target/dpkg.*
			# The following files are not wanted for the website
			# because of size restraints
			rm -f $target/aptitude[5678].png
			rm -f $target/debconf[678].png
			rm -f $target/usage[124].png
			rm -f $target/usage3.[12].png
		fi
	fi
done

# Also generate the comparison graphs from apt-cache
if [ "$web" ]; then
	for package in debconf aptitude; do
		outfile=${package}0
		apt-cache dotty $package >$target/$outfile.dot
		for format in ps png svg; do
			dot -T$format -o "$target/$outfile.$format" \
				$target/$outfile.dot
		done
		# Generate thumbnail; from SVG gives best quality
		convert $target/$outfile.svg -thumbnail 400 \
			$target/thumbs/$outfile.png
	done
fi