]>
git.ipfire.org Git - pakfire.git/blob - pakfire/repository/base.py
241fc3ec03709452ef28ff8f72d237d43a38ddc3
2 ###############################################################################
4 # Pakfire - The IPFire package management system #
5 # Copyright (C) 2011 Pakfire development team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
28 import pakfire
.packages
as packages
29 import pakfire
.satsolver
as satsolver
31 class RepositoryFactory(object):
32 def __init__(self
, pakfire
, name
, description
):
33 self
.pakfire
= pakfire
35 self
.description
= description
37 # Reference to corresponding Repo object in the solver.
38 self
.solver_repo
= satsolver
.Repo(self
.pool
, self
.name
)
39 self
.solver_repo
.set_priority(self
.priority
)
41 logging
.debug("Initialized new repository: %s" % self
)
43 # Create an cache object
44 self
.cache
= cache
.RepositoryCache(self
.pakfire
, self
)
46 # The index MUST be set by an inheriting class.
50 return "<%s %s>" % (self
.__class
__.__name
__, self
.name
)
52 def __cmp__(self
, other
):
53 return cmp(self
.priority
* -1, other
.priority
* -1) or \
54 cmp(self
.name
, other
.name
)
57 return self
.solver_repo
.size()
62 for solv
in self
.solver_repo
.get_all():
63 pkg
= packages
.SolvPackage(self
.pakfire
, solv
, self
)
70 return self
.pakfire
.pool
72 def get_enabled(self
):
73 return self
.solver_repo
.get_enabled()
75 def set_enabled(self
, val
):
76 self
.solver_repo
.set_enabled(val
)
79 logging
.debug("Enabled repository '%s'." % self
.name
)
81 logging
.debug("Disabled repository '%s'." % self
.name
)
83 enabled
= property(get_enabled
, set_enabled
)
87 return self
.pakfire
.distro
.arch
92 Link to distro object.
94 return self
.pakfire
.distro
98 raise NotImplementedError
103 Say if a repository is a local one or remotely located.
105 Used to check if we need to download files.
109 def update(self
, force
=False, offline
=False):
111 A function that is called to update the local data of
116 self
.index
.update(force
, offline
=offline
)
120 Cleanup all temporary files of this repository.
122 logging
.info("Cleaning up repository '%s'..." % self
.name
)
128 def dump(self
, long=False, filelist
=False):
130 # Dump all package information of the packages in this repository.
132 dump
= pkg
.dump(long=long, filelist
=filelist
)
135 return "\n\n".join(dumps
)
138 class RepositoryDummy(RepositoryFactory
):
140 Just a dummy repository that actually does nothing.
142 def __init__(self
, pakfire
):
143 RepositoryFactory
.__init
__(self
, pakfire
, "dummy",
144 "This is a dummy repository.")
148 # This will never be used in the solving process, but still it needs