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
:: \"--force-architecture\";" >> aptconfig.conf # Added to test multiarch before dpkg is ready for it…
153 echo "DPKG
::options
:: \"--log=${TMPWORKINGDIRECTORY}/rootdir
/var
/log
/dpkg.log
\";" >> aptconfig.conf
154 echo 'quiet::NoUpdate "true
";' >> aptconfig.conf
156 export PATH="${PATH}:/usr
/local
/sbin
:/usr
/sbin
:/sbin
"
161 if [ "$1" = "native
" -o -z "$1" ]; then
162 eval `aptconfig shell ARCH APT::Architecture`
163 if [ -n "$ARCH" ]; then
166 dpkg-architecture -qDEB_BUILD_ARCH
173 configarchitecture() {
174 local CONFFILE=rootdir/etc/apt/apt.conf.d/01multiarch.conf
176 echo "APT
::Architecture
\"$(getarchitecture $1)\";" > $CONFFILE
178 while [ -n "$1" ]; do
179 echo "APT
::Architectures
:: \"$(getarchitecture $1)\";" >> $CONFFILE
184 setupsimplenativepackage() {
188 local RELEASE="${4:-unstable}"
189 local DEPENDENCIES="$5"
190 local DESCRIPTION="$6"
191 local SECTION="${7:-others}"
193 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
196 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
198 local BUILDDIR=incoming/${NAME}-${VERSION}
199 mkdir -p ${BUILDDIR}/debian/source
201 echo "* most suckless software product ever
" > FEATURES
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
207 -- Joe Sixpack
<joe@example.org
> $(date -R)" > debian/changelog
208 test -e debian/control || echo "Source
: $NAME
211 Maintainer
: Joe Sixpack
<joe@example.org
>
212 Build
-Depends: debhelper
(>= 7)
213 Standards
-Version: 3.9.1
215 Package
: $NAME" > debian/control
216 if [ "$ARCH" = 'all' ]; then
217 echo "Architecture
: all
" >> debian/control
219 echo "Architecture
: any
" >> debian/control
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
228 echo "Description
: $DESCRIPTION" >> debian/control
230 test -e debian/compat || echo "7" > debian/compat
231 test -e debian/source/format || echo "3.0 (native
)" > debian/source/format
232 test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
236 buildsimplenativepackage() {
240 local RELEASE="${4:-unstable}"
241 local DEPENDENCIES="$5"
242 local DESCRIPTION="$6"
243 local SECTION="${7:-others}"
244 local PRIORITY="${8:-optional}"
246 if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
249 DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
251 local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
253 msgninfo "Build package
${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}…
"
254 mkdir -p $BUILDDIR/debian/source
255 echo "* most suckless software product ever
" > ${BUILDDIR}/FEATURES
257 echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
259 echo "Copyleft by Joe Sixpack
$(date +%Y)" > ${BUILDDIR}/debian/copyright
260 echo "$NAME ($VERSION) $RELEASE; urgency
=low
264 -- Joe Sixpack
<joe@example.org
> $(date -R)" > ${BUILDDIR}/debian/changelog
268 Maintainer
: Joe Sixpack
<joe@example.org
>
269 Standards
-Version: 3.9.1
271 Package
: $NAME" > ${BUILDDIR}/debian/control
272 if [ "$ARCH" = 'all' ]; then
273 echo "Architecture
: all
" >> ${BUILDDIR}/debian/control
275 echo "Architecture
: any
" >> ${BUILDDIR}/debian/control
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
284 echo "Description
: $DESCRIPTION" >> ${BUILDIR}/debian/control
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._+~-]*$')"
289 echo "pool
/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
292 for arch in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do
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
)
300 dpkg
-deb --build ${BUILDDIR}/debian
/tmp
${BUILDDIR}/..
2> /dev
/null
> /dev
/null
301 echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/..
/${RELEASE}.
${DISTSECTION}.pkglist
304 mkdir -p ${BUILDDIR}/..
/${NAME}_
${VERSION}
305 cp ${BUILDDIR}/debian
/changelog
${BUILDDIR}/..
/${NAME}_
${VERSION}/
306 cp ${BUILDDIR}/debian
/changelog
${BUILDDIR}/..
/${NAME}_
${VERSION}.changelog
315 local ARCH
=$(getarchitecture $4)
316 msgninfo
"Build package $(echo "$BUILDDIR" | grep -o '[^/]*$') for ${RELEASE} in ${SECTION}… "
318 if [ "$ARCH" = "all" ]; then
319 ARCH
="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
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#'\.##")"
323 local SRCS
="$( echo "$BUILT" | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')"
326 echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.pkglist
329 echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming
/${RELEASE}.
${SECTION}.srclist
335 if [ -d incoming
]; then
336 buildaptarchivefromincoming $
*
338 buildaptarchivefromfiles $
*
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' ' ')"
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' ' ')"
349 ArchiveDir "' >> ftparchive.conf
350 echo -n $(readlink -f .) >> ftparchive.conf
352 CacheDir "' >> ftparchive.conf
353 echo -n $(readlink -f ..) >> ftparchive.conf
355 FileListDir "' >> ftparchive.conf
356 echo -n $(readlink -f pool/) >> ftparchive.conf
360 Packages::Compress ". gzip bzip2 lzma xz";
361 Sources::Compress ". gzip bzip2 lzma xz";
362 Contents::Compress ". gzip bzip2 lzma xz";
363 Translation::Compress ". gzip bzip2 lzma xz";
364 LongDescription "false";
368 SrcDirectory "pool/";
374 Label "apttestcases";
376 Description "repository with dummy packages";
377 Architectures "' >> ftparchive.conf
378 echo -n "$ARCHS" >> ftparchive.conf
382 };' >> ftparchive.conf
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
387 Architectures "' >> ftparchive.conf
388 echo -n "$ARCHS" >> ftparchive.conf
390 FileList "' >> ftparchive.conf
391 echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
393 SourceFileList "' >> ftparchive.conf
394 echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
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
399 };' >> ftparchive.conf
403 buildaptftparchivedirectorystructure
() {
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}
412 mkdir -p dists
/${DIST}/${SECTION}/source
413 mkdir -p dists
/${DIST}/${SECTION}/i18n
423 local DEPENDENCIES
="$5"
424 local PRIORITY
="${6:-optional}"
426 for arch
in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do
427 if [ "$arch" = "all" ]; then
428 ARCHS
="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
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"
441 Maintainer: Joe Sixpack <joe@example.org>
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}
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…
460 local DEPENDENCIES
="$5"
462 local SPATH
="aptarchive/dists/${RELEASE}/main/source"
464 local FILE
="${SPATH}/Sources"
468 Maintainer: Joe Sixpack <joe@example.org>
469 Architecture: $ARCH" >> $FILE
470 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
472 d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc
473 d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz" >> $FILE
476 insertinstalledpackage
() {
480 local DEPENDENCIES
="$4"
481 local PRIORITY
="${5:-optional}"
482 local FILE
="rootdir/var/lib/dpkg/status"
483 for arch
in $(echo "$ARCH" | sed -e 's#,#\n#g' | sed -e "s#^native\$#$(getarchitecture 'native')#"); do
485 Status: install ok installed
489 Maintainer: Joe Sixpack <joe@example.org>
491 Version: $VERSION" >> $FILE
492 test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
493 echo "Description: an autogenerated dummy ${NAME}=${VERSION}/installed
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…
502 buildaptarchivefromincoming
() {
503 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
505 [ -e pool
] || ln -s ..
/incoming pool
506 [ -e ftparchive.conf
] || createaptftparchiveconfig
507 [ -e dists
] || buildaptftparchivedirectorystructure
508 msgninfo
"\tGenerate Packages, Sources and Contents files… "
509 aptftparchive
-qq generate ftparchive.conf
515 buildaptarchivefromfiles
() {
516 msginfo
"Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
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
522 cat ${line} | xz
> ${line}.xz
528 # can be overridden by testcases for their pleasure
529 getcodenamefromsuite
() { echo -n "$1"; }
530 getreleaseversionfromsuite
() { true
; }
531 getlabelfromsuite
() { true
; }
533 generatereleasefiles
() {
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
536 msgninfo
"\tGenerate Release files… "
537 if [ -e aptarchive
/dists
]; then
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
541 for dir
in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
542 local SUITE
="$(echo "$dir" | cut -d'/' -f 4)"
543 local CODENAME
="$(getcodenamefromsuite $SUITE)"
544 local VERSION
="$(getreleaseversionfromsuite $SUITE)"
545 local LABEL
="$(getlabelfromsuite $SUITE)"
546 if [ -n "$VERSION" ]; then
547 VERSION
="-o APT::FTPArchive::Release::Version=${VERSION}"
549 if [ -n "$LABEL" ]; then
550 LABEL
="-o APT::FTPArchive::Release::Label=${LABEL}"
552 aptftparchive
-qq release
$dir \
553 -o APT
::FTPArchive
::Release
::Suite
="${SUITE}" \
554 -o APT
::FTPArchive
::Release
::Codename
="${CODENAME}" \
557 | sed -e '/0 Release$/ d' > $dir/Release
# remove the self reference
558 if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
560 NotAutomatic: yes' $dir/Release
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
567 Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
571 aptftparchive
-qq release .
/aptarchive
| sed -e '/0 Release$/ d' > aptarchive
/Release
# remove the self reference
573 if [ -n "$1" -a "$1" != "now" ]; then
574 for release
in $(find ./aptarchive -name 'Release'); do
575 touch -d "$1" $release
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
594 setupflataptarchive
() {
595 local APTARCHIVE
=$(readlink -f ./aptarchive)
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
601 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb.list
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
608 rm -f rootdir
/etc
/apt
/sources.list.d
/apt
-test-archive-deb-src.list
614 if [ -e aptarchive
/dists
]; then
620 msgninfo
"\tSync APT's cache with the archive… "
626 local SIGNER
="${1:-Joe Sixpack}"
627 msgninfo
"\tSign archive with $SIGNER key… "
629 for KEY
in $(find keys/ -name '*.sec'); do
630 SECKEYS
="$SECKEYS --secret-keyring $KEY"
633 for KEY
in $(find keys/ -name '*.pub'); do
634 PUBKEYS
="$PUBKEYS --keyring $KEY"
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}
638 gpg
--yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" --clearsign -o "$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')" $RELEASE
643 changetowebserver
() {
644 if which weborf
> /dev
/null
; then
645 weborf
-xb aptarchive
/ 2>&1 > /dev
/null
&
647 elif which gatling
> /dev
/null
; then
649 gatling
-p 8080 -F -S 2>&1 > /dev
/null
&
652 elif which lighttpd
> /dev
/null
; then
653 echo "server.document-root = \"$(readlink -f ./aptarchive)\"
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
&
660 msgdie
'You have to install weborf or lighttpd first'
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/#"
671 local DIFFTEXT
="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
672 if [ -n "$DIFFTEXT" ]; then
684 msgtest
"Test for correctness of file" "$FILE"
686 echo -n "" | checkdiff
$FILE - && msgpass
|| msgfail
688 echo "$*" | checkdiff
$FILE - && msgpass
|| msgfail
693 local COMPAREFILE
=$(mktemp)
694 addtrap
"rm $COMPAREFILE;"
695 echo "$1" > $COMPAREFILE
697 msgtest
"Test for equality of" "$*"
698 $
* 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
702 local COMPAREFILE1
=$(mktemp)
703 local COMPAREFILE2
=$(mktemp)
704 local COMPAREAGAINST
=$(mktemp)
705 addtrap
"rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST;"
706 echo "$1" > $COMPAREFILE1
707 echo "$2" > $COMPAREFILE2
709 msgtest
"Test for equality OR of" "$*"
710 $
* 2>&1 1> $COMPAREAGAINST
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)" &&
719 local VIRTUAL
="N: Can't select versions from package '$1' as it is purely virtual"
722 while [ -n "$1" ]; do
724 N: Can't select versions from package '$1' as it is purely virtual"
725 PACKAGE
="${PACKAGE} $1"
728 msgtest
"Test for virtual packages" "apt-cache show $PACKAGE"
730 N: No packages found"
731 local COMPAREFILE
=$(mktemp)
732 addtrap
"rm $COMPAREFILE;"
733 local ARCH
="$(getarchitecture 'native')"
734 echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
735 aptcache show
-q=0 $PACKAGE 2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
739 msgtest
"Test for non-existent packages" "apt-cache show $*"
740 local SHOWPKG
="$(aptcache show $* 2>&1 | grep '^Package: ')"
741 if [ -n "$SHOWPKG" ]; then
750 testdpkginstalled
() {
751 msgtest
"Test for correctly installed package(s) with" "dpkg -l $*"
752 local PKGS
="$(dpkg -l $* | grep '^i' | wc -l)"
753 if [ "$PKGS" != $# ]; then
755 dpkg
-l $
* | grep '^[a-z]'
762 testdpkgnotinstalled
() {
763 msgtest
"Test for correctly not-installed package(s) with" "dpkg -l $*"
764 local PKGS
="$(dpkg -l $* 2> /dev/null | grep '^i' | wc -l)"
765 if [ "$PKGS" != 0 ]; then
767 dpkg
-l $
* | grep '^[a-z]'
775 local COMPAREFILE
=$(mktemp)
776 addtrap
"rm $COMPAREFILE;"
778 msgtest
'Test for correctly marked as auto-installed' "$*"
779 while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
781 msgtest
'Test for correctly marked as auto-installed' 'no package'
782 echo -n > $COMPAREFILE
784 aptmark showauto
2>&1 | checkdiff
$COMPAREFILE - && msgpass
|| msgfail
788 echo "STOPPED execution. Press enter to continue"