def run(self): if self.build: if self.filename: BuildGppkg(self.build, self.filename).run() else: BuildGppkg(self.build, None).run() return #Check for RPM and Solaris OS if curr_platform == SUNOS: raise ExceptionNoStackTraceNeeded( 'gppkg is not supported on Solaris') try: if platform.linux_distribution()[0] == 'Ubuntu': cmd = Command(name='Check for dpkg', cmdStr='dpkg --version') cmd.run(validateAfter=True) else: cmd = Command(name='Check for rpm', cmdStr='rpm --version') cmd.run(validateAfter=True) results = cmd.get_results().stdout.strip() rpm_version_string = results.split(' ')[-1] if not rpm_version_string.startswith('4.'): raise ExceptionNoStackTraceNeeded( 'gppkg requires rpm version 4.x') except ExecutionError, ex: results = ex.cmd.get_results().stderr.strip() if len(results) != 0 and 'not found' in results: raise ExceptionNoStackTraceNeeded( 'gppkg requires RPM to be available in PATH')
def run(self): if self.build: if self.filename: BuildGppkg(self.build, self.filename).run() else: BuildGppkg(self.build, None).run() return if platform.linux_distribution()[0] == 'Ubuntu': try: cmd = Command(name='Check for dpkg', cmdStr='dpkg --version') cmd.run(validateAfter=True) cmd = Command(name='Check for fakeroot', cmdStr='fakeroot --version') cmd.run(validateAfter=True) except Exception, ex: raise ExceptionNoStackTraceNeeded('fakeroot and dpkg are both required by gppkg')
def run(self): if self.build: if self.filename: BuildGppkg(self.build, self.filename).run() else: BuildGppkg(self.build, None).run() return if linux_distribution_id() == 'ubuntu': try: cmd = Command(name='Check for dpkg', cmdStr='dpkg --version') cmd.run(validateAfter=True) cmd = Command(name='Check for fakeroot', cmdStr='fakeroot --version') cmd.run(validateAfter=True) except Exception as ex: raise ExceptionNoStackTraceNeeded( 'fakeroot and dpkg are both required by gppkg') else: try: cmd = Command(name='Check for rpm', cmdStr='rpm --version') cmd.run(validateAfter=True) results = cmd.get_results().stdout.strip() rpm_version_string = results.split(' ')[-1] if not rpm_version_string.startswith('4.'): raise ExceptionNoStackTraceNeeded( 'gppkg requires rpm version 4.x') except ExecutionError as ex: results = ex.cmd.get_results().stderr.strip() if len(results) != 0 and 'not found' in results: raise ExceptionNoStackTraceNeeded( 'gppkg requires RPM to be available in PATH') if self.coordinator_datadir is None: self.coordinator_datadir = gp.get_coordinatordatadir() self.coordinator_port = self._get_coordinator_port( self.coordinator_datadir) self._get_gpdb_host_list() if self.migrate: MigratePackages(from_gphome=self.migrate[0], to_gphome=self.migrate[1], standby_host=self.standby_host, segment_host_list=self.segment_host_list).run() return if self.install: pkg = Gppkg.from_package_path(self.install) InstallPackage(pkg, self.coordinator_host, self.standby_host, self.segment_host_list).run() elif self.query: query_type, package_path = self.query QueryPackage(query_type, package_path).run() elif self.remove: # Check for exact match first, then use wildcard for what will be removed. pkg_file_list = ListFilesByPattern( GPPKG_ARCHIVE_PATH, self.remove + GPPKG_EXTENSION).run() if len(pkg_file_list) == 0: # now try wildcard pkg_file_list = ListFilesByPattern( GPPKG_ARCHIVE_PATH, self.remove + '*' + GPPKG_EXTENSION).run() if len(pkg_file_list) == 0: raise ExceptionNoStackTraceNeeded( 'Package %s has not been installed.' % self.remove) # refuse to remove at all if the match is too broad, i.e., > 1 if len(pkg_file_list) > 1: err_msg = "Remove request '%s' too broad. " \ "Multiple packages match remove request: ( %s )." % (self.remove, ", ".join(pkg_file_list)) raise ExceptionNoStackTraceNeeded(err_msg) pkg_file = pkg_file_list[0] pkg = Gppkg.from_package_path( os.path.join(GPPKG_ARCHIVE_PATH, pkg_file)) UninstallPackage(pkg, self.coordinator_host, self.standby_host, self.segment_host_list).run() elif self.update: logger.warning( 'WARNING: The process of updating a package includes removing all' ) logger.warning( 'previous versions of the system objects related to the package. For' ) logger.warning( 'example, previous versions of shared libraries are removed.') logger.warning( 'After the update process, a database function will fail when it is' ) logger.warning( 'called if the function references a package file that has been removed.' ) if self.interactive: if not ask_yesno(None, 'Do you still want to continue ?', 'N'): logger.info('Skipping update of gppkg based on user input') return pkg = Gppkg.from_package_path(self.update) UpdatePackage(pkg, self.coordinator_host, self.standby_host, self.segment_host_list).run() elif self.clean: CleanGppkg(self.standby_host, self.segment_host_list).run()