def check_svn(self, checkdir, checkdir_relative, xpkg): try: myf = repoman_popen("svn status --depth=files --verbose " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[:1] == "?": continue if l[:7] == ' >': # tree conflict, new in subversion 1.6 continue l = l.split()[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) try: myf = repoman_popen("svn status " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[0] == "A": l = l.rstrip().split(' ')[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) return True
def check_svn(self, checkdir, checkdir_relative, xpkg): try: myf = repoman_popen( "svn status --depth=files --verbose " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[:1] == "?": continue if l[:7] == ' >': # tree conflict, new in subversion 1.6 continue l = l.split()[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) try: myf = repoman_popen( "svn status " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[0] == "A": l = l.rstrip().split(' ')[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) return True
def check(self, checkdir, repolevel): '''Runs checks on the package metadata.xml file @param checkdir: string, path @param repolevel: integer @return boolean, False == bad metadata ''' if not self.capable: if self.options.xml_parse or repolevel == 3: print("%s sorry, xmllint is needed. failing\n" % red("!!!")) sys.exit(1) return True # xmlint can produce garbage output even on success, so only dump # the ouput when it fails. st, out = repoman_getstatusoutput( self.binary + " --nonet --noout --dtdvalid %s %s" % ( portage._shell_quote(self.metadata_dtd), portage._shell_quote( os.path.join(checkdir, "metadata.xml")))) if st != os.EX_OK: print(red("!!!") + " metadata.xml is invalid:") for z in out.splitlines(): print(red("!!! ") + z) return False return True
def check(self, checkdir, checkdir_relative, xpkg): """Perform the svn status check @param checkdir: string of the directory being checked @param checkdir_relative: string of the relative directory being checked @param xpkg: string of the package being checked @returns: boolean """ try: myf = repoman_popen("svn status --depth=files --verbose " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[:1] == "?": continue if l[:7] == " >": # tree conflict, new in subversion 1.6 continue l = l.split()[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) try: myf = repoman_popen("svn status " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[0] == "A": l = l.rstrip().split(" ")[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) return True
def thick_manifest(self, updates, headers, no_expansion, expansion): """Create a thick manifest @param updates: @param headers: @param no_expansion: @param expansion: """ headerstring = r"'\$(Header|Id).*\$'" for _file in updates: # for CVS, no_expansion contains files that are excluded from expansion if _file in no_expansion: continue _out = repoman_getstatusoutput( "egrep -q %s %s" % (headerstring, portage._shell_quote(_file)) ) if _out[0] == 0: headers.append(_file) print("%s have headers that will change." % green(str(len(headers)))) print( "* Files with headers will" " cause the manifests to be changed and committed separately." )
def thick_manifest(self, updates, headers, no_expansion, expansion): '''Create a thick manifest @param updates: @param headers: @param no_expansion: @param expansion: ''' headerstring = r"'\$(Header|Id).*\$'" for _file in updates: # for CVS, no_expansion contains files that are excluded from expansion if _file in no_expansion: continue _out = repoman_getstatusoutput( "egrep -q %s %s" % (headerstring, portage._shell_quote(_file))) if _out[0] == 0: headers.append(_file) print("%s have headers that will change." % green(str(len(headers)))) print( "* Files with headers will" " cause the manifests to be changed and committed separately.")
def _add_repo(self, config_root, portdir_overlay): self.repo_conf = portage.repository.config self.repo_name = self.repo_conf.RepoConfig._read_valid_repo_name( portdir_overlay)[0] self.layout_conf_data = self.repo_conf.parse_layout_conf( portdir_overlay)[0] if self.layout_conf_data['repo-name']: self.repo_name = self.layout_conf_data['repo-name'] tmp_conf_file = io.StringIO( textwrap.dedent(""" [%s] location = %s """) % (self.repo_name, portdir_overlay)) # Ensure that the repository corresponding to $PWD overrides a # repository of the same name referenced by the existing PORTDIR # or PORTDIR_OVERLAY settings. self.repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % ( self.repoman_settings.get( 'PORTDIR_OVERLAY', ''), portage._shell_quote(portdir_overlay)) self.repositories = self.repo_conf.load_repository_config( self.repoman_settings, extra_files=[tmp_conf_file]) # We have to call the config constructor again so that attributes # dependent on config.repositories are initialized correctly. self.repoman_settings = portage.config(config_root=config_root, local_config=False, repositories=self.repositories)
def thick_manifest(self, updates, headers, no_expansion, expansion): """Create a thick manifest @param updates: @param headers: @param no_expansion: @param expansion: """ svn_keywords = dict( (k.lower(), k) for k in [ "Rev", "Revision", "LastChangedRevision", "Date", "LastChangedDate", "Author", "LastChangedBy", "URL", "HeadURL", "Id", "Header", ] ) for _file in updates: # for SVN, expansion contains files that are included in expansion if _file not in expansion: continue # Subversion keywords are case-insensitive # in svn:keywords properties, # but case-sensitive in contents of files. enabled_keywords = [] for k in expansion[_file]: keyword = svn_keywords.get(k.lower()) if keyword is not None: enabled_keywords.append(keyword) headerstring = r"'\$(%s).*\$'" % "|".join(enabled_keywords) _out = repoman_getstatusoutput( "egrep -q %s %s" % (headerstring, portage._shell_quote(_file)) ) if _out[0] == 0: headers.append(_file) print("%s have headers that will change." % green(str(len(headers)))) print( "* Files with headers will" " cause the manifests to be changed and committed separately." )
def check(self, checkdir, checkdir_relative, xpkg): '''Perform the svn status check @param checkdir: string of the directory being checked @param checkdir_relative: string of the relative directory being checked @param xpkg: string of the package being checked @returns: boolean ''' try: myf = repoman_popen( "svn status --depth=files --verbose " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[:1] == "?": continue if l[:7] == ' >': # tree conflict, new in subversion 1.6 continue l = l.split()[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) try: myf = repoman_popen( "svn status " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[0] == "A": l = l.rstrip().split(' ')[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) return True
def check(self, checkdir, repolevel): '''Runs checks on the package metadata.xml file @param checkdir: string, path @param repolevel: integer @return boolean, False == bad metadata ''' if not self.capable: if self.options.xml_parse or repolevel == 3: print("%s sorry, xmllint is needed. failing\n" % red("!!!")) sys.exit(1) return True # xmlint can produce garbage output even on success, so only dump # the ouput when it fails. st, out = repoman_getstatusoutput( self.binary + " --nonet --noout --dtdvalid %s %s" % (portage._shell_quote(self.metadata_dtd), portage._shell_quote(os.path.join(checkdir, "metadata.xml")))) if st != os.EX_OK: print(red("!!!") + " metadata.xml is invalid:") for z in out.splitlines(): print(red("!!! ") + z) return False return True
def check_bzr(self, checkdir, checkdir_relative, xpkg): try: myf = repoman_popen("bzr ls -v --kind=file " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[1:2] == "?": continue l = l.split()[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) return True
def check_bzr(self, checkdir, checkdir_relative, xpkg): try: myf = repoman_popen( "bzr ls -v --kind=file " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[1:2] == "?": continue l = l.split()[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) return True
def check(self, checkdir, checkdir_relative, xpkg): '''Perform the git status check @param checkdir: string of the directory being checked @param checkdir_relative: string of the relative directory being checked @param xpkg: string of the package being checked @returns: boolean ''' with repoman_popen("git ls-files --others %s" % (portage._shell_quote(checkdir_relative), )) as myf: for l in myf: if l[:-1][-7:] == ".ebuild": self.qatracker.add_error( "ebuild.notadded", os.path.join(xpkg, os.path.basename(l[:-1]))) return True
def thick_manifest(self, updates, headers, no_expansion, expansion): '''Create a thick manifest @param updates: @param headers: @param no_expansion: @param expansion: ''' svn_keywords = dict((k.lower(), k) for k in [ "Rev", "Revision", "LastChangedRevision", "Date", "LastChangedDate", "Author", "LastChangedBy", "URL", "HeadURL", "Id", "Header", ]) for _file in updates: # for SVN, expansion contains files that are included in expansion if _file not in expansion: continue # Subversion keywords are case-insensitive # in svn:keywords properties, # but case-sensitive in contents of files. enabled_keywords = [] for k in expansion[_file]: keyword = svn_keywords.get(k.lower()) if keyword is not None: enabled_keywords.append(keyword) headerstring = r"'\$(%s).*\$'" % "|".join(enabled_keywords) _out = repoman_getstatusoutput( "egrep -q %s %s" % (headerstring, portage._shell_quote(_file))) if _out[0] == 0: headers.append(_file) print("%s have headers that will change." % green(str(len(headers)))) print( "* Files with headers will" " cause the manifests to be changed and committed separately.")
def check(self, checkdir, checkdir_relative, xpkg): """Perform the svn status check @param checkdir: string of the directory being checked @param checkdir_relative: string of the relative directory being checked @param xpkg: string of the package being checked @returns: boolean """ myf = repoman_popen("hg status --no-status --unknown %s" % (portage._shell_quote(checkdir_relative), )) for l in myf: if l[:-1][-7:] == ".ebuild": self.qatracker.add_error( "ebuild.notadded", os.path.join(xpkg, os.path.basename(l[:-1]))) myf.close() return True
def check(self, checkdir, checkdir_relative, xpkg): '''Perform the git status check @param checkdir: string of the directory being checked @param checkdir_relative: string of the relative directory being checked @param xpkg: string of the package being checked @returns: boolean ''' with repoman_popen( "git ls-files --others %s" % (portage._shell_quote(checkdir_relative),)) as myf: for l in myf: if l[:-1][-7:] == ".ebuild": self.qatracker.add_error( "ebuild.notadded", os.path.join(xpkg, os.path.basename(l[:-1]))) return True
def check(self, checkdir, checkdir_relative, xpkg): '''Perform the svn status check @param checkdir: string of the directory being checked @param checkdir_relative: string of the relative directory being checked @param xpkg: string of the package being checked @returns: boolean ''' myf = repoman_popen( "hg status --no-status --unknown %s" % (portage._shell_quote(checkdir_relative),)) for l in myf: if l[:-1][-7:] == ".ebuild": self.qatracker.add_error( "ebuild.notadded", os.path.join(xpkg, os.path.basename(l[:-1]))) myf.close() return True
def _add_repo(self, config_root, portdir_overlay): self.repo_conf = portage.repository.config self.repo_name = self.repo_conf._read_repo_name(portdir_overlay, quiet=True) tmp_conf_file = io.StringIO(textwrap.dedent(""" [%s] location = %s """) % (self.repo_name, portdir_overlay)) # Ensure that the repository corresponding to $PWD overrides a # repository of the same name referenced by the existing PORTDIR # or PORTDIR_OVERLAY settings. self.repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % ( self.repoman_settings.get('PORTDIR_OVERLAY', ''), portage._shell_quote(portdir_overlay)) self.repositories = self.repo_conf.load_repository_config( self.repoman_settings, extra_files=[tmp_conf_file]) # We have to call the config constructor again so that attributes # dependent on config.repositories are initialized correctly. self.repoman_settings = portage.config( config_root=config_root, local_config=False, repositories=self.repositories)
def check(self, checkdir, checkdir_relative, xpkg): '''Perform the svn status check @param checkdir: string of the directory being checked @param checkdir_relative: string of the relative directory being checked @param xpkg: string of the package being checked @returns: boolean ''' try: myf = repoman_popen("bzr ls -v --kind=file " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[1:2] == "?": continue l = l.split()[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) return True
def check(self, checkdir, checkdir_relative, xpkg): '''Perform the svn status check @param checkdir: string of the directory being checked @param checkdir_relative: string of the relative directory being checked @param xpkg: string of the package being checked @returns: boolean ''' try: myf = repoman_popen( "bzr ls -v --kind=file " + portage._shell_quote(checkdir)) myl = myf.readlines() myf.close() except IOError: raise for l in myl: if l[1:2] == "?": continue l = l.split()[-1] if l[-7:] == ".ebuild": self.eadded.append(os.path.basename(l[:-7])) return True
def check_git(self, checkdir, checkdir_relative, xpkg): myf = repoman_popen("git ls-files --others %s" % (portage._shell_quote(checkdir_relative), )) self.post_git_hg(myf, xpkg)
def check_git(self, checkdir, checkdir_relative, xpkg): myf = repoman_popen( "git ls-files --others %s" % (portage._shell_quote(checkdir_relative),)) self.post_git_hg(myf, xpkg)
def check_hg(self, checkdir, checkdir_relative, xpkg): myf = repoman_popen( "hg status --no-status --unknown %s" % (portage._shell_quote(checkdir_relative),)) self.post_git_hg(myf, xpkg)
def check_hg(self, checkdir, checkdir_relative, xpkg): myf = repoman_popen("hg status --no-status --unknown %s" % (portage._shell_quote(checkdir_relative), )) self.post_git_hg(myf, xpkg)