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.
 
 
 
 
 
 

494 lines
16 KiB

  1. #!/bin/sh -- # no runable script, just for vi
  2. # we all like colorful messages
  3. CERROR="" # red
  4. CWARNING="" # yellow
  5. CMSG="" # green
  6. CINFO="" # light blue
  7. CDEBUG="" # blue
  8. CNORMAL="" # default system console color
  9. CDONE="" # green
  10. CPASS="" # green
  11. CFAIL="" # red
  12. CCMD="" # pink
  13. msgdie() { echo "${CERROR}E: $1${CNORMAL}" >&2; exit 1; }
  14. msgwarn() { echo "${CWARNING}W: $1${CNORMAL}" >&2; }
  15. msgmsg() { echo "${CMSG}$1${CNORMAL}" >&2; }
  16. msginfo() { echo "${CINFO}I: $1${CNORMAL}" >&2; }
  17. msgdebug() { echo "${CDEBUG}D: $1${CNORMAL}" >&2; }
  18. msgdone() { echo "${CDONE}DONE${CNORMAL}" >&2; }
  19. msgnwarn() { echo -n "${CWARNING}W: $1${CNORMAL}" >&2; }
  20. msgnmsg() { echo -n "${CMSG}$1${CNORMAL}" >&2; }
  21. msgninfo() { echo -n "${CINFO}I: $1${CNORMAL}" >&2; }
  22. msgndebug() { echo -n "${CDEBUG}D: $1${CNORMAL}" >&2; }
  23. msgtest() { echo -n "${CINFO}$1 ${CCMD}$(echo "$2" | sed -e 's/^aptc/apt-c/' -e 's/^aptg/apt-g/' -e 's/^aptf/apt-f/')${CINFO} …${CNORMAL} " >&2; }
  24. msgpass() { echo "${CPASS}PASS${CNORMAL}" >&2; }
  25. msgskip() { echo "${CWARNING}SKIP${CNORMAL}" >&2; }
  26. msgfail() { echo "${CFAIL}FAIL${CNORMAL}" >&2; }
  27. # enable / disable Debugging
  28. MSGLEVEL=${MSGLEVEL:-3}
  29. if [ $MSGLEVEL -le 0 ]; then
  30. msgdie() { true; }
  31. fi
  32. if [ $MSGLEVEL -le 1 ]; then
  33. msgwarn() { true; }
  34. msgnwarn() { true; }
  35. fi
  36. if [ $MSGLEVEL -le 2 ]; then
  37. msgmsg() { true; }
  38. msgnmsg() { true; }
  39. fi
  40. if [ $MSGLEVEL -le 3 ]; then
  41. msginfo() { true; }
  42. msgninfo() { true; }
  43. fi
  44. if [ $MSGLEVEL -le 4 ]; then
  45. msgdebug() { true; }
  46. msgndebug() { true; }
  47. fi
  48. msgdone() {
  49. if [ "$1" = "debug" -a $MSGLEVEL -le 4 ] ||
  50. [ "$1" = "info" -a $MSGLEVEL -le 3 ] ||
  51. [ "$1" = "msg" -a $MSGLEVEL -le 2 ] ||
  52. [ "$1" = "warn" -a $MSGLEVEL -le 1 ] ||
  53. [ "$1" = "die" -a $MSGLEVEL -le 0 ]; then
  54. true;
  55. else
  56. echo "${CDONE}DONE${CNORMAL}" >&2;
  57. fi
  58. }
  59. runapt() {
  60. msgdebug "Executing: ${CCMD}$*${CDEBUG} "
  61. if [ -f ./aptconfig.conf ]; then
  62. APT_CONFIG=aptconfig.conf LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
  63. else
  64. LD_LIBRARY_PATH=${BUILDDIRECTORY} ${BUILDDIRECTORY}/$*
  65. fi
  66. }
  67. aptconfig() { runapt apt-config $*; }
  68. aptcache() { runapt apt-cache $*; }
  69. aptget() { runapt apt-get $*; }
  70. aptftparchive() { runapt apt-ftparchive $*; }
  71. setupenvironment() {
  72. TMPWORKINGDIRECTORY=$(mktemp -d)
  73. local TESTDIR=$(readlink -f $(dirname $0))
  74. msgninfo "Preparing environment for ${CCMD}$0${CINFO} in ${TMPWORKINGDIRECTORY}… "
  75. BUILDDIRECTORY="${TESTDIR}/../../build/bin"
  76. test -x "${BUILDDIRECTORY}/apt-get" || msgdie "You need to build tree first"
  77. local OLDWORKINGDIRECTORY=$(pwd)
  78. CURRENTTRAP="cd /; rm -rf $TMPWORKINGDIRECTORY; cd $OLDWORKINGDIRECTORY"
  79. trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
  80. cd $TMPWORKINGDIRECTORY
  81. mkdir rootdir aptarchive keys
  82. cd rootdir
  83. mkdir -p etc/apt/apt.conf.d etc/apt/sources.list.d etc/apt/trusted.gpg.d etc/apt/preferences.d var/cache
  84. mkdir -p var/log/apt var/lib/apt
  85. mkdir -p var/lib/dpkg/info var/lib/dpkg/updates var/lib/dpkg/triggers
  86. local STATUSFILE=$(echo "$(basename $0)" | sed 's/^test-/status-/')
  87. if [ -f "${TESTDIR}/${STATUSFILE}" ]; then
  88. cp "${TESTDIR}/${STATUSFILE}" var/lib/dpkg/status
  89. else
  90. touch var/lib/dpkg/status
  91. fi
  92. touch var/lib/dpkg/available
  93. mkdir -p usr/lib/apt
  94. ln -s ${BUILDDIRECTORY}/methods usr/lib/apt/methods
  95. cd ..
  96. local PACKAGESFILE=$(echo "$(basename $0)" | sed 's/^test-/Packages-/')
  97. if [ -f "${TESTDIR}/${PACKAGESFILE}" ]; then
  98. cp "${TESTDIR}/${PACKAGESFILE}" aptarchive/Packages
  99. else
  100. touch aptarchive/Packages
  101. fi
  102. cp $(find $TESTDIR -name '*.pub' -o -name '*.sec') keys/
  103. ln -s ${TMPWORKINGDIRECTORY}/keys/joesixpack.pub rootdir/etc/apt/trusted.gpg.d/joesixpack.gpg
  104. echo "Dir \"${TMPWORKINGDIRECTORY}/rootdir\";" > aptconfig.conf
  105. echo "Debug::NoLocking \"true\";" >> aptconfig.conf
  106. echo "APT::Get::Show-User-Simulation-Note \"false\";" >> aptconfig.conf
  107. echo "Dir::Bin::dpkg \"fakeroot\";" >> aptconfig.conf
  108. echo "DPKG::options:: \"dpkg\";" >> aptconfig.conf
  109. echo "DPKG::options:: \"--root=${TMPWORKINGDIRECTORY}/rootdir\";" >> aptconfig.conf
  110. echo "DPKG::options:: \"--force-not-root\";" >> aptconfig.conf
  111. echo "DPKG::options:: \"--force-bad-path\";" >> aptconfig.conf
  112. echo "DPKG::options:: \"--log=${TMPWORKINGDIRECTORY}/rootdir/var/log/dpkg.log\";" >> aptconfig.conf
  113. export LC_ALL=C
  114. msgdone "info"
  115. }
  116. configarchitecture() {
  117. local CONFFILE=rootdir/etc/apt/apt.conf.d/01multiarch.conf
  118. echo "APT::Architecture \"$1\";" > $CONFFILE
  119. shift
  120. while [ -n "$1" ]; do
  121. echo "APT::Architectures:: \"$1\";" >> $CONFFILE
  122. shift
  123. done
  124. }
  125. setupsimplenativepackage() {
  126. local NAME="$1"
  127. local ARCH="$2"
  128. local VERSION="$3"
  129. local RELEASE="${4:-unstable}"
  130. local DEPENDENCIES="$5"
  131. local DESCRIPTION="$6"
  132. local SECTION="${7:-others}"
  133. local DISTSECTION
  134. if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
  135. DISTSECTION="main"
  136. else
  137. DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
  138. fi
  139. local BUILDDIR=incoming/${NAME}-${VERSION}
  140. mkdir -p ${BUILDDIR}/debian/source
  141. cd ${BUILDDIR}
  142. echo "* most suckless software product ever" > FEATURES
  143. test -e debian/copyright || echo "Copyleft by Joe Sixpack $(date +%Y)" > debian/copyright
  144. test -e debian/changelog || echo "$NAME ($VERSION) $RELEASE; urgency=low
  145. * Initial release
  146. -- Joe Sixpack <joe@example.org> $(date -R)" > debian/changelog
  147. test -e debian/control || echo "Source: $NAME
  148. Section: $SECTION
  149. Priority: optional
  150. Maintainer: Joe Sixpack <joe@example.org>
  151. Build-Depends: debhelper (>= 7)
  152. Standards-Version: 3.9.1
  153. Package: $NAME
  154. Architecture: $ARCH" > debian/control
  155. test -z "$DEPENDENCIES" || echo "$DEPENDENCIES" >> debian/control
  156. if [ -z "$DESCRIPTION" ]; then
  157. echo "Description: an autogenerated dummy ${NAME}=${VERSION}/${RELEASE}
  158. If you find such a package installed on your system,
  159. YOU did something horribly wrong! They are autogenerated
  160. und used only by testcases for APT and surf no other propose…" >> debian/control
  161. else
  162. echo "Description: $DESCRIPTION" >> debian/control
  163. fi
  164. test -e debian/compat || echo "7" > debian/compat
  165. test -e debian/source/format || echo "3.0 (native)" > debian/source/format
  166. test -e debian/rules || cp /usr/share/doc/debhelper/examples/rules.tiny debian/rules
  167. cd - > /dev/null
  168. }
  169. buildsimplenativepackage() {
  170. local NAME="$1"
  171. local ARCH="$2"
  172. local VERSION="$3"
  173. local RELEASE="${4:-unstable}"
  174. local DEPENDENCIES="$5"
  175. local DESCRIPTION="$6"
  176. local SECTION="${7:-others}"
  177. local DISTSECTION
  178. if [ "$SECTION" = "$(echo "$SECTION" | cut -d'/' -f 2)" ]; then
  179. DISTSECTION="main"
  180. else
  181. DISTSECTION="$(echo "$SECTION" | cut -d'/' -f 1)"
  182. fi
  183. setupsimplenativepackage "$NAME" "$ARCH" "$VERSION" "$RELEASE" "$DEPENDENCIES" "$DESCRIPTION" "$SECTION"
  184. buildpackage "incoming/${NAME}-${VERSION}" "$RELEASE" "$DISTSECTION"
  185. rm -rf "incoming/${NAME}-${VERSION}"
  186. }
  187. buildpackage() {
  188. local BUILDDIR=$1
  189. local RELEASE=$2
  190. local SECTION=$3
  191. msgninfo "Build package $(echo "$BUILDDIR" | grep -o '[^/]*$') for ${RELEASE} in ${SECTION}… "
  192. cd $BUILDDIR
  193. if [ "$ARCH" = "all" ]; then
  194. ARCH="$(dpkg-architecture -qDEB_HOST_ARCH 2> /dev/null)"
  195. fi
  196. local BUILT="$(dpkg-buildpackage -uc -us -a$ARCH 2> /dev/null)"
  197. local PKGS="$( echo "$BUILT" | grep '^dpkg-deb: building package' | cut -d'/' -f 2 | sed -e "s#'\.##")"
  198. local SRCS="$( echo "$BUILT" | grep '^dpkg-source: info: building' | grep -o '[a-z0-9._-]*$')"
  199. cd - > /dev/null
  200. for PKG in $PKGS; do
  201. echo "pool/${PKG}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.pkglist
  202. done
  203. for SRC in $SRCS; do
  204. echo "pool/${SRC}" >> ${TMPWORKINGDIRECTORY}/incoming/${RELEASE}.${SECTION}.srclist
  205. done
  206. msgdone "info"
  207. }
  208. buildaptarchive() {
  209. if [ -d incoming ]; then
  210. buildaptarchivefromincoming $*
  211. else
  212. buildaptarchivefromfiles $*
  213. fi
  214. }
  215. createaptftparchiveconfig() {
  216. 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' ' ')"
  217. echo -n 'Dir {
  218. ArchiveDir "' >> ftparchive.conf
  219. echo -n $(readlink -f .) >> ftparchive.conf
  220. echo -n '";
  221. CacheDir "' >> ftparchive.conf
  222. echo -n $(readlink -f ..) >> ftparchive.conf
  223. echo -n '";
  224. FileListDir "' >> ftparchive.conf
  225. echo -n $(readlink -f pool/) >> ftparchive.conf
  226. echo -n '";
  227. };
  228. Default {
  229. Packages::Compress ". gzip bzip2 lzma";
  230. Sources::Compress ". gzip bzip2 lzma";
  231. Contents::Compress ". gzip bzip2 lzma";
  232. };
  233. TreeDefault {
  234. Directory "pool/";
  235. SrcDirectory "pool/";
  236. };
  237. APT {
  238. FTPArchive {
  239. Release {
  240. Origin "joesixpack";
  241. Label "apttestcases";
  242. Suite "unstable";
  243. Description "repository with dummy packages";
  244. Architectures "' >> ftparchive.conf
  245. echo -n "$ARCHS" >> ftparchive.conf
  246. echo 'source";
  247. };
  248. };
  249. };' >> ftparchive.conf
  250. for DIST in $(find ./pool/ -maxdepth 1 -name '*.pkglist' -type f | cut -d'/' -f 3 | cut -d'.' -f 1 | sort | uniq); do
  251. echo -n 'tree "dists/' >> ftparchive.conf
  252. echo -n "$DIST" >> ftparchive.conf
  253. echo -n '" {
  254. Architectures "' >> ftparchive.conf
  255. echo -n "$ARCHS" >> ftparchive.conf
  256. echo -n 'source";
  257. FileList "' >> ftparchive.conf
  258. echo -n "${DIST}.\$(SECTION).pkglist" >> ftparchive.conf
  259. echo -n '";
  260. SourceFileList "' >> ftparchive.conf
  261. echo -n "${DIST}.\$(SECTION).srclist" >> ftparchive.conf
  262. echo -n '";
  263. Sections "' >> ftparchive.conf
  264. 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
  265. echo '";
  266. };' >> ftparchive.conf
  267. done
  268. }
  269. buildaptftparchivedirectorystructure() {
  270. local DISTS="$(grep -i '^tree ' ftparchive.conf | cut -d'/' -f 2 | sed -e 's#".*##')"
  271. for DIST in $DISTS; do
  272. local SECTIONS="$(grep -i -A 5 "dists/$DIST" ftparchive.conf | grep -i 'Sections' | cut -d'"' -f 2)"
  273. for SECTION in $SECTIONS; do
  274. local ARCHS="$(grep -A 5 "dists/$DIST" ftparchive.conf | grep Architectures | cut -d'"' -f 2 | sed -e 's#source##')"
  275. for ARCH in $ARCHS; do
  276. mkdir -p dists/${DIST}/${SECTION}/binary-${ARCH}
  277. done
  278. mkdir -p dists/${DIST}/${SECTION}/source
  279. mkdir -p dists/${DIST}/${SECTION}/i18n
  280. done
  281. done
  282. }
  283. buildaptarchivefromincoming() {
  284. msginfo "Build APT archive for ${CCMD}$0${CINFO} based on incoming packages…"
  285. cd aptarchive
  286. [ -e pool ] || ln -s ../incoming pool
  287. [ -e ftparchive.conf ] || createaptftparchiveconfig
  288. [ -e dists ] || buildaptftparchivedirectorystructure
  289. msgninfo "\tGenerate Packages, Sources and Contents files… "
  290. aptftparchive -qq generate ftparchive.conf
  291. msgdone "info"
  292. msgninfo "\tGenerate Release files… "
  293. for dir in $(find ./dists -mindepth 1 -maxdepth 1 -type d); do
  294. aptftparchive -qq release $dir -o APT::FTPArchive::Release::Codename="$(echo "$dir" | cut -d'/' -f 3)" | sed -e '/0 Release$/ d' > $dir/Release # remove the self reference
  295. done
  296. cd - > /dev/null
  297. msgdone "info"
  298. }
  299. buildaptarchivefromfiles() {
  300. msginfo "Build APT archive for ${CCMD}$0${CINFO} based on prebuild files…"
  301. cd aptarchive
  302. if [ -f Packages ]; then
  303. msgninfo "\tPackages file… "
  304. cat Packages | gzip > Packages.gz
  305. cat Packages | bzip2 > Packages.bz2
  306. cat Packages | lzma > Packages.lzma
  307. msgdone "info"
  308. fi
  309. if [ -f Sources ]; then
  310. msgninfo "\tSources file… "
  311. cat Sources | gzip > Sources.gz
  312. cat Sources | bzip2 > Sources.bz2
  313. cat Sources | lzma > Sources.lzma
  314. msgdone "info"
  315. fi
  316. msgninfo "\tRelease file… "
  317. aptftparchive -qq release . | sed -e '/0 Release$/ d' > Release # remove the self reference
  318. msgdone "info"
  319. cd ..
  320. }
  321. setupdistsaptarchive() {
  322. local APTARCHIVE=$(readlink -f ./aptarchive)
  323. rm -f root/etc/apt/sources.list.d/apt-test-*-deb.list
  324. rm -f root/etc/apt/sources.list.d/apt-test-*-deb-src.list
  325. for DISTS in $(find ./aptarchive/dists/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 4); do
  326. SECTIONS=$(find ./aptarchive/dists/${DISTS}/ -mindepth 1 -maxdepth 1 -type d | cut -d'/' -f 5 | tr '\n' ' ')
  327. msgninfo "\tadd deb and deb-src sources.list lines for ${CCMD}${DISTS} ${SECTIONS}${CINFO}… "
  328. echo "deb file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb.list
  329. echo "deb-src file://$APTARCHIVE $DISTS $SECTIONS" > rootdir/etc/apt/sources.list.d/apt-test-${DISTS}-deb-src.list
  330. msgdone "info"
  331. done
  332. }
  333. setupflataptarchive() {
  334. local APTARCHIVE=$(readlink -f ./aptarchive)
  335. if [ -f ${APTARCHIVE}/Packages ]; then
  336. msgninfo "\tadd deb sources.list line… "
  337. echo "deb file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
  338. msgdone "info"
  339. else
  340. rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb.list
  341. fi
  342. if [ -f ${APTARCHIVE}/Sources ]; then
  343. msgninfo "\tadd deb-src sources.list line… "
  344. echo "deb-src file://$APTARCHIVE /" > rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
  345. msgdone "info"
  346. else
  347. rm -f rootdir/etc/apt/sources.list.d/apt-test-archive-deb-src.list
  348. fi
  349. }
  350. setupaptarchive() {
  351. buildaptarchive
  352. if [ -e aptarchive/dists ]; then
  353. setupdistsaptarchive
  354. else
  355. setupflataptarchive
  356. fi
  357. signreleasefiles
  358. msgninfo "\tSync APT's cache with the archive… "
  359. aptget update -qq
  360. msgdone "info"
  361. }
  362. signreleasefiles() {
  363. local SIGNER="${1:-Joe Sixpack}"
  364. msgninfo "\tSign archive with $SIGNER key… "
  365. local SECKEYS=""
  366. for KEY in $(find keys/ -name '*.sec'); do
  367. SECKEYS="$SECKEYS --secret-keyring $KEY"
  368. done
  369. local PUBKEYS=""
  370. for KEY in $(find keys/ -name '*.pub'); do
  371. PUBKEYS="$PUBKEYS --keyring $KEY"
  372. done
  373. for RELEASE in $(find aptarchive/ -name Release); do
  374. gpg --yes --no-default-keyring $SECKEYS $PUBKEYS --default-key "$SIGNER" -abs -o ${RELEASE}.gpg ${RELEASE}
  375. done
  376. msgdone "info"
  377. }
  378. changetowebserver() {
  379. if which weborf > /dev/null; then
  380. weborf -xb aptarchive/ 2>&1 > /dev/null &
  381. CURRENTTRAP="kill $(ps | grep weborf | sed -e 's#^[ ]*##' | cut -d' ' -f 1); $CURRENTTRAP"
  382. trap "$CURRENTTRAP" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
  383. local APTARCHIVE="file://$(readlink -f ./aptarchive)"
  384. for LIST in $(find rootdir/etc/apt/sources.list.d/ -name 'apt-test-*.list'); do
  385. sed -i $LIST -e "s#$APTARCHIVE#http://localhost:8080/#"
  386. done
  387. return 0
  388. fi
  389. return 1
  390. }
  391. checkdiff() {
  392. local DIFFTEXT="$($(which diff) -u $* | sed -e '/^---/ d' -e '/^+++/ d' -e '/^@@/ d')"
  393. if [ -n "$DIFFTEXT" ]; then
  394. echo
  395. echo "$DIFFTEXT"
  396. return 1
  397. else
  398. return 0
  399. fi
  400. }
  401. testfileequal() {
  402. local FILE="$1"
  403. shift
  404. msgtest "Test for correctness of file" "$FILE"
  405. if [ -z "$*" ]; then
  406. echo -n "" | checkdiff $FILE - && msgpass || msgfail
  407. else
  408. echo "$*" | checkdiff $FILE - && msgpass || msgfail
  409. fi
  410. }
  411. testequal() {
  412. local COMPAREFILE=$(mktemp)
  413. echo "$1" > $COMPAREFILE
  414. shift
  415. msgtest "Test for equality of" "$*"
  416. $* 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
  417. rm $COMPAREFILE
  418. }
  419. testequalor2() {
  420. local COMPAREFILE1=$(mktemp)
  421. local COMPAREFILE2=$(mktemp)
  422. local COMPAREAGAINST=$(mktemp)
  423. echo "$1" > $COMPAREFILE1
  424. echo "$2" > $COMPAREFILE2
  425. shift 2
  426. msgtest "Test for equality OR of" "$*"
  427. $* 2>&1 1> $COMPAREAGAINST
  428. (checkdiff $COMPAREFILE1 $COMPAREAGAINST 1> /dev/null ||
  429. checkdiff $COMPAREFILE2 $COMPAREAGAINST 1> /dev/null) && msgpass ||
  430. ( echo "\n${CINFO}Diff against OR 1${CNORMAL}" "$(checkdiff $COMPAREFILE1 $COMPAREAGAINST)" \
  431. "\n${CINFO}Diff against OR 2${CNORMAL}" "$(checkdiff $COMPAREFILE2 $COMPAREAGAINST)" &&
  432. msgfail )
  433. rm $COMPAREFILE1 $COMPAREFILE2 $COMPAREAGAINST
  434. }
  435. testshowvirtual() {
  436. local VIRTUAL="N: Can't select versions from package '$1' as it purely virtual"
  437. local PACKAGE="$1"
  438. shift
  439. while [ -n "$1" ]; do
  440. VIRTUAL="${VIRTUAL}
  441. N: Can't select versions from package '$1' as it purely virtual"
  442. PACKAGE="${PACKAGE} $1"
  443. shift
  444. done
  445. msgtest "Test for virtual packages" "apt-cache show $PACKAGE"
  446. VIRTUAL="${VIRTUAL}
  447. N: No packages found"
  448. local COMPAREFILE=$(mktemp)
  449. local ARCH=$(dpkg-architecture -qDEB_HOST_ARCH_CPU)
  450. eval `apt-config shell ARCH APT::Architecture`
  451. echo "$VIRTUAL" | sed -e "s/:$ARCH//" -e 's/:all//' > $COMPAREFILE
  452. aptcache show $PACKAGE 2>&1 | checkdiff $COMPAREFILE - && msgpass || msgfail
  453. rm $COMPAREFILE
  454. }
  455. testnopackage() {
  456. msgtest "Test for non-existent packages" "apt-cache show $*"
  457. local SHOWPKG="$(aptcache show $* 2>&1 | grep '^Package: ')"
  458. if [ -n "$SHOWPKG" ]; then
  459. echo
  460. echo "$SHOWPKG"
  461. msgfail
  462. return 1
  463. fi
  464. msgpass
  465. }