File: debtest.sh

package info (click to toggle)
reprepro 4.2.0-2squeeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,016 kB
  • ctags: 3,674
  • sloc: ansic: 46,905; sh: 13,899; pascal: 160; makefile: 159; python: 138
file content (127 lines) | stat: -rwxr-xr-x 3,707 bytes parent folder | download
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
#!/bin/bash

set -e

WORKDIR="`pwd`/testdir"

if [ "x$1" == "x--delete" ] ; then
	rm -r "$WORKDIR" || true
	shift
fi
HELPER=""
#HELPER="valgrind -v --leak-check=full --suppressions=../valgrind.supp --log-fd=5"
if [ "x$1" == "x--helper" ] ; then
	shift
	HELPER="$1"
	shift
fi

mkdir "$WORKDIR"
cd "$WORKDIR"

if [ "1" -gt "$#" ] || [ "2" -lt "$#" ] ; then
	echo "Syntax: test.sh <src-dir> [<reprepro-binary>]" >&2
	exit 1
fi
SRCDIR="$1"
if [ "2" -le "$#" ] ; then
	REPREPRO="$2"
else
	REPREPRO="$SRCDIR/reprepro"
fi
TESTS="$SRCDIR/tests"
UPDATETYPE=update
export PATH="$TESTS:$PATH"
if ! [ -x "$REPREPRO" ] ; then
	echo "Could not find $REPREPRO!" >&2
	exit 1
fi
mkdir -p conf
cat > conf/distributions <<CONFEND
Codename: test
Architectures: ${FAKEARCHITECTURE} source
Components: stupid ugly
CONFEND

set -v
mkdir test
mkdir test/DEBIAN
echo "Package: test1" > test/DEBIAN/control
echo "Version: 1" >> test/DEBIAN/control
echo "Maintainer: me <its@me>" >> test/DEBIAN/control
echo "Description: test" >> test/DEBIAN/control
echo " bla fasel" >> test/DEBIAN/control
mkdir -p test/usr/bin
echo "echo hallo world" > test/usr/bin/hallo
dpkg-deb -b test

ERRORMSG="`$HELPER "$REPREPRO" -b . includedeb test test.deb 2>&1 || echo "error:$?"`"
echo $ERRORMSG
echo $ERRORMSG | grep -q "Cannot find Architecture-header"
echo $ERRORMSG | grep -q "error:255"

echo "Package: test1" > test/DEBIAN/control
echo "Version: 1" >> test/DEBIAN/control
echo "Maintainer: me <its@me>" >> test/DEBIAN/control
echo "Architecture: ${FAKEARCHITECTURE}" >> test/DEBIAN/control
echo "Description: test" >> test/DEBIAN/control
echo " bla fasel" >> test/DEBIAN/control
dpkg-deb -b test

ERRORMSG="`$HELPER "$REPREPRO" -b . includedeb test test.deb 2>&1 || echo "error:$?"`"
echo $ERRORMSG
echo $ERRORMSG | grep -q "No section was given"
echo $ERRORMSG | grep -q "error:255"

ERRORMSG="`$HELPER "$REPREPRO" -b . -S funnystuff includedeb test test.deb 2>&1 || echo "error:$?"`"
echo $ERRORMSG
echo $ERRORMSG | grep -q "No priority was given"
echo $ERRORMSG | grep -q "error:255"

$HELPER "$REPREPRO" -b . -S funnystuff -P useless includedeb test test.deb
echo returned: $?

echo "Package: test2" > test/DEBIAN/control
echo "Version: 1" >> test/DEBIAN/control
echo "Maintainer: me <its@me>" >> test/DEBIAN/control
echo "Section: funnystuff" >> test/DEBIAN/control
echo "Priority: useless" >> test/DEBIAN/control
echo "Architecture: ${FAKEARCHITECTURE}" >> test/DEBIAN/control
echo "Description: test" >> test/DEBIAN/control
echo " bla fasel" >> test/DEBIAN/control
dpkg-deb -b test

$HELPER "$REPREPRO" -b . includedeb test test.deb
echo returned: $?

echo "Package: bla" > test/DEBIAN/control
echo "Version: 1" >> test/DEBIAN/control
echo "Maintainer: me <its@me>" >> test/DEBIAN/control
echo "Section: funnystuff" >> test/DEBIAN/control
echo "Priority: useless" >> test/DEBIAN/control
echo "Architecture: ${FAKEARCHITECTURE}" >> test/DEBIAN/control
echo "Description: test" >> test/DEBIAN/control
echo " bla fasel" >> test/DEBIAN/control
(cd test/DEBIAN &&  tar -cvvzf ../../control.tar.gz ./control)
(cd test &&  tar -cvvzf ../data.tar.gz ./usr)
#wrong ar:
ar r bla.deb data.tar.gz control.tar.gz
rm *.tar.gz

$HELPER "$REPREPRO" -b . includedeb test bla.deb
echo returned: $?

echo -e ',g/Version/s/1/2/\nw' | ed -s test/DEBIAN/control
#not also wrong paths:
(cd test/DEBIAN &&  tar -cvvzf ../../control.tar.gz control)
(cd test &&  tar -cvvzf ../data.tar.gz usr)
ar r bla2.deb data.tar.gz control.tar.gz

$HELPER "$REPREPRO" -b . includedeb test bla2.deb
echo returned: $?

set +v 
echo
echo "If the script is still running to show this,"
echo "all tested cases seem to work. (Though writing some tests more can never harm)."
exit 0