diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-07-20 16:15:33 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-07-20 16:15:33 +0200 |
| commit | c35f51be417e029a9ca4a571c3fcd7309634b21b (patch) | |
| tree | dfe745c03bb39070a2b72a5dba094b903c1fbd3c /apt/cache.py | |
| parent | 86007bcc5e1faa40d2d4e456121b839f96136fb6 (diff) | |
| parent | 8f9c131d127a59e5ea4ce3eed8d96be1766399f0 (diff) | |
| download | python-apt-c35f51be417e029a9ca4a571c3fcd7309634b21b.tar.gz | |
Merge from debian-sid
Diffstat (limited to 'apt/cache.py')
| -rw-r--r-- | apt/cache.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/apt/cache.py b/apt/cache.py index 9982559b..40808abd 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -66,8 +66,32 @@ 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 _run_callbacks(self, name): """ internal helper to run a callback """ if name in self._callbacks: |
