[apt-proxy-devel] r623 - trunk/apt_proxy
Chris Halls
halls at costa.debian.org
Mon Aug 14 12:45:37 UTC 2006
Author: halls
Date: Mon Aug 14 12:45:36 2006
New Revision: 623
Modified:
trunk/apt_proxy/packages.py
Log:
Fix apt-proxy-import
Modified: trunk/apt_proxy/packages.py
==============================================================================
--- trunk/apt_proxy/packages.py (original)
+++ trunk/apt_proxy/packages.py Mon Aug 14 12:45:36 2006
@@ -298,18 +298,18 @@
for backend in factory.backends.values():
backend.get_packages_db().cleanup()
-#def get_mirror_path(factory, file):
- #"""
- #Look for the path of 'file' in all backends.
- #"""
- #info = AptDpkgInfo(file)
- #paths = []
- #for backend in factory.backends:
- #path = backend.get_packages_db().get_mirror_path(info['Package'],
- #info['Version'])
- #if path:
- #paths.append('/'+backend.base+'/'+path)
- #return paths
+def get_mirror_path(factory, file):
+ """
+ Look for the path of 'file' in all backends.
+ """
+ info = AptDpkgInfo(file)
+ paths = []
+ for backend in factory.backends.values():
+ path = backend.get_packages_db().get_mirror_path(info['Package'],
+ info['Version'])
+ if path:
+ paths.append('/'+backend.base+'/'+path)
+ return paths
def get_mirror_versions(factory, package):
"""
@@ -354,6 +354,8 @@
This is used by apt-proxy-import to import new files
into the cache
"""
+ imported_count = 0
+
if not os.path.exists(dir):
log.err('Directory ' + dir + ' does not exist', 'import')
return
@@ -362,32 +364,34 @@
log.msg("Importing packages from directory tree: " + dir, 'import',3)
for root, dirs, files in os.walk(dir):
for file in files:
- import_file(factory, root, file)
+ imported_count += import_file(factory, root, file)
else:
log.debug("Importing packages from directory: " + dir, 'import',3)
for file in os.listdir(dir):
mode = os.stat(dir + '/' + file)[stat.ST_MODE]
if not stat.S_ISDIR(mode):
- import_file(factory, dir, file)
+ imported_count += import_file(factory, dir, file)
- for backend in factory.backends:
+ for backend in factory.backends.values():
backend.get_packages_db().unload()
-
-
+
+ log.msg("Imported %s files" % (imported_count))
+ return imported_count
+
def import_file(factory, dir, file):
"""
Import a .deb or .udeb into cache from given filename
"""
if file[-4:]!='.deb' and file[-5:]!='.udeb':
log.msg("Ignoring (unknown file type):"+ file, 'import')
- return
+ return 0
log.debug("considering: " + dir + '/' + file, 'import')
try:
paths = get_mirror_path(factory, dir+'/'+file)
except SystemError:
log.msg(file + ' skipped - wrong format or corrupted', 'import')
- return
+ return 0
if paths:
if len(paths) != 1:
log.debug("WARNING: multiple ocurrences", 'import')
@@ -417,11 +421,14 @@
atime = os.stat(src_path)[stat.ST_ATIME]
factory.access_times[cache_path] = atime
log.msg(file + ' imported', 'import')
+ return 1
else:
log.msg(file + ' skipped - already in cache', 'import')
+ return 0
else:
log.msg(file + ' skipped - no suitable backend found', 'import')
+ return 0
def test(factory, file):
"Just for testing purposes, this should probably go to hell soon."
More information about the apt-proxy-devel
mailing list