From 1045b28226eb3e471de9c8768e1e8a48fe7f7d48 Mon Sep 17 00:00:00 2001 From: Devan Franchini Date: Fri, 21 Jun 2013 02:06:29 -0400 Subject: [PATCH] Webappconfig/config.py: Adds check for package name and version in run() function if self.work == "clean" to avoid uninstalling a webapp if the package name and version being listed exist, but aren't the ones located in the .webapp in the specified directory taken from the -d flag. X-Gentoo-Bug: 461410 X-Gentoo-Bug-URL: https://bugs.gentoo.org/461410 --- WebappConfig/config.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/WebappConfig/config.py b/WebappConfig/config.py index fd106c5..b39e2eb 100644 --- a/WebappConfig/config.py +++ b/WebappConfig/config.py @@ -937,12 +937,16 @@ class Config: self.parser.print_help() OUT.die('You need to specify at least the application you' ' would like to handle!') + else: + return self.config.get('USER', 'pn') def check_version_set(self): if not self.config.has_option('USER', 'pvr'): OUT.die('You did not specify which version to handle.\n Use "' + self.config.get('USER','g_myname') + ' --help" for usage') + else: + return self.config.get('USER', 'pvr') def split_hostname(self): @@ -1225,10 +1229,12 @@ class Config: self.__r = wrapper.get_root(self) wrapper.want_category(self) - self.check_package_set() - self.check_version_set() + package = self.check_package_set() + version = self.check_version_set() self.set_vars() + webapp = package + ' ' + version + # special case # # if a package has been specified, then chances are that they forgot @@ -1260,6 +1266,13 @@ class Config: self.config.set('USER', 'pn', old['WEB_PN']) self.config.set('USER', 'pvr', old['WEB_PVR']) + old_webapp = old['WEB_PN'] + ' ' + old['WEB_PVR'] + + if not webapp == old_webapp: + OUT.die(webapp + ' does not match ' + + old_webapp + ' found in .webapp file at ' + + self.installdir() + '.') + # we don't want to read the .webapp file if we're upgrading, # because we've just written the *new* app's details into the file!! # -- 1.8.1.5