]>
git.ipfire.org Git - people/stevee/pakfire.git/blob - src/pakfire/repository/base.py
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 ###############################################################################
23 log
= logging
.getLogger("pakfire")
27 import pakfire
.packages
as packages
28 import pakfire
.satsolver
as satsolver
30 class RepositoryFactory(object):
31 def __init__(self
, pakfire
, name
, description
):
32 self
.pakfire
= pakfire
34 self
.description
= description
36 # Reference to corresponding Repo object in the solver.
37 self
.solver_repo
= satsolver
.Repo(self
.pool
, self
.name
)
38 self
.solver_repo
.set_priority(self
.priority
)
40 # Some repositories may have a cache.
43 log
.debug("Initialized new repository: %s" % self
)
45 # Create an index (in memory).
46 self
.index
= index
.Index(self
.pakfire
, self
)
48 # Marks if this repository has been opened.
52 return "<%s %s>" % (self
.__class
__.__name
__, self
.name
)
54 def __cmp__(self
, other
):
55 return cmp(self
.priority
* -1, other
.priority
* -1) or \
56 cmp(self
.name
, other
.name
)
59 return self
.solver_repo
.size()
64 for solv
in self
.solver_repo
.get_all():
65 pkg
= packages
.SolvPackage(self
.pakfire
, solv
, self
)
72 return self
.pakfire
.pool
74 def get_enabled(self
):
75 return self
.solver_repo
.get_enabled()
77 def set_enabled(self
, val
):
78 self
.solver_repo
.set_enabled(val
)
81 log
.debug("Enabled repository '%s'." % self
.name
)
83 log
.debug("Disabled repository '%s'." % self
.name
)
85 enabled
= property(get_enabled
, set_enabled
)
89 return self
.pakfire
.distro
.arch
94 Link to distro object.
96 return self
.pakfire
.distro
100 raise NotImplementedError
105 Say if a repository is a local one or remotely located.
107 Used to check if we need to download files.
113 Opens the repository, so we can work with the data.
119 Close and delete all resources that are used by this repository.
125 Cleanup all temporary files of this repository.
127 log
.info("Cleaning up repository '%s'..." % self
.name
)
129 # Clear all packages in the index.
132 def dump(self
, long=False, filelist
=False):
134 # Dump all package information of the packages in this repository.
136 dump
= pkg
.dump(long=long, filelist
=filelist
)
139 return "\n\n".join(dumps
)
141 def get_config(self
):
143 Return the configuration as a list of string which
144 can be written to a configuration file.
149 class RepositoryDummy(RepositoryFactory
):
151 Just a dummy repository that actually does nothing.
153 def __init__(self
, pakfire
):
154 RepositoryFactory
.__init
__(self
, pakfire
, "dummy",
155 "This is a dummy repository.")
159 # This will never be used in the solving process, but still it needs