Esempio n. 1
0
    def sign_packages(self, keyfp=None):
        # Do nothing if signing is not requested.
        if not self.settings.get("sign_packages"):
            return

        # Get key, that should be used for signing.
        if not keyfp:
            keyfp = self.keyring.get_host_key_id()

        # Find all files to process.
        files = self.find_result_packages()

        # Create a progressbar.
        print _("Signing packages...")
        p = util.make_progress(keyfp, len(files))
        i = 0

        for file in files:
            # Update progressbar.
            if p:
                i += 1
                p.update(i)

            # Open package file.
            pkg = packages.open(self.pakfire, None, file)

            # Sign it.
            pkg.sign(keyfp)

        # Close progressbar.
        if p:
            p.finish()
            print ""  # Print an empty line.
Esempio n. 2
0
	def handle_extract(self):
		p = self.create_pakfire()

		# Open all packages.
		pkgs = []
		for pkg in self.args.package:
			pkg = packages.open(self, None, pkg)
			pkgs.append(pkg)

		target_prefix = self.args.target

		# Search for binary packages.
		binary_packages = any([p.type == "binary" for p in pkgs])
		source_packages = any([p.type == "source" for p in pkgs])

		if binary_packages and source_packages:
			raise Error, _("Cannot extract mixed package types")

		if binary_packages and not target_prefix:
			raise Error, _("You must provide an install directory with --target=...")

		elif source_packages and not target_prefix:
			target_prefix = "/usr/src/packages/"

		if target_prefix == "/":
			raise Error, _("Cannot extract to /.")

		for pkg in pkgs:
			if pkg.type == "binary":
				target_dir = target_prefix
			elif pkg.type == "source":
				target_dir = os.path.join(target_prefix, pkg.friendly_name)

			pkg.extract(message=_("Extracting"), prefix=target_dir)
Esempio n. 3
0
    def info(self, patterns):
        # Initialize this pakfire instance.
        self.initialize()

        pkgs = []

        # For all patterns we run a single search which returns us a bunch
        # of solvables which are transformed into Package objects.
        for pattern in patterns:
            if os.path.exists(pattern) and not os.path.isdir(pattern):
                pkg = packages.open(self, self.repos.dummy, pattern)
                if pkg:
                    pkgs.append(pkg)

            else:
                solvs = self.pool.search(pattern, satsolver.SEARCH_GLOB,
                                         "solvable:name")

                for solv in solvs:
                    pkg = packages.SolvPackage(self, solv)
                    if pkg in pkgs:
                        continue

                    pkgs.append(pkg)

        return sorted(pkgs)
Esempio n. 4
0
	def info(self, patterns):
		# Initialize this pakfire instance.
		self.initialize()

		pkgs = []

		# For all patterns we run a single search which returns us a bunch
		# of solvables which are transformed into Package objects.
		for pattern in patterns:
			if os.path.exists(pattern) and not os.path.isdir(pattern):
				pkg = packages.open(self, self.repos.dummy, pattern)
				if pkg:
					pkgs.append(pkg)

			else:
				solvs = self.pool.search(pattern, satsolver.SEARCH_GLOB, "solvable:name")

				for solv in solvs:
					pkg = packages.SolvPackage(self, solv)
					if pkg in pkgs:
						continue

					pkgs.append(pkg)

		return sorted(pkgs)
Esempio n. 5
0
    def sign_packages(self, keyfp=None):
        # Do nothing if signing is not requested.
        if not self.settings.get("sign_packages"):
            return

            # Get key, that should be used for signing.
        if not keyfp:
            keyfp = self.keyring.get_host_key_id()

            # Find all files to process.
        files = self.find_result_packages()

        # Create a progressbar.
        print _("Signing packages...")
        p = util.make_progress(keyfp, len(files))
        i = 0

        for file in files:
            # Update progressbar.
            if p:
                i += 1
                p.update(i)

                # Open package file.
            pkg = packages.open(self.pakfire, None, file)

            # Sign it.
            pkg.sign(keyfp)

            # Close progressbar.
        if p:
            p.finish()
            print ""  # Print an empty line.
Esempio n. 6
0
    def dump(self):
        pkgs = []

        for file in self.find_result_packages():
            pkg = packages.open(self.pakfire, None, file)
            pkgs.append(pkg)

        # If there are no packages, there is nothing to do.
        if not pkgs:
            return

        pkgs.sort()

        self.log.info(_("Dumping package information:"))
        for pkg in pkgs:
            dump = pkg.dump(long=True)

            for line in dump.splitlines():
                self.log.info("  %s" % line)
            self.log.info("")  # Empty line.
Esempio n. 7
0
    def dump(self):
        pkgs = []

        for file in self.find_result_packages():
            pkg = packages.open(self.pakfire, None, file)
            pkgs.append(pkg)

            # If there are no packages, there is nothing to do.
        if not pkgs:
            return

        pkgs.sort()

        self.log.info(_("Dumping package information:"))
        for pkg in pkgs:
            dump = pkg.dump(long=True)

            for line in dump.splitlines():
                self.log.info("  %s" % line)
            self.log.info("")  # Empty line.
Esempio n. 8
0
	def handle_verify(self):
		# Get the files from the command line options
		files = []

		for file in self.args.package:
			# Check, if we got a regular file
			if os.path.exists(file) and not os.path.isdir(file):
				file = os.path.abspath(file)
				files.append(file)

		# Create pakfire instance.
		p = self.create_pakfire()

		for file in files:
			# Open the package.
			pkg = packages.open(p, None, file)

			print _("Verifying %s...") % pkg.friendly_name
			sigs = pkg.verify()

			for sig in sigs:
				key = p.keyring.get_key(sig.fpr)
				if key:
					subkey = key.subkeys[0]

					print "  %s %s" % (subkey.fpr[-16:], key.uids[0].uid)
					if sig.validity:
						print "    %s" % _("This signature is valid.")

				else:
					print "  %s <%s>" % (sig.fpr, _("Unknown key"))
					print "    %s" % _("Could not check if this signature is valid.")

				created = datetime.datetime.fromtimestamp(sig.timestamp)
				print "    %s" % _("Created: %s") % created

				if sig.exp_timestamp:
					expires = datetime.datetime.fromtimestamp(sig.exp_timestamp)
					print "    %s" % _("Expires: %s") % expires

			print # Empty line
Esempio n. 9
0
	def resolvdep(self, pakfire, pkg, logger=None):
		assert os.path.exists(pkg)

		# Open the package file.
		pkg = packages.open(pakfire, None, pkg)

		# Create a new request.
		request = self.create_request(install=pkg.requires)

		# Add build dependencies if needed.
		if isinstance(pkg, packages.Makefile) or isinstance(pkg, packages.SourcePackage):
			for req in self.expand_requires(BUILD_PACKAGES):
				request.install(req)

		# Solv the request.
		solver = self.solve(request, logger=logger)

		if solver.status:
			return solver

		raise DependencyError, solver.get_problem_string()
Esempio n. 10
0
	def handle_sign(self):
		# Get the files from the command line options
		files = []

		for file in self.args.package:
			# Check, if we got a regular file
			if os.path.exists(file):
				file = os.path.abspath(file)
				files.append(file)

			else:
				raise FileNotFoundError, file

		key = self.args.key[0]

		# Create pakfire instance.
		p = self.create_pakfire()

		for file in files:
			# Open the package.
			pkg = packages.open(p, None, file)

			print _("Signing %s...") % pkg.friendly_name
			pkg.sign(key)