[arch-dev-public] [PATCH 1/2] check_packages : add support for split packages.
I just found a way to support split packages, by using $(type package_${pkg}), parsing that output and running eval on the relevant lines. This is a bit ugly, and while it works fine on my machine and my current abs tree, I cannot guarantee this code is bug free :) Signed-off-by: Xavier Chantry <shiningxc@gmail.com> --- cron-jobs/check_archlinux/check_packages.py | 5 +- cron-jobs/check_archlinux/parse_pkgbuilds.sh | 82 +++++++++++++++++++++---- 2 files changed, 73 insertions(+), 14 deletions(-) diff --git a/cron-jobs/check_archlinux/check_packages.py b/cron-jobs/check_archlinux/check_packages.py index 9bdd9c1..d42feab 100755 --- a/cron-jobs/check_archlinux/check_packages.py +++ b/cron-jobs/check_archlinux/check_packages.py @@ -38,6 +38,7 @@ checked_deps = [] class PacmanPackage: def __init__(self): self.name,self.version = "","" + self.base = "" self.path,self.repo = "","" self.deps,self.makedeps = [],[] self.provides,self.conflicts = [],[] @@ -77,6 +78,8 @@ def parse_data(repo,data): if packages.has_key(pkg.name): dup = packages[pkg.name] packages[pkg.name] = pkg + elif attrname == "base": + pkg.base = line elif attrname == "version": pkg.version = line elif attrname == "path": @@ -356,7 +359,7 @@ for name,pkg in packages.iteritems(): print "==> checking mismatches" for name,pkg in repopkgs.iteritems(): pkgdirname = pkg.path.split("/")[-1] - if name != pkgdirname: + if name != pkgdirname and pkg.base != pkgdirname: mismatches.append(name + " vs. " + pkg.path) print "==> checking archs" diff --git a/cron-jobs/check_archlinux/parse_pkgbuilds.sh b/cron-jobs/check_archlinux/parse_pkgbuilds.sh index 7dcfbbb..0faa29f 100755 --- a/cron-jobs/check_archlinux/parse_pkgbuilds.sh +++ b/cron-jobs/check_archlinux/parse_pkgbuilds.sh @@ -5,24 +5,36 @@ exit() { return; } -parse() { - unset pkgname pkgver pkgrel - unset depends makedepends conflicts provides - ret=0 - dir=$1 - pkgbuild=$dir/PKGBUILD - source $pkgbuild &>/dev/null || ret=$? +variables=('pkgname' 'pkgver' 'pkgrel' 'depends' 'makedepends' 'provides' 'conflicts' ) +readonly -a variables - # ensure $pkgname and $pkgver variables were found - if [ $ret -ne 0 -o -z "$pkgname" -o -z "$pkgver" ]; then - echo -e "%INVALID%\n$pkgbuild\n" - return 1 - fi +backup_package_variables() { + for var in ${variables[@]}; do + indirect="${var}_backup" + eval "${indirect}=(\${$var[@]})" + done +} + +restore_package_variables() { + for var in ${variables[@]}; do + indirect="${var}_backup" + if [ -n "${!indirect}" ]; then + eval "${var}=(\${$indirect[@]})" + else + unset ${var} + fi + done +} +print_info() { echo -e "%NAME%\n$pkgname\n" echo -e "%VERSION%\n$pkgver-$pkgrel\n" echo -e "%PATH%\n$dir\n" + if [ -n "$pkgbase" ]; then + echo -e "%BASE%\n$pkgbase\n" + fi + if [ -n "$arch" ]; then echo "%ARCH%" for i in ${arch[@]}; do echo $i; done @@ -52,6 +64,50 @@ parse() { for i in ${provides[@]}; do echo $i; done echo "" fi +} + +source_pkgbuild() { + ret=0 + dir=$1 + pkgbuild=$dir/PKGBUILD + for var in ${variables[@]}; do + unset ${var} + done + source $pkgbuild &>/dev/null || ret=$? + + # ensure $pkgname and $pkgver variables were found + if [ $ret -ne 0 -o -z "$pkgname" -o -z "$pkgver" ]; then + echo -e "%INVALID%\n$pkgbuild\n" + return 1 + fi + + if [ "${#pkgname[@]}" -gt "1" ]; then + for pkg in ${pkgname[@]}; do + if [ "$(type -t package_${pkg})" != "function" ]; then + echo -e "%INVALID%\n$pkgbuild\n" + return 1 + else + backup_package_variables + pkgname=$pkg + while IFS= read -r line; do + var=${line%%=*} + var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters + for realvar in ${variables[@]}; do + if [ "$var" == "$realvar" ]; then + eval $line + break + fi + done + done < <(type package_${pkg}) + print_info + restore_package_variables + fi + done + else + echo + print_info + fi + return 0 } @@ -63,7 +119,7 @@ find_pkgbuilds() { fi if [ -f $1/PKGBUILD ]; then - parse $1 + source_pkgbuild $1 return fi empty=1 -- 1.6.4.1
This should help a lot figuring out whether a given hierarchy problem is fixable (if it doesn't require moving too many deps). example output core/crda depends on extra/python-m2crypto (27 extra (make)deps to pull) core/iputils depends on extra/opensp (29 extra (make)deps to pull) core/iputils depends on extra/libxslt (25 extra (make)deps to pull) core/iputils depends on extra/docbook-xsl (27 extra (make)deps to pull) core/udev depends on extra/gperf (0 extra (make)deps to pull) core/udev depends on extra/libxslt (25 extra (make)deps to pull) core/e2fsprogs depends on extra/bc (0 extra (make)deps to pull) core/sqlite3 depends on extra/tcl (0 extra (make)deps to pull) core/ca-certificates depends on extra/ruby (25 extra (make)deps to pull) the actual deps are only displayed when there are less than 10. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> --- cron-jobs/check_archlinux/check_packages.py | 50 +++++++++++++++++++++++++-- 1 files changed, 47 insertions(+), 3 deletions(-) diff --git a/cron-jobs/check_archlinux/check_packages.py b/cron-jobs/check_archlinux/check_packages.py index d42feab..f2a9601 100755 --- a/cron-jobs/check_archlinux/check_packages.py +++ b/cron-jobs/check_archlinux/check_packages.py @@ -182,11 +182,50 @@ def verify_deps(name,repo,deps): break if not pkgdep: pkgdep = pkglist[0] - hierarchy.append(repo + "/" + name + " depends on " + pkgdep.repo + "/" + pkgdep.name) + hierarchy.append((repo,name,pkgdep)) + pkg_deps.append(pkgdep) return (pkg_deps,missdeps,hierarchy) +def compute_deplist_aux(pkg,deplist): + newdeplist = [] + list = [] + if pkgdeps.has_key(pkg): + list.extend(pkgdeps[pkg]) + if makepkgdeps.has_key(pkg): + list.extend(makepkgdeps[pkg]) + for dep in list: + if dep not in deplist: + newdeplist.append(dep) + deplist.append(dep) + for dep in newdeplist: + deplist2 = compute_deplist_aux(dep,deplist) + for dep2 in deplist2: + if dep2 not in deplist: + deplist.append(dep2) + return deplist + +def compute_deplist(pkg): + return compute_deplist_aux(pkg,[]) + +def check_hierarchy(deph): + hierarchy = [] + for (repo,name,pkgdep) in deph: + deplist = compute_deplist(pkgdep) + valid_repos = get_repo_hierarchy(repo) + extdeps = [] + for dep in deplist: + if dep.repo not in valid_repos: + extdeps.append(dep.name) + string = repo + "/" + name + " depends on " + pkgdep.repo + "/" + pkgdep.name + " (" + string += "%s extra (make)deps to pull" % len(extdeps) + if 0 < len(extdeps) < 10: + string += " : " + ' '.join(extdeps) + string += ")" + hierarchy.append(string) + return hierarchy + def get_repo_hierarchy(repo): repo_hierarchy = {'core': ['core'], \ 'extra': ['core', 'extra'], \ @@ -373,19 +412,24 @@ for name,pkg in packages.iteritems(): pkg.deps = [dep for dep in pkg.deps if not p.match(dep)] pkg.makedeps = [dep for dep in pkg.makedeps if not p.match(dep)] +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) - dep_hierarchy.extend(hierarchy) + 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) - makedep_hierarchy.extend(hierarchy) + makedeph.extend(hierarchy) + +dep_hierarchy = check_hierarchy(deph) +makedep_hierarchy = check_hierarchy(makedeph) print "==> checking for circular dependencies" # make sure pkgdeps is filled for every package -- 1.6.4.1
participants (1)
-
Xavier Chantry