1 |
commit: af1bd6b54ef751af96ec800e256a6e91412401e8 |
2 |
Author: Devan Franchini <twitch153 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Nov 5 22:11:07 2013 +0000 |
4 |
Commit: Devan Franchini <twitch153 <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Jan 25 03:11:45 2014 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=af1bd6b5 |
7 |
|
8 |
WebappConfig/db.py: Adds prune_db() function. |
9 |
|
10 |
This function will check for "stray" webapp installation entries in |
11 |
the installs files located in /var/db/webapps/<package name>/<version>. |
12 |
This function is not implemented yet. |
13 |
|
14 |
X-Gentoo-Bug: 490090 |
15 |
X-Gentoo-Bug-URL: https://bugs.gentoo.org/490090 |
16 |
|
17 |
--- |
18 |
WebappConfig/db.py | 37 +++++++++++++++++++++++++++++++++++++ |
19 |
1 file changed, 37 insertions(+) |
20 |
|
21 |
diff --git a/WebappConfig/db.py b/WebappConfig/db.py |
22 |
index 11e5dae..37bfdc9 100644 |
23 |
--- a/WebappConfig/db.py |
24 |
+++ b/WebappConfig/db.py |
25 |
@@ -424,6 +424,43 @@ class WebappDB(AppHierarchy): |
26 |
|
27 |
return result |
28 |
|
29 |
+ def prune_db(self): |
30 |
+ ''' |
31 |
+ Prunes the installs files to ensure no webapp |
32 |
+ is incorrectly listed as installed. |
33 |
+ ''' |
34 |
+ |
35 |
+ loc = self.read_db() |
36 |
+ |
37 |
+ if not loc and self.__v: |
38 |
+ OUT.die('No virtual installs found!') |
39 |
+ |
40 |
+ files = self.list_locations() |
41 |
+ keys = sorted(loc) |
42 |
+ |
43 |
+ for j in keys: |
44 |
+ for i in loc[j]: |
45 |
+ appdir = i[3].strip() |
46 |
+ # We check to see if the webapp is installed. |
47 |
+ if not os.path.exists(appdir+'/.webapp'): |
48 |
+ if self.__v: |
49 |
+ OUT.warn('No .webapp file found in dir: ') |
50 |
+ OUT.warn(appdir) |
51 |
+ OUT.warn('Assuming webapp is no longer installed.') |
52 |
+ OUT.warn('Pruning entry from database.') |
53 |
+ |
54 |
+ for installs in files.keys(): |
55 |
+ contents = open(installs).readlines() |
56 |
+ new_entries = '' |
57 |
+ for entry in contents: |
58 |
+ # Grab all the other entries but the one that |
59 |
+ # isn't installed. |
60 |
+ if not re.search('.* ' + appdir +'\\n', entry): |
61 |
+ new_entries += entry |
62 |
+ f = open(installs, 'w') |
63 |
+ f.write(new_entries) |
64 |
+ f.close() |
65 |
+ |
66 |
def has_installs(self): |
67 |
''' Return True in case there are any virtual install locations |
68 |
listed in the db file ''' |