Unverified Kaydet (Commit) 42de0d8b authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Merge remote-tracking branch 'github/patch-41829' into develop

......@@ -342,42 +342,11 @@ class Install(AtomicOperation):
ctx.ui.notify(inary.ui.extracting, package=self.pkginfo, files=self.files)
config_changed = []
def check_config_changed(config):
fpath = util.join_path(ctx.config.dest_dir(), config.path)
if util.config_changed(config):
config_changed.append(fpath)
self.historydb.save_config(self.pkginfo.name, fpath)
if os.path.exists(fpath + '.old-byinary'):
os.unlink(fpath + '.old-byinary')
os.rename(fpath, fpath + '.old-byinary')
# old config files are kept as they are. New config files from the installed
# packages are saved with ".newconfig" string appended to their names.
def rename_configs():
for path in config_changed:
newconfig = path + '.newconfig-byinary'
oldconfig = path + '.old-byinary'
if os.path.exists(newconfig):
os.unlink(newconfig)
# In the case of delta packages: the old package and the new package
# may contain same config typed files with same hashes, so the delta
# package will not have that config file. In order to protect user
# changed config files, they are renamed with ".old-byinary" prefix in case
# of the hashes of these files on the filesystem and the new config
# file that is coming from the new package. But in delta package case
# with the given scenario there wont be any, so we can pass this one.
# If the config files were not be the same between these packages the
# delta package would have it and extract it and the path would point
# to that new config file. If they are same and the user had changed
# that file and using the changed config file, there is no problem
# here.
if os.path.exists(path):
os.rename(path, newconfig)
os.rename(oldconfig, path)
# Package file's path may not be relocated or content may not be changed but
# permission may be changed
......@@ -503,9 +472,6 @@ class Install(AtomicOperation):
self.package.extract_install(ctx.config.dest_dir())
if config_changed:
rename_configs()
if self.reinstall():
clean_leftovers()
......
......@@ -58,7 +58,7 @@ You can also give the name of a component.
self.parser.add_option_group(group)
def run(self):
import inary.operations.emerge as emerge
from inary.operations import emerge, helper
self.init(database=True)
component = ctx.get_option('component')
......@@ -79,5 +79,7 @@ You can also give the name of a component.
ctx.config.options.output_dir = ctx.config.cached_packages_dir()
emerge.emerge(sources)
if not self.options.ignore_sysconf:
sysconf.proceed(self.options.force_sysconf)
......@@ -58,7 +58,7 @@ You can also give the name of a component.
self.parser.add_option_group(group)
def run(self):
from inary.operations import repository, emerge
from inary.operations import repository, emerge, helper
self.init(database=True)
source = inary.db.sourcedb.SourceDB()
......@@ -85,5 +85,7 @@ You can also give the name of a component.
repository.update_repos(repos, ctx.get_option('force'))
emerge.emerge(emerge_up_list)
if not self.options.ignore_sysconf:
sysconf.proceed(self.options.force_sysconf)
\ No newline at end of file
sysconf.proceed(self.options.force_sysconf)
......@@ -116,12 +116,13 @@ expanded to package names.
reinstall = bool(packages) and packages[0].endswith(ctx.const.package_suffix)
install.install(packages, ctx.get_option('reinstall') or reinstall)
config_changes = helper.check_config_changes([util.parse_package_name_legacy(i.split("/")[-1])[0] for i in packages])
try:
config_changes,opt = helper.check_config_changes([util.parse_package_name_legacy(i.split("/")[-1])[0] for i in packages])
if config_changes:
if ctx.ui.confirm(_("[!] Some config files have been changed. Would you like to see and apply them?")):
helper.show_changed_configs(config_changes,opt)
except ValueError:
pass
if not self.options.ignore_sysconf:
sysconf.proceed(self.options.force_sysconf)
if config_changes:
if ctx.ui.confirm(_("[!] Some config files have been changed. Would you like to see and apply them?")):
helper.show_changed_configs(config_changes)
......@@ -112,12 +112,13 @@ expanded to package names.
upgrade.upgrade(packages, reposit)
config_changes = helper.check_config_changes(
[util.parse_package_name_legacy(i.split("/")[-1])[0] for i in packages])
try:
config_changes,opt = helper.check_config_changes([util.parse_package_name_legacy(i.split("/")[-1])[0] for i in packages])
if config_changes:
if ctx.ui.confirm(_("[!] Some config files have been changed. Would you like to see and apply them?")):
helper.show_changed_configs(config_changes,opt)
except ValueError:
pass
if not self.options.ignore_sysconf:
sysconf.proceed(self.options.force_sysconf)
if config_changes:
if ctx.ui.confirm(_("[!] Some config files have been changed. Would you like to see and apply them?")):
helper.show_changed_configs(config_changes)
......@@ -197,9 +197,17 @@ def get_package_requirements(packages):
return requirements
def check_config_changes(order):
def check_config_changes(order, opt=None):
if not opt:
import inary.data.history as History
history = History.History()
opt="%03d" % (int(history._get_latest())-1)
config_changes=dict()
if not os.path.exists(os.path.join(ctx.config.history_dir(), opt)):
return []
for package in order:
all_files = inary.db.installdb.InstallDB().get_files(package)
......@@ -209,37 +217,43 @@ def check_config_changes(order):
newconfig = []
for path in config_paths:
if os.path.exists(path) and os.path.exists(path + ".newconfig-byinary"):
if os.path.exists(os.path.join(ctx.config.history_dir(), opt, path)) and os.path.exists(path):
newconfig.append(path)
if newconfig:
config_changes[package] = newconfig
return config_changes, opt
return config_changes
def apply_changed_config(file, keep=True):
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(file), verbose=True)
util.copy_file(file, file+".old-byinary")
util.copy_file(file+".newconfig-byinary", file)
util.delete_file(file+".newconfig-byinary")
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):
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, file), color='brightyellow')):
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]:
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")
new_file = util.join_path(ctx.config.history_dir(), opt, package, ctx.config.dest_dir(), file)
if os.path.exist(new_file):
ctx.ui.info(_("[*] Changes in config file: {}").format(file), color='yellow')
os.system("diff -u {0} {1} | less".format(new_file, file))
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)"),
_("4. 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(util.join_path(ctx.config.dest_dir(),file), new_file, keep=True)
elif prompt == _("3. Apply new config file (don't keep old config)"):
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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment