diff options
author | Nicolás Reynolds <fauno@kiwwwi.com.ar> | 2012-01-08 15:17:16 -0300 |
---|---|---|
committer | Nicolás Reynolds <fauno@kiwwwi.com.ar> | 2012-01-08 15:17:16 -0300 |
commit | 341400146cbde0dbf05eaa8aec531f5286fd91fb (patch) | |
tree | aef2a4b704731ee405345bc8e22dbcdad2056cb5 | |
parent | a749983e8f2becf7c5427b0e5c449d457afbe385 (diff) | |
parent | a8b219b325cd642a781a64d8e08a0e66d25c1b44 (diff) |
Merge branch 'master' of https://projects.archlinux.org/git/dbscripts
Conflicts:
db-remove
-rw-r--r-- | cron-jobs/check_archlinux/README | 8 | ||||
-rw-r--r-- | cron-jobs/check_archlinux/alpm.c | 40 | ||||
-rwxr-xr-x | cron-jobs/check_archlinux/alpm.so | bin | 7057 -> 0 bytes | |||
-rwxr-xr-x | cron-jobs/check_archlinux/check_packages.py | 258 | ||||
-rw-r--r-- | cron-jobs/check_archlinux/setup.py | 10 | ||||
-rwxr-xr-x | db-remove | 35 | ||||
-rwxr-xr-x | db-repo-add | 24 | ||||
-rwxr-xr-x | db-repo-remove | 17 | ||||
-rw-r--r-- | test/lib/common.inc | 43 | ||||
-rwxr-xr-x | test/test.d/create-filelists.sh | 2 | ||||
-rwxr-xr-x | test/test.d/db-move.sh | 24 | ||||
-rwxr-xr-x | test/test.d/db-remove.sh | 29 | ||||
-rwxr-xr-x | test/test.d/db-repo-add.sh | 54 | ||||
-rwxr-xr-x | test/test.d/db-repo-remove.sh | 58 | ||||
-rwxr-xr-x | test/test.d/ftpdir-cleanup.sh | 8 | ||||
-rwxr-xr-x | test/test.d/sourceballs.sh | 2 |
16 files changed, 385 insertions, 227 deletions
diff --git a/cron-jobs/check_archlinux/README b/cron-jobs/check_archlinux/README deleted file mode 100644 index 8f178dc..0000000 --- a/cron-jobs/check_archlinux/README +++ /dev/null @@ -1,8 +0,0 @@ -1) Build the python module -$ python2 setup.py build - -2) copy it back to the current working directory -$ cp build/lib.*/alpm.* . - -3) run the script -$ ./check_packages.py -h diff --git a/cron-jobs/check_archlinux/alpm.c b/cron-jobs/check_archlinux/alpm.c deleted file mode 100644 index 0b7cd2c..0000000 --- a/cron-jobs/check_archlinux/alpm.c +++ /dev/null @@ -1,40 +0,0 @@ -#include <Python.h> -#include <alpm.h> - -static PyObject * -alpm_vercmp(PyObject *self, PyObject *args) -{ - const char *v1, *v2; - int ret; - - if (!PyArg_ParseTuple(args, "ss", &v1, &v2)) - return NULL; - ret = alpm_pkg_vercmp(v1, v2); - return Py_BuildValue("i", ret); -} - -static PyMethodDef AlpmMethods[] = { - {"vercmp", alpm_vercmp, METH_VARARGS, - "Execute vercmp."}, - {NULL, NULL, 0, NULL} /* Sentinel */ -}; - -PyMODINIT_FUNC -initalpm(void) -{ - (void) Py_InitModule("alpm", AlpmMethods); -} - -int -main(int argc, char *argv[]) -{ - /* Pass argv[0] to the Python interpreter */ - Py_SetProgramName(argv[0]); - - /* Initialize the Python interpreter. Required. */ - Py_Initialize(); - - /* Add a static module */ - initalpm(); - return 0; -} diff --git a/cron-jobs/check_archlinux/alpm.so b/cron-jobs/check_archlinux/alpm.so Binary files differdeleted file mode 100755 index 8944bbe..0000000 --- a/cron-jobs/check_archlinux/alpm.so +++ /dev/null diff --git a/cron-jobs/check_archlinux/check_packages.py b/cron-jobs/check_archlinux/check_packages.py index 0a2b10e..d233bf6 100755 --- a/cron-jobs/check_archlinux/check_packages.py +++ b/cron-jobs/check_archlinux/check_packages.py @@ -16,9 +16,12 @@ # a non-core package) # 8. Circular dependencies -import os,re,commands,getopt,sys,tarfile,alpm +import os,re,commands,getopt,sys,tarfile import pdb +import ctypes +_alpm = ctypes.cdll.LoadLibrary("libalpm.so") + DBEXT='.db.tar.gz' packages = {} # pkgname : PacmanPackage @@ -143,7 +146,17 @@ def splitprov(prov): return (name,version) def vercmp(v1,mod,v2): - res = alpm.vercmp(v1,v2) + """ + >>> vercmp("1.0", "<=", "2.0") + True + >>> vercmp("1:1.0", ">", "2.0") + True + >>> vercmp("1.0.2", ">=", "2.1.0") + False + """ + s1 = ctypes.c_char_p(v1) + s2 = ctypes.c_char_p(v2) + res = _alpm.alpm_pkg_vercmp(s1,s2) if res == 0: return (mod.find("=") > -1) elif res < 0: @@ -364,131 +377,132 @@ def print_usage(): print " ./check_packages.py --abs-tree=/var/abs --repos=community --arch=i686" print "" -## Default path to the abs root directory -absroots = ["/var/abs"] -## Default list of repos to check -repos = ['core', 'extra'] -## Default arch -arch = "i686" -## Default repodir -repodir = "/srv/ftp" - -try: - opts, args = getopt.getopt(sys.argv[1:], "", ["abs-tree=", "repos=", - "arch=", "repo-dir="]) -except getopt.GetoptError: - print_usage() - sys.exit() -if opts != []: - for o, a in opts: - if o in ("--abs-tree"): - absroots = a.split(',') - elif o in ("--repos"): - repos = a.split(",") - elif o in ("--arch"): - arch = a - elif o in ("--repo-dir"): - repodir = a - else: - print_usage() - sys.exit() - if args != []: - print_usage() +if __name__ == "__main__": + ## Default path to the abs root directory + absroots = ["/var/abs"] + ## Default list of repos to check + repos = ['core', 'extra'] + ## Default arch + arch = "i686" + ## Default repodir + repodir = "/srv/ftp" + + try: + opts, args = getopt.getopt(sys.argv[1:], "", ["abs-tree=", "repos=", + "arch=", "repo-dir="]) + except getopt.GetoptError: + print_usage() + sys.exit() + if opts != []: + for o, a in opts: + if o in ("--abs-tree"): + absroots = a.split(',') + elif o in ("--repos"): + repos = a.split(",") + elif o in ("--arch"): + arch = a + elif o in ("--repo-dir"): + repodir = a + else: + print_usage() + sys.exit() + if args != []: + print_usage() + sys.exit() + + for absroot in absroots: + if not os.path.isdir(absroot): + print "Error : the abs tree " + absroot + " does not exist" sys.exit() + for repo in repos: + repopath = absroot + "/" + repo + if not os.path.isdir(repopath): + print("Warning : the repository " + repo + " does not exist in " + absroot) -for absroot in absroots: - if not os.path.isdir(absroot): - print "Error : the abs tree " + absroot + " does not exist" + if not os.path.isdir(repodir): + print "Error: the repository directory %s does not exist" % repodir sys.exit() for repo in repos: - repopath = absroot + "/" + repo - if not os.path.isdir(repopath): - print("Warning : the repository " + repo + " does not exist in " + absroot) - -if not os.path.isdir(repodir): - print "Error: the repository directory %s does not exist" % repodir - sys.exit() -for repo in repos: - path = os.path.join(repodir,repo,'os',arch,repo + DBEXT) - if not os.path.isfile(path): - print "Error : repo DB %s : File not found" % path - sys.exit() - if not tarfile.is_tarfile(path): - print "Error : Cant open repo DB %s, not a valid tar file" % path - sys.exit() -# repos which need to be loaded -loadrepos = set([]) -for repo in repos: - loadrepos = loadrepos | set(get_repo_hierarchy(repo)) + path = os.path.join(repodir,repo,'os',arch,repo + DBEXT) + if not os.path.isfile(path): + print "Error : repo DB %s : File not found" % path + sys.exit() + if not tarfile.is_tarfile(path): + print "Error : Cant open repo DB %s, not a valid tar file" % path + sys.exit() + # repos which need to be loaded + loadrepos = set([]) + for repo in repos: + loadrepos = loadrepos | set(get_repo_hierarchy(repo)) -print_heading("Integrity Check " + arch + " of " + ",".join(repos)) -print("\nPerforming integrity checks...") + print_heading("Integrity Check " + arch + " of " + ",".join(repos)) + print("\nPerforming integrity checks...") -print("==> parsing pkgbuilds") -parse_pkgbuilds(loadrepos,arch) + print("==> parsing pkgbuilds") + parse_pkgbuilds(loadrepos,arch) -# fill provisions -for name,pkg in packages.iteritems(): - for prov in pkg.provides: - provname=prov.split("=")[0] - if provname not in provisions: - provisions[provname] = [] - provisions[provname].append(pkg) - -# fill repopkgs -for name,pkg in packages.iteritems(): - if pkg.repo in repos: - repopkgs[name] = pkg - -print("==> parsing db files") -dbpkgs = parse_dbs(repos,arch) - -print("==> checking mismatches") -for name,pkg in repopkgs.iteritems(): - pkgdirname = pkg.path.split("/")[-1] - if name != pkgdirname and pkg.base != pkgdirname: - mismatches.append(name + " vs. " + pkg.path) - -print("==> checking archs") -for name,pkg in repopkgs.iteritems(): - archs = verify_archs(name,pkg.repo,pkg.archs) - invalid_archs.extend(archs) - -deph,makedeph = [],[] - -print("==> checking dependencies") -for name,pkg in repopkgs.iteritems(): - (deps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.deps) - pkgdeps[pkg] = deps - missing_deps.extend(missdeps) - deph.extend(hierarchy) - -print("==> checking makedepends") -for name,pkg in repopkgs.iteritems(): - (makedeps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.makedeps) - makepkgdeps[pkg] = makedeps - missing_makedeps.extend(missdeps) - makedeph.extend(hierarchy) - -print("==> checking hierarchy") -dep_hierarchy = check_hierarchy(deph) -makedep_hierarchy = check_hierarchy(makedeph) - -print("==> checking for circular dependencies") -# make sure pkgdeps is filled for every package -for name,pkg in packages.iteritems(): - if pkg not in pkgdeps: - (deps,missdeps,_) = verify_deps(name,pkg.repo,pkg.deps) + # fill provisions + for name,pkg in packages.iteritems(): + for prov in pkg.provides: + provname=prov.split("=")[0] + if provname not in provisions: + provisions[provname] = [] + provisions[provname].append(pkg) + + # fill repopkgs + for name,pkg in packages.iteritems(): + if pkg.repo in repos: + repopkgs[name] = pkg + + print("==> parsing db files") + dbpkgs = parse_dbs(repos,arch) + + print("==> checking mismatches") + for name,pkg in repopkgs.iteritems(): + pkgdirname = pkg.path.split("/")[-1] + if name != pkgdirname and pkg.base != pkgdirname: + mismatches.append(name + " vs. " + pkg.path) + + print("==> checking archs") + for name,pkg in repopkgs.iteritems(): + archs = verify_archs(name,pkg.repo,pkg.archs) + invalid_archs.extend(archs) + + deph,makedeph = [],[] + + print("==> checking dependencies") + for name,pkg in repopkgs.iteritems(): + (deps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.deps) pkgdeps[pkg] = deps -find_scc(repopkgs.values()) - -print("==> checking for differences between db files and pkgbuilds") -for repo in repos: - for pkg in dbpkgs[repo]: - if not (pkg in repopkgs and repopkgs[pkg].repo == repo): - dbonly.append("%s/%s" % (repo,pkg)) -for name,pkg in repopkgs.iteritems(): - if not name in dbpkgs[pkg.repo]: - absonly.append("%s/%s" % (pkg.repo,name)) - -print_results() + missing_deps.extend(missdeps) + deph.extend(hierarchy) + + print("==> checking makedepends") + for name,pkg in repopkgs.iteritems(): + (makedeps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.makedeps) + makepkgdeps[pkg] = makedeps + missing_makedeps.extend(missdeps) + makedeph.extend(hierarchy) + + print("==> checking hierarchy") + dep_hierarchy = check_hierarchy(deph) + makedep_hierarchy = check_hierarchy(makedeph) + + print("==> checking for circular dependencies") + # make sure pkgdeps is filled for every package + for name,pkg in packages.iteritems(): + if pkg not in pkgdeps: + (deps,missdeps,_) = verify_deps(name,pkg.repo,pkg.deps) + pkgdeps[pkg] = deps + find_scc(repopkgs.values()) + + print("==> checking for differences between db files and pkgbuilds") + for repo in repos: + for pkg in dbpkgs[repo]: + if not (pkg in repopkgs and repopkgs[pkg].repo == repo): + dbonly.append("%s/%s" % (repo,pkg)) + for name,pkg in repopkgs.iteritems(): + if not name in dbpkgs[pkg.repo]: + absonly.append("%s/%s" % (pkg.repo,name)) + + print_results() diff --git a/cron-jobs/check_archlinux/setup.py b/cron-jobs/check_archlinux/setup.py deleted file mode 100644 index b172752..0000000 --- a/cron-jobs/check_archlinux/setup.py +++ /dev/null @@ -1,10 +0,0 @@ -from distutils.core import setup, Extension - -alpm = Extension('alpm', - libraries = ['alpm'], - sources = ['alpm.c']) - -setup (name = 'Alpm', - version = '1.0', - description = 'Alpm bindings', - ext_modules = [alpm]) @@ -3,14 +3,14 @@ . "$(dirname $0)/db-functions" . "$(dirname $0)/config" -if [ $# -ne 3 ]; then - msg "usage: $(basename $0) <pkgname|pkgbase> <repo> <arch>" +if [ $# -lt 3 ]; then + msg "usage: $(basename $0) <repo> <arch> <pkgname|pkgbase> ..." exit 1 fi -pkgbase="$1" -repo="$2" -arch="$3" +repo="$1" +arch="$2" +pkgbases=(${@:3}) if ! check_repo_permission $repo; then die "You don't have permission to remove packages from ${repo}" @@ -26,18 +26,21 @@ for tarch in ${tarches[@]}; do repo_lock $repo $tarch || exit 1 done -msg "Removing $pkgbase from [$repo]..." - -if [ -d "${SVNREPO}/$repo/$pkgbase" ]; then - pkgnames=($(. "${SVNREPO}/$repo/$pkgbase/PKGBUILD"; echo ${pkgname[@]})) -else - warning "$pkgbase not found in $repo" - warning "Removing only $pkgbase from the repo" - warning "If it was a split package you have to remove the others yourself!" - pkgnames=($pkgbase) -fi +remove_pkgs=() +for pkgbase in ${pkgbases[@]}; do + msg "Removing $pkgbase from [$repo]..." + + if [ -d "${SVNREPO}/$repo/$pkgbase" ]; then + remove_pkgs=($(. "${SVNREPO}/$repo/$pkgbase/PKGBUILD"; echo ${pkgname[@]})) + else + warning "$pkgbase not found in $svnrepo" + warning "Removing only $pkgbase from the repo" + warning "If it was a split package you have to remove the others yourself!" + remove_pkgs[${#remove_pkgs[*]}]=$pkgbase + fi +done for tarch in ${tarches[@]}; do - arch_repo_remove "${repo}" "${tarch}" ${pkgnames[@]} + arch_repo_remove "${repo}" "${tarch}" ${remove_pkgs[@]} repo_unlock $repo $tarch done diff --git a/db-repo-add b/db-repo-add index 53cfc84..b83fb77 100755 --- a/db-repo-add +++ b/db-repo-add @@ -3,14 +3,14 @@ . "$(dirname $0)/db-functions" . "$(dirname $0)/config" -if [ $# -ne 3 ]; then - msg "usage: $(basename $0) <pkgfile> <repo> <arch>" +if [ $# -lt 3 ]; then + msg "usage: $(basename $0) <repo> <arch> <pkgfile> ..." exit 1 fi -pkgfile="$1" -repo="$2" -arch="$3" +repo="$1" +arch="$2" +pkgfiles=(${@:3}) ftppath="$FTP_BASE/$repo/os" @@ -28,12 +28,14 @@ for tarch in ${tarches[@]}; do repo_lock $repo $tarch || exit 1 done -msg "Adding $pkgfile to [$repo]..." - for tarch in ${tarches[@]}; do - if [ ! -f "${pkgfile}" ]; then - die "Package file ${pkgfile} not found" - fi - arch_repo_add "${repo}" "${tarch}" ${pkgfile} + for pkgfile in ${pkgfiles[@]}; do + if [[ ! -f "${FTP_BASE}/${repo}/os/${arch}/${pkgfile##*/}" ]]; then + die "Package file ${pkgfile##*/} not found in ${FTP_BASE}/${repo}/os/${arch}/" + else + msg "Adding $pkgfile to [$repo]..." + fi + done + arch_repo_add "${repo}" "${tarch}" ${pkgfiles[@]} repo_unlock $repo $tarch done diff --git a/db-repo-remove b/db-repo-remove index b01910f..4f04ed1 100755 --- a/db-repo-remove +++ b/db-repo-remove @@ -3,14 +3,14 @@ . "$(dirname $0)/db-functions" . "$(dirname $0)/config" -if [ $# -ne 3 ]; then - msg "usage: $(basename $0) <pkgname> <repo> <arch>" +if [ $# -lt 3 ]; then + msg "usage: $(basename $0) <repo> <arch> <pkgname> ..." exit 1 fi -pkgname="$1" -repo="$2" -arch="$3" +repo="$1" +arch="$2" +pkgnames=(${@:3}) ftppath="$FTP_BASE/$repo/os" @@ -28,9 +28,10 @@ for tarch in ${tarches[@]}; do repo_lock $repo $tarch || exit 1 done -msg "Removing $pkgname from [$repo]..." - for tarch in ${tarches[@]}; do - arch_repo_remove "${repo}" "${tarch}" ${pkgname} + for pkgname in ${pkgnames[@]}; do + msg "Removing $pkgname from [$repo]..." + done + arch_repo_remove "${repo}" "${tarch}" ${pkgnames[@]} repo_unlock $repo $tarch done diff --git a/test/lib/common.inc b/test/lib/common.inc index c96e677..a2dee10 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -125,7 +125,7 @@ releasePackage() { fi } -checkAnyPackage() { +checkAnyPackageDB() { local repo=$1 local pkg=$2 local arch @@ -160,7 +160,19 @@ checkAnyPackage() { [ -r "${FTP_BASE}/${repo}/os/any/${pkg}.sig" ] && fail "${repo}/os/any/${pkg}.sig should not exist" } -checkPackage() { +checkAnyPackage() { + local repo=$1 + local pkg=$2 + + checkAnyPackageDB $repo $pkg + + local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") + 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" +} + +checkPackageDB() { local repo=$1 local pkg=$2 local arch=$3 @@ -187,6 +199,14 @@ checkPackage() { && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkg}) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done +} + +checkPackage() { + local repo=$1 + local pkg=$2 + local arch=$3 + + checkPackageDB $repo $pkg $arch local pkgbase=$(getpkgbase "${FTP_BASE}/${PKGPOOL}/${pkg}") svn up -q "${TMP}/svn-packages-copy/${pkgbase}" @@ -194,7 +214,7 @@ checkPackage() { || fail "svn-packages-copy/${pkgbase}/repos/${repo}-${arch} does not exist" } -checkRemovedPackage() { +checkRemovedPackageDB() { local repo=$1 local pkgbase=$2 local arch=$3 @@ -205,13 +225,21 @@ checkRemovedPackage() { && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q ${pkgbase}) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done +} + +checkRemovedPackage() { + local repo=$1 + local pkgbase=$2 + local arch=$3 + + checkRemovedPackageDB $repo $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" } -checkRemovedAnyPackage() { +checkRemovedAnyPackageDB() { local repo=$1 local pkgbase=$2 local arch @@ -224,6 +252,13 @@ checkRemovedAnyPackage() { && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done +} + +checkRemovedAnyPackage() { + local repo=$1 + local pkgbase=$2 + + checkRemovedAnyPackageDB $repo $pkgbase svn up -q "${TMP}/svn-packages-copy/${pkgbase}" [ -d "${TMP}/svn-packages-copy/${pkgbase}/repos/${repo}-any" ] \ diff --git a/test/test.d/create-filelists.sh b/test/test.d/create-filelists.sh index 80b0927..49734c4 100755 --- a/test/test.d/create-filelists.sh +++ b/test/test.d/create-filelists.sh @@ -88,7 +88,7 @@ testCleanupFileLists() { ../db-update for arch in ${arches[@]}; do - ../db-remove pkg-simple-a extra ${arch} + ../db-remove extra ${arch} pkg-simple-a done for arch in ${arches[@]}; do diff --git a/test/test.d/db-move.sh b/test/test.d/db-move.sh index 40b40de..9d7c1f6 100755 --- a/test/test.d/db-move.sh +++ b/test/test.d/db-move.sh @@ -27,6 +27,30 @@ testMoveSimplePackages() { 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} + done + done + + ../db-update + + ../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} + done + done +} + testMoveEpochPackages() { local arches=('i686' 'x86_64') local pkgs=('pkg-simple-epoch') diff --git a/test/test.d/db-remove.sh b/test/test.d/db-remove.sh index 573bd71..416e693 100755 --- a/test/test.d/db-remove.sh +++ b/test/test.d/db-remove.sh @@ -19,7 +19,7 @@ testRemovePackages() { for pkgbase in ${pkgs[@]}; do for arch in ${arches[@]}; do - ../db-remove ${pkgbase} extra ${arch} + ../db-remove extra ${arch} ${pkgbase} done done @@ -30,6 +30,31 @@ testRemovePackages() { 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} + done + done + + ../db-update + + for arch in ${arches[@]}; do + ../db-remove extra ${arch} ${pkgs[@]} + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkRemovedPackage extra ${pkgbase} ${arch} + done + done +} + testRemoveAnyPackages() { local pkgs=('pkg-any-a' 'pkg-any-b') local pkgbase @@ -41,7 +66,7 @@ testRemoveAnyPackages() { ../db-update for pkgbase in ${pkgs[@]}; do - ../db-remove ${pkgbase} extra any + ../db-remove extra any ${pkgbase} done for pkgbase in ${pkgs[@]}; do diff --git a/test/test.d/db-repo-add.sh b/test/test.d/db-repo-add.sh new file mode 100755 index 0000000..8603104 --- /dev/null +++ b/test/test.d/db-repo-add.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $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 + 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 + done + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; 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 + add_pkgs=() + 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 + done + ../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} + done + done +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/db-repo-remove.sh b/test/test.d/db-repo-remove.sh new file mode 100755 index 0000000..315d63d --- /dev/null +++ b/test/test.d/db-repo-remove.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +curdir=$(readlink -e $(dirname $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} + done + done + + ../db-update + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + ../db-repo-remove extra ${arch} ${pkgbase} + done + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; 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} + done + done + + ../db-update + + for arch in ${arches[@]}; do + ../db-repo-remove extra ${arch} ${pkgs[@]} + done + + for pkgbase in ${pkgs[@]}; do + for arch in ${arches[@]}; do + checkRemovedPackageDB extra ${pkgbase} ${arch} + done + done +} + +. "${curdir}/../lib/shunit2" diff --git a/test/test.d/ftpdir-cleanup.sh b/test/test.d/ftpdir-cleanup.sh index 77b02b8..20026b4 100755 --- a/test/test.d/ftpdir-cleanup.sh +++ b/test/test.d/ftpdir-cleanup.sh @@ -18,7 +18,7 @@ testCleanupSimplePackages() { ../db-update for arch in ${arches[@]}; do - ../db-remove pkg-simple-a extra ${arch} + ../db-remove extra ${arch} pkg-simple-a done ../cron-jobs/ftpdir-cleanup >/dev/null @@ -49,7 +49,7 @@ testCleanupEpochPackages() { ../db-update for arch in ${arches[@]}; do - ../db-remove pkg-simple-epoch extra ${arch} + ../db-remove extra ${arch} pkg-simple-epoch done ../cron-jobs/ftpdir-cleanup >/dev/null @@ -72,7 +72,7 @@ testCleanupAnyPackages() { done ../db-update - ../db-remove pkg-any-a extra any + ../db-remove extra any pkg-any-a ../cron-jobs/ftpdir-cleanup >/dev/null local pkg1='pkg-any-a-1-1-any.pkg.tar.xz' @@ -100,7 +100,7 @@ testCleanupSplitPackages() { ../db-update for arch in ${arches[@]}; do - ../db-remove ${pkgs[0]} extra ${arch} + ../db-remove extra ${arch} ${pkgs[0]} done ../cron-jobs/ftpdir-cleanup >/dev/null diff --git a/test/test.d/sourceballs.sh b/test/test.d/sourceballs.sh index 11bd0f4..fdcf08c 100755 --- a/test/test.d/sourceballs.sh +++ b/test/test.d/sourceballs.sh @@ -73,7 +73,7 @@ testSourceballsCleanup() { ../cron-jobs/sourceballs for arch in ${arches[@]}; do - ../db-remove pkg-simple-a extra ${arch} + ../db-remove extra ${arch} pkg-simple-a done ../cron-jobs/sourceballs |