mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 15:39:43 +00:00
force_chmod as global option to the installer
This commit is contained in:
@@ -101,7 +101,8 @@ def _dotfile_compare(opts, dotfile, tmp):
|
|||||||
dry=opts.dry, base=opts.dotpath,
|
dry=opts.dry, base=opts.dotpath,
|
||||||
workdir=opts.workdir, debug=opts.debug,
|
workdir=opts.workdir, debug=opts.debug,
|
||||||
backup_suffix=opts.install_backup_suffix,
|
backup_suffix=opts.install_backup_suffix,
|
||||||
diff_cmd=opts.diff_command)
|
diff_cmd=opts.diff_command,
|
||||||
|
force_chmod=True)
|
||||||
comp = Comparator(diff_cmd=opts.diff_command, debug=opts.debug,
|
comp = Comparator(diff_cmd=opts.diff_command, debug=opts.debug,
|
||||||
ignore_missing_in_dotdrop=ignore_missing_in_dotdrop)
|
ignore_missing_in_dotdrop=ignore_missing_in_dotdrop)
|
||||||
|
|
||||||
@@ -234,8 +235,7 @@ def _dotfile_install(opts, dotfile, tmpdir=None):
|
|||||||
actionexec=pre_actions_exec,
|
actionexec=pre_actions_exec,
|
||||||
is_template=is_template,
|
is_template=is_template,
|
||||||
ignore=ignores,
|
ignore=ignores,
|
||||||
chmod=dotfile.chmod,
|
chmod=dotfile.chmod)
|
||||||
force_chmod=opts.install_force_chmod)
|
|
||||||
else:
|
else:
|
||||||
# nolink
|
# nolink
|
||||||
src = dotfile.src
|
src = dotfile.src
|
||||||
@@ -254,8 +254,7 @@ def _dotfile_install(opts, dotfile, tmpdir=None):
|
|||||||
noempty=dotfile.noempty,
|
noempty=dotfile.noempty,
|
||||||
ignore=ignores,
|
ignore=ignores,
|
||||||
is_template=is_template,
|
is_template=is_template,
|
||||||
chmod=dotfile.chmod,
|
chmod=dotfile.chmod)
|
||||||
force_chmod=opts.install_force_chmod)
|
|
||||||
if tmp:
|
if tmp:
|
||||||
tmp = os.path.join(opts.dotpath, tmp)
|
tmp = os.path.join(opts.dotpath, tmp)
|
||||||
if os.path.exists(tmp):
|
if os.path.exists(tmp):
|
||||||
@@ -765,7 +764,8 @@ def _get_install_installer(opts, tmpdir=None):
|
|||||||
showdiff=opts.install_showdiff,
|
showdiff=opts.install_showdiff,
|
||||||
backup_suffix=opts.install_backup_suffix,
|
backup_suffix=opts.install_backup_suffix,
|
||||||
diff_cmd=opts.diff_command,
|
diff_cmd=opts.diff_command,
|
||||||
remove_existing_in_dir=opts.install_remove_existing)
|
remove_existing_in_dir=opts.install_remove_existing,
|
||||||
|
force_chmod=opts.install_force_chmod)
|
||||||
return inst
|
return inst
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class Installer:
|
|||||||
dry=False, safe=False, workdir='~/.config/dotdrop',
|
dry=False, safe=False, workdir='~/.config/dotdrop',
|
||||||
debug=False, diff=True, totemp=None, showdiff=False,
|
debug=False, diff=True, totemp=None, showdiff=False,
|
||||||
backup_suffix='.dotdropbak', diff_cmd='',
|
backup_suffix='.dotdropbak', diff_cmd='',
|
||||||
remove_existing_in_dir=False):
|
remove_existing_in_dir=False, force_chmod=False):
|
||||||
"""
|
"""
|
||||||
@base: directory path where to search for templates
|
@base: directory path where to search for templates
|
||||||
@create: create directory hierarchy if missing when installing
|
@create: create directory hierarchy if missing when installing
|
||||||
@@ -45,6 +45,7 @@ class Installer:
|
|||||||
@diff_cmd: diff command to use
|
@diff_cmd: diff command to use
|
||||||
@remove_existing_in_dir: remove file in dir dotfiles
|
@remove_existing_in_dir: remove file in dir dotfiles
|
||||||
if not managed by dotdrop
|
if not managed by dotdrop
|
||||||
|
@force_chmod: apply chmod without confirmation
|
||||||
"""
|
"""
|
||||||
self.create = create
|
self.create = create
|
||||||
self.backup = backup
|
self.backup = backup
|
||||||
@@ -64,6 +65,7 @@ class Installer:
|
|||||||
self.diff_cmd = diff_cmd
|
self.diff_cmd = diff_cmd
|
||||||
self.action_executed = False
|
self.action_executed = False
|
||||||
self.remove_existing_in_dir = remove_existing_in_dir
|
self.remove_existing_in_dir = remove_existing_in_dir
|
||||||
|
self.force_chmod = force_chmod
|
||||||
# avoids printing file copied logs
|
# avoids printing file copied logs
|
||||||
# when using install_to_tmp for comparing
|
# when using install_to_tmp for comparing
|
||||||
self.comparing = False
|
self.comparing = False
|
||||||
@@ -77,7 +79,7 @@ class Installer:
|
|||||||
def install(self, templater, src, dst, linktype,
|
def install(self, templater, src, dst, linktype,
|
||||||
actionexec=None, noempty=False,
|
actionexec=None, noempty=False,
|
||||||
ignore=None, is_template=True,
|
ignore=None, is_template=True,
|
||||||
chmod=None, force_chmod=False):
|
chmod=None):
|
||||||
"""
|
"""
|
||||||
install src to dst
|
install src to dst
|
||||||
|
|
||||||
@@ -90,7 +92,6 @@ class Installer:
|
|||||||
@ignore: pattern to ignore when installing
|
@ignore: pattern to ignore when installing
|
||||||
@is_template: this dotfile is a template
|
@is_template: this dotfile is a template
|
||||||
@chmod: rights to apply if any
|
@chmod: rights to apply if any
|
||||||
@force_chmod: do not ask user to chmod
|
|
||||||
|
|
||||||
return
|
return
|
||||||
- True, None : success
|
- True, None : success
|
||||||
@@ -189,7 +190,6 @@ class Installer:
|
|||||||
|
|
||||||
self._apply_chmod_after_install(src, dst, ret, err,
|
self._apply_chmod_after_install(src, dst, ret, err,
|
||||||
chmod=chmod,
|
chmod=chmod,
|
||||||
force_chmod=force_chmod,
|
|
||||||
linktype=linktype)
|
linktype=linktype)
|
||||||
|
|
||||||
return self._log_install(ret, err)
|
return self._log_install(ret, err)
|
||||||
@@ -197,7 +197,6 @@ class Installer:
|
|||||||
def _apply_chmod_after_install(self, src, dst, ret, err,
|
def _apply_chmod_after_install(self, src, dst, ret, err,
|
||||||
chmod=None,
|
chmod=None,
|
||||||
is_sub=False,
|
is_sub=False,
|
||||||
force_chmod=False,
|
|
||||||
linktype=LinkTypes.NOLINK):
|
linktype=LinkTypes.NOLINK):
|
||||||
"""
|
"""
|
||||||
handle chmod after install
|
handle chmod after install
|
||||||
@@ -227,7 +226,7 @@ class Installer:
|
|||||||
if dstperms != chmod:
|
if dstperms != chmod:
|
||||||
# apply mode
|
# apply mode
|
||||||
msg = f'chmod {dst} to {chmod:o}'
|
msg = f'chmod {dst} to {chmod:o}'
|
||||||
if not force_chmod and self.safe and not self.log.ask(msg):
|
if not self.force_chmod and self.safe and not self.log.ask(msg):
|
||||||
ret = False
|
ret = False
|
||||||
err = 'aborted'
|
err = 'aborted'
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user