You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

framework 30 KiB

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