self.not_installed = []
self.invalid_category = []
self.okay = []
+ from portage.sets import make_default_config
+ setconfig = make_default_config(portage.settings,
+ portage.db[portage.settings["ROOT"]])
+ self._sets = setconfig.getSetsWithAliases()
def _check_world(self, onProgress):
categories = set(portage.settings.categories)
self.found = os.access(self.world_file, os.R_OK)
vardb = portage.db[myroot]["vartree"].dbapi
- world_atoms = open(self.world_file).read().split()
+ from portage.sets import SETPREFIX
+ sets = self._sets
+ world_atoms = list(sets["world"])
maxval = len(world_atoms)
if onProgress:
onProgress(maxval, 0)
for i, atom in enumerate(world_atoms):
if not portage.isvalidatom(atom):
- self.invalid.append(atom)
+ if atom.startswith(SETPREFIX):
+ s = atom[len(SETPREFIX):]
+ if s in sets:
+ self.okay.append(atom)
+ else:
+ self.not_installed.append(atom)
+ else:
+ self.invalid.append(atom)
if onProgress:
onProgress(maxval, i+1)
continue
return errors
def fix(self, onProgress=None):
- self._check_world(onProgress)
- errors = []
+ world_set = self._sets["world"]
+ world_set.lock()
try:
- portage.write_atomic(self.world_file,
- "\n".join(sorted(self.okay)) + "\n")
- except portage.exception.PortageException:
- errors.append(self.world_file + " could not be opened for writing")
- return errors
+ world_set.load() # maybe it's changed on disk
+ before = set(world_set)
+ self._check_world(onProgress)
+ after = set(self.okay)
+ errors = []
+ if before != after:
+ try:
+ world_set.replace(self.okay)
+ except portage.exception.PortageException:
+ errors.append("%s could not be opened for writing" % \
+ self.world_file)
+ return errors
+ finally:
+ world_set.unlock()
class BinhostHandler(object):
from repoman.checks import EbuildWhitespace, EbuildHeader, EbuildQuote, \
EbuildAssignment, EbuildNestedDie, EbuildUselessDodoc, EbuildUselessCdS
-try:
- import cStringIO as StringIO
-except ImportError:
- import StringIO
-
import portage.checksum
import portage.const
import portage.dep
# Syntax Checks
path = checkdir + '/' + y + '.ebuild'
myear = time.gmtime(os.stat(path)[ST_MTIME])[0]
- contents = StringIO.StringIO(open(path, 'rb').read())
+ f = open(path, 'rb')
+ try:
+ contents = f.readlines()
+ finally:
+ f.close()
+ del f
for check in (EbuildWhitespace, EbuildQuote,
EbuildAssignment, EbuildUselessDodoc, EbuildUselessCdS):
c = check(contents)
for e in errors:
stats[c.repoman_check_name] += 1
fails[c.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e[1] % e[0])
- contents.seek(0) # move fp to the beginning of the StringIO Object
del check
check = EbuildHeader(contents, str(myear))
errors = check.Run()
for e in errors:
stats[check.repoman_check_name] += 1
fails[check.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e[1] % e[0])
- contents.seek(0)
del check
check = EbuildNestedDie(contents)
errors = check.Run()
for e in errors:
stats[check.repoman_check_name] += 1
- fails[check.repoman_check_name].append(x + '/' + y + '.ebuild: %s' % e)
+ fails[check.repoman_check_name].append(
+ x + '/' + y + '.ebuild: %s' % e[1] % e[0])
del check, errors, path, contents, myear
if options.force:
metadata["DESC"] = metadata["DESCRIPTION"]
del metadata["DESCRIPTION"]
use = metadata["USE"].split()
+ raw_use = use
iuse = set(metadata["IUSE"].split())
use = [f for f in use if f in iuse]
use.sort()
for k in "LICENSE", "RDEPEND", "DEPEND", "PDEPEND", "PROVIDE":
try:
deps = paren_reduce(metadata[k])
- deps = use_reduce(deps, uselist=use)
+ deps = use_reduce(deps, uselist=raw_use)
deps = paren_normalize(deps)
deps = paren_enclose(deps)
except portage.exception.InvalidDependString, e:
writemsg("\nInvalid ebuild name: %s\n" % \
os.path.join(oroot, mycp, x), noiselevel=-1)
continue
+ if ps[0] != mysplit[1]:
+ writemsg("\nInvalid ebuild name: %s\n" % \
+ os.path.join(oroot, mycp, x), noiselevel=-1)
+ continue
d[mysplit[0]+"/"+pf] = None
if invalid_category and d:
writemsg(("\n!!! '%s' has a category that is not listed in " + \
self.__init__(self.pkgdir, self.distdir,
fetchlist_dict=self.fetchlist_dict, from_scratch=True,
manifest1_compat=self.compat)
+ cpvlist = []
+ pn = os.path.basename(self.pkgdir.rstrip(os.path.sep))
+ cat = self._pkgdir_category()
for pkgdir, pkgdir_dirs, pkgdir_files in os.walk(self.pkgdir):
break
for f in pkgdir_files:
if f.endswith(".ebuild"):
mytype = "EBUILD"
+ pf = f[:-7]
+ ps = portage.versions.pkgsplit(pf)
+ cpv = "%s/%s" % (cat, pf)
+ if not ps:
+ raise PortagePackageException(
+ "Invalid package name: '%s'" % cpv)
+ if ps[0] != pn:
+ raise PortagePackageException(
+ "Package name does not " + \
+ "match directory name: '%s'" % cpv)
+ cpvlist.append(cpv)
elif manifest2MiscfileFilter(f):
mytype = "MISC"
else:
continue
self.fhashdict["AUX"][f] = perform_multiple_checksums(
os.path.join(self.pkgdir, "files", f.lstrip(os.sep)), self.hashes)
- cpvlist = [os.path.join(self._pkgdir_category(), x[:-7]) for x in os.listdir(self.pkgdir) if x.endswith(".ebuild")]
distlist = set()
for cpv in cpvlist:
distlist.update(self._getCpvDistfiles(cpv))
def _setAtoms(self, atoms):
atoms = map(str.strip, atoms)
- nonatoms = set()
+ self._nonatoms.clear()
for a in atoms[:]:
if a == "":
atoms.remove(a)
TRAILING_WHITESPACE_ERROR = 'Trailing whitespace error on line: %d'
READONLY_ASSIGNMENT_ERROR = 'Ebuild contains assignment to read-only variable on line: %d'
MISSING_QUOTES_ERROR = 'Unquoted Variable on line: %d'
-NESTED_DIE_ERROR = 'Ebuild calls die in a subshell'
+NESTED_DIE_ERROR = 'Ebuild calls die in a subshell on line: %d'
REDUNDANT_CD_S_ERROR = 'Ebuild has redundant cd ${S} statement on line: %d'