+ def remaster(self):
+ log.info("Going to update repository %s..." % self.name)
+
+ # Update the timestamp when we started at last.
+ self.updated()
+
+ for arch in self.arches:
+ changed = False
+
+ # Get all package paths that are to be included in this repository.
+ paths = self.get_paths(arch)
+
+ repo_path = os.path.join(
+ REPOS_DIR,
+ self.distro.identifier,
+ self.identifier,
+ arch
+ )
+
+ if not os.path.exists(repo_path):
+ os.makedirs(repo_path)
+
+ source_files = []
+ remove_files = []
+
+ for filename in os.listdir(repo_path):
+ path = os.path.join(repo_path, filename)
+
+ if not os.path.isfile(path):
+ continue
+
+ remove_files.append(path)
+
+ for path in paths:
+ filename = os.path.basename(path)
+
+ source_file = os.path.join(PACKAGES_DIR, path)
+ target_file = os.path.join(repo_path, filename)
+
+ # Do not add duplicate files twice.
+ if source_file in source_files:
+ continue
+
+ source_files.append(source_file)
+
+ try:
+ remove_files.remove(target_file)
+ except ValueError:
+ changed = True
+
+ if remove_files:
+ changed = True
+
+ # If nothing in the repository data has changed, there
+ # is nothing to do.
+ if changed:
+ log.info("The repository has updates...")
+ else:
+ log.info("Nothing to update.")
+ continue
+
+ # Find the key to sign the package.
+ key_id = None
+ if repo.key:
+ key_id = self.key.fingerprint
+
+ # Create package index.
+ p = pakfire.PakfireServer(arch=arch)
+
+ p.repo_create(repo_path, source_files,
+ name="%s - %s.%s" % (self.distro.name, self.name, arch),
+ key_id=key_id)
+
+ # Remove files afterwards.
+ for file in remove_files:
+ file = os.path.join(repo_path, file)
+
+ try:
+ os.remove(file)
+ except OSError:
+ log.warning("Could not remove %s." % file)
+