def gpgsign(filename, repoman_settings, options): gpgcmd = repoman_settings.get("PORTAGE_GPG_SIGNING_COMMAND") if gpgcmd in [None, '']: raise MissingParameter("PORTAGE_GPG_SIGNING_COMMAND is unset!" " Is make.globals missing?") if "${PORTAGE_GPG_KEY}" in gpgcmd and \ "PORTAGE_GPG_KEY" not in repoman_settings: raise MissingParameter("PORTAGE_GPG_KEY is unset!") if "${PORTAGE_GPG_DIR}" in gpgcmd: if "PORTAGE_GPG_DIR" not in repoman_settings: repoman_settings["PORTAGE_GPG_DIR"] = \ os.path.expanduser("~/.gnupg") logging.info("Automatically setting PORTAGE_GPG_DIR to '%s'" % repoman_settings["PORTAGE_GPG_DIR"]) else: repoman_settings["PORTAGE_GPG_DIR"] = \ os.path.expanduser(repoman_settings["PORTAGE_GPG_DIR"]) if not os.access(repoman_settings["PORTAGE_GPG_DIR"], os.X_OK): raise portage.exception.InvalidLocation( "Unable to access directory: PORTAGE_GPG_DIR='%s'" % repoman_settings["PORTAGE_GPG_DIR"]) gpgvars = {"FILE": filename} for k in ("PORTAGE_GPG_DIR", "PORTAGE_GPG_KEY"): v = repoman_settings.get(k) if v is not None: gpgvars[k] = v gpgcmd = portage.util.varexpand(gpgcmd, mydict=gpgvars) if options.pretend: print("(" + gpgcmd + ")") else: # Encode unicode manually for bug #310789. gpgcmd = portage.util.shlex_split(gpgcmd) if sys.hexversion < 0x3020000 and sys.hexversion >= 0x3000000 and \ not os.path.isabs(gpgcmd[0]): # Python 3.1 _execvp throws TypeError for non-absolute executable # path passed as bytes (see https://bugs.python.org/issue8513). fullname = find_binary(gpgcmd[0]) if fullname is None: raise portage.exception.CommandNotFound(gpgcmd[0]) gpgcmd[0] = fullname gpgcmd = [ _unicode_encode(arg, encoding=_encodings['fs'], errors='strict') for arg in gpgcmd ] rValue = subprocess.call(gpgcmd) if rValue == os.EX_OK: os.rename(filename + ".asc", filename) else: raise portage.exception.PortageException("!!! gpg exited with '" + str(rValue) + "' status")
def checkIntegrity(self): for t in self.fhashdict: for f in self.fhashdict[t]: if MANIFEST2_REQUIRED_HASH not in self.fhashdict[t][f]: raise MissingParameter( _("Missing %s checksum: %s %s") % (MANIFEST2_REQUIRED_HASH, t, f))
def gpgsign(filename, repoman_settings, options): gpgcmd = repoman_settings.get("PORTAGE_GPG_SIGNING_COMMAND") if gpgcmd in [None, ""]: raise MissingParameter( "PORTAGE_GPG_SIGNING_COMMAND is unset!" " Is make.globals missing?" ) if "${PORTAGE_GPG_KEY}" in gpgcmd and "PORTAGE_GPG_KEY" not in repoman_settings: raise MissingParameter("PORTAGE_GPG_KEY is unset!") if "${PORTAGE_GPG_DIR}" in gpgcmd: if "PORTAGE_GPG_DIR" not in repoman_settings: repoman_settings["PORTAGE_GPG_DIR"] = os.path.expanduser("~/.gnupg") logging.info( "Automatically setting PORTAGE_GPG_DIR to '%s'" % repoman_settings["PORTAGE_GPG_DIR"] ) else: repoman_settings["PORTAGE_GPG_DIR"] = os.path.expanduser( repoman_settings["PORTAGE_GPG_DIR"] ) if not os.access(repoman_settings["PORTAGE_GPG_DIR"], os.X_OK): raise portage.exception.InvalidLocation( "Unable to access directory: PORTAGE_GPG_DIR='%s'" % repoman_settings["PORTAGE_GPG_DIR"] ) gpgvars = {"FILE": filename} for k in ("PORTAGE_GPG_DIR", "PORTAGE_GPG_KEY"): v = repoman_settings.get(k) if v is not None: gpgvars[k] = v gpgcmd = portage.util.varexpand(gpgcmd, mydict=gpgvars) if options.pretend: print("(" + gpgcmd + ")") else: # Encode unicode manually for bug #310789. gpgcmd = portage.util.shlex_split(gpgcmd) gpgcmd = [ _unicode_encode(arg, encoding=_encodings["fs"], errors="strict") for arg in gpgcmd ] rValue = subprocess.call(gpgcmd) if rValue == os.EX_OK: os.rename(filename + ".asc", filename) else: raise portage.exception.PortageException( "!!! gpg exited with '" + str(rValue) + "' status" )
def checkIntegrity(self): for t in self.fhashdict: for f in self.fhashdict[t]: diff = self.required_hashes.difference(set(self.fhashdict[t][f])) if diff: raise MissingParameter( _("Missing %s checksum(s): %s %s") % (" ".join(diff), t, f) )
def checkIntegrity(self): manifest_data = (( self.required_hashes.difference(set( self.fhashdict[mytype][myfile])), mytype, myfile, ) for mytype in self.fhashdict for myfile in self.fhashdict[mytype]) for needed_hashes, its_type, its_file in manifest_data: if needed_hashes: raise MissingParameter( _(f"Missing {' '.join(needed_hashes)} checksum(s): {its_type} {its_file}" ))