summaryrefslogtreecommitdiff
path: root/apt/cache.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-06-15 11:04:55 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-06-15 11:04:55 +0200
commita0f7295b7cd2d64bfc1e0b7c52fa39b1132f1fe5 (patch)
tree083a40b73208e88d7a7449f0268b33e5394e6159 /apt/cache.py
parentf6415fe3135a1ae7d36a1f0f83fbdf597d789c0f (diff)
downloadpython-apt-a0f7295b7cd2d64bfc1e0b7c52fa39b1132f1fe5.tar.gz
* apt/cache.py:
- when the cache is run with a alternative rootdir, create required dirs/files automatically * python/progress.cc: - fix crash in RunSimpleCallback()
Diffstat (limited to 'apt/cache.py')
-rw-r--r--apt/cache.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/apt/cache.py b/apt/cache.py
index cc425ccb..94a77fd8 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -60,8 +60,33 @@ class Cache(object):
apt_pkg.Config.Set("Dir", rootdir)
apt_pkg.Config.Set("Dir::State::status",
rootdir + "/var/lib/dpkg/status")
+ # create required dirs/files when run with special rootdir
+ # automatically
+ self._check_and_create_required_dirs(rootdir)
self.open(progress)
+ def _check_and_create_required_dirs(self, rootdir):
+ """
+ check if the required apt directories/files are there and if
+ not create them
+ """
+ files = ["/var/lib/dpkg/status",
+ "/etc/apt/sources.list",
+ ]
+ dirs = ["/var/lib/dpkg",
+ "/etc/apt/",
+ "/var/cache/apt/archives/partial",
+ "/var/lib/apt/lists/partial",
+ ]
+ for d in dirs:
+ if not os.path.exists(rootdir+d):
+ print "creating: ",rootdir+d
+ os.makedirs(rootdir+d)
+ for f in files:
+ if not os.path.exists(rootdir+f):
+ open(rootdir+f,"w")
+
+
def _runCallbacks(self, name):
""" internal helper to run a callback """
if name in self._callbacks: