1 #!/bin/sh -- # no runable script, just for vi
3 # we all like colorful messages
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
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; }
33 # enable / disable Debugging
34 MSGLEVEL
=${MSGLEVEL:-3}
35 if [ $MSGLEVEL -le 0 ]; then
38 if [ $MSGLEVEL -le 1 ]; then
42 if [ $MSGLEVEL -le 2 ]; then
46 msgpass
() { echo -n " ${CPASS}P${CNORMAL}" >&2; }
47 msgskip
() { echo -n " ${CWARNING}S${CNORMAL}" >&2; }
48 if [ -n "$CFAIL" ]; then
49 msgfail
() { echo -n " ${CFAIL}FAIL${CNORMAL}" >&2; }
51 msgfail
() { echo -n " ###FAILED###" >&2; }
54 if [ $MSGLEVEL -le 3 ]; then
58 if [ $MSGLEVEL -le 4 ]; then
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
70 echo "${CDONE}DONE${CNORMAL}" >&2;
75 msgdebug
"Executing: ${CCMD}$*${CDEBUG} "
76 if [ -f .
/aptconfig.conf
]; then
77 APT_CONFIG
=aptconfig.conf LD_LIBRARY_PATH
=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$
*
78 elif [ -f ..
/aptconfig.conf
]; then
79 APT_CONFIG
=..
/aptconfig.conf LD_LIBRARY_PATH
=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$
*
81 LD_LIBRARY_PATH
=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$
*
84 aptconfig
() { runapt apt
-config $
*; }
85 aptcache
() { runapt apt
-cache $
*; }
86 aptget
() { runapt apt
-get $
*; }
87 aptftparchive
() { runapt apt
-ftparchive $
*; }
88 aptkey
() { runapt apt
-key $
*; }
89 aptmark
() { runapt apt
-mark $
*; }
91 $(which dpkg) --root=${TMPWORKINGDIRECTORY}/rootdir
--force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir
/var
/log
/dpkg.log $
*
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) $
*
99 LD_LIBRARY_PATH
=${BUILDDIRECTORY} $(which aptitude) $
*
104 CURRENTTRAP
="$CURRENTTRAP $1"
105 trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
109 TMPWORKINGDIRECTORY
=$(mktemp -d)
110 local TESTDIR
=$(readlink -f $(dirname $0))
111 msgninfo
"Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
112 BUILDDIRECTORY
="${TESTDIR}/../../build/bin"
113 test -x "${BUILDDIRECTORY}/apt-get" || msgdie
"You need to build tree first"
114 local OLDWORKINGDIRECTORY
=$(pwd)
115 addtrap
"cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY;"
116 cd $TMPWORKINGDIRECTORY
117 mkdir rootdir aptarchive keys
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
121 mkdir -p var
/lib
/dpkg
/info var
/lib
/dpkg
/updates var
/lib
/dpkg
/triggers
122 local STATUSFILE
=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
123 if [ -f "${TESTDIR}/${STATUSFILE}" ]; then
124 cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status
126 touch var/lib/dpkg/status
128 touch var/lib/dpkg/available
130 ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods
132 local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
133 if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then
134 cp "${TESTDIR}/${PACKAGESFILE}" aptarchive
/Packages
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
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
142 echo "Dir
\"${TMPWORKINGDIRECTORY}/rootdir
\";" > aptconfig.conf
143 echo "Dir
::state
::status
\"${TMPWORKINGDIRECTORY}/rootdir
/var
/lib
/dpkg
/status
\";" >> aptconfig.conf
144 echo "Debug
::NoLocking
\"true
\";" >> aptconfig.conf
145 echo "APT
::Get
::Show
-User-Simulation-Note \"false
\";" >> aptconfig.conf
146 echo "Dir
::Bin
::Methods
\"${BUILDDIRECTORY}/methods
\";" >> aptconfig.conf
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
152 echo "DPKG
::options
:: \"--log=${TMPWORKINGDIRECTORY}/rootdir
/var
/log
/dpkg.log
\";" >> aptconfig.conf
153 echo 'quiet::NoUpdate "true
";' >> aptconfig.conf
155 export PATH="${PATH}:/usr
/local
/sbin
:/usr
/sbin
:/sbin
"
159 configarchitecture() {
160 local CONFFILE=rootdir/etc/apt/apt.conf.d/01multiarch.conf
162 echo "APT
::Architecture
\"$1\";" > $CONFFILE
164 while [ -n "$1" ]; do
165 echo "APT
::Architectures
:: \"$1\";" >> $CONFFILE
170 setupsimplenativepackage() {
174 local RELEASE="${4:-unstable}"
175 local DEPENDENCIES="$5"
176 local DESCRIPTION="$6"
177 local SECTION="${7:-others}"
179 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
182 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
184 local BUILDDIR=incoming/${NAME}-${VERSION}
185 mkdir -p ${BUILDDIR}/debian/source
187 echo "* most suckless software product ever
" > FEATURES
188 test -e debian/copyright || echo "Copyleft by Joe Sixpack
$(date +%Y)" > debian/copyright
189 test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency
=low
193 -- Joe Sixpack
<joe@example.org
> $(date -R)" > debian/changelog
194 test -e debian/control || echo "Source
: $NAME
197 Maintainer
: Joe Sixpack
<joe@example.org
>
198 Build
-Depends: debhelper
(>= 7)
199 Standards
-Version: 3.9.1
201 Package
: $NAME" > debian/control
202 if [ "$ARCH" = 'all' ]; then
203 echo "Architecture
: all
" >> debian/control
205 echo "Architecture
: any
" >> debian/control
207 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
208 if [ -z "$DESCRIPTION" ]; then
209 echo "Description
: an autogenerated dummy
${NAME}=${VERSION}/${RELEASE}
210 If you
find such a package installed on your system
,
211 YOU did something horribly wrong
! They are autogenerated
212 und used only by testcases
for APT and surf no other propose…
" >> debian/control
214 echo "Description
: $DESCRIPTION" >> debian/control
216 test -e debian/compat || echo "7" > debian/compat
217 test -e debian/source/format || echo "3.0 (native
)" > debian/source/format
218 test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
222 buildsimplenativepackage() {
226 local RELEASE="${4:-unstable}"
227 local DEPENDENCIES="$5"
228 local DESCRIPTION="$6"
229 local SECTION="${7:-others}"
230 local PRIORITY="${8:-optional}"
232 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
235 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
237 local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
239 msgninfo "Build package
${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}…
"
240 mkdir -p $BUILDDIR/debian/source
241 echo "* most suckless software product ever
" > ${BUILDDIR}/FEATURES
243 echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
245 echo "Copyleft by Joe Sixpack
$(date +%Y)" > ${BUILDDIR}/debian/copyright
246 echo "$NAME ($VERSION) $RELEASE; urgency
=low
250 -- Joe Sixpack
<joe@example.org
> $(date -R)" > ${BUILDDIR}/debian/changelog
254 Maintainer
: Joe Sixpack
<joe@example.org
>
255 Standards
-Version: 3.9.1
257 Package
: $NAME" > ${BUILDDIR}/debian/control
258 if [ "$ARCH" = 'all' ]; then
259 echo "Architecture
: all
" >> ${BUILDDIR}/debian/control
261 echo "Architecture
: any
" >> ${BUILDDIR}/debian/control
263 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> ${BUILDDIR}/debian/control
264 if [ -z "$DESCRIPTION" ]; then
265 echo "Description
: an autogenerated dummy
${NAME}=${VERSION}/${RELEASE}
266 If you
find such a package installed on your system
,
267 YOU did something horribly wrong
! They are autogenerated
268 und used only by testcases
for APT and surf no other propose…
" >> ${BUILDDIR}/debian/control
270 echo "Description
: $DESCRIPTION" >> ${BUILDIR}/debian/control
272 echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
273 local SRCS="$( (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')"
275 echo "pool
/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
278 for arch in $(echo "$ARCH" | sed -e 's#,#\n#g'); do
279 rm -rf ${BUILDDIR}/debian/tmp
280 mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
281 cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
282 cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch}
283 (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch)
284 (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
286 dpkg-deb --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. 2> /dev/null > /dev/null
287 echo "pool
/${NAME}_
${VERSION}_
${arch}.deb
" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
290 mkdir -p ${BUILDDIR}/../${NAME}_${VERSION}
291 cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}/
292 cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}.changelog
301 msgninfo "Build package
$(echo "$BUILDDIR" | grep -o '[^/]*$') for ${RELEASE} in ${SECTION}…
"
303 if [ "$ARCH" = "all
" ]; then
304 ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
306 local BUILT="$(dpkg-buildpackage -uc -us -a$ARCH 2> /dev/null)"
307 local PKGS="$( echo "$BUILT" | grep '^dpkg-deb: building package' | cut -d'/' -f 2 | sed -e "s#'\.##")"
308 local SRCS="$( echo "$BUILT" | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')"
311 echo "pool
/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
314 echo "pool
/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist
320 if [ -d incoming ]; then
321 buildaptarchivefromincoming $*
323 buildaptarchivefromfiles $*
327 createaptftparchiveconfig() {
328 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' ' ')"
329 if [ -z "$ARCHS" ]; then
330 # the pool is empty, so we will operate on faked packages - let us use the configured archs
331 ARCHS
="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
334 ArchiveDir "' >> ftparchive.conf
335 echo -n $(readlink -f .) >> ftparchive.conf
337 CacheDir "' >> ftparchive.conf
338 echo -n $(readlink -f ..) >> ftparchive.conf
340 FileListDir "' >> ftparchive.conf
341 echo -n $(readlink -f pool/) >> ftparchive.conf
345 Packages::Compress ". gzip bzip2 lzma xz";
346 Sources::Compress ". gzip bzip2 lzma xz";
347 Contents::Compress ". gzip bzip2 lzma xz";
348 Translation::Compress ". gzip bzip2 lzma xz";
349 LongDescription "false";
353 SrcDirectory "pool/";
359 Label "apttestcases";
361 Description "repository with dummy packages";
362 Architectures "' >> ftparchive.conf
363 echo -n "$ARCHS" >> ftparchive.conf
367 };' >> ftparchive.conf
368 for DIST
in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
369 echo -n 'tree "dists/' >> ftparchive.conf
370 echo -n "$DIST" >> ftparchive.conf
372 Architectures "' >> ftparchive.conf
373 echo -n "$ARCHS" >> ftparchive.conf
375 FileList "' >> ftparchive.conf
376 echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
378 SourceFileList "' >> ftparchive.conf
379 echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
381 Sections "' >> ftparchive.conf
382 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
384 };' >> ftparchive.conf
388 buildaptftparchivedirectorystructure
() {
389 local DISTS
="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
390 for DIST
in $DISTS; do
391 local SECTIONS
="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
392 for SECTION
in $SECTIONS; do
393 local ARCHS
="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
394 for ARCH
in $ARCHS; do
395 mkdir -p dists
/${DIST}/${SECTION}/binary
-${ARCH}
397 mkdir -p dists
/${DIST}/${SECTION}/source
398 mkdir -p dists
/${DIST}/${SECTION}/i18n
408 local DEPENDENCIES
="$5"
409 local PRIORITY
="${6:-optional}"
411 for arch
in $(echo "$ARCH" | sed -e 's#,#\n#g'); do
412 if [ "$arch" = "all" ]; then
413 ARCHS
="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
417 for BUILDARCH
in $ARCHS; do
418 local PPATH
="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}"
419 mkdir -p $PPATH aptarchive
/dists
/${RELEASE}/main
/source
420 touch aptarchive
/dists
/${RELEASE}/main
/source
/Sources
421 local FILE
="${PPATH}/Packages"
426 Maintainer: Joe Sixpack <joe@example.org>
429 Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
430 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
431 echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
432 If you find such a package installed on your system,
433 YOU did something horribly wrong! They are autogenerated
434 und used only by testcases for APT and surf no other propose…
445 local DEPENDENCIES
="$5"
447 local SPATH
="aptarchive/dists/${RELEASE}/main/source"
449 local FILE
="${SPATH}/Sources"
453 Maintainer: Joe Sixpack <joe@example.org>
454 Architecture: $ARCH" >> $FILE
455 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
457 d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc
458 d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz" >> $FILE
461 insertinstalledpackage
() {
465 local DEPENDENCIES
="$4"
466 local PRIORITY
="${5:-optional}"
467 local FILE
="rootdir/var/lib/dpkg/status"
468 for arch
in $(echo "$ARCH" | sed -e 's#,#\n#g'); do
470 Status: install ok installed
474 Maintainer: Joe Sixpack <joe@example.org>
476 Version: $VERSION" >> $FILE
477 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
478 echo "Description: an autogenerated dummy ${NAME}=${VERSION}/installed
479 If you find such a package installed on your system,
480 YOU did something horribly wrong! They are autogenerated
481 und used only by testcases for APT and surf no other propose…
487 buildaptarchivefromincoming
() {
488 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
490 [ -e pool
] || ln -s ..
/incoming pool
491 [ -e ftparchive.conf
] || createaptftparchiveconfig
492 [ -e dists
] || buildaptftparchivedirectorystructure
493 msgninfo
"\tGenerate Packages, Sources and Contents files… "
494 aptftparchive
-qq generate ftparchive.conf
500 buildaptarchivefromfiles
() {
501 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
502 find aptarchive
-name 'Packages' -o -name 'Sources' | while read line
; do
503 msgninfo
"\t${line} file… "
504 cat ${line} | gzip > ${line}.gz
505 cat ${line} | bzip2 > ${line}.bz2
506 cat ${line} | lzma
> ${line}.lzma
507 cat ${line} | xz
> ${line}.xz
513 # can be overridden by testcases for their pleasure
514 getcodenamefromsuite
() { echo -n "$1"; }
515 getreleaseversionfromsuite
() { true
; }
517 generatereleasefiles
() {
518 msgninfo
"\tGenerate Release files… "
519 local DATE
="${1:-now}"
520 if [ -e aptarchive
/dists
]; then
521 for dir
in $(find ./aptarchive/dists -mindepth 3 -maxdepth 3 -type d -name 'i18n'); do
522 aptftparchive
-qq release
$dir -o APT
::FTPArchive
::Release
::Patterns
::='Translation-*' > $dir/Index
524 for dir
in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
525 local SUITE
="$(echo "$dir" | cut -d'/' -f 4)"
526 local CODENAME
="$(getcodenamefromsuite $SUITE)"
527 local VERSION
="$(getreleaseversionfromsuite $SUITE)"
528 if [ -z "$VERSION" ]; then
529 aptftparchive
-qq release
$dir \
530 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
531 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
532 | sed -e '/0 Release$/ d' > $dir/Release
# remove the self reference
534 aptftparchive
-qq release
$dir \
535 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
536 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
537 -o APT
::FTPArchive
::Release
::Version
="${VERSION}" \
538 | sed -e '/0 Release$/ d' > $dir/Release
# remove the self reference
540 if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
542 NotAutomatic: yes' $dir/Release
546 aptftparchive
-qq release .
/aptarchive
| sed -e '/0 Release$/ d' > aptarchive
/Release
# remove the self reference
548 if [ "$DATE" != "now" ]; then
549 for release
in $(find ./aptarchive -name 'Release'); do
550 touch -d "$1" $release
556 setupdistsaptarchive
() {
557 local APTARCHIVE
=$(readlink -f ./aptarchive)
558 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb.list
559 rm -f root
/etc
/apt
/sources.list.d
/apt
-test-*-deb-src.list
560 for DISTS
in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
561 SECTIONS
=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
562 msgninfo
"\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
563 echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb.list
564 echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-${DISTS}-deb-src.list
569 setupflataptarchive
() {
570 local APTARCHIVE
=$(readlink -f ./aptarchive)
571 if [ -f ${APTARCHIVE}/Packages
]; then
572 msgninfo
"\tadd deb sources.list line… "
573 echo "deb file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
576 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
578 if [ -f ${APTARCHIVE}/Sources
]; then
579 msgninfo
"\tadd deb-src sources.list line… "
580 echo "deb-src file://$APTARCHIVE /" > rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
583 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
589 if [ -e aptarchive
/dists
]; then
595 msgninfo
"\tSync APT's cache with the archive… "
601 local SIGNER
="${1:-Joe Sixpack}"
602 msgninfo
"\tSign archive with $SIGNER key… "
604 for KEY
in $(find keys/ -name '*.sec'); do
605 SECKEYS
="$SECKEYS --secret-keyring $KEY"
608 for KEY
in $(find keys/ -name '*.pub'); do
609 PUBKEYS
="$PUBKEYS --keyring $KEY"
611 for RELEASE
in $(find aptarchive/ -name Release); do
612 gpg
--yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" -abs -o ${RELEASE}.gpg
${RELEASE}
613 gpg
--yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" --clearsign -o "$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')" $RELEASE
618 changetowebserver
() {
619 if which weborf
> /dev
/null
; then
620 weborf
-xb aptarchive
/ 2>&1 > /dev
/null
&
622 elif which gatling
> /dev
/null
; then
624 gatling
-p 8080 -F -S 2>&1 > /dev
/null
&
627 elif which lighttpd
> /dev
/null
; then
628 echo "server.document-root = \"$(readlink -f ./aptarchive)\"
630 server.stat-cache-engine = \"disable\"" > lighttpd.conf
631 lighttpd
-t -f lighttpd.conf
>/dev
/null
|| msgdie
'Can not change to webserver: our lighttpd config is invalid'
632 lighttpd
-D -f lighttpd.conf
2>/dev
/null
>/dev
/null
&
635 msgdie
'You have to install weborf or lighttpd first'
638 local APTARCHIVE
="file://$(readlink -f ./aptarchive)"
639 for LIST
in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
640 sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
646 local DIFFTEXT
="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
647 if [ -n "$DIFFTEXT" ]; then
659 msgtest
"Test for correctness of file" "$FILE"
661 echo -n "" | checkdiff
$FILE - && msgpass
|| msgfail
663 echo "$*" | checkdiff
$FILE - && msgpass
|| msgfail
668 local COMPAREFILE
=$(mktemp)
669 addtrap
"rm $COMPAREFILE;"
670 echo "$1" > $COMPAREFILE
672 msgtest
"Test for equality of" "$*"
673 $
* 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
677 local COMPAREFILE1
=$(mktemp)
678 local COMPAREFILE2
=$(mktemp)
679 local COMPAREAGAINST
=$(mktemp)
680 addtrap
"rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST;"
681 echo "$1" > $COMPAREFILE1
682 echo "$2" > $COMPAREFILE2
684 msgtest
"Test for equality OR of" "$*"
685 $
* 2>&1 1> $COMPAREAGAINST
686 (checkdiff
$COMPAREFILE1 $COMPAREAGAINST 1> /dev
/null
||
687 checkdiff
$COMPAREFILE2 $COMPAREAGAINST 1> /dev
/null
) && msgpass
||
688 ( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(checkdiff $COMPAREFILE1 $COMPAREAGAINST)" \
689 "\n${CINFO}Diff against OR 2${CNORMAL}" "$(checkdiff $COMPAREFILE2 $COMPAREAGAINST)" &&
694 local VIRTUAL
="N: Can't select versions from package '$1' as it is purely virtual"
697 while [ -n "$1" ]; do
699 N: Can't select versions from package '$1' as it is purely virtual"
700 PACKAGE
="${PACKAGE} $1"
703 msgtest
"Test for virtual packages" "apt-cache show $PACKAGE"
705 N: No packages found"
706 local COMPAREFILE
=$(mktemp)
707 addtrap
"rm $COMPAREFILE;"
708 local ARCH
=$(dpkg-architecture -qDEB_HOST_ARCH_CPU)
709 eval `apt-config shell ARCH APT::Architecture`
710 echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
711 aptcache show
-q=0 $PACKAGE 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
715 msgtest
"Test for non-existent packages" "apt-cache show $*"
716 local SHOWPKG
="$(aptcache show $* 2>&1 | grep '^Package: ')"
717 if [ -n "$SHOWPKG" ]; then
726 testdpkginstalled
() {
727 msgtest
"Test for correctly installed package(s) with" "dpkg -l $*"
728 local PKGS
="$(dpkg -l $* | grep '^i' | wc -l)"
729 if [ "$PKGS" != $# ]; then
731 dpkg
-l $
* | grep '^[a-z]'
738 testdpkgnotinstalled
() {
739 msgtest
"Test for correctly not-installed package(s) with" "dpkg -l $*"
740 local PKGS
="$(dpkg -l $* 2> /dev/null | grep '^i' | wc -l)"
741 if [ "$PKGS" != 0 ]; then
743 dpkg
-l $
* | grep '^[a-z]'
751 local COMPAREFILE
=$(mktemp)
752 addtrap
"rm $COMPAREFILE;"
754 msgtest
'Test for correctly marked as auto-installed' "$*"
755 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
757 msgtest
'Test for correctly marked as auto-installed' 'no package'
758 echo -n > $COMPAREFILE
760 aptmark showauto
2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
764 echo "STOPPED execution. Press enter to continue"