]>
git.ipfire.org Git - people/jschlag/pbs.git/blob - manager/repositories.py
9 from backend
.constants
import *
11 class RepositoriesUpdateEvent(base
.Event
):
16 return self
.pakfire
.settings
.get_int("repository_update_interval", 600)
19 for distro
in self
.pakfire
.distros
.get_all():
20 for repo
in distro
.repositories
:
21 # Skip repostories that do not need an update at all.
22 if not repo
.needs_update():
23 logging
.info("Repository %s - %s is already up to date." % (distro
.name
, repo
.name
))
26 e
= RepositoryUpdateEvent(self
.pakfire
, repo
.id)
27 self
.scheduler
.add_event(e
)
30 class RepositoryUpdateEvent(base
.Event
):
31 # This is an important task, but it may take a while to process.
34 def run(self
, repo_id
):
35 # Run this in a new process.
36 self
.run_subprocess_background(self
.update_repo
, repo_id
)
39 def update_repo(_pakfire
, repo_id
):
40 repo
= _pakfire
.repos
.get_by_id(repo_id
)
43 logging
.info("Going to update repository %s..." % repo
.name
)
45 # Update the timestamp when we started at last.
48 # Find out for which arches this repository is created.
51 # Add the source repository.
52 arches
.append(_pakfire
.arches
.get_by_name("src"))
57 # Get all package paths that are to be included in this repository.
58 paths
= repo
.get_paths(arch
)
60 repo_path
= os
.path
.join(
62 repo
.distro
.identifier
,
67 if not os
.path
.exists(repo_path
):
68 os
.makedirs(repo_path
)
73 for filename
in os
.listdir(repo_path
):
74 path
= os
.path
.join(repo_path
, filename
)
76 if not os
.path
.isfile(path
):
79 remove_files
.append(path
)
82 filename
= os
.path
.basename(path
)
84 source_file
= os
.path
.join(PACKAGES_DIR
, path
)
85 target_file
= os
.path
.join(repo_path
, filename
)
87 # Do not add duplicate files twice.
88 if source_file
in source_files
:
91 source_files
.append(source_file
)
94 remove_files
.remove(target_file
)
101 # If nothing in the repository data has changed, there
104 logging
.info("The repository has updates...")
106 logging
.info("Nothing to update.")
109 # Find the key to sign the package.
112 key_id
= repo
.key
.fingerprint
114 # Create package index.
115 p
= pakfire
.PakfireServer(arch
=arch
.name
)
117 p
.repo_create(repo_path
, source_files
,
118 name
="%s - %s.%s" % (repo
.distro
.name
, repo
.name
, arch
.name
),
121 # Remove files afterwards.
122 for file in remove_files
:
123 file = os
.path
.join(repo_path
, file)
128 logging
.warning("Could not remove %s." % file)