39
39
if [ $MSGLEVEL -le 2 ]; then
41
41
msgnmsg() { true; }
43
msgpass() { echo -n " ${CPASS}P${CNORMAL}" >&2; }
44
msgskip() { echo -n " ${CWARNING}S${CNORMAL}" >&2; }
45
msgfail() { echo -n " ${CFAIL}FAIL${CNORMAL}" >&2; }
43
47
if [ $MSGLEVEL -le 3 ]; then
44
48
msginfo() { true; }
79
83
$(which dpkg) --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log $*
86
if [ -f ./aptconfig.conf ]; then
87
APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which aptitude) $*
88
elif [ -f ../aptconfig.conf ]; then
89
APT_CONFIG=../aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which aptitude) $*
91
LD_LIBRARY_PATH=${BUILDDIRECTORY} $(which aptitude) $*
96
CURRENTTRAP="$CURRENTTRAP $1"
97
trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
82
100
setupenvironment() {
83
101
TMPWORKINGDIRECTORY=$(mktemp -d)
86
104
BUILDDIRECTORY="${TESTDIR}/../../build/bin"
87
105
test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
88
106
local OLDWORKINGDIRECTORY=$(pwd)
89
CURRENTTRAP="cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY"
90
trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
107
addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY;"
91
108
cd $TMPWORKINGDIRECTORY
92
109
mkdir rootdir aptarchive keys
107
124
local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
108
125
if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then
109
126
cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages
111
touch aptarchive/Packages
128
local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
129
if [ -f "${TESTDIR}/${SOURCESSFILE}" ]; then
130
cp "${TESTDIR}/${SOURCESSFILE}" aptarchive/Sources
113
132
cp $(find $TESTDIR -name '*.pub' -o -name '*.sec') keys/
114
133
ln -s ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
116
135
echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
117
136
echo "Debug::NoLocking \"true\";" >> aptconfig.conf
118
137
echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
138
echo "Dir::Bin::Methods \"${BUILDDIRECTORY}/methods\";" >> aptconfig.conf
119
139
echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
120
140
echo "Dir::Bin::methods \"${BUILDDIRECTORY}/methods\";" >> aptconfig.conf
121
141
echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
123
143
echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
124
144
echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
125
145
echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
146
echo 'quiet::NoUpdate "true";' >> aptconfig.conf
168
189
Build-Depends: debhelper (>= 7)
169
190
Standards-Version: 3.9.1
172
Architecture: $ARCH" > debian/control
192
Package: $NAME" > debian/control
193
if [ "$ARCH" = 'all' ]; then
194
echo "Architecture: all" >> debian/control
196
echo "Architecture: any" >> debian/control
173
198
test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
174
199
if [ -z "$DESCRIPTION" ]; then
175
200
echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
200
225
DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
202
setupsimplenativepackage "$NAME" "$ARCH" "$VERSION" "$RELEASE" "$DEPENDENCIES" "$DESCRIPTION" "$SECTION"
203
buildpackage "incoming/${NAME}-${VERSION}" "$RELEASE" "$DISTSECTION"
204
rm -rf "incoming/${NAME}-${VERSION}"
227
local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
229
msgninfo "Build package ${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}… "
230
mkdir -p $BUILDDIR/debian/source
231
echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES
233
echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
235
echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright
236
echo "$NAME ($VERSION) $RELEASE; urgency=low
240
-- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog
244
Maintainer: Joe Sixpack <joe@example.org>
245
Standards-Version: 3.9.1
247
Package: $NAME" > ${BUILDDIR}/debian/control
248
if [ "$ARCH" = 'all' ]; then
249
echo "Architecture: all" >> ${BUILDDIR}/debian/control
251
echo "Architecture: any" >> ${BUILDDIR}/debian/control
253
test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> ${BUILDDIR}/debian/control
254
if [ -z "$DESCRIPTION" ]; then
255
echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
256
If you find such a package installed on your system,
257
YOU did something horribly wrong! They are autogenerated
258
und used only by testcases for APT and surf no other propose…" >> ${BUILDDIR}/debian/control
260
echo "Description: $DESCRIPTION" >> ${BUILDIR}/debian/control
262
echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
263
local SRCS="$( (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._+~-]*$')"
265
mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
266
cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
267
cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
268
(cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$ARCH)
269
(cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
271
dpkg-deb --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. > /dev/null
272
echo "pool/${NAME}_${VERSION}_${ARCH}.deb" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
274
echo "pool/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
391
local DEPENDENCIES="$5"
393
if [ "$ARCHS" = "all" ]; then
394
ARCHS="$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
396
for BUILDARCH in $ARCHS; do
397
local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}"
398
mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
399
touch aptarchive/dists/${RELEASE}/main/source/Sources
400
local FILE="${PPATH}/Packages"
405
Maintainer: Joe Sixpack <joe@example.org>
408
Filename: pool/main/${NAME}/${NAME}_${VERSION}_${ARCH}.deb" >> $FILE
409
test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
410
echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
411
If you find such a package installed on your system,
412
YOU did something horribly wrong! They are autogenerated
413
und used only by testcases for APT and surf no other propose…
311
418
buildaptarchivefromincoming() {
312
419
msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
316
423
[ -e dists ] || buildaptftparchivedirectorystructure
317
424
msgninfo "\tGenerate Packages, Sources and Contents files… "
318
425
aptftparchive -qq generate ftparchive.conf
320
msgninfo "\tGenerate Release files… "
321
for dir in $(find ./dists -mindepth 1 -maxdepth 1 -type d); do
322
aptftparchive -qq release $dir -o APT::FTPArchive::Release::Codename="$(echo "$dir" | cut -d'/' -f 3)" | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
328
431
buildaptarchivefromfiles() {
329
432
msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
331
if [ -f Packages ]; then
332
msgninfo "\tPackages file… "
333
cat Packages | gzip > Packages.gz
334
cat Packages | bzip2 > Packages.bz2
335
cat Packages | lzma > Packages.lzma
338
if [ -f Sources ]; then
339
msgninfo "\tSources file… "
340
cat Sources | gzip > Sources.gz
341
cat Sources | bzip2 > Sources.bz2
342
cat Sources | lzma > Sources.lzma
345
msgninfo "\tRelease file… "
346
aptftparchive -qq release . | sed -e '/0 Release$/ d' > Release # remove the self reference
433
find aptarchive -name 'Packages' -o -name 'Sources' | while read line; do
434
msgninfo "\t${line} file… "
435
cat ${line} | gzip > ${line}.gz
436
cat ${line} | bzip2 > ${line}.bz2
437
cat ${line} | lzma > ${line}.lzma
443
generatereleasefiles() {
444
msgninfo "\tGenerate Release files… "
445
local DATE="${1:-now}"
446
if [ -e aptarchive/dists ]; then
447
for dir in $(find ./aptarchive/dists -mindepth 3 -maxdepth 3 -type d -name 'i18n'); do
448
aptftparchive -qq release $dir -o APT::FTPArchive::Release::Patterns::='Translation-*' > $dir/Index
450
for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
451
local CODENAME="$(echo "$dir" | cut -d'/' -f 4)"
452
aptftparchive -qq release $dir -o APT::FTPArchive::Release::Suite="${CODENAME}" -o APT::FTPArchive::Release::Codename="${CODENAME}" | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
453
if [ "$CODENAME" = "experimental" -o "$CODENAME" = "experimental2" ]; then
455
NotAutomatic: yes' $dir/Release
459
aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference
461
if [ "$DATE" != "now" ]; then
462
for release in $(find ./aptarchive -name 'Release'); do
463
touch -d "$1" $release
351
469
setupdistsaptarchive() {
412
531
changetowebserver() {
413
532
if which weborf > /dev/null; then
414
533
weborf -xb aptarchive/ 2>&1 > /dev/null &
415
CURRENTTRAP="kill $(ps | grep weborf | sed -e 's#^[ ]*##' | cut -d' ' -f 1); $CURRENTTRAP"
416
trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
417
535
local APTARCHIVE="file://$(readlink -f ./aptarchive)"
418
536
for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
419
537
sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
449
567
local COMPAREFILE=$(mktemp)
568
addtrap "rm $COMPAREFILE;"
450
569
echo "$1" > $COMPAREFILE
452
571
msgtest "Test for equality of" "$*"
453
572
$* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
458
576
local COMPAREFILE1=$(mktemp)
459
577
local COMPAREFILE2=$(mktemp)
460
578
local COMPAREAGAINST=$(mktemp)
579
addtrap "rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST;"
461
580
echo "$1" > $COMPAREFILE1
462
581
echo "$2" > $COMPAREFILE2
485
603
VIRTUAL="${VIRTUAL}
486
604
N: No packages found"
487
605
local COMPAREFILE=$(mktemp)
606
addtrap "rm $COMPAREFILE;"
488
607
local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU)
489
608
eval `apt-config shell ARCH APT::Architecture`
490
609
echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
491
610
aptcache show -q=0 $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
495
613
testnopackage() {