def install_package(self, name): if self.is_installed(name): return gub_log.action('installing package: %s\n' % name) if self.is_installed(name): message = 'already have package: ' + name + '\n' gub_log.error(message) raise Exception(message) d = self._packages[name] ball = '%(split_ball)s' % d self.install_tarball(ball, name, d['prefix_dir']) self._package_dict_db[name] = pickle.dumps(d, protocol=2)
def install_package (self, name): if self.is_installed (name): return gub_log.action ('installing package: %s\n' % name) if self.is_installed (name): message = 'already have package: ' + name + '\n' gub_log.error (message) raise Exception (message) d = self._packages[name] ball = '%(split_ball)s' % d self.install_tarball (ball, name, d['prefix_dir']) self._package_dict_db[name] = pickle.dumps (d, protocol=2)
def install_tarball(self, ball, name, prefix_dir): gub_log.action('untarring: %(ball)s\n' % locals()) _z = misc.compression_flag(ball) _v = '' # self.os_interface.verbose_flag () lst = loggedos.read_pipe(gub_log.default_logger, 'tar -t%(_z)s -f "%(ball)s"' % locals()).split('\n') conflicts = False installed_files = self.installed_files() installed_files_string = ':'.join([''] + installed_files + ['']) misc.timing() for f in lst: if (':' + f + ':' in installed_files_string and not os.path.isdir(os.path.join(self.root, f))): package = self._file_package_db[f] gub_log.error('already have file %(f)s: %(package)s\n' % locals()) conflicts = True gub_log.command('GUP: for f in lst:' + misc.timing() + '\n') if conflicts and not self.is_distro: raise Exception('Duplicate files found.') root = self.root loggedos.system( gub_log.default_logger, # cd %(root)s to avoid open(2) of cwd, see # http://lists.gnu.org/archive/html/lilypond-devel/2009-03/msg00304.html 'cd %(root)s && tar -C %(root)s -p -x%(_z)s%(_v)s -f %(ball)s' % locals()) for f in lst: if f.endswith('.la'): self.libtool_la_fixup(root, f) if f.endswith('.pc'): self.pkgconfig_pc_fixup(root, f, prefix_dir) self._package_file_db[name] = '\n'.join(lst) for f in lst: # ignore directories. if not f.endswith('/'): self._file_package_db[f] = name if os.path.exists('%(root)s/usr/etc/postinstall/%(name)s' % locals()): loggedos.system( gub_log.default_logger, 'PATH=%(root)s/usr/bin:$PATH %(root)s/usr/etc/postinstall/%(name)s && mv %(root)s/usr/etc/postinstall/%(name)s %(root)s/usr/etc/postinstall/%(name)s.done || :' % locals())
def install_tarball (self, ball, name, prefix_dir): gub_log.action ('untarring: %(ball)s\n' % locals ()) _z = misc.compression_flag (ball) _v = '' # self.os_interface.verbose_flag () lst = loggedos.read_pipe (gub_log.default_logger, 'tar -t%(_z)s -f "%(ball)s"' % locals ()).split ('\n') conflicts = False installed_files = self.installed_files () installed_files_string = ':'.join ([''] + installed_files + ['']) misc.timing () for f in lst: if (':' + f + ':' in installed_files_string and not os.path.isdir (os.path.join (self.root, f))): package = self._file_package_db[f] gub_log.error ('already have file %(f)s: %(package)s\n' % locals ()) conflicts = True gub_log.command ('GUP: for f in lst:' + misc.timing () + '\n') if conflicts and not self.is_distro: raise Exception ('Duplicate files found.') root = self.root loggedos.system (gub_log.default_logger, # cd %(root)s to avoid open(2) of cwd, see # http://lists.gnu.org/archive/html/lilypond-devel/2009-03/msg00304.html 'cd %(root)s && tar -C %(root)s -p -x%(_z)s%(_v)s -f %(ball)s' % locals ()) for f in lst: if f.endswith ('.la'): self.libtool_la_fixup (root, f) if f.endswith ('.pc'): self.pkgconfig_pc_fixup (root, f, prefix_dir) self._package_file_db[name] = '\n'.join (lst) for f in lst: # ignore directories. if not f.endswith ('/'): self._file_package_db[f] = name if os.path.exists ('%(root)s/usr/etc/postinstall/%(name)s' % locals ()): loggedos.system (gub_log.default_logger, 'PATH=%(root)s/usr/bin:$PATH %(root)s/usr/etc/postinstall/%(name)s && mv %(root)s/usr/etc/postinstall/%(name)s %(root)s/usr/etc/postinstall/%(name)s.done || :' % locals ())
def uninstall_package (self, name): gub_log.action ('uninstalling package: %s\n' % name) lst = self.package_installed_files (name) dirs = [] files = [] for i in lst: f = os.path.join (self.root, i) if os.path.islink (f): files.append (f) elif (not os.path.exists (f) and not self.is_distro): printf ('FileManager: uninstall: %s' % name) printf ('FileManager: no such file: %s' % f) elif os.path.isdir (f): dirs.append (f) else: files.append (f) for f in files: os.unlink (f) for d in reversed (dirs): try: os.rmdir (d) except OSError: gub_log.verbose ('warning: %(d)s not empty\n' % locals ()) for f in lst: ## fixme (?) -- when is f == '' if not f or f.endswith ('/'): continue try: del self._file_package_db[f] except: printf ('db delete failing for ', f) del self._package_file_db[name]