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 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 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 git_supports_gpg_sign(): status, cmd_output = \ repoman_getstatusoutput("git --version") cmd_output = cmd_output.split() if cmd_output: version = re.match(r'^(\d+)\.(\d+)\.(\d+)', cmd_output[-1]) if version is not None: version = [int(x) for x in version.groups()] if version[0] > 1 or \ (version[0] == 1 and version[1] > 7) or \ (version[0] == 1 and version[1] == 7 and version[2] >= 9): return True return False
def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): if self.vcs_settings.vcs == 'cvs': headerstring = "'\$(Header|Id).*\$'" elif self.vcs_settings.vcs == "svn": svn_keywords = dict((k.lower(), k) for k in [ "Rev", "Revision", "LastChangedRevision", "Date", "LastChangedDate", "Author", "LastChangedBy", "URL", "HeadURL", "Id", "Header", ]) for myfile in myupdates: # for CVS, no_expansion contains files that are excluded from expansion if self.vcs_settings.vcs == "cvs": if myfile in no_expansion: continue # for SVN, expansion contains files that are included in expansion elif self.vcs_settings.vcs == "svn": if myfile 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[myfile]: keyword = svn_keywords.get(k.lower()) if keyword is not None: enabled_keywords.append(keyword) headerstring = "'\$(%s).*\$'" % "|".join(enabled_keywords) myout = repoman_getstatusoutput( "egrep -q %s %s" % (headerstring, portage._shell_quote(myfile))) if myout[0] == 0: myheaders.append(myfile) print("%s have headers that will change." % green(str(len(myheaders)))) print("* Files with headers will" " cause the manifests to be changed and committed separately.")
def thick_manifest(self, myupdates, myheaders, no_expansion, expansion): if self.vcs_settings.vcs == 'cvs': headerstring = "'\$(Header|Id).*\$'" elif self.vcs_settings.vcs == "svn": svn_keywords = dict((k.lower(), k) for k in [ "Rev", "Revision", "LastChangedRevision", "Date", "LastChangedDate", "Author", "LastChangedBy", "URL", "HeadURL", "Id", "Header", ]) for myfile in myupdates: # for CVS, no_expansion contains files that are excluded from expansion if self.vcs_settings.vcs == "cvs": if myfile in no_expansion: continue # for SVN, expansion contains files that are included in expansion elif self.vcs_settings.vcs == "svn": if myfile 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[myfile]: keyword = svn_keywords.get(k.lower()) if keyword is not None: enabled_keywords.append(keyword) headerstring = "'\$(%s).*\$'" % "|".join(enabled_keywords) myout = repoman_getstatusoutput( "egrep -q %s %s" % (headerstring, portage._shell_quote(myfile))) if myout[0] == 0: myheaders.append(myfile) print("%s have headers that will change." % green(str(len(myheaders)))) print( "* Files with headers will" " cause the manifests to be changed and committed separately.")
def supports_gpg_sign(): """Does this vcs system support gpg commit signatures @returns: Boolean """ status, cmd_output = repoman_getstatusoutput("git --version") cmd_output = cmd_output.split() if cmd_output: version = re.match(r"^(\d+)\.(\d+)\.(\d+)", cmd_output[-1]) if version is not None: version = [int(x) for x in version.groups()] if (version[0] > 1 or (version[0] == 1 and version[1] > 7) or (version[0] == 1 and version[1] == 7 and version[2] >= 9)): return True return False
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 supports_gpg_sign(): '''Does this vcs system support gpg commit signatures @returns: Boolean ''' status, cmd_output = \ repoman_getstatusoutput("git --version") cmd_output = cmd_output.split() if cmd_output: version = re.match(r'^(\d+)\.(\d+)\.(\d+)', cmd_output[-1]) if version is not None: version = [int(x) for x in version.groups()] if version[0] > 1 or \ (version[0] == 1 and version[1] > 7) or \ (version[0] == 1 and version[1] == 7 and version[2] >= 9): return True return False
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