diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-04-17 01:59:40 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-04-17 01:59:40 -0400 |
commit | fdc37e5cf06d845a88971881a99de034a723c94a (patch) | |
tree | 6a12e5972fecd04800713d0e50dbc4d4a3d51d49 | |
parent | ff2983c207e6ab2a9381e20312355c42307187f6 (diff) |
Grab an updated test/ directory from lukeshu/archlinux+cleanup+librelib
It's not like we were running the tests anyway, and this makes merging
easier.
28 files changed, 353 insertions, 724 deletions
diff --git a/test/__init__.py b/test/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/test/__init__.py +++ /dev/null diff --git a/test/blacklist_sample b/test/blacklist_sample deleted file mode 100644 index 2a02af6..0000000 --- a/test/blacklist_sample +++ /dev/null @@ -1,2 +0,0 @@ -alex:alex-libre: Aquí va un comentario -gmime22 ::Non free dependencies
\ No newline at end of file diff --git a/test/core.db.tar.gz b/test/core.db.tar.gz Binary files differdeleted file mode 100644 index 5eb2081..0000000 --- a/test/core.db.tar.gz +++ /dev/null diff --git a/test/depends b/test/depends deleted file mode 100644 index 7ff3ad4..0000000 --- a/test/depends +++ /dev/null @@ -1,4 +0,0 @@ -%DEPENDS% -glibc>=2.13 -zlib - diff --git a/test/desc b/test/desc deleted file mode 100644 index abba644..0000000 --- a/test/desc +++ /dev/null @@ -1,39 +0,0 @@ -%FILENAME% -binutils-2.21-4-x86_64.pkg.tar.xz - -%NAME% -binutils - -%VERSION% -2.21-4 - -%DESC% -A set of programs to assemble and manipulate binary and object files - -%GROUPS% -base - -%CSIZE% -3412892 - -%ISIZE% -17571840 - -%MD5SUM% -4e666f87c78998f4839f33dc06d2043a - -%URL% -http://www.gnu.org/software/binutils/ - -%LICENSE% -GPL - -%ARCH% -x86_64 - -%BUILDDATE% -1297240369 - -%PACKAGER% -Allan McRae <allan@archlinux.org> - diff --git a/test/lib/common.inc b/test/lib/common.inc index a2dee10..954868b 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -1,7 +1,24 @@ +#!/hint/bash set -E -. "$(dirname ${BASH_SOURCE[0]})/../../config" -. "$(dirname ${BASH_SOURCE[0]})/../../db-functions" +. "$(dirname "${BASH_SOURCE[0]}")/../../config" +. "$(dirname "${BASH_SOURCE[0]}")/../../config.testing" +. "$(dirname "${BASH_SOURCE[0]}")/../../db-functions" + +signpkg() { + if [[ -r '/etc/makepkg.conf' ]]; then + source '/etc/makepkg.conf' + else + die '/etc/makepkg.conf not found!' + fi + if [[ -r ~/.makepkg.conf ]]; then + . ~/.makepkg.conf + fi + if [[ -n $GPGKEY ]]; then + SIGNWITHKEY=(-u "${GPGKEY}") + fi + gpg --detach-sign --use-agent "${SIGNWITHKEY[@]}" "${@}" || die +} oneTimeSetUp() { local p @@ -11,34 +28,38 @@ oneTimeSetUp() { local pkgarch local pkgversion local build - pkgdir="$(mktemp -d /tmp/$(basename $0).XXXXXXXXXX)" - cp -Lr $(dirname ${BASH_SOURCE[0]})/../packages/* "${pkgdir}" + pkgdir="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" + cp -Lr "$(dirname "${BASH_SOURCE[0]}")"/../packages/* "${pkgdir}" msg 'Building packages...' for d in "${pkgdir}"/*; do - pushd $d >/dev/null - pkgname=($(. PKGBUILD; echo ${pkgname[@]})) - pkgarch=($(. PKGBUILD; echo ${arch[@]})) - pkgversion=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) + pushd "$d" >/dev/null + pkgname=($(. PKGBUILD; echo "${pkgname[@]}")) + pkgarch=($(. PKGBUILD; echo "${arch[@]}")) + pkgversion=$(. PKGBUILD; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}") build=true - for a in ${pkgarch[@]}; do - for p in ${pkgname[@]}; do - [ ! -f ${p}-${pkgversion}-${a}${PKGEXT} ] && build=false + for a in "${pkgarch[@]}"; do + for p in "${pkgname[@]}"; do + [ ! -f "${p}-${pkgversion}-${a}"${PKGEXT} ] && build=false done done - if ! ${build}; then + if ! "${build}"; then if [ "${pkgarch[0]}" == 'any' ]; then sudo extra-x86_64-build || die 'extra-x86_64-build failed' else - for a in ${pkgarch[@]}; do - sudo extra-${a}-build || die "extra-${a}-build failed" + for a in "${pkgarch[@]}"; do + if in_array "$a" "${ARCH_BUILD[@]}"; then + sudo "extra-${a}-build" || die "extra-${a}-build failed" + fi done fi - for a in ${pkgarch[@]}; do - for p in ${pkgname[@]}; do - cp ${p}-${pkgversion}-${a}${PKGEXT} $(dirname ${BASH_SOURCE[0]})/../packages/$(basename ${d}) - done + for a in "${pkgarch[@]}"; do + if in_array "$a" "${ARCH_BUILD[@]}"; then + for p in "${pkgname[@]}"; do + cp "${p}-${pkgversion}-${a}"${PKGEXT} "$(dirname "${BASH_SOURCE[0]}")/../packages/${d##*/}" + done + fi done fi popd >/dev/null @@ -55,17 +76,17 @@ setUp() { local r local a - [ -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" ] && die "$(dirname ${BASH_SOURCE[0]})/../../config.local exists" - TMP="$(mktemp -d /dev/shm/$(basename $0).XXXXXXXXXX)" + [ -f "$(dirname "${BASH_SOURCE[0]}")/../../config.local" ] && die "$(dirname "${BASH_SOURCE[0]}")/../../config.local exists" + TMP="$(mktemp -dt "${0##*/}.XXXXXXXXXX")" #msg "Using ${TMP}" PKGREPOS=('core' 'extra' 'testing') PKGPOOL='pool/packages' mkdir -p "${TMP}/"{ftp,tmp,staging,{package,source}-cleanup,svn-packages-{copy,repo}} - for r in ${PKGREPOS[@]}; do + for r in "${PKGREPOS[@]}"; do mkdir -p "${TMP}/staging/${r}" - for a in ${ARCHES[@]} any; do + for a in "${ARCHES[@]}"; do mkdir -p "${TMP}/ftp/${r}/os/${a}" done done @@ -74,21 +95,23 @@ setUp() { msg 'Creating svn repository...' svnadmin create "${TMP}/svn-packages-repo" - svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy" + arch_svn checkout -q "file://${TMP}/svn-packages-repo" "${TMP}/svn-packages-copy" for p in "${pkgdir}"/*; do - pkg=$(basename $p) + pkg=${p##*/} mkdir -p "${TMP}/svn-packages-copy/${pkg}"/{trunk,repos} - cp "${p}"/* "${TMP}/svn-packages-copy"/${pkg}/trunk/ - svn add -q "${TMP}/svn-packages-copy"/${pkg} - svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" + cp "${p}"/* "${TMP}/svn-packages-copy/${pkg}/trunk/" + arch_svn add -q "${TMP}/svn-packages-copy/${pkg}" + arch_svn commit -q -m"initial commit of ${pkg}" "${TMP}/svn-packages-copy" done - cat <<eot > "$(dirname ${BASH_SOURCE[0]})/../../config.local" + cat <<eot > "$(dirname "${BASH_SOURCE[0]}")/../../config.local" FTP_BASE="${TMP}/ftp" SVNREPO="file://${TMP}/svn-packages-repo" - PKGREPOS=(${PKGREPOS[@]}) + PKGREPOS=("${PKGREPOS[@]}") PKGPOOL="${PKGPOOL}" + TESTING_REPO='testing' + STABLE_REPOS=('core' 'extra') CLEANUP_DESTDIR="${TMP}/package-cleanup" SOURCE_CLEANUP_DESTDIR="${TMP}/source-cleanup" STAGING="${TMP}/staging" @@ -97,12 +120,12 @@ setUp() { SOURCE_CLEANUP_DRYRUN=false REQUIRE_SIGNATURE=true eot - . "$(dirname ${BASH_SOURCE[0]})/../../config" + . "$(dirname "${BASH_SOURCE[0]}")/../../config" } tearDown() { rm -rf "${TMP}" - rm -f "$(dirname ${BASH_SOURCE[0]})/../../config.local" + rm -f "$(dirname "${BASH_SOURCE[0]}")/../../config.local" echo } @@ -110,18 +133,24 @@ releasePackage() { local repo=$1 local pkgbase=$2 local arch=$3 + local a + local p + local pkgver + local pkgname - pushd "${TMP}/svn-packages-copy"/${pkgbase}/trunk/ >/dev/null - archrelease ${repo}-${arch} >/dev/null 2&>1 - pkgver=$(. PKGBUILD; echo $(get_full_version ${epoch:-0} ${pkgver} ${pkgrel})) + pushd "${TMP}/svn-packages-copy/${pkgbase}/trunk/" >/dev/null + archrelease "${repo}-${arch}" >/dev/null 2>&1 + pkgver=$(. PKGBUILD; get_full_version "${epoch:-0}" "${pkgver}" "${pkgrel}") + pkgname=($(. PKGBUILD; echo "${pkgname[@]}")) popd >/dev/null - cp "${pkgdir}/${pkgbase}"/*-${pkgver}-${arch}${PKGEXT} "${STAGING}"/${repo}/ + cp "${pkgdir}/${pkgbase}"/*-"${pkgver}-${arch}"${PKGEXT} "${STAGING}/${repo}/" - if ${REQUIRE_SIGNATURE}; then - # TODO: really sign the packages with a valid key - find "${STAGING}"/${repo}/ -type f \ - -name "*-${pkgver}-${arch}${PKGEXT}" \ - -exec touch {}.sig \; + if "${REQUIRE_SIGNATURE}"; then + for a in "${arch[@]}"; do + for p in "${pkgname[@]}"; do + signpkg "${STAGING}/${repo}/${p}-${pkgver}-${a}"${PKGEXT} + done + done fi } @@ -132,42 +161,39 @@ checkAnyPackageDB() { local db [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" - if ${REQUIRE_SIGNATURE}; then + if "${REQUIRE_SIGNATURE}"; then [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found" fi - for arch in i686 x86_64; do + for arch in "${ARCH_BUILD[@]}"; do [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} is not a symlink" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" - if ${REQUIRE_SIGNATURE}; then + if "${REQUIRE_SIGNATURE}"; then [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig" ] || fail "${repo}/os/${arch}/${pkg}.sig is not a symlink" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] \ || fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig" fi - done - [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" - [ -r "${STAGING}"/${repo}/${pkg}.sig ] && fail "${repo}/${pkg}.sig found in staging dir" - for db in ${DBEXT} ${FILESEXT}; do - ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \ - || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" + for db in "${DBEXT}" "${FILESEXT}"; do + ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ + || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" + done done - - [ -r "${FTP_BASE}/${repo}/os/any/${pkg}" ] && fail "${repo}/os/any/${pkg} should not exist" - [ -r "${FTP_BASE}/${repo}/os/any/${pkg}.sig" ] && fail "${repo}/os/any/${pkg}.sig should not exist" + [ -r "${STAGING}/${repo}/${pkg}" ] && fail "${repo}/${pkg} found in staging dir" + [ -r "${STAGING}/${repo}/${pkg}".sig ] && fail "${repo}/${pkg}.sig found in staging dir" } checkAnyPackage() { local repo=$1 local pkg=$2 - checkAnyPackageDB $repo $pkg + checkAnyPackageDB "$repo" "$pkg" local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") - svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ || fail "svn-packages-copy/${pkgbase}/repos/${repo}-any does not exist" } @@ -180,23 +206,23 @@ checkPackageDB() { [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}" ] || fail "${PKGPOOL}/${pkg} not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] || fail "${repo}/os/${arch}/${pkg} not a symlink" - [ -r "${STAGING}"/${repo}/${pkg} ] && fail "${repo}/${pkg} found in staging dir" + [ -r "${STAGING}/${repo}/${pkg}" ] && fail "${repo}/${pkg} found in staging dir" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}")" == "${FTP_BASE}/${PKGPOOL}/${pkg}" ] \ || fail "${repo}/os/${arch}/${pkg} does not link to ${PKGPOOL}/${pkg}" - if ${REQUIRE_SIGNATURE}; then + if "${REQUIRE_SIGNATURE}"; then [ -r "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] || fail "${PKGPOOL}/${pkg}.sig not found" [ -L "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig" ] || fail "${repo}/os/${arch}/${pkg}.sig is not a symlink" - [ -r "${STAGING}"/${repo}/${pkg}.sig ] && fail "${repo}/${pkg}.sig found in staging dir" + [ -r "${STAGING}/${repo}/${pkg}.sig" ] && fail "${repo}/${pkg}.sig found in staging dir" [ "$(readlink -e "${FTP_BASE}/${repo}/os/${arch}/${pkg}.sig")" == "${FTP_BASE}/${PKGPOOL}/${pkg}.sig" ] \ || fail "${repo}/os/${arch}/${pkg}.sig does not link to ${PKGPOOL}/${pkg}.sig" fi - for db in ${DBEXT} ${FILESEXT}; do + for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -206,10 +232,10 @@ checkPackage() { local pkg=$2 local arch=$3 - checkPackageDB $repo $pkg $arch + checkPackageDB "$repo" "$pkg" "$arch" local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") - svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" } @@ -220,9 +246,9 @@ checkRemovedPackageDB() { local arch=$3 local db - for db in ${DBEXT} ${FILESEXT}; do + for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -232,9 +258,9 @@ checkRemovedPackage() { local pkgbase=$2 local arch=$3 - checkRemovedPackageDB $repo $pkgbase $arch + checkRemovedPackageDB "$repo" "$pkgbase" "$arch" - svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-${arch}" ] \ && fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} should not exist" } @@ -245,10 +271,10 @@ checkRemovedAnyPackageDB() { local arch local db - for db in ${DBEXT} ${FILESEXT}; do - for arch in i686 x86_64; do + for db in "${DBEXT}" "${FILESEXT}"; do + for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done @@ -258,9 +284,9 @@ checkRemovedAnyPackage() { local repo=$1 local pkgbase=$2 - checkRemovedAnyPackageDB $repo $pkgbase + checkRemovedAnyPackageDB "$repo" "$pkgbase" - svn up -q "${TMP}/svn-packages-copy/${pkgbase}" + arch_svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ && fail "svn-packages-copy/${pkgbase}/repos/${repo}-any should not exist" } diff --git a/test/packages/pkg-any-a/PKGBUILD b/test/packages/pkg-any-a/PKGBUILD index 8749a35..cd5d66f 100644 --- a/test/packages/pkg-any-a/PKGBUILD +++ b/test/packages/pkg-any-a/PKGBUILD @@ -7,6 +7,6 @@ url='http://www.archlinux.org/' license=('GPL') package() { - install -d -m755 ${pkgdir}/usr/share/${pkgname} - echo 'test' > ${pkgdir}/usr/share/${pkgname}/test + install -d -m755 "${pkgdir}"/usr/share/${pkgname} + echo 'test' > "${pkgdir}"/usr/share/${pkgname}/test } diff --git a/test/packages/pkg-any-b/PKGBUILD b/test/packages/pkg-any-b/PKGBUILD index e6a0498..90794fc 100644 --- a/test/packages/pkg-any-b/PKGBUILD +++ b/test/packages/pkg-any-b/PKGBUILD @@ -7,6 +7,6 @@ url='http://www.archlinux.org/' license=('GPL') package() { - install -d -m755 ${pkgdir}/usr/share/${pkgname} - echo 'test' > ${pkgdir}/usr/share/${pkgname}/test + install -d -m755 "${pkgdir}"/usr/share/${pkgname} + echo 'test' > "${pkgdir}"/usr/share/${pkgname}/test } diff --git a/test/packages/pkg-simple-a/PKGBUILD b/test/packages/pkg-simple-a/PKGBUILD index 953ecfa..9b4478e 100644 --- a/test/packages/pkg-simple-a/PKGBUILD +++ b/test/packages/pkg-simple-a/PKGBUILD @@ -12,11 +12,11 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname}" } diff --git a/test/packages/pkg-simple-b/PKGBUILD b/test/packages/pkg-simple-b/PKGBUILD index 95ffd09..4a9e58d 100644 --- a/test/packages/pkg-simple-b/PKGBUILD +++ b/test/packages/pkg-simple-b/PKGBUILD @@ -12,11 +12,11 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname}" } diff --git a/test/packages/pkg-simple-epoch/PKGBUILD b/test/packages/pkg-simple-epoch/PKGBUILD index eebe2bd..0761b32 100644 --- a/test/packages/pkg-simple-epoch/PKGBUILD +++ b/test/packages/pkg-simple-epoch/PKGBUILD @@ -13,11 +13,11 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname}" } diff --git a/test/packages/pkg-split-a/PKGBUILD b/test/packages/pkg-split-a/PKGBUILD index e941976..f7a0576 100644 --- a/test/packages/pkg-split-a/PKGBUILD +++ b/test/packages/pkg-split-a/PKGBUILD @@ -13,16 +13,16 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package_pkg-split-a1() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname[0]} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname[0]}" } package_pkg-split-a2() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname[1]} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname[1]}" } diff --git a/test/packages/pkg-split-b/PKGBUILD b/test/packages/pkg-split-b/PKGBUILD index 6ddbc45..3bd635c 100644 --- a/test/packages/pkg-split-b/PKGBUILD +++ b/test/packages/pkg-split-b/PKGBUILD @@ -14,16 +14,16 @@ md5sums=('c6cb8dcc86253355fed559416d0c8dcf' '3c1e4279feb678fd9cabaccdb28e40d0') build() { - cd ${srcdir} + cd "${srcdir}" make } package_pkg-split-b1() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname[0]} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname[0]}" } package_pkg-split-b2() { - cd ${srcdir} - make install DESTDIR=${pkgdir} DESTBIN=${pkgname[1]} + cd "${srcdir}" + make install DESTDIR="${pkgdir}" DESTBIN="${pkgname[1]}" } diff --git a/test/rsync_output_sample b/test/rsync_output_sample deleted file mode 100644 index 72d9cd0..0000000 --- a/test/rsync_output_sample +++ /dev/null @@ -1,14 +0,0 @@ -dr-xr-sr-x 4096 2010/09/11 11:37:10 . --rw-r--r-- 11 2011/02/08 00:00:01 lastsync -drwxrwxr-x 15 2010/09/11 11:28:50 community-staging -drwxrwxr-x 30 2010/09/11 11:28:50 community-staging/os -drwxrwxr-x 8192 2011/02/07 17:00:01 community-staging/os/i686 -lrwxrwxrwx 52 2010/12/23 16:51:01 community-staging/os/i686/alex-2.3.4-1-i686.pkg.tar.xz -> ../../../pool/community/alex-2.3.4-1-i686.pkg.tar.xz -lrwxrwxrwx 27 2011/02/07 14:02:54 community-staging/os/i686/community-staging.db -> community-staging.db.tar.gz --rw-rw-r-- 2237 2011/02/07 14:02:54 community-staging/os/i686/community-staging.db.tar.gz --rw-rw-r-- 3209 2011/02/07 14:00:13 community-staging/os/i686/community-staging.db.tar.gz.old -drwxrwxr-x 15 2009/07/22 15:07:56 community -drwxrwxr-x 40 2009/08/04 15:57:42 community/os -drwxrwsr-x 36864 2011/02/03 05:00:01 community/os/any --rw-rw-r-- 303336 2010/07/16 10:06:28 community/os/any/any2dvd-0.34-4-any.pkg.tar.xz --rw-rw-r-- 221664 2010/03/28 15:55:48 community/os/x86_64/gmime22-2.2.26-1-x86_64.pkg.tar.xz diff --git a/test/runTest b/test/runTest index b8713d8..7163e30 100755 --- a/test/runTest +++ b/test/runTest @@ -1,12 +1,12 @@ #!/bin/bash -. "$(dirname ${BASH_SOURCE[0]})/lib/common.inc" +. "$(dirname "${BASH_SOURCE[0]}")/lib/common.inc" -for t in "$(dirname ${BASH_SOURCE[0]})/test.d/"*.sh; do - l=$(basename ${t} .sh) - if [ -x ${t} ]; then +for t in "$(dirname "${BASH_SOURCE[0]}")/test.d/"*.sh; do + l=$(basename "${t}" .sh) + if [ -x "${t}" ]; then msg "Running test '${l}'" - ${t} + "${t}" [ $? -ne 0 ] && die "Test '${l}' failed" echo -e "\n\n\n" else diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index 49734c4..21bf292 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -1,23 +1,22 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testCreateSimpleFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgbase}"; then fail "usr/bin/${pkgbase} not found in ${arch}/extra${FILESEXT}" fi @@ -26,18 +25,17 @@ testCreateSimpleFileLists() { } testCreateAnyFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/share/${pkgbase}/test"; then fail "usr/share/${pkgbase}/test not found in ${arch}/extra${FILESEXT}" fi @@ -46,7 +44,6 @@ testCreateAnyFileLists() { } testCreateSplitFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase @@ -54,17 +51,17 @@ testCreateSplitFileLists() { local pkgnames local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do + for pkgbase in "${pkgs[@]}"; do pkgnames=($(source "${TMP}/svn-packages-copy/${pkgbase}/trunk/PKGBUILD"; echo ${pkgname[@]})) - for pkgname in ${pkgnames[@]}; do - for arch in ${arches[@]}; do + for pkgname in "${pkgnames[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/${pkgname}"; then fail "usr/bin/${pkgname} not found in ${arch}/extra${FILESEXT}" fi @@ -75,23 +72,22 @@ testCreateSplitFileLists() { testCleanupFileLists() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} pkg-simple-a + for arch in "${ARCH_BUILD[@]}"; do + ../db-remove extra "${arch}" pkg-simple-a done - for arch in ${arches[@]}; do + for arch in "${ARCH_BUILD[@]}"; do if ! bsdtar -xOf "${FTP_BASE}/extra/os/${arch}/extra${FILESEXT}" | grep -q "usr/bin/pkg-simple-b"; then fail "usr/bin/pkg-simple-b not found in ${arch}/extra${FILESEXT}" fi diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 9d7c1f6..4b4120e 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -1,17 +1,16 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testMoveSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage testing "${pkgbase}" "${arch}" done done @@ -19,23 +18,22 @@ testMoveSimplePackages() { ../db-move testing extra pkg-simple-a - for arch in ${arches[@]}; do - checkPackage extra pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} - checkRemovedPackage testing pkg-simple-a-1-1-${arch}.pkg.tar.xz ${arch} + for arch in "${ARCH_BUILD[@]}"; do + checkPackage extra "pkg-simple-a-1-1-${arch}.pkg.tar.xz" "${arch}" + checkRemovedPackage testing "pkg-simple-a-1-1-${arch}.pkg.tar.xz" "${arch}" - checkPackage testing pkg-simple-b-1-1-${arch}.pkg.tar.xz ${arch} + checkPackage testing "pkg-simple-b-1-1-${arch}.pkg.tar.xz" "${arch}" done } testMoveMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage testing "${pkgbase}" "${arch}" done done @@ -43,23 +41,22 @@ testMoveMultiplePackages() { ../db-move testing extra pkg-simple-a pkg-simple-b - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkPackage extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} - checkRemovedPackage testing ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + checkPackage extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" + checkRemovedPackage testing "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } testMoveEpochPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-epoch') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage testing "${pkgbase}" "${arch}" done done @@ -67,9 +64,9 @@ testMoveEpochPackages() { ../db-move testing extra pkg-simple-epoch - for arch in ${arches[@]}; do - checkPackage extra pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz ${arch} - checkRemovedPackage testing pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz ${arch} + for arch in "${ARCH_BUILD[@]}"; do + checkPackage extra "pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" "${arch}" + checkRemovedPackage testing "pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" "${arch}" done } @@ -77,8 +74,8 @@ testMoveAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase - for pkgbase in ${pkgs[@]}; do - releasePackage testing ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage testing "${pkgbase}" any done ../db-update @@ -90,29 +87,28 @@ testMoveAnyPackages() { } testMoveSplitPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage testing "${pkgbase}" "${arch}" done done ../db-update ../db-move testing extra pkg-split-a - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/pkg-split-a"/*-${arch}${PKGEXT}; do - checkPackage extra $(basename ${pkg}) ${arch} + for arch in "${ARCH_BUILD[@]}"; do + for pkg in "${pkgdir}/pkg-split-a"/*-"${arch}"${PKGEXT}; do + checkPackage extra "${pkg##*/}" "${arch}" done done - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/pkg-split-b"/*-${arch}${PKGEXT}; do - checkPackage testing $(basename ${pkg}) ${arch} + for arch in "${ARCH_BUILD[@]}"; do + for pkg in "${pkgdir}/pkg-split-b"/*-"${arch}"${PKGEXT}; do + checkPackage testing "${pkg##*/}" "${arch}" done done diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index 416e693..a391197 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -1,56 +1,54 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testRemovePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - ../db-remove extra ${arch} ${pkgbase} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + ../db-remove extra "${arch}" "${pkgbase}" done done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkRemovedPackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + checkRemovedPackage extra "${pkgbase}" "${arch}" done done } testRemoveMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b' 'pkg-simple-epoch') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} ${pkgs[@]} + for arch in "${ARCH_BUILD[@]}"; do + ../db-remove extra "${arch}" "${pkgs[@]}" done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkRemovedPackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + checkRemovedPackage extra "${pkgbase}" "${arch}" done done } @@ -59,18 +57,18 @@ testRemoveAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update - for pkgbase in ${pkgs[@]}; do - ../db-remove extra any ${pkgbase} + for pkgbase in "${pkgs[@]}"; do + ../db-remove extra any "${pkgbase}" done - for pkgbase in ${pkgs[@]}; do - checkRemovedAnyPackage extra ${pkgbase} + for pkgbase in "${pkgs[@]}"; do + checkRemovedAnyPackage extra "${pkgbase}" done } diff --git a/test/test.d/db-repo-add.sh b/test/test.d/db-repo-add.sh index 8603104..266a696 100755 --- a/test/test.d/db-repo-add.sh +++ b/test/test.d/db-repo-add.sh @@ -1,52 +1,50 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testAddSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" touch "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/extra/os/${arch}/" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" "${FTP_BASE}/extra/os/${arch}/" - ../db-repo-add extra ${arch} ${pkgbase}-1-1-${arch}.pkg.tar.xz + ../db-repo-add extra "${arch}" "${pkgbase}-1-1-${arch}.pkg.tar.xz" done done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkPackageDB extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + checkPackageDB extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } testAddMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for arch in ${arches[@]}; do + for arch in "${ARCH_BUILD[@]}"; do add_pkgs=() - for pkgbase in ${pkgs[@]}; do + for pkgbase in "${pkgs[@]}"; do cp "${pkgdir}/${pkgbase}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/${PKGPOOL}/" touch "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz" "${FTP_BASE}/extra/os/${arch}/" ln -s "${FTP_BASE}/${PKGPOOL}/${pkgbase}-1-1-${arch}.pkg.tar.xz.sig" "${FTP_BASE}/extra/os/${arch}/" - add_pkgs[${#add_pkgs[*]}]=${pkgbase}-1-1-${arch}.pkg.tar.xz + add_pkgs+=("${pkgbase}-1-1-${arch}.pkg.tar.xz") done - ../db-repo-add extra ${arch} ${add_pkgs[@]} + ../db-repo-add extra "${arch}" "${add_pkgs[@]}" done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkPackageDB extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + checkPackageDB extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } diff --git a/test/test.d/db-repo-remove.sh b/test/test.d/db-repo-remove.sh index 315d63d..727188d 100755 --- a/test/test.d/db-repo-remove.sh +++ b/test/test.d/db-repo-remove.sh @@ -1,56 +1,54 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testRemovePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - ../db-repo-remove extra ${arch} ${pkgbase} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + ../db-repo-remove extra "${arch}" "${pkgbase}" done done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkRemovedPackageDB extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + checkRemovedPackageDB extra "${pkgbase}" "${arch}" done done } testRemoveMultiplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-repo-remove extra ${arch} ${pkgs[@]} + for arch in "${ARCH_BUILD[@]}"; do + ../db-repo-remove extra "${arch}" "${pkgs[@]}" done - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkRemovedPackageDB extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + checkRemovedPackageDB extra "${pkgbase}" "${arch}" done done } diff --git a/test/test.d/db-update.sh b/test/test.d/db-update.sh index e38c328..ca4efe7 100755 --- a/test/test.d/db-update.sh +++ b/test/test.d/db-update.sh @@ -1,25 +1,24 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testAddSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - checkPackage extra ${pkgbase}-1-1-${arch}.pkg.tar.xz ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + checkPackage extra "${pkgbase}-1-1-${arch}.pkg.tar.xz" "${arch}" done done } @@ -40,36 +39,35 @@ testAddAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update - for pkgbase in ${pkgs[@]}; do - checkAnyPackage extra ${pkgbase}-1-1-any.pkg.tar.xz + for pkgbase in "${pkgs[@]}"; do + checkAnyPackage extra "${pkgbase}-1-1-any.pkg.tar.xz" done } testAddSplitPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-${arch}${PKGEXT}; do - checkPackage extra $(basename ${pkg}) ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + for pkg in "${pkgdir}/${pkgbase}"/*-"${arch}"${PKGEXT}; do + checkPackage extra "${pkg##*/}" "${arch}" done done done @@ -81,8 +79,8 @@ testUpdateAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD - svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build >/dev/null 2>&1 + arch_svn commit -q -m"update pkg to pkgrel=2" >/dev/null + sudo extra-i686-build mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null @@ -99,8 +97,8 @@ testUpdateAnyPackageToDifferentRepositoriesAtOnce() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD - svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build >/dev/null 2>&1 + arch_svn commit -q -m"update pkg to pkgrel=2" >/dev/null + sudo extra-i686-build mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null @@ -134,32 +132,41 @@ testUpdateSameAnyPackageToDifferentRepositories() { local arch for arch in i686 x86_64; do ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in testing/os/${arch}/testing${DBEXT%.tar.*}" done } testAddIncompleteSplitPackage() { - local arches=('i686' 'x86_64') local repo='extra' local pkgbase='pkg-split-a' local arch - for arch in ${arches[@]}; do - releasePackage ${repo} ${pkgbase} ${arch} + for arch in "${ARCH_BUILD[@]}"; do + releasePackage "${repo}" "${pkgbase}" "${arch}" done # remove a split package to make db-update fail - rm "${STAGING}"/extra/${pkgbase}1-* + rm "${STAGING}/extra/${pkgbase}1-"* ../db-update >/dev/null 2>&1 && fail "db-update should fail when a split package is missing!" - for arch in ${arches[@]}; do + for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q ${pkgbase}) \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" -O | grep -q "${pkgbase}") \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${DBEXT%.tar.*}" done } +testUnknownRepo() { + mkdir "${STAGING}/unknown/" + releasePackage extra 'pkg-simple-a' 'i686' + releasePackage unknown 'pkg-simple-b' 'i686' + ../db-update + checkPackage extra 'pkg-simple-a-1-1-i686.pkg.tar.xz' 'i686' + [ -e "${FTP_BASE}/unknown" ] && fail "db-update pushed a package into an unknown repository" + rm -rf "${STAGING}/unknown/" +} + . "${curdir}/../lib/shunit2" diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index 20026b4..5a7afea 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -1,62 +1,60 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testCleanupSimplePackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} pkg-simple-a + for arch in "${ARCH_BUILD[@]}"; do + ../db-remove extra "${arch}" pkg-simple-a done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in ${arches[@]}; do + for arch in "${ARCH_BUILD[@]}"; do local pkg1="pkg-simple-a-1-1-${arch}.pkg.tar.xz" - checkRemovedPackage extra 'pkg-simple-a' ${arch} + checkRemovedPackage extra 'pkg-simple-a' "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-simple-b-1-1-${arch}.pkg.tar.xz" - checkPackage extra ${pkg2} ${arch} + checkPackage extra "${pkg2}" "${arch}" done } testCleanupEpochPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-epoch') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} pkg-simple-epoch + for arch in "${ARCH_BUILD[@]}"; do + ../db-remove extra "${arch}" pkg-simple-epoch done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in ${arches[@]}; do + for arch in "${ARCH_BUILD[@]}"; do local pkg1="pkg-simple-epoch-1:1-1-${arch}.pkg.tar.xz" - checkRemovedPackage extra 'pkg-simple-epoch' ${arch} + checkRemovedPackage extra 'pkg-simple-epoch' "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" done @@ -67,8 +65,8 @@ testCleanupAnyPackages() { local pkgbase local arch='any' - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update @@ -81,39 +79,38 @@ testCleanupAnyPackages() { [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg1}" ] && fail "${repo}/os/${arch}/${pkg1} found" local pkg2="pkg-any-b-1-1-${arch}.pkg.tar.xz" - checkAnyPackage extra ${pkg2} + checkAnyPackage extra "${pkg2}" } testCleanupSplitPackages() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update - for arch in ${arches[@]}; do - ../db-remove extra ${arch} ${pkgs[0]} + for arch in "${ARCH_BUILD[@]}"; do + ../db-remove extra "${arch}" "${pkgs[0]}" done ../cron-jobs/ftpdir-cleanup >/dev/null - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgs[0]}"/*-${arch}${PKGEXT}; do - checkRemovedPackage extra ${pkgs[0]} ${arch} + for arch in "${ARCH_BUILD[@]}"; do + for pkg in "${pkgdir}/${pkgs[0]}"/*-"${arch}"${PKGEXT}; do + checkRemovedPackage extra "${pkgs[0]}" "${arch}" [ -f "${FTP_BASE}/${PKGPOOL}/${pkg}" ] && fail "${PKGPOOL}/${pkg} found" [ -f "${FTP_BASE}/${repo}/os/${arch}/${pkg}" ] && fail "${repo}/os/${arch}/${pkg} found" done - for pkg in "${pkgdir}/${pkgs[1]}"/*-${arch}${PKGEXT}; do - checkPackage extra $(basename ${pkg}) ${arch} + for pkg in "${pkgdir}/${pkgs[1]}"/*-"${arch}"${PKGEXT}; do + checkPackage extra "${pkg##*/}" "${arch}" done done } diff --git a/test/test.d/packages.sh b/test/test.d/packages.sh index 488cb15..18266eb 100755 --- a/test/test.d/packages.sh +++ b/test/test.d/packages.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testPackages() { diff --git a/test/test.d/pool-transition.sh b/test/test.d/pool-transition.sh deleted file mode 100755 index 5873f00..0000000 --- a/test/test.d/pool-transition.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/bash - -curdir=$(readlink -e $(dirname $0)) -. "${curdir}/../lib/common.inc" - -testMovePackagesWithoutPool() { - local arches=('i686' 'x86_64') - local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-split-a' 'pkg-split-b') - local pkgbase - local arch - local pkg - local old - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage testing ${pkgbase} ${arch} - done - done - - ../db-update - - # transform two packages to old style layout - for arch in ${arches[@]}; do - for old in 0 2; do - for pkg in "${pkgdir}/${pkgs[${old}]}"/*-${arch}${PKGEXT}; do - pkg=$(basename $pkg) - mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" - done - done - done - - ../cron-jobs/ftpdir-cleanup >/dev/null - - ../db-move testing extra ${pkgs[@]} - - ../cron-jobs/ftpdir-cleanup >/dev/null - - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-${arch}${PKGEXT}; do - checkPackage extra $(basename ${pkg}) ${arch} - done - checkRemovedPackage testing ${pkgbase} ${arch} - done - done -} - -testUpdateAnyPackageWithoutPool() { - local pkgname='pkg-any-a' - local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' - local pkg2='pkg-any-a-1-2-any.pkg.tar.xz' - local arch - - - releasePackage extra pkg-any-a any - ../db-update - # transform two packages to old style layout - mv -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" "${FTP_BASE}/extra/os/any" - for arch in i686 x86_64; do - ln -sf "../any/${pkg1}" "${FTP_BASE}/extra/os/${arch}" - done - - pushd "${TMP}/svn-packages-copy/${pkgname}/trunk/" >/dev/null - sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD - svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build >/dev/null 2>&1 - mv "${pkg2}" "${pkgdir}/${pkgname}/" - popd >/dev/null - - releasePackage extra ${pkgname} any - ../db-update - rm -f "${pkgdir}/${pkgname}/${pkg2}" - - ../cron-jobs/ftpdir-cleanup >/dev/null - - checkAnyPackage extra "${pkg2}" - - [ -f "${FTP_BASE}/${PKGPOOL}/${pkg1}" ] && fail "${PKGPOOL}/${pkg1} found" - for arch in any i686 x86_64; do - [ -f "${FTP_BASE}/extra/os/${arch}/${pkg1}" ] && fail "extra/os/${arch}/${pkg1} found" - done -} - -testMoveAnyPackagesWithoutPool() { - local pkgs=('pkg-any-a' 'pkg-any-b') - local pkgbase - local arch - local pkg - - for pkgbase in ${pkgs[@]}; do - releasePackage testing ${pkgbase} any - done - - ../db-update - - # transform a package to old style layout - for pkg in "${pkgdir}/${pkgs[0]}"/*-any${PKGEXT}; do - pkg=$(basename $pkg) - mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/testing/os/any/${pkg}" - for arch in i686 x86_64; do - ln -sf "../any/${pkg}" "${FTP_BASE}/testing/os/${arch}/${pkg}" - done - done - - ../cron-jobs/ftpdir-cleanup >/dev/null - - ../db-move testing extra ${pkgs[@]} - - ../cron-jobs/ftpdir-cleanup >/dev/null - - for pkgbase in ${pkgs[@]}; do - for pkg in "${pkgdir}/${pkgbase}"/*-any${PKGEXT}; do - checkAnyPackage extra $(basename ${pkg}) - done - checkRemovedAnyPackage testing ${pkgbase} - done - - for pkg in "${pkgdir}/${pkgs[0]}"/*-any${PKGEXT}; do - pkg=$(basename $pkg) - for arch in any i686 x86_64; do - [ -f "${FTP_BASE}/testing/os/${arch}/${pkg}" ] && fail "testing/os/${arch}/${pkg} found" - done - done -} - -testUpdateSameAnyPackageToDifferentRepositoriesWithoutPool() { - local pkg - local arch - - releasePackage extra pkg-any-a any - ../db-update - - # transform a package to old style layout - for pkg in "${pkgdir}/pkg-any-a"/*-any${PKGEXT}; do - pkg=$(basename $pkg) - mv -f "${FTP_BASE}/${PKGPOOL}/${pkg}" "${FTP_BASE}/extra/os/any/${pkg}" - for arch in i686 x86_64; do - ln -sf "../any/${pkg}" "${FTP_BASE}/extra/os/${arch}/${pkg}" - done - done - - releasePackage testing pkg-any-a any - ../db-update >/dev/null 2>&1 && (fail 'Adding an existing package to another repository should fail'; return 1) - - for arch in i686 x86_64; do - ( [ -r "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/testing/os/${arch}/testing${DBEXT%.tar.*}" -O | grep -q pkg-any-a) \ - && fail "pkg-any-a should not be in testing/os/${arch}/testing${DBEXT%.tar.*}" - done -} - -. "${curdir}/../lib/shunit2" diff --git a/test/test.d/signed-packages.sh b/test/test.d/signed-packages.sh index 5d6f4ff..3ffe146 100755 --- a/test/test.d/signed-packages.sh +++ b/test/test.d/signed-packages.sh @@ -1,13 +1,36 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" +testAddSignedPackage() { + releasePackage extra 'pkg-simple-a' 'i686' + ../db-update || fail "db-update failed!" +} + testAddUnsignedPackage() { releasePackage extra 'pkg-simple-a' 'i686' - # remove any signature rm "${STAGING}"/extra/*.sig ../db-update >/dev/null 2>&1 && fail "db-update should fail when a signature is missing!" } +testAddInvalidSignedPackage() { + local p + releasePackage extra 'pkg-simple-a' 'i686' + for p in "${STAGING}"/extra/*${PKGEXT}; do + unxz "$p" + xz -0 "${p%%.xz}" + done + ../db-update >/dev/null 2>&1 && fail "db-update should fail when a signature is invalid!" +} + +testAddBrokenSignature() { + local s + releasePackage extra 'pkg-simple-a' 'i686' + for s in "${STAGING}"/extra/*.sig; do + echo 0 > "$s" + done + ../db-update >/dev/null 2>&1 && fail "db-update should fail when a signature is broken!" +} + . "${curdir}/../lib/shunit2" diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index fdcf08c..81c9265 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -1,24 +1,23 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testSourceballs() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b' 'pkg-simple-epoch') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update ../cron-jobs/sourceballs - for pkgbase in ${pkgs[@]}; do - [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + for pkgbase in "${pkgs[@]}"; do + [ ! -r "${FTP_BASE}/${SRCPOOL}/${pkgbase}"-*"${SRCEXT}" ] && fail "source package not found!" done } @@ -26,59 +25,57 @@ testAnySourceballs() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase - for pkgbase in ${pkgs[@]}; do - releasePackage extra ${pkgbase} any + for pkgbase in "${pkgs[@]}"; do + releasePackage extra "${pkgbase}" any done ../db-update ../cron-jobs/sourceballs - for pkgbase in ${pkgs[@]}; do - [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + for pkgbase in "${pkgs[@]}"; do + [ ! -r "${FTP_BASE}/${SRCPOOL}/${pkgbase}"-*"${SRCEXT}" ] && fail "source package not found!" done } testSplitSourceballs() { - local arches=('i686' 'x86_64') local pkgs=('pkg-split-a' 'pkg-split-b') local pkg local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update ../cron-jobs/sourceballs - for pkgbase in ${pkgs[@]}; do - [ ! -r ${FTP_BASE}/${SRCPOOL}/${pkgbase}-*${SRCEXT} ] && fail "source package not found!" + for pkgbase in "${pkgs[@]}"; do + [ ! -r "${FTP_BASE}/${SRCPOOL}/${pkgbase}"-*"${SRCEXT}" ] && fail "source package not found!" done } testSourceballsCleanup() { - local arches=('i686' 'x86_64') local pkgs=('pkg-simple-a' 'pkg-simple-b') local pkgbase local arch - for pkgbase in ${pkgs[@]}; do - for arch in ${arches[@]}; do - releasePackage extra ${pkgbase} ${arch} + for pkgbase in "${pkgs[@]}"; do + for arch in "${ARCH_BUILD[@]}"; do + releasePackage extra "${pkgbase}" "${arch}" done done ../db-update ../cron-jobs/sourceballs - for arch in ${arches[@]}; do - ../db-remove extra ${arch} pkg-simple-a + for arch in "${ARCH_BUILD[@]}"; do + ../db-remove extra "${arch}" pkg-simple-a done ../cron-jobs/sourceballs - [ -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-a-*${SRCEXT} ] && fail "source package was not removed!" - [ ! -r ${FTP_BASE}/${SRCPOOL}/pkg-simple-b-*${SRCEXT} ] && fail "source package not found!" + [ -r "${FTP_BASE}/${SRCPOOL}/pkg-simple-a"-*"${SRCEXT}" ] && fail "source package was not removed!" + [ ! -r "${FTP_BASE}/${SRCPOOL}/pkg-simple-b"-*"${SRCEXT}" ] && fail "source package not found!" } . "${curdir}/../lib/shunit2" diff --git a/test/test.d/testing2x.sh b/test/test.d/testing2x.sh index eda6cd6..c611ce4 100755 --- a/test/test.d/testing2x.sh +++ b/test/test.d/testing2x.sh @@ -1,6 +1,6 @@ #!/bin/bash -curdir=$(readlink -e $(dirname $0)) +curdir="$(dirname "$(readlink -e "$0")")" . "${curdir}/../lib/common.inc" testTesting2xAnyPackage() { @@ -9,8 +9,8 @@ testTesting2xAnyPackage() { pushd "${TMP}/svn-packages-copy/pkg-any-a/trunk/" >/dev/null sed 's/pkgrel=1/pkgrel=2/g' -i PKGBUILD - svn commit -q -m"update pkg to pkgrel=2" >/dev/null - sudo extra-i686-build >/dev/null 2>&1 + arch_svn commit -q -m"update pkg to pkgrel=2" >/dev/null + sudo extra-i686-build mv pkg-any-a-1-2-any.pkg.tar.xz "${pkgdir}/pkg-any-a/" popd >/dev/null diff --git a/test/test_filter.py b/test/test_filter.py deleted file mode 100644 index d8006f9..0000000 --- a/test/test_filter.py +++ /dev/null @@ -1,196 +0,0 @@ -# -*- encoding: utf-8 -*- -""" """ - -__author__ = "Joshua Ismael Haase Hernández <hahj87@gmail.com>" -__version__ = "$Revision: 1.1 $" -__date__ = "$Date: 2011/02/08 $" -__copyright__ = "Copyright (c) 2011 Joshua Ismael Haase Hernández" -__license__ = "GPL3+" - -from repm.config import * -from repm.filter import * -import unittest - -class pkginfo_from_file_KnownValues(unittest.TestCase): - # (filename, name, version, release, arch) - # filename is location - known=( - ("community-testing/os/i686/inputattach-1.24-3-i686.pkg.tar.xz","inputattach","1.24","3","i686"), - ("community-testing/os/i686/ngspice-22-1-i686.pkg.tar.xz","ngspice","22","1","i686"), - ("community-testing/os/i686/tmux-1.4-2-i686.pkg.tar.xz","tmux","1.4","2","i686"), - ("community-testing/os/i686/tor-0.2.1.29-2-i686.pkg.tar.xz","tor","0.2.1.29","2","i686"), - ("../../../pool/community/tor-0.2.1.29-2-i686.pkg.tar.xz","tor","0.2.1.29","2","i686"), - ("community-testing/os/x86_64/inputattach-1.24-3-x86_64.pkg.tar.xz","inputattach","1.24","3","x86_64"), - ("../../../pool/community/inputattach-1.24-3-x86_64.pkg.tar.xz","inputattach","1.24","3","x86_64"), - ("tor-0.2.1.29-2-x86_64.pkg.tar.xz","tor","0.2.1.29","2","x86_64"), - ) - - def generate_results(self, example_tuple, attr): - location, name, version, release, arch = example_tuple - return pkginfo_from_filename(location)[attr], locals()[attr] - - def testReturnPackageObject(self): - for i in self.known: - location, name, version, release, arch = i - self.assertIsInstance(pkginfo_from_filename(location),Package) - - def testNames(self): - for i in self.known: - k,v = self.generate_results(example_tuple=i,attr="name") - self.assertEqual(k, v) - - def testVersions(self): - for i in self.known: - k,v = self.generate_results(example_tuple=i,attr="version") - self.assertEqual(k, v) - - def testArchs(self): - for i in self.known: - k,v = self.generate_results(example_tuple=i,attr="arch") - self.assertEqual(k, v) - - def testReleases(self): - for i in self.known: - k,v = self.generate_results(example_tuple=i,attr="release") - self.assertEqual(k, v) - - def testLocations(self): - for i in self.known: - k,v = self.generate_results(example_tuple=i,attr="location") - self.assertEqual(k, v) - -class pkginfo_from_file_BadInput(unittest.TestCase): - bad=("community-testing/os/i686/community-testing.db", - "community-testing/os/i686/community-testing.db.tar.gz", - "community-testing/os/i686/community-testing.db.tar.gz.old", - "community-testing/os/i686/community-testing.files", - "community-testing/os/i686/community-testing.files.tar.gz", - "community-testing/os/x86_64") - - def testBadInput(self): - for i in self.bad: - self.assertRaises(NonValidFile,pkginfo_from_filename,i) - -class pkginfoFromRsyncOutput(unittest.TestCase): - example_package_list=(Package(),Package(),Package()) - example_package_list[0].package_info={ "name" : "alex", - "version" : "2.3.4", - "release" : "1", - "arch" : "i686", - "license" : False, - "location": "community-staging/os/i686/alex-2.3.4-1-i686.pkg.tar.xz", - "depends" : False,} - example_package_list[1].package_info={ "name" : "any2dvd", - "version" : "0.34", - "release" : "4", - "arch" : "any", - "license" : False, - "location": "community/os/any/any2dvd-0.34-4-any.pkg.tar.xz", - "depends" : False,} - example_package_list[2].package_info={ "name" : "gmime22", - "version" : "2.2.26", - "release" : "1", - "arch" : "x86_64", - "license" : False, - "location": "community/os/x86_64/gmime22-2.2.26-1-x86_64.pkg.tar.xz", - "depends" : False,} - - try: - output_file = open("rsync_output_sample") - rsync_out= output_file.read() - output_file.close() - except IOError: print("There is no rsync_output_sample file") - - pkglist = pkginfo_from_rsync_output(rsync_out) - - def testOutputArePackages(self): - if not self.pkglist: - self.fail("not pkglist:" + str(self.pkglist)) - for pkg in self.pkglist: - self.assertIsInstance(pkg,Package) - - def testPackageInfo(self): - if not self.pkglist: - self.fail("Pkglist doesn't exist: " + str(self.pkglist)) - self.assertEqual(self.pkglist,self.example_package_list) - -class generateRsyncBlacklist(unittest.TestCase): - example_package_list=(Package(),Package(),Package()) - example_package_list[0].package_info={ "name" : "alex", - "version" : "2.3.4", - "release" : "1", - "arch" : "i686", - "license" : False, - "location": "community-staging/os/i686/alex-2.3.4-1-i686.pkg.tar.xz", - "depends" : False,} - example_package_list[1].package_info={ "name" : "any2dvd", - "version" : "0.34", - "release" : "4", - "arch" : "any", - "license" : False, - "location": "community/os/any/any2dvd-0.34-4-any.pkg.tar.xz", - "depends" : False,} - example_package_list[2].package_info={ "name" : "gmime22", - "version" : "2.2.26", - "release" : "1", - "arch" : "x86_64", - "license" : False, - "location": "community/os/x86_64/gmime22-2.2.26-1-x86_64.pkg.tar.xz", - "depends" : False,} - - def testListado(self): - self.assertEqual(listado("blacklist_sample"),["alex","gmime22"]) - - def testExcludeFiles(self): - a=rsyncBlacklist_from_blacklist(self.example_package_list, - listado("blacklist_sample"), - False) - b=[self.example_package_list[0]["location"],self.example_package_list[2]["location"]] - self.assertEqual(a,b) - -class pkginfo_from_descKnownValues(unittest.TestCase): - pkgsample=Package() - pkgsample.package_info={"name" : "binutils", - "version" : "2.21", - "release" : "4", - "arch" : "x86_64", - "license" : "GPL", - "location": "binutils-2.21-4-x86_64.pkg.tar.xz", - "depends" : False,} - fsock=open("desc") - pkggen=pkginfo_from_desc(fsock.read()) - fsock.close() - def testPkginfoFromDesc(self): - if self.pkggen is None: - self.fail("return value is None") - self.assertEqual(self.pkgsample,self.pkggen) - -class pkginfo_from_db(unittest.TestCase): - archdb = os.path.join("./workdir") - example_package_list=(Package(),Package(),Package()) - example_package_list[0].package_info={ "name" : "acl", - "version" : "2.2.49", - "release" : "2", - "arch" : "x86_64", - "license" : ("LGPL",), - "location": "acl-2.2.49-2-x86_64.pkg.tar.xz", - "depends" : ("attr>=2.4.41"),} - example_package_list[1].package_info={ "name" : "glibc", - "version" : "2.13", - "release" : "4", - "arch" : "x86_64", - "license" : ("GPL","LGPL"), - "location": "glibc-2.13-4-x86_64.pkg.tar.xz", - "depends" : ("linux-api-headers>=2.6.37","tzdata",),} - example_package_list[2].package_info={ "name" : "", - "version" : "2.2.26", - "release" : "1", - "arch" : "x86_64", - "license" : False, - "location": "", - "depends" : False,} - - -if __name__ == "__main__": - unittest.main() - |