# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-import sys, os, config, string, urllib, re
+import os, config, string, urllib, re
from common import fileexists, noarchcachedir
from baseftptree import BasePkg, BaseFtpTree
errnum=0
+SomeError="Oh no"
+
def bailoutonerror():
if not errnum == 0:
print "%d error(s) encountered... aborting" % errnum
- sys.exit(1)
+ raise SomeError
def pinfo(msg):
print msg
def perror(msg):
global errnum
errnum=errnum+1
- print msg
+ print 'ERR: ' + msg
+
+def pwarning(msg):
+ print 'WARN: ' + msg
def rm(file):
os.remove(file)
if loadall:
for pkgname in self.pkgnames:
self.loadedpkgs[pkgname]=Pkg(pkgname, self)
+ # Tests:
+ self.do_checkbuild=True
def __getitem__(self, key):
if self.loadedpkgs.has_key(key):
return pkg
else:
raise KeyError, key
+
def has_key(self, key):
if key in self.pkgnames:
return True
else:
return False
+
def keys(self):
return self.pkgnames
self.__checkarchs(dsttree)
def movepkgs(self, dsttree):
- self.__checkbuild()
+ if self.do_checkbuild:
+ self.__checkbuild()
bailoutonerror()
self.__checkarchs(dsttree)
bailoutonerror()
self.loadedpkgs[pkgname]=Pkg(pkgname, self)
markfunction(self.loadedpkgs[pkgname])
else:
- perror(pkgname+" was not found in source tree")
+ perror('%s not found in source tree' % pkgname)
bailoutonerror()
def __checkbuild(self):
for pkg in self.marked4moving:
for bid in pkg.build.keys():
if requests.has_key(bid) and not requests[bid].find('?') == -1:
- perror("Building of package %s (buildid %s) not finished" % (pkg,bid))
+ perror("%s (buildid %s) building not finished" % (pkg,bid))
def __checkarchs(self, dsttree):
for pkg in self.marked4moving:
+ if len(pkg.files.keys()) <= 1:
+ perror('%s has only src.rpm built' % pkg)
+ continue
otherpkgnames=self.__find_other_pkgs(pkg, dsttree)
- curarchs=[]
- missingarchs=[]
- for somepkg in otherpkgnames:
- curarchs.extend(Pkg(somepkg, dsttree).files.keys())
- for arch in curarchs:
- if arch not in pkg.files.keys():
- missingarchs.append(arch)
- if missingarchs:
- perror('Moving %s would remove archs: %s' % (pkg, missingarchs))
+ if otherpkgnames: # check if we're not removing some archs
+ curarchs=[]
+ missingarchs=[]
+ for somepkg in otherpkgnames:
+ curarchs.extend(Pkg(somepkg, dsttree).files.keys())
+ for arch in curarchs:
+ if arch not in pkg.files.keys():
+ missingarchs.append(arch)
+ if missingarchs:
+ perror('%s moving would remove archs: %s' %
+ (pkg, missingarchs))
+ else: # warn if a package isn't built for all archs
+ if (config.separate_noarch and 'noarch' in pkg.files.keys() and
+ len(pkg.files.keys())==2):
+ continue
+ elif len(pkg.files.keys()) != len(config.ftp_archs)+1:
+ missingarchs=[]
+ for arch in config.ftp_archs:
+ if arch not in pkg.files.keys():
+ missingarchs.append(arch)
+ pwarning('%s not built for archs: %s' %
+ (pkg, missingarchs))
def __rmolderfromsrc(self):
for pkg in self.marked4moving:
# Used more than once filter functions
def __find_other_pkgs(self, pkg, tree):
- ziewre=re.compile(string.join(pkg.name.split('-')[:-2], '-')+'-[^-]*-[^-]*$')
+ pkgname=string.join(pkg.name.split('-')[:-2], '-')
+ escapedpkgname=pkgname.replace('.', '\.').replace('+', '\+')
+ ziewre=re.compile(escapedpkgname+'-[^-]*-[^-]*$')
def filter_other_pkgs(x):
if ziewre.match(x) and not x == pkg.name:
return True