]>
Commit | Line | Data |
---|---|---|
8d876415 DK |
1 | #!/bin/sh -- # no runable script, just for vi |
2 | ||
3 | # we all like colorful messages | |
682a3bf7 DK |
4 | if expr match "$(readlink -f /proc/$$/fd/1)" '/dev/pts/[0-9]\+' > /dev/null && \ |
5 | expr match "$(readlink -f /proc/$$/fd/2)" '/dev/pts/[0-9]\+' > /dev/null; then | |
6 | CERROR="\e[1;31m" # red | |
7 | CWARNING="\e[1;33m" # yellow | |
8 | CMSG="\e[1;32m" # green | |
9 | CINFO="\e[1;96m" # light blue | |
10 | CDEBUG="\e[1;94m" # blue | |
11 | CNORMAL="\e[0;39m" # default system console color | |
12 | CDONE="\e[1;32m" # green | |
13 | CPASS="\e[1;32m" # green | |
14 | CFAIL="\e[1;31m" # red | |
15 | CCMD="\e[1;35m" # pink | |
16 | fi | |
8d876415 DK |
17 | |
18 | msgdie() { echo "${CERROR}E: $1${CNORMAL}" >&2; exit 1; } | |
19 | msgwarn() { echo "${CWARNING}W: $1${CNORMAL}" >&2; } | |
20 | msgmsg() { echo "${CMSG}$1${CNORMAL}" >&2; } | |
21 | msginfo() { echo "${CINFO}I: $1${CNORMAL}" >&2; } | |
22 | msgdebug() { echo "${CDEBUG}D: $1${CNORMAL}" >&2; } | |
23 | msgdone() { echo "${CDONE}DONE${CNORMAL}" >&2; } | |
24 | msgnwarn() { echo -n "${CWARNING}W: $1${CNORMAL}" >&2; } | |
25 | msgnmsg() { echo -n "${CMSG}$1${CNORMAL}" >&2; } | |
26 | msgninfo() { echo -n "${CINFO}I: $1${CNORMAL}" >&2; } | |
27 | msgndebug() { echo -n "${CDEBUG}D: $1${CNORMAL}" >&2; } | |
28 | msgtest() { echo -n "${CINFO}$1 ${CCMD}$(echo "$2" | sed -e 's/^aptc/apt-c/' -e 's/^aptg/apt-g/' -e 's/^aptf/apt-f/')${CINFO} …${CNORMAL} " >&2; } | |
29 | msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; } | |
30 | msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; } | |
31 | msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; } | |
32 | ||
33 | # enable / disable Debugging | |
fc89263e DK |
34 | MSGLEVEL=${MSGLEVEL:-3} |
35 | if [ $MSGLEVEL -le 0 ]; then | |
36 | msgdie() { true; } | |
37 | fi | |
38 | if [ $MSGLEVEL -le 1 ]; then | |
39 | msgwarn() { true; } | |
40 | msgnwarn() { true; } | |
41 | fi | |
42 | if [ $MSGLEVEL -le 2 ]; then | |
43 | msgmsg() { true; } | |
44 | msgnmsg() { true; } | |
39cc8228 DK |
45 | msgtest() { true; } |
46 | msgpass() { echo -n " ${CPASS}P${CNORMAL}" >&2; } | |
47 | msgskip() { echo -n " ${CWARNING}S${CNORMAL}" >&2; } | |
682a3bf7 DK |
48 | if [ -n "$CFAIL" ]; then |
49 | msgfail() { echo -n " ${CFAIL}FAIL${CNORMAL}" >&2; } | |
50 | else | |
51 | msgfail() { echo -n " ###FAILED###" >&2; } | |
52 | fi | |
fc89263e DK |
53 | fi |
54 | if [ $MSGLEVEL -le 3 ]; then | |
55 | msginfo() { true; } | |
56 | msgninfo() { true; } | |
57 | fi | |
58 | if [ $MSGLEVEL -le 4 ]; then | |
59 | msgdebug() { true; } | |
60 | msgndebug() { true; } | |
61 | fi | |
62 | msgdone() { | |
63 | if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] || | |
64 | [ "$1" = "info" -a $MSGLEVEL -le 3 ] || | |
65 | [ "$1" = "msg" -a $MSGLEVEL -le 2 ] || | |
66 | [ "$1" = "warn" -a $MSGLEVEL -le 1 ] || | |
67 | [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then | |
68 | true; | |
69 | else | |
70 | echo "${CDONE}DONE${CNORMAL}" >&2; | |
71 | fi | |
72 | } | |
8d876415 DK |
73 | |
74 | runapt() { | |
75 | msgdebug "Executing: ${CCMD}$*${CDEBUG} " | |
7d0627b6 DK |
76 | if [ -f ./aptconfig.conf ]; then |
77 | APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* | |
4b2a4ab8 MV |
78 | elif [ -f ../aptconfig.conf ]; then |
79 | APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* | |
7d0627b6 DK |
80 | else |
81 | LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$* | |
82 | fi | |
8d876415 DK |
83 | } |
84 | aptconfig() { runapt apt-config $*; } | |
85 | aptcache() { runapt apt-cache $*; } | |
86 | aptget() { runapt apt-get $*; } | |
87 | aptftparchive() { runapt apt-ftparchive $*; } | |
1f8b2599 | 88 | aptkey() { runapt apt-key $*; } |
ec7f904e | 89 | aptmark() { runapt apt-mark $*; } |
158fda31 DK |
90 | dpkg() { |
91 | $(which dpkg) --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log $* | |
92 | } | |
b6b5a542 DK |
93 | aptitude() { |
94 | if [ -f ./aptconfig.conf ]; then | |
95 | APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which aptitude) $* | |
96 | elif [ -f ../aptconfig.conf ]; then | |
97 | APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which aptitude) $* | |
98 | else | |
99 | LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which aptitude) $* | |
100 | fi | |
101 | } | |
8d876415 | 102 | |
b720d0bd DK |
103 | addtrap() { |
104 | CURRENTTRAP="$CURRENTTRAP $1" | |
105 | trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM | |
106 | } | |
8d876415 DK |
107 | |
108 | setupenvironment() { | |
75954ae2 | 109 | TMPWORKINGDIRECTORY=$(mktemp -d) |
8f8169ac | 110 | local TESTDIR=$(readlink -f $(dirname $0)) |
3cbbda3c | 111 | msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… " |
8f8169ac | 112 | BUILDDIRECTORY="${TESTDIR}/../../build/bin" |
8d876415 DK |
113 | test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first" |
114 | local OLDWORKINGDIRECTORY=$(pwd) | |
b720d0bd | 115 | addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY;" |
8d876415 | 116 | cd $TMPWORKINGDIRECTORY |
cd725954 | 117 | mkdir rootdir aptarchive keys |
8d876415 | 118 | cd rootdir |
b29c3712 DK |
119 | mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d |
120 | mkdir -p var/cache var/lib var/log | |
cffea9af | 121 | mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers |
2c6baa5a | 122 | local STATUSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/') |
8f8169ac DK |
123 | if [ -f "${TESTDIR}/${STATUSFILE}" ]; then |
124 | cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status | |
125 | else | |
126 | touch var/lib/dpkg/status | |
127 | fi | |
cd725954 | 128 | touch var/lib/dpkg/available |
8d876415 DK |
129 | mkdir -p usr/lib/apt |
130 | ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods | |
131 | cd .. | |
2c6baa5a | 132 | local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/') |
8f8169ac DK |
133 | if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then |
134 | cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages | |
8f8169ac | 135 | fi |
4a4ea26c AM |
136 | local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/') |
137 | if [ -f "${TESTDIR}/${SOURCESSFILE}" ]; then | |
138 | cp "${TESTDIR}/${SOURCESSFILE}" aptarchive/Sources | |
8f8169ac | 139 | fi |
cd725954 DK |
140 | cp $(find $TESTDIR -name '*.pub' -o -name '*.sec') keys/ |
141 | ln -s ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg | |
cffea9af | 142 | echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf |
94eb3bee | 143 | echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf |
8d876415 DK |
144 | echo "Debug::NoLocking \"true\";" >> aptconfig.conf |
145 | echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf | |
f425d4d5 | 146 | echo "Dir::Bin::Methods \"${BUILDDIRECTORY}/methods\";" >> aptconfig.conf |
cffea9af DK |
147 | echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf |
148 | echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf | |
149 | echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf | |
150 | echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf | |
151 | echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf | |
ea65d079 | 152 | echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf # Added to test multiarch before dpkg is ready for it… |
cffea9af | 153 | echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf |
2c085486 | 154 | echo 'quiet::NoUpdate "true";' >> aptconfig.conf |
8d876415 | 155 | export LC_ALL=C |
7f52cf7b | 156 | export PATH="${PATH}:/usr/local/sbin:/usr/sbin:/sbin" |
8d876415 DK |
157 | msgdone "info" |
158 | } | |
159 | ||
ea65d079 DK |
160 | getarchitecture() { |
161 | if [ "$1" = "native" -o -z "$1" ]; then | |
162 | eval `aptconfig shell ARCH APT::Architecture` | |
163 | if [ -n "$ARCH" ]; then | |
164 | echo $ARCH | |
165 | else | |
166 | dpkg-architecture -qDEB_BUILD_ARCH | |
167 | fi | |
168 | else | |
169 | echo $1 | |
170 | fi | |
171 | } | |
172 | ||
8d876415 DK |
173 | configarchitecture() { |
174 | local CONFFILE=rootdir/etc/apt/apt.conf.d/01multiarch.conf | |
234675b7 | 175 | rm -f $CONFFILE |
ea65d079 | 176 | echo "APT::Architecture \"$(getarchitecture $1)\";" > $CONFFILE |
8d876415 DK |
177 | shift |
178 | while [ -n "$1" ]; do | |
ea65d079 | 179 | echo "APT::Architectures:: \"$(getarchitecture $1)\";" >> $CONFFILE |
8d876415 DK |
180 | shift |
181 | done | |
182 | } | |
183 | ||
75954ae2 | 184 | setupsimplenativepackage() { |
ce9864a8 DK |
185 | local NAME="$1" |
186 | local ARCH="$2" | |
187 | local VERSION="$3" | |
188 | local RELEASE="${4:-unstable}" | |
189 | local DEPENDENCIES="$5" | |
190 | local DESCRIPTION="$6" | |
b7899b00 DK |
191 | local SECTION="${7:-others}" |
192 | local DISTSECTION | |
193 | if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then | |
194 | DISTSECTION="main" | |
195 | else | |
196 | DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)" | |
197 | fi | |
ce9864a8 DK |
198 | local BUILDDIR=incoming/${NAME}-${VERSION} |
199 | mkdir -p ${BUILDDIR}/debian/source | |
200 | cd ${BUILDDIR} | |
201 | echo "* most suckless software product ever" > FEATURES | |
b7899b00 DK |
202 | test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright |
203 | test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low | |
ce9864a8 DK |
204 | |
205 | * Initial release | |
206 | ||
b7899b00 DK |
207 | -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog |
208 | test -e debian/control || echo "Source: $NAME | |
209 | Section: $SECTION | |
ce9864a8 DK |
210 | Priority: optional |
211 | Maintainer: Joe Sixpack <joe@example.org> | |
212 | Build-Depends: debhelper (>= 7) | |
213 | Standards-Version: 3.9.1 | |
214 | ||
875bcb36 DK |
215 | Package: $NAME" > debian/control |
216 | if [ "$ARCH" = 'all' ]; then | |
217 | echo "Architecture: all" >> debian/control | |
218 | else | |
219 | echo "Architecture: any" >> debian/control | |
220 | fi | |
ce9864a8 DK |
221 | test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control |
222 | if [ -z "$DESCRIPTION" ]; then | |
223 | echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE} | |
224 | If you find such a package installed on your system, | |
225 | YOU did something horribly wrong! They are autogenerated | |
226 | und used only by testcases for APT and surf no other propose…" >> debian/control | |
227 | else | |
228 | echo "Description: $DESCRIPTION" >> debian/control | |
229 | fi | |
b7899b00 DK |
230 | test -e debian/compat || echo "7" > debian/compat |
231 | test -e debian/source/format || echo "3.0 (native)" > debian/source/format | |
ce9864a8 | 232 | test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules |
75954ae2 DK |
233 | cd - > /dev/null |
234 | } | |
235 | ||
236 | buildsimplenativepackage() { | |
237 | local NAME="$1" | |
238 | local ARCH="$2" | |
239 | local VERSION="$3" | |
240 | local RELEASE="${4:-unstable}" | |
241 | local DEPENDENCIES="$5" | |
242 | local DESCRIPTION="$6" | |
243 | local SECTION="${7:-others}" | |
d67004e0 | 244 | local PRIORITY="${8:-optional}" |
75954ae2 DK |
245 | local DISTSECTION |
246 | if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then | |
247 | DISTSECTION="main" | |
248 | else | |
249 | DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)" | |
250 | fi | |
5a635ee4 | 251 | local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION} |
b761356f | 252 | |
18331adf | 253 | msgninfo "Build package ${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}… " |
b761356f DK |
254 | mkdir -p $BUILDDIR/debian/source |
255 | echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES | |
256 | echo "#!/bin/sh | |
257 | echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME} | |
258 | ||
259 | echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright | |
260 | echo "$NAME ($VERSION) $RELEASE; urgency=low | |
261 | ||
262 | * Initial release | |
263 | ||
264 | -- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog | |
265 | echo "Source: $NAME | |
266 | Section: $SECTION | |
d67004e0 | 267 | Priority: $PRIORITY |
b761356f DK |
268 | Maintainer: Joe Sixpack <joe@example.org> |
269 | Standards-Version: 3.9.1 | |
270 | ||
875bcb36 DK |
271 | Package: $NAME" > ${BUILDDIR}/debian/control |
272 | if [ "$ARCH" = 'all' ]; then | |
273 | echo "Architecture: all" >> ${BUILDDIR}/debian/control | |
274 | else | |
275 | echo "Architecture: any" >> ${BUILDDIR}/debian/control | |
276 | fi | |
b761356f DK |
277 | test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> ${BUILDDIR}/debian/control |
278 | if [ -z "$DESCRIPTION" ]; then | |
279 | echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE} | |
280 | If you find such a package installed on your system, | |
281 | YOU did something horribly wrong! They are autogenerated | |
282 | und used only by testcases for APT and surf no other propose…" >> ${BUILDDIR}/debian/control | |
283 | else | |
284 | echo "Description: $DESCRIPTION" >> ${BUILDIR}/debian/control | |
285 | fi | |
286 | echo '3.0 (native)' > ${BUILDDIR}/debian/source/format | |
287 | local SRCS="$( (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')" | |
b761356f | 288 | for SRC in $SRCS; do |
5a635ee4 | 289 | echo "pool/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist |
b761356f | 290 | done |
84aa13f4 | 291 | |
ea65d079 | 292 | for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do |
84aa13f4 DK |
293 | rm -rf ${BUILDDIR}/debian/tmp |
294 | mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin | |
295 | cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} | |
296 | cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch} | |
297 | (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch) | |
298 | (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums) | |
299 | ||
300 | dpkg-deb --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. 2> /dev/null > /dev/null | |
301 | echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist | |
302 | done | |
303 | ||
13845042 DK |
304 | mkdir -p ${BUILDDIR}/../${NAME}_${VERSION} |
305 | cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}/ | |
306 | cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}.changelog | |
5a635ee4 | 307 | rm -rf "${BUILDDIR}" |
b761356f | 308 | msgdone "info" |
75954ae2 DK |
309 | } |
310 | ||
311 | buildpackage() { | |
312 | local BUILDDIR=$1 | |
313 | local RELEASE=$2 | |
314 | local SECTION=$3 | |
ea65d079 | 315 | local ARCH=$(getarchitecture $4) |
75954ae2 DK |
316 | msgninfo "Build package $(echo "$BUILDDIR" | grep -o '[^/]*$') for ${RELEASE} in ${SECTION}… " |
317 | cd $BUILDDIR | |
318 | if [ "$ARCH" = "all" ]; then | |
319 | ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)" | |
320 | fi | |
b7899b00 DK |
321 | local BUILT="$(dpkg-buildpackage -uc -us -a$ARCH 2> /dev/null)" |
322 | local PKGS="$( echo "$BUILT" | grep '^dpkg-deb: building package' | cut -d'/' -f 2 | sed -e "s#'\.##")" | |
5ed56f93 | 323 | local SRCS="$( echo "$BUILT" | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')" |
ce9864a8 | 324 | cd - > /dev/null |
b7899b00 | 325 | for PKG in $PKGS; do |
75954ae2 | 326 | echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist |
b7899b00 DK |
327 | done |
328 | for SRC in $SRCS; do | |
75954ae2 | 329 | echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist |
b7899b00 | 330 | done |
cffea9af | 331 | msgdone "info" |
ce9864a8 DK |
332 | } |
333 | ||
334 | buildaptarchive() { | |
ce9864a8 DK |
335 | if [ -d incoming ]; then |
336 | buildaptarchivefromincoming $* | |
337 | else | |
338 | buildaptarchivefromfiles $* | |
339 | fi | |
340 | } | |
341 | ||
342 | createaptftparchiveconfig() { | |
343 | local ARCHS="$(find pool/ -name '*.deb' | grep -oE '_[a-z0-9-]+\.deb$' | sort | uniq | sed -e '/^_all.deb$/ d' -e 's#^_\([a-z0-9-]*\)\.deb$#\1#' | tr '\n' ' ')" | |
158fda31 DK |
344 | if [ -z "$ARCHS" ]; then |
345 | # the pool is empty, so we will operate on faked packages - let us use the configured archs | |
346 | ARCHS="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')" | |
347 | fi | |
ce9864a8 DK |
348 | echo -n 'Dir { |
349 | ArchiveDir "' >> ftparchive.conf | |
350 | echo -n $(readlink -f .) >> ftparchive.conf | |
351 | echo -n '"; | |
352 | CacheDir "' >> ftparchive.conf | |
353 | echo -n $(readlink -f ..) >> ftparchive.conf | |
354 | echo -n '"; | |
b7899b00 DK |
355 | FileListDir "' >> ftparchive.conf |
356 | echo -n $(readlink -f pool/) >> ftparchive.conf | |
357 | echo -n '"; | |
358 | }; | |
359 | Default { | |
bc33e0f0 DK |
360 | Packages::Compress ". gzip bzip2 lzma xz"; |
361 | Sources::Compress ". gzip bzip2 lzma xz"; | |
362 | Contents::Compress ". gzip bzip2 lzma xz"; | |
b7080ced | 363 | Translation::Compress ". gzip bzip2 lzma xz"; |
18331adf | 364 | LongDescription "false"; |
ce9864a8 DK |
365 | }; |
366 | TreeDefault { | |
367 | Directory "pool/"; | |
368 | SrcDirectory "pool/"; | |
369 | }; | |
370 | APT { | |
371 | FTPArchive { | |
372 | Release { | |
373 | Origin "joesixpack"; | |
374 | Label "apttestcases"; | |
375 | Suite "unstable"; | |
376 | Description "repository with dummy packages"; | |
377 | Architectures "' >> ftparchive.conf | |
378 | echo -n "$ARCHS" >> ftparchive.conf | |
379 | echo 'source"; | |
380 | }; | |
381 | }; | |
382 | };' >> ftparchive.conf | |
b7899b00 DK |
383 | for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do |
384 | echo -n 'tree "dists/' >> ftparchive.conf | |
385 | echo -n "$DIST" >> ftparchive.conf | |
386 | echo -n '" { | |
ce9864a8 DK |
387 | Architectures "' >> ftparchive.conf |
388 | echo -n "$ARCHS" >> ftparchive.conf | |
b7899b00 DK |
389 | echo -n 'source"; |
390 | FileList "' >> ftparchive.conf | |
391 | echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf | |
392 | echo -n '"; | |
393 | SourceFileList "' >> ftparchive.conf | |
394 | echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf | |
395 | echo -n '"; | |
396 | Sections "' >> ftparchive.conf | |
397 | echo -n "$(find ./pool/ -maxdepth 1 -name "${DIST}.*.pkglist" -type f | cut -d'/' -f 3 | cut -d'.' -f 2 | sort | uniq | tr '\n' ' ')" >> ftparchive.conf | |
398 | echo '"; | |
ce9864a8 | 399 | };' >> ftparchive.conf |
b7899b00 | 400 | done |
ce9864a8 DK |
401 | } |
402 | ||
403 | buildaptftparchivedirectorystructure() { | |
b7899b00 DK |
404 | local DISTS="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')" |
405 | for DIST in $DISTS; do | |
406 | local SECTIONS="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)" | |
407 | for SECTION in $SECTIONS; do | |
408 | local ARCHS="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')" | |
409 | for ARCH in $ARCHS; do | |
410 | mkdir -p dists/${DIST}/${SECTION}/binary-${ARCH} | |
411 | done | |
412 | mkdir -p dists/${DIST}/${SECTION}/source | |
413 | mkdir -p dists/${DIST}/${SECTION}/i18n | |
414 | done | |
ce9864a8 | 415 | done |
ce9864a8 DK |
416 | } |
417 | ||
9b78cda6 DK |
418 | insertpackage() { |
419 | local RELEASE="$1" | |
420 | local NAME="$2" | |
421 | local ARCH="$3" | |
422 | local VERSION="$4" | |
423 | local DEPENDENCIES="$5" | |
d67004e0 DK |
424 | local PRIORITY="${6:-optional}" |
425 | local ARCHS="" | |
ea65d079 | 426 | for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do |
d67004e0 DK |
427 | if [ "$arch" = "all" ]; then |
428 | ARCHS="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')" | |
429 | else | |
430 | ARCHS="$arch" | |
431 | fi | |
432 | for BUILDARCH in $ARCHS; do | |
433 | local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}" | |
434 | mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source | |
435 | touch aptarchive/dists/${RELEASE}/main/source/Sources | |
436 | local FILE="${PPATH}/Packages" | |
437 | echo "Package: $NAME | |
438 | Priority: $PRIORITY | |
9b78cda6 | 439 | Section: other |
2c085486 | 440 | Installed-Size: 42 |
9b78cda6 | 441 | Maintainer: Joe Sixpack <joe@example.org> |
d67004e0 | 442 | Architecture: $arch |
2c085486 | 443 | Version: $VERSION |
d67004e0 DK |
444 | Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE |
445 | test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE | |
446 | echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE} | |
9b78cda6 DK |
447 | If you find such a package installed on your system, |
448 | YOU did something horribly wrong! They are autogenerated | |
449 | und used only by testcases for APT and surf no other propose… | |
450 | " >> $FILE | |
d67004e0 | 451 | done |
9b78cda6 DK |
452 | done |
453 | } | |
454 | ||
234675b7 DK |
455 | insertsource() { |
456 | local RELEASE="$1" | |
457 | local NAME="$2" | |
458 | local ARCH="$3" | |
459 | local VERSION="$4" | |
460 | local DEPENDENCIES="$5" | |
461 | local ARCHS="" | |
462 | local SPATH="aptarchive/dists/${RELEASE}/main/source" | |
463 | mkdir -p $SPATH | |
464 | local FILE="${SPATH}/Sources" | |
465 | echo "Package: $NAME | |
466 | Binary: $NAME | |
467 | Version: $VERSION | |
468 | Maintainer: Joe Sixpack <joe@example.org> | |
469 | Architecture: $ARCH" >> $FILE | |
470 | test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE | |
471 | echo "Files: | |
472 | d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc | |
473 | d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz" >> $FILE | |
474 | } | |
475 | ||
dfc2b1be DK |
476 | insertinstalledpackage() { |
477 | local NAME="$1" | |
478 | local ARCH="$2" | |
479 | local VERSION="$3" | |
480 | local DEPENDENCIES="$4" | |
d67004e0 | 481 | local PRIORITY="${5:-optional}" |
dfc2b1be | 482 | local FILE="rootdir/var/lib/dpkg/status" |
ea65d079 | 483 | for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do |
d67004e0 | 484 | echo "Package: $NAME |
dfc2b1be | 485 | Status: install ok installed |
d67004e0 | 486 | Priority: $PRIORITY |
dfc2b1be DK |
487 | Section: other |
488 | Installed-Size: 42 | |
489 | Maintainer: Joe Sixpack <joe@example.org> | |
d67004e0 | 490 | Architecture: $arch |
dfc2b1be | 491 | Version: $VERSION" >> $FILE |
d67004e0 DK |
492 | test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE |
493 | echo "Description: an autogenerated dummy ${NAME}=${VERSION}/installed | |
dfc2b1be DK |
494 | If you find such a package installed on your system, |
495 | YOU did something horribly wrong! They are autogenerated | |
496 | und used only by testcases for APT and surf no other propose… | |
497 | " >> $FILE | |
d67004e0 | 498 | done |
dfc2b1be DK |
499 | } |
500 | ||
501 | ||
ce9864a8 | 502 | buildaptarchivefromincoming() { |
3cbbda3c | 503 | msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…" |
ce9864a8 DK |
504 | cd aptarchive |
505 | [ -e pool ] || ln -s ../incoming pool | |
506 | [ -e ftparchive.conf ] || createaptftparchiveconfig | |
507 | [ -e dists ] || buildaptftparchivedirectorystructure | |
b7899b00 | 508 | msgninfo "\tGenerate Packages, Sources and Contents files… " |
ce9864a8 | 509 | aptftparchive -qq generate ftparchive.conf |
ce9864a8 DK |
510 | cd - > /dev/null |
511 | msgdone "info" | |
9b78cda6 | 512 | generatereleasefiles |
ce9864a8 DK |
513 | } |
514 | ||
515 | buildaptarchivefromfiles() { | |
3cbbda3c | 516 | msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…" |
9b78cda6 DK |
517 | find aptarchive -name 'Packages' -o -name 'Sources' | while read line; do |
518 | msgninfo "\t${line} file… " | |
519 | cat ${line} | gzip > ${line}.gz | |
520 | cat ${line} | bzip2 > ${line}.bz2 | |
521 | cat ${line} | lzma > ${line}.lzma | |
b7080ced | 522 | cat ${line} | xz > ${line}.xz |
8d876415 | 523 | msgdone "info" |
9b78cda6 DK |
524 | done |
525 | generatereleasefiles | |
526 | } | |
527 | ||
a3bbbab7 DK |
528 | # can be overridden by testcases for their pleasure |
529 | getcodenamefromsuite() { echo -n "$1"; } | |
530 | getreleaseversionfromsuite() { true; } | |
718f797c | 531 | getlabelfromsuite() { true; } |
a3bbbab7 | 532 | |
9b78cda6 | 533 | generatereleasefiles() { |
884a4c0a DK |
534 | # $1 is the Date header and $2 is the ValidUntil header to be set |
535 | # both should be given in notation date/touch can understand | |
9b78cda6 DK |
536 | msgninfo "\tGenerate Release files… " |
537 | if [ -e aptarchive/dists ]; then | |
18331adf DK |
538 | for dir in $(find ./aptarchive/dists -mindepth 3 -maxdepth 3 -type d -name 'i18n'); do |
539 | aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index | |
540 | done | |
9b78cda6 | 541 | for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do |
a3bbbab7 DK |
542 | local SUITE="$(echo "$dir" | cut -d'/' -f 4)" |
543 | local CODENAME="$(getcodenamefromsuite $SUITE)" | |
544 | local VERSION="$(getreleaseversionfromsuite $SUITE)" | |
718f797c | 545 | local LABEL="$(getlabelfromsuite $SUITE)" |
884a4c0a | 546 | if [ -n "$VERSION" ]; then |
718f797c DK |
547 | VERSION="-o APT::FTPArchive::Release::Version=${VERSION}" |
548 | fi | |
549 | if [ -n "$LABEL" ]; then | |
550 | LABEL="-o APT::FTPArchive::Release::Label=${LABEL}" | |
a3bbbab7 | 551 | fi |
884a4c0a DK |
552 | aptftparchive -qq release $dir \ |
553 | -o APT::FTPArchive::Release::Suite="${SUITE}" \ | |
554 | -o APT::FTPArchive::Release::Codename="${CODENAME}" \ | |
718f797c | 555 | ${LABEL} \ |
884a4c0a DK |
556 | ${VERSION} \ |
557 | | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference | |
a3bbbab7 | 558 | if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then |
35faae11 DK |
559 | sed -i '/^Date: / a\ |
560 | NotAutomatic: yes' $dir/Release | |
561 | fi | |
884a4c0a DK |
562 | if [ -n "$1" -a "$1" != "now" ]; then |
563 | sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release | |
564 | fi | |
565 | if [ -n "$2" ]; then | |
566 | sed -i "/^Date: / a\ | |
567 | Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release | |
568 | fi | |
9b78cda6 DK |
569 | done |
570 | else | |
571 | aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference | |
8d876415 | 572 | fi |
884a4c0a | 573 | if [ -n "$1" -a "$1" != "now" ]; then |
fe0f7911 DK |
574 | for release in $(find ./aptarchive -name 'Release'); do |
575 | touch -d "$1" $release | |
576 | done | |
8d876415 | 577 | fi |
b7899b00 | 578 | msgdone "info" |
8d876415 DK |
579 | } |
580 | ||
b7899b00 DK |
581 | setupdistsaptarchive() { |
582 | local APTARCHIVE=$(readlink -f ./aptarchive) | |
583 | rm -f root/etc/apt/sources.list.d/apt-test-*-deb.list | |
584 | rm -f root/etc/apt/sources.list.d/apt-test-*-deb-src.list | |
585 | for DISTS in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do | |
586 | SECTIONS=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ') | |
587 | msgninfo "\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… " | |
588 | echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb.list | |
589 | echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list | |
590 | msgdone "info" | |
591 | done | |
592 | } | |
593 | ||
594 | setupflataptarchive() { | |
ce9864a8 | 595 | local APTARCHIVE=$(readlink -f ./aptarchive) |
8d876415 DK |
596 | if [ -f ${APTARCHIVE}/Packages ]; then |
597 | msgninfo "\tadd deb sources.list line… " | |
598 | echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list | |
599 | msgdone "info" | |
600 | else | |
601 | rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list | |
602 | fi | |
603 | if [ -f ${APTARCHIVE}/Sources ]; then | |
604 | msgninfo "\tadd deb-src sources.list line… " | |
605 | echo "deb-src file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list | |
606 | msgdone "info" | |
607 | else | |
608 | rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list | |
609 | fi | |
b7899b00 DK |
610 | } |
611 | ||
612 | setupaptarchive() { | |
613 | buildaptarchive | |
614 | if [ -e aptarchive/dists ]; then | |
615 | setupdistsaptarchive | |
616 | else | |
617 | setupflataptarchive | |
618 | fi | |
f213b6ea | 619 | signreleasefiles |
cd725954 | 620 | msgninfo "\tSync APT's cache with the archive… " |
8d876415 | 621 | aptget update -qq |
cd725954 | 622 | msgdone "info" |
8d876415 DK |
623 | } |
624 | ||
f213b6ea DK |
625 | signreleasefiles() { |
626 | local SIGNER="${1:-Joe Sixpack}" | |
627 | msgninfo "\tSign archive with $SIGNER key… " | |
628 | local SECKEYS="" | |
629 | for KEY in $(find keys/ -name '*.sec'); do | |
630 | SECKEYS="$SECKEYS --secret-keyring $KEY" | |
631 | done | |
632 | local PUBKEYS="" | |
633 | for KEY in $(find keys/ -name '*.pub'); do | |
634 | PUBKEYS="$PUBKEYS --keyring $KEY" | |
635 | done | |
636 | for RELEASE in $(find aptarchive/ -name Release); do | |
637 | gpg --yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" -abs -o ${RELEASE}.gpg ${RELEASE} | |
fe0f7911 | 638 | gpg --yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" --clearsign -o "$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')" $RELEASE |
f213b6ea DK |
639 | done |
640 | msgdone "info" | |
641 | } | |
642 | ||
643 | changetowebserver() { | |
644 | if which weborf > /dev/null; then | |
645 | weborf -xb aptarchive/ 2>&1 > /dev/null & | |
b720d0bd | 646 | addtrap "kill $!;" |
6e7d39d0 DK |
647 | elif which gatling > /dev/null; then |
648 | cd aptarchive | |
649 | gatling -p 8080 -F -S 2>&1 > /dev/null & | |
650 | addtrap "kill $!;" | |
651 | cd - > /dev/null | |
c5bcc607 DK |
652 | elif which lighttpd > /dev/null; then |
653 | echo "server.document-root = \"$(readlink -f ./aptarchive)\" | |
654 | server.port = 8080 | |
655 | server.stat-cache-engine = \"disable\"" > lighttpd.conf | |
656 | lighttpd -t -f lighttpd.conf >/dev/null || msgdie 'Can not change to webserver: our lighttpd config is invalid' | |
657 | lighttpd -D -f lighttpd.conf 2>/dev/null >/dev/null & | |
658 | addtrap "kill $!;" | |
659 | else | |
660 | msgdie 'You have to install weborf or lighttpd first' | |
661 | return 1 | |
f213b6ea | 662 | fi |
c5bcc607 DK |
663 | local APTARCHIVE="file://$(readlink -f ./aptarchive)" |
664 | for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do | |
665 | sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#" | |
666 | done | |
667 | return 0 | |
f213b6ea DK |
668 | } |
669 | ||
670 | checkdiff() { | |
8d876415 DK |
671 | local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')" |
672 | if [ -n "$DIFFTEXT" ]; then | |
673 | echo | |
674 | echo "$DIFFTEXT" | |
675 | return 1 | |
676 | else | |
677 | return 0 | |
678 | fi | |
679 | } | |
680 | ||
75954ae2 DK |
681 | testfileequal() { |
682 | local FILE="$1" | |
683 | shift | |
684 | msgtest "Test for correctness of file" "$FILE" | |
685 | if [ -z "$*" ]; then | |
f213b6ea | 686 | echo -n "" | checkdiff $FILE - && msgpass || msgfail |
75954ae2 | 687 | else |
f213b6ea | 688 | echo "$*" | checkdiff $FILE - && msgpass || msgfail |
75954ae2 DK |
689 | fi |
690 | } | |
691 | ||
8d876415 DK |
692 | testequal() { |
693 | local COMPAREFILE=$(mktemp) | |
b720d0bd | 694 | addtrap "rm $COMPAREFILE;" |
8d876415 DK |
695 | echo "$1" > $COMPAREFILE |
696 | shift | |
697 | msgtest "Test for equality of" "$*" | |
f213b6ea | 698 | $* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail |
8d876415 DK |
699 | } |
700 | ||
685625bd DK |
701 | testequalor2() { |
702 | local COMPAREFILE1=$(mktemp) | |
703 | local COMPAREFILE2=$(mktemp) | |
704 | local COMPAREAGAINST=$(mktemp) | |
b720d0bd | 705 | addtrap "rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST;" |
685625bd DK |
706 | echo "$1" > $COMPAREFILE1 |
707 | echo "$2" > $COMPAREFILE2 | |
708 | shift 2 | |
709 | msgtest "Test for equality OR of" "$*" | |
710 | $* 2>&1 1> $COMPAREAGAINST | |
f213b6ea DK |
711 | (checkdiff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null || |
712 | checkdiff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass || | |
713 | ( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(checkdiff $COMPAREFILE1 $COMPAREAGAINST)" \ | |
714 | "\n${CINFO}Diff against OR 2${CNORMAL}" "$(checkdiff $COMPAREFILE2 $COMPAREAGAINST)" && | |
685625bd DK |
715 | msgfail ) |
716 | } | |
717 | ||
8d876415 | 718 | testshowvirtual() { |
edc0ef10 | 719 | local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual" |
8d876415 DK |
720 | local PACKAGE="$1" |
721 | shift | |
722 | while [ -n "$1" ]; do | |
723 | VIRTUAL="${VIRTUAL} | |
edc0ef10 | 724 | N: Can't select versions from package '$1' as it is purely virtual" |
8d876415 DK |
725 | PACKAGE="${PACKAGE} $1" |
726 | shift | |
727 | done | |
728 | msgtest "Test for virtual packages" "apt-cache show $PACKAGE" | |
729 | VIRTUAL="${VIRTUAL} | |
4bec02c2 | 730 | N: No packages found" |
8d876415 | 731 | local COMPAREFILE=$(mktemp) |
b720d0bd | 732 | addtrap "rm $COMPAREFILE;" |
ea65d079 | 733 | local ARCH="$(getarchitecture 'native')" |
8d876415 | 734 | echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE |
e8379ba3 | 735 | aptcache show -q=0 $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail |
8d876415 DK |
736 | } |
737 | ||
738 | testnopackage() { | |
739 | msgtest "Test for non-existent packages" "apt-cache show $*" | |
740 | local SHOWPKG="$(aptcache show $* 2>&1 | grep '^Package: ')" | |
741 | if [ -n "$SHOWPKG" ]; then | |
742 | echo | |
743 | echo "$SHOWPKG" | |
744 | msgfail | |
745 | return 1 | |
746 | fi | |
747 | msgpass | |
748 | } | |
01a6e24c DK |
749 | |
750 | testdpkginstalled() { | |
751 | msgtest "Test for correctly installed package(s) with" "dpkg -l $*" | |
87bc1c45 DK |
752 | local PKGS="$(dpkg -l $* | grep '^i' | wc -l)" |
753 | if [ "$PKGS" != $# ]; then | |
01a6e24c DK |
754 | echo $PKGS |
755 | dpkg -l $* | grep '^[a-z]' | |
756 | msgfail | |
757 | return 1 | |
758 | fi | |
759 | msgpass | |
760 | } | |
761 | ||
5cf733e1 DK |
762 | testdpkgnotinstalled() { |
763 | msgtest "Test for correctly not-installed package(s) with" "dpkg -l $*" | |
87bc1c45 | 764 | local PKGS="$(dpkg -l $* 2> /dev/null | grep '^i' | wc -l)" |
01a6e24c DK |
765 | if [ "$PKGS" != 0 ]; then |
766 | echo | |
767 | dpkg -l $* | grep '^[a-z]' | |
768 | msgfail | |
769 | return 1 | |
770 | fi | |
771 | msgpass | |
772 | } | |
ec7f904e DK |
773 | |
774 | testmarkedauto() { | |
775 | local COMPAREFILE=$(mktemp) | |
776 | addtrap "rm $COMPAREFILE;" | |
777 | if [ -n "$1" ]; then | |
778 | msgtest 'Test for correctly marked as auto-installed' "$*" | |
779 | while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE | |
780 | else | |
781 | msgtest 'Test for correctly marked as auto-installed' 'no package' | |
c98fb5e0 | 782 | echo -n > $COMPAREFILE |
ec7f904e DK |
783 | fi |
784 | aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail | |
785 | } | |
89a1aa5d DK |
786 | |
787 | pause() { | |
788 | echo "STOPPED execution. Press enter to continue" | |
789 | local IGNORE | |
790 | read IGNORE | |
791 | } |