/usr/share/pyshared/debpartial_mirror/Backend.py is in debpartial-mirror 0.3.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | # debpartial_mirror - partial debian mirror package tool
# (c) 2004 Otavio Salvador <otavio@debian.org>, Marco Presi <zufus@debian.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from cdd import FileSystem
from debpartial_mirror import Config
from debpartial_mirror import Dists
from debpartial_mirror import Files
from debpartial_mirror import Pool
class Backend:
"""
This class provides methods to create backendss dirs into the
partial-mirror
"""
backends = []
def __init__ (self, name, config):
# Store myself on list
self.backends.append(self)
self._cfg = config
self._name = name
self._filesystem = FileSystem.FileSystem(self["mirror_dir"])
def __getitem__ (self, key):
try:
item = self._cfg.get_option(key, self._name)
except Config.InvalidOption, msg:
raise Config.InvalidOption(self._name, key, "lookup")
return item
def has_key (self, key):
try:
self.__getitem__ (key)
except:
return False
else:
return True
def get_config_with_default(self, key, default):
if self.has_key(key):
return self[key]
return default
def get_binary_list (self, architecture):
"""
Return the partial binList associated to this Backend
"""
return self._dists.get_binary_list(architecture)
def get_source_list (self):
"""
Return the partial srcList associated to this Backend
"""
return self._dists.get_source_list()
def get_full_binary_list (self, architecture):
"""
Return the full binList associated to this Backend
"""
return self._dists.get_full_binary_list(architecture)
def get_full_source_list (self):
"""
Return the full srcList associated to this Backend
"""
return self._dists.get_full_source_list()
def filter(self):
return self._dists.filter()
def remove (self):
""" Remove backend """
self._pool.remove()
self._dists.remove()
def clean (self):
self._pool.clean()
class MirrorBackend(Backend):
def __init__ (self, name, config):
Backend.__init__(self, name, config)
self._dists = Dists.RemoteDists(self)
self._pool = Pool.RemotePool(self)
self._files = Files.RemoteFiles(self)
def update (self):
if not self._filesystem.exists(self._name):
self._filesystem.mkdir(self._name)
self._dists.update()
def load (self):
return self._dists.load()
def process (self):
self._dists.process()
def upgrade (self):
self._files.upgrade()
self._pool.upgrade()
if self.isIndexGenerationRequired():
self._dists.writeIndexFiles()
def isIndexGenerationRequired(self):
return self._pool.containsForeignPackages()
class MergeBackend(Backend):
def __init__ (self, name, config):
Backend.__init__(self, name, config)
self._dists = Dists.MergeDists(self)
self._pool = Pool.MergePool(self)
self._files = Files.RemoteFiles(self)
def merge (self):
self._dists.merge()
self._pool.merge()
def get_mirrors (self):
return self._dists.get_mirrors()
def get_packages_for_mirror(self, mirror, architecture):
return self._dists.get_packages_for_mirror(mirror, architecture)
|