def preinstall(self, specdir): self.specdir = specdir for postops in ctx.const.postops: self.postscript = util.join_path(self.specdir, postops) retval = self.run_command("preInstall") util.delete_file(self.postscript) return retval
def apply_changed_config(old_file, new_file, keep=True): if keep: ctx.ui.info( _("Keeping old config file {0} as {0}.old-byinary").format(old_file), verbose=True) util.copy_file(old_file, old_file + ".old-byinary") util.copy_file(new_file, old_file) util.delete_file(new_file)
def show_changed_configs(package_dict, opt): for package in package_dict: if package_dict[package]: if ctx.ui.confirm(util.colorize( _("[?] Would you like to see changes in config files of \"{0}\" package").format( package), color='brightyellow')): for file in package_dict[package]: new_file = util.join_path( ctx.config.history_dir(), opt, package, ctx.config.dest_dir(), file) if os.path.exists(new_file): if ctx.config.options and ctx.config.options.yes_all: prompt = "1" else: ctx.ui.info( _("[*] Changes in config file: {}").format(file), color='yellow') os.system( "diff -u {0} {1} | less".format(new_file, file)) ctx.ui.info(_("[?] Select the process which will be happened:")) ctx.ui.info(_("1. Store new config file, not apply [*]")) ctx.ui.info(_("2. Apply new config file (keep old config)")) ctx.ui.info(_("3. Apply new config file (don't keep old config)")) ctx.ui.info(_("4. Delete new config file")) prompt = subprocess.getoutput("read -n 1 c ; echo $c") if prompt == "1": pass elif pprompt == "2": apply_changed_config( util.join_path( ctx.config.dest_dir(), file), new_file, keep=True) elif pprompt == "3": apply_changed_config( util.join_path( ctx.config.dest_dir(), file), new_file, keep=False) else: ctx.ui.info( _("Deleting new config file {0}").format(file), verbose=True) util.delete_file(new_file)
def show_changed_configs(package_dict): for package in package_dict: if package_dict[package]: if ctx.ui.confirm( util.colorize(_( "[?] Would you like to see changes in config files of \"{0}\" package" ).format(package, file), color='brightyellow')): for file in package_dict[package]: ctx.ui.info( _("[*] Changes in config file: {}").format(file), color='yellow') os.system("diff -u {0} {1} | less".format( file, file + ".newconfig-byinary")) prompt = ctx.ui.choose( _("[?] Select the process which will be happened:"), _("1. Store new config file, not apply [*]"), _("2. Apply new config file (keep old config)"), _("3. Apply new config file (don't keep old config)"), _("3. Delete new config file")) if prompt == _("1. Store new config file, not apply [*]"): pass elif prompt == _( "2. Apply new config file (keep old config)"): apply_changed_config(file, keep=True) elif prompt == _( "3. Apply new config file (don't keep old config)" ): apply_changed_config(file, keep=False) else: ctx.ui.info( _("Deleting new config file {0}").format(file), verbose=True) util.delete_file(file + ".newconfig-byinary")