framework 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376
  1. #!/bin/sh -- # no runable script, just for vi
  2. EXIT_CODE=0
  3. # we all like colorful messages
  4. if [ "$MSGCOLOR" != 'NO' ]; then
  5. if [ ! -t 1 ]; then # but check that we output to a terminal
  6. export MSGCOLOR='NO'
  7. fi
  8. fi
  9. if [ "$MSGCOLOR" != 'NO' ]; then
  10. CERROR="\033[1;31m" # red
  11. CWARNING="\033[1;33m" # yellow
  12. CMSG="\033[1;32m" # green
  13. CINFO="\033[1;96m" # light blue
  14. CDEBUG="\033[1;94m" # blue
  15. CNORMAL="\033[0;39m" # default system console color
  16. CDONE="\033[1;32m" # green
  17. CPASS="\033[1;32m" # green
  18. CFAIL="\033[1;31m" # red
  19. CCMD="\033[1;35m" # pink
  20. fi
  21. msgprintf() {
  22. local START="$1"
  23. local MIDDLE="$2"
  24. local END="$3"
  25. shift 3
  26. if [ -n "$1" ]; then
  27. printf "$START " "$1"
  28. shift
  29. while [ -n "$1" ]; do
  30. printf "$MIDDLE " "$(echo "$1" | sed -e 's#^apt\([cfghs]\)#apt-\1#')"
  31. shift
  32. done
  33. fi
  34. printf "${END}"
  35. }
  36. msgdie() { msgprintf "${CERROR}E: %s" '%s' "${CNORMAL}\n" "$@" >&2; exit 1; }
  37. msgwarn() { msgprintf "${CWARNING}W: %s" '%s' "${CNORMAL}\n" "$@" >&2; }
  38. msgmsg() { msgprintf "${CMSG}%s" '%s' "${CNORMAL}\n" "$@"; }
  39. msginfo() { msgprintf "${CINFO}I: %s" '%s' "${CNORMAL}\n" "$@"; }
  40. msgdebug() { msgprintf "${CDEBUG}D: %s" '%s' "${CNORMAL}\n" "$@"; }
  41. msgdone() { msgprintf "${CDONE}DONE" '%s' "${CNORMAL}\n" "$@"; }
  42. msgnwarn() { msgprintf "${CWARNING}W: %s" '%s' "${CNORMAL}" "$@" >&2; }
  43. msgnmsg() { msgprintf "${CMSG}%s" '%s' "${CNORMAL}" "$@"; }
  44. msgninfo() { msgprintf "${CINFO}I: %s" '%s' "${CNORMAL}" "$@"; }
  45. msgndebug() { msgprintf "${CDEBUG}D: %s" '%s' "${CNORMAL}" "$@"; }
  46. msgtest() { msgprintf "${CINFO}%s" "${CCMD}%s${CINFO}" "…${CNORMAL} " "$@"; }
  47. msgpass() { printf "${CPASS}PASS${CNORMAL}\n"; }
  48. msgskip() {
  49. if [ $# -gt 0 ]; then printf "${CWARNING}SKIP: $*${CNORMAL}\n" >&2;
  50. else printf "${CWARNING}SKIP${CNORMAL}\n" >&2; fi
  51. }
  52. msgfail() {
  53. if [ $# -gt 0 ]; then printf "${CFAIL}FAIL: $*${CNORMAL}\n" >&2;
  54. else printf "${CFAIL}FAIL${CNORMAL}\n" >&2; fi
  55. if [ -n "$APT_DEBUG_TESTS" ]; then
  56. $SHELL
  57. fi
  58. EXIT_CODE=$((EXIT_CODE+1));
  59. }
  60. # enable / disable Debugging
  61. MSGLEVEL=${MSGLEVEL:-3}
  62. if [ $MSGLEVEL -le 0 ]; then
  63. msgdie() { true; }
  64. fi
  65. if [ $MSGLEVEL -le 1 ]; then
  66. msgwarn() { true; }
  67. msgnwarn() { true; }
  68. fi
  69. if [ $MSGLEVEL -le 2 ]; then
  70. msgmsg() { true; }
  71. msgnmsg() { true; }
  72. msgtest() { true; }
  73. msgpass() { printf " ${CPASS}P${CNORMAL}"; }
  74. msgskip() { printf " ${CWARNING}S${CNORMAL}" >&2; }
  75. if [ -n "$CFAIL" ]; then
  76. msgfail() { printf " ${CFAIL}FAIL${CNORMAL}" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
  77. else
  78. msgfail() { printf " ###FAILED###" >&2; EXIT_CODE=$((EXIT_CODE+1)); }
  79. fi
  80. fi
  81. if [ $MSGLEVEL -le 3 ]; then
  82. msginfo() { true; }
  83. msgninfo() { true; }
  84. fi
  85. if [ $MSGLEVEL -le 4 ]; then
  86. msgdebug() { true; }
  87. msgndebug() { true; }
  88. fi
  89. msgdone() {
  90. if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
  91. [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
  92. [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
  93. [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
  94. [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
  95. true;
  96. else
  97. printf "${CDONE}DONE${CNORMAL}\n";
  98. fi
  99. }
  100. getaptconfig() {
  101. if [ -f ./aptconfig.conf ]; then
  102. echo "./aptconfig.conf"
  103. elif [ -f ../aptconfig.conf ]; then
  104. echo "../aptconfig.conf"
  105. fi
  106. }
  107. runapt() {
  108. msgdebug "Executing: ${CCMD}$*${CDEBUG} "
  109. local CMD="$1"
  110. shift
  111. case $CMD in
  112. sh|aptitude|*/*|command) ;;
  113. *) CMD="${BUILDDIRECTORY}/$CMD";;
  114. esac
  115. MALLOC_PERTURB_=21 MALLOC_CHECK_=2 APT_CONFIG="$(getaptconfig)" LD_LIBRARY_PATH=${LIBRARYPATH} $CMD "$@"
  116. }
  117. aptconfig() { runapt apt-config "$@"; }
  118. aptcache() { runapt apt-cache "$@"; }
  119. aptcdrom() { runapt apt-cdrom "$@"; }
  120. aptget() { runapt apt-get "$@"; }
  121. aptftparchive() { runapt apt-ftparchive "$@"; }
  122. aptkey() { runapt apt-key "$@"; }
  123. aptmark() { runapt apt-mark "$@"; }
  124. aptsortpkgs() { runapt apt-sortpkgs "$@"; }
  125. apt() { runapt apt "$@"; }
  126. apthelper() { runapt "${APTHELPERBINDIR}/apt-helper" "$@"; }
  127. aptwebserver() { runapt "${APTWEBSERVERBINDIR}/aptwebserver" "$@"; }
  128. aptitude() { runapt aptitude "$@"; }
  129. aptextracttemplates() { runapt apt-extracttemplates "$@"; }
  130. aptinternalsolver() { runapt "${APTINTERNALSOLVER}" "$@"; }
  131. dpkg() {
  132. command dpkg --root=${TMPWORKINGDIRECTORY}/rootdir --force-not-root --force-bad-path --log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log "$@"
  133. }
  134. dpkgcheckbuilddeps() {
  135. command dpkg-checkbuilddeps --admindir=${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg "$@"
  136. }
  137. gdb() {
  138. local CMD="$1"
  139. shift
  140. runapt command gdb --quiet -ex run "${BUILDDIRECTORY}/$CMD" --args "${BUILDDIRECTORY}/$CMD" "$@"
  141. }
  142. exitwithstatus() {
  143. # error if we about to overflow, but ...
  144. # "255 failures ought to be enough for everybody"
  145. if [ $EXIT_CODE -gt 255 ]; then
  146. msgdie "Total failure count $EXIT_CODE too big"
  147. fi
  148. exit $((EXIT_CODE <= 255 ? EXIT_CODE : 255));
  149. }
  150. shellsetedetector() {
  151. local exit_status=$?
  152. if [ "$exit_status" != '0' ]; then
  153. printf >&2 "${CERROR}E: Looks like the testcases ended prematurely with exitcode: ${exit_status}${CNORMAL}\n"
  154. if [ "$EXIT_CODE" = '0' ]; then
  155. EXIT_CODE="$exit_status"
  156. fi
  157. fi
  158. }
  159. addtrap() {
  160. if [ "$1" = 'prefix' ]; then
  161. CURRENTTRAP="$2 $CURRENTTRAP"
  162. else
  163. CURRENTTRAP="$CURRENTTRAP $1"
  164. fi
  165. trap "shellsetedetector; $CURRENTTRAP exitwithstatus;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
  166. }
  167. setupenvironment() {
  168. # privilege dropping and testing doesn't work if /tmp isn't world-writeable (as e.g. with libpam-tmpdir)
  169. if [ -n "$TMPDIR" ] && [ "$(id -u)" = '0' ] && [ "$(stat --format '%a' "$TMPDIR")" != '1777' ]; then
  170. unset TMPDIR
  171. fi
  172. TMPWORKINGDIRECTORY=$(mktemp -d)
  173. addtrap "cd /; rm -rf $TMPWORKINGDIRECTORY;"
  174. msgninfo "Preparing environment for ${CCMD}$(basename $0)${CINFO} in ${TMPWORKINGDIRECTORY}… "
  175. mkdir -m 700 "${TMPWORKINGDIRECTORY}/downloaded"
  176. if [ "$(id -u)" = '0' ]; then
  177. # relax permissions so that running as root with user switching works
  178. umask 022
  179. chmod 711 "$TMPWORKINGDIRECTORY"
  180. chown _apt:root "${TMPWORKINGDIRECTORY}/downloaded"
  181. fi
  182. TESTDIRECTORY=$(readlink -f $(dirname $0))
  183. # allow overriding the default BUILDDIR location
  184. BUILDDIRECTORY=${APT_INTEGRATION_TESTS_BUILD_DIR:-"${TESTDIRECTORY}/../../build/bin"}
  185. LIBRARYPATH=${APT_INTEGRATION_TESTS_LIBRARY_PATH:-"${BUILDDIRECTORY}"}
  186. METHODSDIR=${APT_INTEGRATION_TESTS_METHODS_DIR:-"${BUILDDIRECTORY}/methods"}
  187. APTHELPERBINDIR=${APT_INTEGRATION_TESTS_LIBEXEC_DIR:-"${BUILDDIRECTORY}"}
  188. APTWEBSERVERBINDIR=${APT_INTEGRATION_TESTS_WEBSERVER_BIN_DIR:-"${BUILDDIRECTORY}"}
  189. APTINTERNALSOLVER=${APT_INTEGRATION_TESTS_INTERNAL_SOLVER:-"${BUILDDIRECTORY}/apt-internal-solver"}
  190. test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
  191. # -----
  192. cd $TMPWORKINGDIRECTORY
  193. mkdir rootdir aptarchive keys
  194. cd rootdir
  195. mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d
  196. mkdir -p usr/bin var/cache var/lib/apt var/log tmp
  197. mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
  198. touch var/lib/dpkg/available
  199. mkdir -p usr/lib/apt
  200. ln -s ${METHODSDIR} usr/lib/apt/methods
  201. if [ "$BUILDDIRECTORY" = "$LIBRARYPATH" ]; then
  202. mkdir -p usr/lib/apt/solvers
  203. ln -s "${BUILDDIRECTORY}/apt-dump-solver" usr/lib/apt/solvers/dump
  204. ln -s "${BUILDDIRECTORY}/apt-internal-solver" usr/lib/apt/solvers/apt
  205. echo "Dir::Bin::Solvers \"${TMPWORKINGDIRECTORY}/rootdir/usr/lib/apt/solvers\";" > etc/apt/apt.conf.d/externalsolver.conf
  206. fi
  207. # use the autoremove from the BUILDDIRECTORY if its there, otherwise
  208. # system
  209. if [ -e ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove ]; then
  210. ln -s ${BUILDDIRECTORY}/../../debian/apt.conf.autoremove etc/apt/apt.conf.d/01autoremove
  211. else
  212. ln -s /etc/apt/apt.conf.d/01autoremove etc/apt/apt.conf.d/01autoremove
  213. fi
  214. cd ..
  215. local PACKAGESFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Packages-/' -e 's/^skip-/Packages-/')
  216. if [ -f "${TESTDIRECTORY}/${PACKAGESFILE}" ]; then
  217. cp "${TESTDIRECTORY}/${PACKAGESFILE}" aptarchive/Packages
  218. fi
  219. local SOURCESSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/Sources-/' -e 's/^skip-/Sources-/')
  220. if [ -f "${TESTDIRECTORY}/${SOURCESSFILE}" ]; then
  221. cp "${TESTDIRECTORY}/${SOURCESSFILE}" aptarchive/Sources
  222. fi
  223. cp $(find $TESTDIRECTORY -name '*.pub' -o -name '*.sec') keys/
  224. chmod 644 $(find keys -name '*.pub' -o -name '*.sec')
  225. ln -s ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
  226. echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
  227. echo "Dir::state::status \"${TMPWORKINGDIRECTORY}/rootdir/var/lib/dpkg/status\";" >> aptconfig.conf
  228. echo "Debug::NoLocking \"true\";" >> aptconfig.conf
  229. echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
  230. echo "Dir::Bin::Methods \"${METHODSDIR}\";" >> aptconfig.conf
  231. # store apt-key were we can access it, even if we run it as a different user
  232. # destroys coverage reporting though, so just do it for root for now
  233. if [ "$(id -u)" = '0' ]; then
  234. cp "${BUILDDIRECTORY}/apt-key" "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/"
  235. chmod o+rx "${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key"
  236. echo "Dir::Bin::apt-key \"${TMPWORKINGDIRECTORY}/rootdir/usr/bin/apt-key\";" >> aptconfig.conf
  237. else
  238. echo "Dir::Bin::apt-key \"${BUILDDIRECTORY}/apt-key\";" >> aptconfig.conf
  239. fi
  240. echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
  241. echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
  242. echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
  243. echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
  244. echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
  245. if ! command dpkg --assert-multi-arch >/dev/null 2>&1; then
  246. echo "DPKG::options:: \"--force-architecture\";" >> aptconfig.conf # Added to test multiarch before dpkg is ready for it…
  247. fi
  248. echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
  249. echo 'quiet::NoUpdate "true";' >> aptconfig.conf
  250. echo 'quiet::NoStatistic "true";' >> aptconfig.conf
  251. # too distracting for users, but helpful to detect changes
  252. echo 'Acquire::Progress::Ignore::ShowErrorText "true";' >> aptconfig.conf
  253. # in testcases, it can appear as if localhost has a rotation setup,
  254. # hide this as we can't really deal with it properly
  255. echo 'Acquire::Failure::ShowIP "false";' >> aptconfig.conf
  256. cp "${TESTDIRECTORY}/apt.pem" "${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
  257. if [ "$(id -u)" = '0' ]; then
  258. chown _apt:root "${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem"
  259. fi
  260. echo "Acquire::https::CaInfo \"${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem\";" > rootdir/etc/apt/apt.conf.d/99https
  261. echo "Apt::Cmd::Disable-Script-Warning \"1\";" > rootdir/etc/apt/apt.conf.d/apt-binary
  262. configcompression '.' 'gz' #'bz2' 'lzma' 'xz'
  263. # Acquire::AllowInsecureRepositories=false is not yet the default
  264. # but we want it to be the default soon
  265. configallowinsecurerepositories "false";
  266. # cleanup the environment a bit
  267. # prefer our apt binaries over the system apt binaries
  268. export PATH="${BUILDDIRECTORY}:${PATH}:/usr/local/sbin:/usr/sbin:/sbin"
  269. export LC_ALL=C.UTF-8
  270. unset LANGUAGE APT_CONFIG
  271. unset GREP_OPTIONS DEB_BUILD_PROFILES
  272. msgdone "info"
  273. }
  274. getarchitecture() {
  275. if [ "$1" = "native" -o -z "$1" ]; then
  276. eval `aptconfig shell ARCH APT::Architecture`
  277. if [ -n "$ARCH" ]; then
  278. echo $ARCH
  279. else
  280. dpkg --print-architecture
  281. fi
  282. else
  283. echo $1
  284. fi
  285. }
  286. getarchitectures() {
  287. echo "$(aptconfig dump | grep APT::Architecture | cut -d'"' -f 2 | sed '/^$/ d' | sort | uniq | tr '\n' ' ')"
  288. }
  289. getarchitecturesfromcommalist() {
  290. echo "$1" | sed -e 's#,#\n#g' | sed -e "s/^native\$/$(getarchitecture 'native')/"
  291. }
  292. configarchitecture() {
  293. {
  294. echo "APT::Architecture \"$(getarchitecture $1)\";"
  295. while [ -n "$1" ]; do
  296. echo "APT::Architectures:: \"$(getarchitecture $1)\";"
  297. shift
  298. done
  299. } >rootdir/etc/apt/apt.conf.d/01multiarch.conf
  300. configdpkg
  301. }
  302. configdpkg() {
  303. if [ ! -e rootdir/var/lib/dpkg/status ]; then
  304. local STATUSFILE=$(echo "$(basename $0)" | sed -e 's/^test-/status-/' -e 's/^skip-/status-/')
  305. if [ -f "${TESTDIRECTORY}/${STATUSFILE}" ]; then
  306. cp "${TESTDIRECTORY}/${STATUSFILE}" rootdir/var/lib/dpkg/status
  307. else
  308. echo -n > rootdir/var/lib/dpkg/status
  309. fi
  310. fi
  311. rm -f rootdir/etc/apt/apt.conf.d/00foreigndpkg
  312. if command dpkg --assert-multi-arch >/dev/null 2>&1 ; then
  313. local ARCHS="$(getarchitectures)"
  314. if echo "$ARCHS" | grep -E -q '[^ ]+ [^ ]+'; then
  315. DPKGARCH="$(dpkg --print-architecture)"
  316. for ARCH in ${ARCHS}; do
  317. if [ "${ARCH}" != "${DPKGARCH}" ]; then
  318. if ! dpkg --add-architecture ${ARCH} >/dev/null 2>&1; then
  319. # old-style used e.g. in Ubuntu-P – and as it seems travis
  320. echo "DPKG::options:: \"--foreign-architecture\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
  321. echo "DPKG::options:: \"${ARCH}\";" >> rootdir/etc/apt/apt.conf.d/00foreigndpkg
  322. fi
  323. fi
  324. done
  325. if [ "0" = "$(dpkg -l dpkg 2> /dev/null | grep '^i' | wc -l)" ]; then
  326. # dpkg doesn't really check the version as long as it is fully installed,
  327. # but just to be sure we choose one above the required version
  328. insertinstalledpackage 'dpkg' "all" '1.16.2+fake'
  329. fi
  330. fi
  331. fi
  332. }
  333. configallowinsecurerepositories() {
  334. echo "Acquire::AllowInsecureRepositories \"$1\";" > rootdir/etc/apt/apt.conf.d/allow-insecure-repositories.conf
  335. }
  336. configcompression() {
  337. while [ -n "$1" ]; do
  338. case "$1" in
  339. '.') printf ".\t.\tcat\n";;
  340. 'gz') printf "gzip\tgz\tgzip\n";;
  341. 'bz2') printf "bzip2\tbz2\tbzip2\n";;
  342. 'lzma') printf "lzma\tlzma\txz --format=lzma\n";;
  343. 'xz') printf "xz\txz\txz\n";;
  344. *) printf "$1\t$1\t$1\n";;
  345. esac
  346. shift
  347. done > ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf
  348. }
  349. forcecompressor() {
  350. COMPRESSOR="$1"
  351. COMPRESSOR_CMD="$1"
  352. case $COMPRESSOR in
  353. gzip) COMPRESS='gz';;
  354. bzip2) COMPRESS='bz2';;
  355. lzma) COMPRESS='lzma';;
  356. xz) COMPRESS='xz';;
  357. *) msgdie "Compressor $COMPRESSOR is unknown to framework, so can't be forced by forcecompressor!";;
  358. esac
  359. local CONFFILE="${TMPWORKINGDIRECTORY}/rootdir/etc/apt/apt.conf.d/00force-compressor"
  360. echo "Acquire::CompressionTypes::Order { \"${COMPRESS}\"; };
  361. Dir::Bin::uncompressed \"/does/not/exist\";
  362. Dir::Bin::gzip \"/does/not/exist\";
  363. Dir::Bin::bzip2 \"/does/not/exist\";
  364. Dir::Bin::lzma \"/does/not/exist\";
  365. Dir::Bin::xz \"/does/not/exist\";" > "$CONFFILE"
  366. if [ -e "/bin/${COMPRESSOR}" ]; then
  367. echo "Dir::Bin::${COMPRESSOR} \"/bin/${COMPRESSOR}\";" >> "$CONFFILE"
  368. elif [ -e "/usr/bin/${COMPRESSOR}" ]; then
  369. echo "Dir::Bin::${COMPRESSOR} \"/usr/bin/${COMPRESSOR}\";" >> "$CONFFILE"
  370. elif [ "${COMPRESSOR}" = 'lzma' ]; then
  371. echo 'Dir::Bin::xz "/usr/bin/xz";' >> "$CONFFILE"
  372. COMPRESSOR_CMD='xz --format=lzma'
  373. else
  374. msgtest 'Test for availability of compressor' "${COMPRESSOR}"
  375. msgfail
  376. fi
  377. }
  378. setupsimplenativepackage() {
  379. local NAME="$1"
  380. local ARCH="$2"
  381. local VERSION="$3"
  382. local RELEASE="${4:-unstable}"
  383. local DEPENDENCIES="$5"
  384. local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
  385. If you find such a package installed on your system,
  386. something went horribly wrong! They are autogenerated
  387. und used only by testcases and surf no other propose…"}"
  388. local SECTION="${7:-others}"
  389. local DISTSECTION
  390. if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
  391. DISTSECTION="main"
  392. else
  393. DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
  394. fi
  395. local BUILDDIR=incoming/${NAME}-${VERSION}
  396. mkdir -p ${BUILDDIR}/debian/source
  397. cd ${BUILDDIR}
  398. echo "* most suckless software product ever" > FEATURES
  399. test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
  400. test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
  401. * Initial release
  402. -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog
  403. test -e debian/control || echo "Source: $NAME
  404. Section: $SECTION
  405. Priority: optional
  406. Maintainer: Joe Sixpack <joe@example.org>
  407. Build-Depends: debhelper (>= 7)
  408. Standards-Version: 3.9.1
  409. Package: $NAME" > debian/control
  410. if [ "$ARCH" = 'all' ]; then
  411. echo "Architecture: all" >> debian/control
  412. else
  413. echo "Architecture: any" >> debian/control
  414. fi
  415. test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
  416. echo "Description: $DESCRIPTION" >> debian/control
  417. test -e debian/compat || echo "7" > debian/compat
  418. test -e debian/source/format || echo "3.0 (native)" > debian/source/format
  419. test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
  420. cd - > /dev/null
  421. }
  422. buildsimplenativepackage() {
  423. local NAME="$1"
  424. local ARCH="$2"
  425. local VERSION="$3"
  426. local RELEASE="${4:-unstable}"
  427. local DEPENDENCIES="$5"
  428. local DESCRIPTION="${6:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
  429. If you find such a package installed on your system,
  430. something went horribly wrong! They are autogenerated
  431. und used only by testcases and surf no other propose…"}"
  432. local SECTION="${7:-others}"
  433. local PRIORITY="${8:-optional}"
  434. local FILE_TREE="$9"
  435. local COMPRESS_TYPE="${10:-gzip}"
  436. local DISTSECTION
  437. if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
  438. DISTSECTION="main"
  439. else
  440. DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
  441. fi
  442. local BUILDDIR=${TMPWORKINGDIRECTORY}/incoming/${NAME}-${VERSION}
  443. msgninfo "Build package ${NAME} in ${VERSION} for ${RELEASE} in ${DISTSECTION}… "
  444. mkdir -p $BUILDDIR/debian/source
  445. echo "* most suckless software product ever" > ${BUILDDIR}/FEATURES
  446. echo "#!/bin/sh
  447. echo '$NAME says \"Hello!\"'" > ${BUILDDIR}/${NAME}
  448. echo "Copyleft by Joe Sixpack $(date +%Y)" > ${BUILDDIR}/debian/copyright
  449. echo "$NAME ($VERSION) $RELEASE; urgency=low
  450. * Initial release
  451. -- Joe Sixpack <joe@example.org> $(date -R)" > ${BUILDDIR}/debian/changelog
  452. echo "Source: $NAME
  453. Section: $SECTION
  454. Priority: $PRIORITY
  455. Maintainer: Joe Sixpack <joe@example.org>
  456. Standards-Version: 3.9.3" > ${BUILDDIR}/debian/control
  457. local BUILDDEPS="$(echo "$DEPENDENCIES" | grep '^Build-')"
  458. test -z "$BUILDDEPS" || echo "$BUILDDEPS" >> ${BUILDDIR}/debian/control
  459. echo "
  460. Package: $NAME" >> ${BUILDDIR}/debian/control
  461. if [ "$ARCH" = 'all' ]; then
  462. echo "Architecture: all" >> ${BUILDDIR}/debian/control
  463. else
  464. echo "Architecture: any" >> ${BUILDDIR}/debian/control
  465. fi
  466. local DEPS="$(echo "$DEPENDENCIES" | grep -v '^Build-')"
  467. test -z "$DEPS" || echo "$DEPS" >> ${BUILDDIR}/debian/control
  468. echo "Description: $DESCRIPTION" >> ${BUILDDIR}/debian/control
  469. echo '3.0 (native)' > ${BUILDDIR}/debian/source/format
  470. (cd ${BUILDDIR}/..; dpkg-source -b ${NAME}-${VERSION} 2>&1) | sed -n 's#^dpkg-source: info: building [^ ]\+ in ##p' \
  471. | while read SRC; do
  472. echo "pool/${SRC}" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.srclist
  473. # if expr match "${SRC}" '.*\.dsc' >/dev/null 2>&1; then
  474. # aptkey --keyring ./keys/joesixpack.pub --secret-keyring ./keys/joesixpack.sec --quiet --readonly \
  475. # adv --yes --default-key 'Joe Sixpack' \
  476. # --clearsign -o "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
  477. # mv "${BUILDDIR}/../${SRC}.sign" "${BUILDDIR}/../$SRC"
  478. # fi
  479. done
  480. for arch in $(getarchitecturesfromcommalist "$ARCH"); do
  481. rm -rf ${BUILDDIR}/debian/tmp
  482. mkdir -p ${BUILDDIR}/debian/tmp/DEBIAN ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME} ${BUILDDIR}/debian/tmp/usr/bin
  483. cp ${BUILDDIR}/debian/copyright ${BUILDDIR}/debian/changelog ${BUILDDIR}/FEATURES ${BUILDDIR}/debian/tmp/usr/share/doc/${NAME}
  484. cp ${BUILDDIR}/${NAME} ${BUILDDIR}/debian/tmp/usr/bin/${NAME}-${arch}
  485. if [ -n "$FILE_TREE" ]; then
  486. cp -ar "$FILE_TREE" ${BUILDDIR}/debian/tmp
  487. fi
  488. (cd ${BUILDDIR}; dpkg-gencontrol -DArchitecture=$arch)
  489. (cd ${BUILDDIR}/debian/tmp; md5sum $(find usr/ -type f) > DEBIAN/md5sums)
  490. local LOG="${BUILDDIR}/../${NAME}_${VERSION}_${arch}.dpkg-deb.log"
  491. # ensure the right permissions as dpkg-deb ensists
  492. chmod 755 ${BUILDDIR}/debian/tmp/DEBIAN
  493. if ! dpkg-deb -Z${COMPRESS_TYPE} --build ${BUILDDIR}/debian/tmp ${BUILDDIR}/.. >$LOG 2>&1; then
  494. cat $LOG
  495. false
  496. fi
  497. rm $LOG
  498. echo "pool/${NAME}_${VERSION}_${arch}.deb" >> ${BUILDDIR}/../${RELEASE}.${DISTSECTION}.pkglist
  499. done
  500. mkdir -p ${BUILDDIR}/../${NAME}_${VERSION}
  501. cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}/
  502. cp ${BUILDDIR}/debian/changelog ${BUILDDIR}/../${NAME}_${VERSION}.changelog
  503. rm -rf "${BUILDDIR}"
  504. msgdone "info"
  505. }
  506. buildpackage() {
  507. local BUILDDIR=$1
  508. local RELEASE=$2
  509. local SECTION=$3
  510. local ARCH=$(getarchitecture $4)
  511. local PKGNAME="$(echo "$BUILDDIR" | grep -o '[^/]*$')"
  512. local BUILDLOG="$(readlink -f "${BUILDDIR}/../${PKGNAME}_${RELEASE}_${SECTION}.dpkg-bp.log")"
  513. msgninfo "Build package ${PKGNAME} for ${RELEASE} in ${SECTION}… "
  514. cd $BUILDDIR
  515. if [ "$ARCH" = "all" ]; then
  516. ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
  517. fi
  518. if ! dpkg-buildpackage -uc -us -a$ARCH >$BUILDLOG 2>&1 ; then
  519. cat $BUILDLOG
  520. false
  521. fi
  522. local PKGS="$(grep '^dpkg-deb: building package' $BUILDLOG | cut -d'/' -f 2 | sed -e "s#'\.##")"
  523. local SRCS="$(grep '^dpkg-source: info: building' $BUILDLOG | grep -o '[a-z0-9._+~-]*$')"
  524. cd - > /dev/null
  525. for PKG in $PKGS; do
  526. echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
  527. done
  528. for SRC in $SRCS; do
  529. echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist
  530. done
  531. msgdone "info"
  532. }
  533. buildaptarchive() {
  534. if [ -d incoming ]; then
  535. buildaptarchivefromincoming "$@"
  536. else
  537. buildaptarchivefromfiles "$@"
  538. fi
  539. }
  540. createaptftparchiveconfig() {
  541. local COMPRESSORS="$(cut -d' ' -f 1 ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | tr '\n' ' ')"
  542. COMPRESSORS="${COMPRESSORS%* }"
  543. 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' ' ')"
  544. if [ -z "$ARCHS" ]; then
  545. # the pool is empty, so we will operate on faked packages - let us use the configured archs
  546. ARCHS="$(getarchitectures)"
  547. fi
  548. echo -n 'Dir {
  549. ArchiveDir "' >> ftparchive.conf
  550. echo -n $(readlink -f .) >> ftparchive.conf
  551. echo -n '";
  552. CacheDir "' >> ftparchive.conf
  553. echo -n $(readlink -f ..) >> ftparchive.conf
  554. echo -n '";
  555. FileListDir "' >> ftparchive.conf
  556. echo -n $(readlink -f pool/) >> ftparchive.conf
  557. echo -n '";
  558. };
  559. Default {
  560. Packages::Compress "'"$COMPRESSORS"'";
  561. Sources::Compress "'"$COMPRESSORS"'";
  562. Contents::Compress "'"$COMPRESSORS"'";
  563. Translation::Compress "'"$COMPRESSORS"'";
  564. LongDescription "false";
  565. };
  566. TreeDefault {
  567. Directory "pool/";
  568. SrcDirectory "pool/";
  569. };
  570. APT {
  571. FTPArchive {
  572. Release {
  573. Origin "joesixpack";
  574. Label "apttestcases";
  575. Suite "unstable";
  576. Description "repository with dummy packages";
  577. Architectures "' >> ftparchive.conf
  578. echo -n "$ARCHS" >> ftparchive.conf
  579. echo 'source";
  580. };
  581. };
  582. };' >> ftparchive.conf
  583. for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
  584. echo -n 'tree "dists/' >> ftparchive.conf
  585. echo -n "$DIST" >> ftparchive.conf
  586. echo -n '" {
  587. Architectures "' >> ftparchive.conf
  588. echo -n "$ARCHS" >> ftparchive.conf
  589. echo -n 'source";
  590. FileList "' >> ftparchive.conf
  591. echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
  592. echo -n '";
  593. SourceFileList "' >> ftparchive.conf
  594. echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
  595. echo -n '";
  596. Sections "' >> ftparchive.conf
  597. 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
  598. echo '";
  599. };' >> ftparchive.conf
  600. done
  601. }
  602. buildaptftparchivedirectorystructure() {
  603. local DISTS="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
  604. for DIST in $DISTS; do
  605. local SECTIONS="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
  606. for SECTION in $SECTIONS; do
  607. local ARCHS="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
  608. for ARCH in $ARCHS; do
  609. mkdir -p dists/${DIST}/${SECTION}/binary-${ARCH}
  610. done
  611. mkdir -p dists/${DIST}/${SECTION}/source
  612. mkdir -p dists/${DIST}/${SECTION}/i18n
  613. done
  614. done
  615. }
  616. insertpackage() {
  617. local RELEASE="$1"
  618. local NAME="$2"
  619. local ARCH="$3"
  620. local VERSION="$4"
  621. local DEPENDENCIES="$5"
  622. local PRIORITY="${6:-optional}"
  623. local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
  624. If you find such a package installed on your system,
  625. something went horribly wrong! They are autogenerated
  626. und used only by testcases and surf no other propose…"}"
  627. local ARCHS=""
  628. for arch in $(getarchitecturesfromcommalist "$ARCH"); do
  629. if [ "$arch" = 'all' -o "$arch" = 'none' ]; then
  630. ARCHS="$(getarchitectures)"
  631. else
  632. ARCHS="$arch"
  633. fi
  634. for BUILDARCH in $ARCHS; do
  635. local PPATH="aptarchive/dists/${RELEASE}/main/binary-${BUILDARCH}"
  636. mkdir -p $PPATH aptarchive/dists/${RELEASE}/main/source
  637. touch aptarchive/dists/${RELEASE}/main/source/Sources
  638. local FILE="${PPATH}/Packages"
  639. echo "Package: $NAME
  640. Priority: $PRIORITY
  641. Section: other
  642. Installed-Size: 42
  643. Maintainer: Joe Sixpack <joe@example.org>" >> $FILE
  644. test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
  645. echo "Version: $VERSION
  646. Filename: pool/main/${NAME}/${NAME}_${VERSION}_${arch}.deb" >> $FILE
  647. test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
  648. echo "Description: $DESCRIPTION" >> $FILE
  649. echo >> $FILE
  650. done
  651. done
  652. }
  653. insertsource() {
  654. local RELEASE="$1"
  655. local NAME="$2"
  656. local ARCH="$3"
  657. local VERSION="$4"
  658. local DEPENDENCIES="$5"
  659. local ARCHS=""
  660. local SPATH="aptarchive/dists/${RELEASE}/main/source"
  661. mkdir -p $SPATH
  662. local FILE="${SPATH}/Sources"
  663. echo "Package: $NAME
  664. Binary: $NAME
  665. Version: $VERSION
  666. Maintainer: Joe Sixpack <joe@example.org>
  667. Architecture: $ARCH" >> $FILE
  668. test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
  669. echo "Files:
  670. d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.dsc
  671. d41d8cd98f00b204e9800998ecf8427e 0 ${NAME}_${VERSION}.tar.gz
  672. " >> $FILE
  673. }
  674. insertinstalledpackage() {
  675. local NAME="$1"
  676. local ARCH="$2"
  677. local VERSION="$3"
  678. local DEPENDENCIES="$4"
  679. local PRIORITY="${5:-optional}"
  680. local STATUS="${6:-install ok installed}"
  681. local DESCRIPTION="${7:-"an autogenerated dummy ${NAME}=${VERSION}/installed
  682. If you find such a package installed on your system,
  683. something went horribly wrong! They are autogenerated
  684. und used only by testcases and surf no other propose…"}"
  685. local FILE='rootdir/var/lib/dpkg/status'
  686. local INFO='rootdir/var/lib/dpkg/info'
  687. for arch in $(getarchitecturesfromcommalist "$ARCH"); do
  688. echo "Package: $NAME
  689. Status: $STATUS
  690. Priority: $PRIORITY
  691. Section: other
  692. Installed-Size: 42
  693. Maintainer: Joe Sixpack <joe@example.org>
  694. Version: $VERSION" >> $FILE
  695. test "$arch" = 'none' || echo "Architecture: $arch" >> $FILE
  696. test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> $FILE
  697. echo "Description: $DESCRIPTION" >> $FILE
  698. echo >> $FILE
  699. if [ "$(dpkg-query -W --showformat='${Multi-Arch}')" = 'same' ]; then
  700. echo -n > ${INFO}/${NAME}:${arch}.list
  701. else
  702. echo -n > ${INFO}/${NAME}.list
  703. fi
  704. done
  705. }
  706. buildaptarchivefromincoming() {
  707. msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on incoming packages…"
  708. cd aptarchive
  709. [ -e pool ] || ln -s ../incoming pool
  710. [ -e ftparchive.conf ] || createaptftparchiveconfig
  711. [ -e dists ] || buildaptftparchivedirectorystructure
  712. msgninfo "\tGenerate Packages, Sources and Contents files… "
  713. aptftparchive -qq generate ftparchive.conf
  714. cd - > /dev/null
  715. msgdone "info"
  716. generatereleasefiles "$@"
  717. }
  718. buildaptarchivefromfiles() {
  719. msginfo "Build APT archive for ${CCMD}$(basename $0)${CINFO} based on prebuild files…"
  720. find aptarchive -name 'Packages' -o -name 'Sources' | while read line; do
  721. msgninfo "\t${line} file… "
  722. compressfile "$line" "$1"
  723. msgdone "info"
  724. done
  725. generatereleasefiles "$@"
  726. }
  727. compressfile() {
  728. cat ${TMPWORKINGDIRECTORY}/rootdir/etc/testcase-compressor.conf | while read compressor extension command; do
  729. if [ "$compressor" = '.' ]; then
  730. if [ -n "$2" ]; then
  731. touch -d "$2" "$1"
  732. fi
  733. continue
  734. fi
  735. cat "$1" | $command > "${1}.${extension}"
  736. if [ -n "$2" ]; then
  737. touch -d "$2" "${1}.${extension}"
  738. fi
  739. done
  740. }
  741. # can be overridden by testcases for their pleasure
  742. getcodenamefromsuite() {
  743. case "$1" in
  744. unstable) echo 'sid';;
  745. *) echo -n "$1";;
  746. esac
  747. }
  748. getreleaseversionfromsuite() { true; }
  749. getlabelfromsuite() { true; }
  750. generatereleasefiles() {
  751. # $1 is the Date header and $2 is the ValidUntil header to be set
  752. # both should be given in notation date/touch can understand
  753. msgninfo "\tGenerate Release files… "
  754. if [ -e aptarchive/dists ]; then
  755. for dir in $(find ./aptarchive/dists -mindepth 1 -maxdepth 1 -type d); do
  756. local SUITE="$(echo "$dir" | cut -d'/' -f 4)"
  757. local CODENAME="$(getcodenamefromsuite $SUITE)"
  758. local VERSION="$(getreleaseversionfromsuite $SUITE)"
  759. local LABEL="$(getlabelfromsuite $SUITE)"
  760. if [ -n "$VERSION" ]; then
  761. VERSION="-o APT::FTPArchive::Release::Version=${VERSION}"
  762. fi
  763. if [ -n "$LABEL" ]; then
  764. LABEL="-o APT::FTPArchive::Release::Label=${LABEL}"
  765. fi
  766. aptftparchive -qq release $dir \
  767. -o APT::FTPArchive::Release::Suite="${SUITE}" \
  768. -o APT::FTPArchive::Release::Codename="${CODENAME}" \
  769. ${LABEL} \
  770. ${VERSION} \
  771. | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
  772. if [ "$SUITE" = "experimental" -o "$SUITE" = "experimental2" ]; then
  773. sed -i '/^Date: / a\
  774. NotAutomatic: yes' $dir/Release
  775. fi
  776. if [ -n "$1" -a "$1" != "now" ]; then
  777. sed -i "s/^Date: .*$/Date: $(date -d "$1" '+%a, %d %b %Y %H:%M:%S %Z')/" $dir/Release
  778. fi
  779. if [ -n "$2" ]; then
  780. sed -i "/^Date: / a\
  781. Valid-Until: $(date -d "$2" '+%a, %d %b %Y %H:%M:%S %Z')" $dir/Release
  782. fi
  783. done
  784. else
  785. aptftparchive -qq release ./aptarchive | sed -e '/0 Release$/ d' > aptarchive/Release # remove the self reference
  786. fi
  787. if [ -n "$1" -a "$1" != "now" ]; then
  788. for release in $(find ./aptarchive -name 'Release'); do
  789. touch -d "$1" $release
  790. done
  791. fi
  792. msgdone "info"
  793. }
  794. setupdistsaptarchive() {
  795. local APTARCHIVE=$(readlink -f ./aptarchive)
  796. rm -f root/etc/apt/sources.list.d/apt-test-*-deb.list
  797. rm -f root/etc/apt/sources.list.d/apt-test-*-deb-src.list
  798. for DISTS in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
  799. SECTIONS=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
  800. msgninfo "\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
  801. echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb.list
  802. echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list
  803. msgdone "info"
  804. done
  805. }
  806. setupflataptarchive() {
  807. local APTARCHIVE=$(readlink -f ./aptarchive)
  808. if [ -f ${APTARCHIVE}/Packages ]; then
  809. msgninfo "\tadd deb sources.list line… "
  810. echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
  811. msgdone "info"
  812. else
  813. rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
  814. fi
  815. if [ -f ${APTARCHIVE}/Sources ]; then
  816. msgninfo "\tadd deb-src sources.list line… "
  817. echo "deb-src file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
  818. msgdone "info"
  819. else
  820. rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
  821. fi
  822. }
  823. setupaptarchive() {
  824. local NOUPDATE=0
  825. if [ "$1" = '--no-update' ]; then
  826. NOUPDATE=1
  827. shift
  828. fi
  829. buildaptarchive "$@"
  830. if [ -e aptarchive/dists ]; then
  831. setupdistsaptarchive
  832. else
  833. setupflataptarchive
  834. fi
  835. signreleasefiles 'Joe Sixpack'
  836. if [ "1" != "$NOUPDATE" ]; then
  837. testsuccess aptget update -o Debug::pkgAcquire::Worker=true -o Debug::Acquire::gpgv=true
  838. fi
  839. }
  840. signreleasefiles() {
  841. local SIGNER="${1:-Joe Sixpack}"
  842. local REPODIR="${2:-aptarchive}"
  843. local KEY="keys/$(echo "$SIGNER" | tr 'A-Z' 'a-z' | sed 's# ##g')"
  844. local GPG="aptkey --quiet --keyring ${KEY}.pub --secret-keyring ${KEY}.sec --readonly adv --batch --yes"
  845. msgninfo "\tSign archive with $SIGNER key $KEY… "
  846. local REXKEY='keys/rexexpired'
  847. local SECEXPIREBAK="${REXKEY}.sec.bak"
  848. local PUBEXPIREBAK="${REXKEY}.pub.bak"
  849. if [ "${SIGNER}" = 'Rex Expired' ]; then
  850. # the key is expired, so gpg doesn't allow to sign with and the --faked-system-time
  851. # option doesn't exist anymore (and using faketime would add a new obscure dependency)
  852. # therefore we 'temporary' make the key not expired and restore a backup after signing
  853. cp ${REXKEY}.sec $SECEXPIREBAK
  854. cp ${REXKEY}.pub $PUBEXPIREBAK
  855. local SECUNEXPIRED="${REXKEY}.sec.unexpired"
  856. local PUBUNEXPIRED="${REXKEY}.pub.unexpired"
  857. if [ -f "$SECUNEXPIRED" ] && [ -f "$PUBUNEXPIRED" ]; then
  858. cp $SECUNEXPIRED ${REXKEY}.sec
  859. cp $PUBUNEXPIRED ${REXKEY}.pub
  860. else
  861. if ! printf "expire\n1w\nsave\n" | $GPG --default-key "$SIGNER" --command-fd 0 --edit-key "${SIGNER}" >setexpire.gpg 2>&1; then
  862. cat setexpire.gpg
  863. exit 1
  864. fi
  865. cp ${REXKEY}.sec $SECUNEXPIRED
  866. cp ${REXKEY}.pub $PUBUNEXPIRED
  867. fi
  868. fi
  869. for RELEASE in $(find ${REPODIR}/ -name Release); do
  870. $GPG --default-key "$SIGNER" --armor --detach-sign --sign --output ${RELEASE}.gpg ${RELEASE}
  871. local INRELEASE="$(echo "${RELEASE}" | sed 's#/Release$#/InRelease#')"
  872. $GPG --default-key "$SIGNER" --clearsign --output $INRELEASE $RELEASE
  873. # we might have set a specific date for the Release file, so copy it
  874. touch -d "$(stat --format "%y" ${RELEASE})" ${RELEASE}.gpg ${INRELEASE}
  875. done
  876. if [ -f "$SECEXPIREBAK" ] && [ -f "$PUBEXPIREBAK" ]; then
  877. mv -f $SECEXPIREBAK ${REXKEY}.sec
  878. mv -f $PUBEXPIREBAK ${REXKEY}.pub
  879. fi
  880. msgdone "info"
  881. }
  882. webserverconfig() {
  883. msgtest "Set webserver config option '${1}' to" "$2"
  884. local DOWNLOG='rootdir/tmp/download-testfile.log'
  885. local STATUS='rootdir/tmp/webserverconfig.status'
  886. rm -f "$STATUS" "$DOWNLOG"
  887. if downloadfile "http://localhost:8080/_config/set/${1}/${2}" "$STATUS" > "$DOWNLOG"; then
  888. msgpass
  889. else
  890. cat "$DOWNLOG" "$STATUS"
  891. msgfail
  892. fi
  893. testwebserverlaststatuscode '200'
  894. }
  895. rewritesourceslist() {
  896. local APTARCHIVE="file://$(readlink -f "${TMPWORKINGDIRECTORY}/aptarchive")"
  897. for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
  898. sed -i $LIST -e "s#$APTARCHIVE#${1}#" -e "s#http://localhost:8080/#${1}#" -e "s#http://localhost:4433/#${1}#"
  899. done
  900. }
  901. # wait for up to 10s for a pid file to appear to avoid possible race
  902. # when a helper is started and dosn't write the PID quick enough
  903. waitforpidfile() {
  904. local PIDFILE="$1"
  905. for i in $(seq 10); do
  906. if test -s "$PIDFILE"; then
  907. return 0
  908. fi
  909. sleep 1
  910. done
  911. msgdie "waiting for $PIDFILE failed"
  912. return 1
  913. }
  914. changetowebserver() {
  915. if [ "$1" != '--no-rewrite' ]; then
  916. rewritesourceslist 'http://localhost:8080/'
  917. else
  918. shift
  919. fi
  920. if test -x ${APTWEBSERVERBINDIR}/aptwebserver; then
  921. cd aptarchive
  922. local LOG="webserver.log"
  923. if ! aptwebserver -o aptwebserver::fork=1 "$@" >$LOG 2>&1 ; then
  924. cat $LOG
  925. false
  926. fi
  927. waitforpidfile aptwebserver.pid
  928. local PID="$(cat aptwebserver.pid)"
  929. if [ -z "$PID" ]; then
  930. msgdie 'Could not fork aptwebserver successfully'
  931. fi
  932. addtrap "kill $PID;"
  933. cd - > /dev/null
  934. else
  935. msgdie 'You have to build aptwerbserver or install a webserver'
  936. fi
  937. }
  938. changetohttpswebserver() {
  939. if ! which stunnel4 >/dev/null; then
  940. msgdie 'You need to install stunnel4 for https testcases'
  941. fi
  942. if [ ! -e "${TMPWORKINGDIRECTORY}/aptarchive/aptwebserver.pid" ]; then
  943. changetowebserver --no-rewrite "$@"
  944. fi
  945. echo "pid = ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid
  946. cert = ${TMPWORKINGDIRECTORY}/rootdir/etc/webserver.pem
  947. output = /dev/null
  948. [https]
  949. accept = 4433
  950. connect = 8080
  951. " > ${TMPWORKINGDIRECTORY}/stunnel.conf
  952. stunnel4 "${TMPWORKINGDIRECTORY}/stunnel.conf"
  953. waitforpidfile "${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid"
  954. local PID="$(cat ${TMPWORKINGDIRECTORY}/aptarchive/stunnel.pid)"
  955. if [ -z "$PID" ]; then
  956. msgdie 'Could not fork stunnel4 successfully'
  957. fi
  958. addtrap 'prefix' "kill ${PID};"
  959. rewritesourceslist 'https://localhost:4433/'
  960. }
  961. changetocdrom() {
  962. mkdir -p rootdir/media/cdrom/.disk
  963. local CD="$(readlink -f rootdir/media/cdrom)"
  964. echo "acquire::cdrom::mount \"${CD}\";
  965. acquire::cdrom::${CD}/::mount \"mv ${CD}-unmounted ${CD}\";
  966. acquire::cdrom::${CD}/::umount \"mv ${CD} ${CD}-unmounted\";
  967. acquire::cdrom::autodetect 0;" > rootdir/etc/apt/apt.conf.d/00cdrom
  968. echo -n "$1" > ${CD}/.disk/info
  969. if [ ! -d aptarchive/dists ]; then
  970. msgdie 'Flat file archive cdroms can not be created currently'
  971. return 1
  972. fi
  973. mv aptarchive/dists "$CD"
  974. ln -s "$(readlink -f ./incoming)" $CD/pool
  975. find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list' -delete
  976. # start with an unmounted disk
  977. mv "${CD}" "${CD}-unmounted"
  978. # we don't want the disk to be modifiable
  979. addtrap 'prefix' "chmod -f -R +w $PWD/rootdir/media/cdrom/dists/ $PWD/rootdir/media/cdrom-unmounted/dists/ || true;"
  980. chmod -R -w rootdir/media/cdrom-unmounted/dists
  981. }
  982. downloadfile() {
  983. local PROTO="$(echo "$1" | cut -d':' -f 1 )"
  984. apthelper -o Debug::Acquire::${PROTO}=1 \
  985. download-file "$1" "$2" 2>&1 || true
  986. # only if the file exists the download was successful
  987. if [ -e "$2" ]; then
  988. return 0
  989. else
  990. return 1
  991. fi
  992. }
  993. checkdiff() {
  994. local DIFFTEXT="$(command diff -u "$@" 2>&1 | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
  995. if [ -n "$DIFFTEXT" ]; then
  996. echo >&2
  997. echo >&2 "$DIFFTEXT"
  998. return 1
  999. else
  1000. return 0
  1001. fi
  1002. }
  1003. testfileequal() {
  1004. local FILE="$1"
  1005. shift
  1006. msgtest "Test for correctness of file" "$FILE"
  1007. if [ -z "$*" ]; then
  1008. echo -n "" | checkdiff $FILE - && msgpass || msgfail
  1009. else
  1010. echo "$*" | checkdiff $FILE - && msgpass || msgfail
  1011. fi
  1012. }
  1013. testempty() {
  1014. msgtest "Test for no output of" "$*"
  1015. local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testempty.comparefile"
  1016. if "$@" >$COMPAREFILE 2>&1 && test ! -s $COMPAREFILE; then
  1017. msgpass
  1018. else
  1019. cat $COMPAREFILE
  1020. msgfail
  1021. fi
  1022. aptautotest 'testempty' "$@"
  1023. }
  1024. testequal() {
  1025. local MSG='Test of equality of'
  1026. if [ "$1" = '--nomsg' ]; then
  1027. MSG=''
  1028. shift
  1029. fi
  1030. local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequal.comparefile"
  1031. echo "$1" > $COMPAREFILE
  1032. shift
  1033. if [ -n "$MSG" ]; then
  1034. msgtest "$MSG" "$*"
  1035. fi
  1036. "$@" 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
  1037. aptautotest 'testequal' "$@"
  1038. }
  1039. testequalor2() {
  1040. local COMPAREFILE1="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile1"
  1041. local COMPAREFILE2="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.comparefile2"
  1042. local COMPAREAGAINST="${TMPWORKINGDIRECTORY}/rootdir/tmp/testequalor2.compareagainst"
  1043. echo "$1" > $COMPAREFILE1
  1044. echo "$2" > $COMPAREFILE2
  1045. shift 2
  1046. msgtest "Test for equality OR of" "$*"
  1047. "$@" >$COMPAREAGAINST 2>&1 || true
  1048. if checkdiff $COMPAREFILE1 $COMPAREAGAINST >/dev/null 2>&1 || \
  1049. checkdiff $COMPAREFILE2 $COMPAREAGAINST >/dev/null 2>&1
  1050. then
  1051. msgpass
  1052. else
  1053. echo -n "\n${CINFO}Diff against OR 1${CNORMAL}"
  1054. checkdiff $COMPAREFILE1 $COMPAREAGAINST || true
  1055. echo -n "${CINFO}Diff against OR 2${CNORMAL}"
  1056. checkdiff $COMPAREFILE2 $COMPAREAGAINST || true
  1057. msgfail
  1058. fi
  1059. aptautotest 'testequalor2' "$@"
  1060. }
  1061. testshowvirtual() {
  1062. local VIRTUAL="N: Can't select versions from package '$1' as it is purely virtual"
  1063. local PACKAGE="$1"
  1064. shift
  1065. while [ -n "$1" ]; do
  1066. VIRTUAL="${VIRTUAL}
  1067. N: Can't select versions from package '$1' as it is purely virtual"
  1068. PACKAGE="${PACKAGE} $1"
  1069. shift
  1070. done
  1071. msgtest "Test for virtual packages" "apt-cache show $PACKAGE"
  1072. VIRTUAL="${VIRTUAL}
  1073. N: No packages found"
  1074. local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testshowvirtual.comparefile"
  1075. local ARCH="$(getarchitecture 'native')"
  1076. echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
  1077. aptcache show -q=0 $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
  1078. }
  1079. testnopackage() {
  1080. msgtest "Test for non-existent packages" "apt-cache show $*"
  1081. local SHOWPKG="$(aptcache show "$@" 2>&1 | grep '^Package: ')"
  1082. if [ -n "$SHOWPKG" ]; then
  1083. echo >&2
  1084. echo >&2 "$SHOWPKG"
  1085. msgfail
  1086. else
  1087. msgpass
  1088. fi
  1089. }
  1090. testdpkginstalled() {
  1091. msgtest "Test for correctly installed package(s) with" "dpkg -l $*"
  1092. local PKGS="$(dpkg -l "$@" 2>/dev/null | grep '^i' | wc -l)"
  1093. if [ "$PKGS" != $# ]; then
  1094. echo >&2 $PKGS
  1095. dpkg -l "$@" | grep '^[a-z]' >&2
  1096. msgfail
  1097. else
  1098. msgpass
  1099. fi
  1100. }
  1101. testdpkgnotinstalled() {
  1102. msgtest "Test for correctly not-installed package(s) with" "dpkg -l $*"
  1103. local PKGS="$(dpkg -l "$@" 2> /dev/null | grep '^i' | wc -l)"
  1104. if [ "$PKGS" != 0 ]; then
  1105. echo
  1106. dpkg -l "$@" | grep '^[a-z]' >&2
  1107. msgfail
  1108. else
  1109. msgpass
  1110. fi
  1111. }
  1112. testmarkedauto() {
  1113. local COMPAREFILE="${TMPWORKINGDIRECTORY}/rootdir/tmp/testmarkedauto.comparefile"
  1114. if [ -n "$1" ]; then
  1115. msgtest 'Test for correctly marked as auto-installed' "$*"
  1116. while [ -n "$1" ]; do echo "$1"; shift; done | sort > $COMPAREFILE
  1117. else
  1118. msgtest 'Test for correctly marked as auto-installed' 'no package'
  1119. echo -n > $COMPAREFILE
  1120. fi
  1121. aptmark showauto 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
  1122. }
  1123. testsuccess() {
  1124. if [ "$1" = '--nomsg' ]; then
  1125. shift
  1126. else
  1127. msgtest 'Test for successful execution of' "$*"
  1128. fi
  1129. local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
  1130. if "$@" >${OUTPUT} 2>&1; then
  1131. if expr match "$1" '^apt.*' >/dev/null; then
  1132. if grep -q -E '^[WE]: ' "$OUTPUT"; then
  1133. echo >&2
  1134. cat >&2 $OUTPUT
  1135. msgfail 'successful run, but output contains warnings/errors'
  1136. else
  1137. msgpass
  1138. fi
  1139. else
  1140. msgpass
  1141. fi
  1142. else
  1143. local EXITCODE=$?
  1144. echo >&2
  1145. cat >&2 $OUTPUT
  1146. msgfail "exitcode $EXITCODE"
  1147. fi
  1148. aptautotest 'testsuccess' "$@"
  1149. }
  1150. testwarning() {
  1151. if [ "$1" = '--nomsg' ]; then
  1152. shift
  1153. else
  1154. msgtest 'Test for successful execution with warnings of' "$*"
  1155. fi
  1156. local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testsuccess.output"
  1157. if "$@" >${OUTPUT} 2>&1; then
  1158. if expr match "$1" '^apt.*' >/dev/null; then
  1159. if grep -q -E '^E: ' "$OUTPUT"; then
  1160. echo >&2
  1161. cat >&2 $OUTPUT
  1162. msgfail 'successful run, but output contains errors'
  1163. elif ! grep -q -E '^W: ' "$OUTPUT"; then
  1164. echo >&2
  1165. cat >&2 $OUTPUT
  1166. msgfail 'successful run, but output contains no warnings'
  1167. else
  1168. msgpass
  1169. fi
  1170. else
  1171. msgpass
  1172. fi
  1173. else
  1174. local EXITCODE=$?
  1175. echo >&2
  1176. cat >&2 $OUTPUT
  1177. msgfail "exitcode $EXITCODE"
  1178. fi
  1179. aptautotest 'testwarning' "$@"
  1180. }
  1181. testfailure() {
  1182. if [ "$1" = '--nomsg' ]; then
  1183. shift
  1184. else
  1185. msgtest 'Test for failure in execution of' "$*"
  1186. fi
  1187. local OUTPUT="${TMPWORKINGDIRECTORY}/rootdir/tmp/testfailure.output"
  1188. if "$@" >${OUTPUT} 2>&1; then
  1189. local EXITCODE=$?
  1190. echo >&2
  1191. cat >&2 $OUTPUT
  1192. msgfail "exitcode $EXITCODE"
  1193. else
  1194. local EXITCODE=$?
  1195. if expr match "$1" '^apt.*' >/dev/null; then
  1196. if ! grep -q -E '^E: ' "$OUTPUT"; then
  1197. echo >&2
  1198. cat >&2 $OUTPUT
  1199. msgfail "run failed with exitcode ${EXITCODE}, but with no errors"
  1200. else
  1201. msgpass
  1202. fi
  1203. else
  1204. msgpass
  1205. fi
  1206. fi
  1207. aptautotest 'testfailure' "$@"
  1208. }
  1209. testfilestats() {
  1210. msgtest "Test that file $1 has $2 $3" "$4"
  1211. if [ "$4" "$3" "$(stat --format "$2" "$1")" ]; then
  1212. msgpass
  1213. else
  1214. echo >&2
  1215. ls -l >&2 "$1"
  1216. echo -n >&2 "stat(1) reports for $2: "
  1217. stat --format "$2" "$1"
  1218. msgfail
  1219. fi
  1220. }
  1221. testaccessrights() {
  1222. testfilestats "$1" '%a' '=' "$2"
  1223. }
  1224. testwebserverlaststatuscode() {
  1225. local DOWNLOG='rootdir/tmp/webserverstatus-testfile.log'
  1226. local STATUS='downloaded/webserverstatus-statusfile.log'
  1227. rm -f "$DOWNLOG" "$STATUS"
  1228. msgtest 'Test last status code from the webserver was' "$1"
  1229. downloadfile "http://localhost:8080/_config/find/aptwebserver::last-status-code" "$STATUS" > "$DOWNLOG"
  1230. if [ "$(cat "$STATUS")" = "$1" ]; then
  1231. msgpass
  1232. else
  1233. echo >&2
  1234. if [ -n "$2" ]; then
  1235. shift
  1236. echo >&2 '#### Additionally provided output files contain:'
  1237. cat >&2 "$@"
  1238. fi
  1239. echo >&2 '#### Download log of the status code:'
  1240. cat >&2 "$DOWNLOG"
  1241. msgfail "Status was $(cat "$STATUS")"
  1242. fi
  1243. }
  1244. pause() {
  1245. echo "STOPPED execution. Press enter to continue"
  1246. local IGNORE
  1247. read IGNORE
  1248. }
  1249. listcurrentlistsdirectory() {
  1250. find rootdir/var/lib/apt/lists -maxdepth 1 -type d | while read line; do
  1251. stat --format '%U:%G:%a:%n' "$line"
  1252. done
  1253. find rootdir/var/lib/apt/lists -maxdepth 1 \! -type d | while read line; do
  1254. stat --format '%U:%G:%a:%s:%y:%n' "$line"
  1255. done
  1256. }
  1257. ### The following tests are run by most test methods automatically to check
  1258. ### general things about commands executed without writing the test every time.
  1259. aptautotest() {
  1260. local TESTCALL="$1"
  1261. local CMD="$2"
  1262. local FIRSTOPT="$3"
  1263. local AUTOTEST="aptautotest_$(basename "$CMD" | tr -d '-')_$(echo "$FIRSTOPT" | tr -d '-')"
  1264. if command -v $AUTOTEST >/dev/null; then
  1265. shift 3
  1266. # save and restore the *.output files from other tests
  1267. # as we might otherwise override them in these automatic tests
  1268. rm -rf ${TMPWORKINGDIRECTORY}/rootdir/tmp-before
  1269. mv ${TMPWORKINGDIRECTORY}/rootdir/tmp ${TMPWORKINGDIRECTORY}/rootdir/tmp-before
  1270. mkdir ${TMPWORKINGDIRECTORY}/rootdir/tmp
  1271. $AUTOTEST "$TESTCALL" "$@"
  1272. rm -rf ${TMPWORKINGDIRECTORY}/rootdir/tmp-aptautotest
  1273. mv ${TMPWORKINGDIRECTORY}/rootdir/tmp ${TMPWORKINGDIRECTORY}/rootdir/tmp-aptautotest
  1274. mv ${TMPWORKINGDIRECTORY}/rootdir/tmp-before ${TMPWORKINGDIRECTORY}/rootdir/tmp
  1275. fi
  1276. }
  1277. aptautotest_aptget_update() {
  1278. if ! test -d "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists"; then return; fi
  1279. # all copied files are properly chmodded
  1280. for file in $(find "${TMPWORKINGDIRECTORY}/rootdir/var/lib/apt/lists" -maxdepth 1 -type f); do
  1281. testfilestats "$file" '%U:%G:%a' '=' "${USER}:${USER}:644"
  1282. done
  1283. }
  1284. aptautotest_apt_update() { aptautotest_aptget_update "$@"; }