mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-04 17:24:46 +00:00
add force_chmod for #304
This commit is contained in:
@@ -19,6 +19,7 @@ Entry | Description | Default
|
|||||||
`diff_command` | the diff command to use for diffing files | `diff -r -u {0} {1}`
|
`diff_command` | the diff command to use for diffing files | `diff -r -u {0} {1}`
|
||||||
`dotpath` | path to the directory containing the dotfiles to be managed by dotdrop (absolute path or relative to the config file location) | `dotfiles`
|
`dotpath` | path to the directory containing the dotfiles to be managed by dotdrop (absolute path or relative to the config file location) | `dotfiles`
|
||||||
`filter_file` | list of paths to load templating filters from (see [Templating available filters](templating.md#template-filters)) | -
|
`filter_file` | list of paths to load templating filters from (see [Templating available filters](templating.md#template-filters)) | -
|
||||||
|
`force_chmod` | if true, do not ask confirmation to apply permissions on install | `false`
|
||||||
`func_file` | list of paths to load templating functions from (see [Templating available methods](templating.md#template-methods)) | -
|
`func_file` | list of paths to load templating functions from (see [Templating available methods](templating.md#template-methods)) | -
|
||||||
`ignore_missing_in_dotdrop` | ignore missing files in dotdrop when comparing and importing (see [Ignore missing](usage.md#ignore-missing)) | false
|
`ignore_missing_in_dotdrop` | ignore missing files in dotdrop when comparing and importing (see [Ignore missing](usage.md#ignore-missing)) | false
|
||||||
`ignoreempty` | do not deploy template if empty | false
|
`ignoreempty` | do not deploy template if empty | false
|
||||||
|
|||||||
@@ -91,12 +91,15 @@ On `install` the following rules are applied:
|
|||||||
|
|
||||||
* if `chmod` is specified in the dotfile, it will be applied to the installed dotfile
|
* if `chmod` is specified in the dotfile, it will be applied to the installed dotfile
|
||||||
* otherwise the permissions of the dotfile in the `dotpath` are applied.
|
* otherwise the permissions of the dotfile in the `dotpath` are applied.
|
||||||
|
* if the global setting `force_chmod` is set to true dotdrop will not ask
|
||||||
|
for confirmation to apply permission
|
||||||
|
|
||||||
On `update`:
|
On `update`:
|
||||||
|
|
||||||
* if the permissions of the file in the filesystem differ from the dotfile in the `dotpath`
|
* if the permissions of the file in the filesystem differ from the dotfile in the `dotpath`
|
||||||
then the dotfile entry `chmod` is added/updated accordingly
|
then the dotfile entry `chmod` is added/updated accordingly
|
||||||
|
|
||||||
|
|
||||||
## Symlink dotfiles
|
## Symlink dotfiles
|
||||||
|
|
||||||
Dotdrop is able to install dotfiles in three different ways
|
Dotdrop is able to install dotfiles in three different ways
|
||||||
@@ -173,7 +176,7 @@ Similar to a `.gitignore` file, you can prefix ignore patterns with an exclamati
|
|||||||
This so-called "negative ignore pattern" will cause any files that match that pattern to __not__ be ignored,
|
This so-called "negative ignore pattern" will cause any files that match that pattern to __not__ be ignored,
|
||||||
provided they *would have* been ignored by an earlier ignore pattern (dotdrop will warn if that is not the
|
provided they *would have* been ignored by an earlier ignore pattern (dotdrop will warn if that is not the
|
||||||
case). This feature allows you to, for example, ignore all files within a certain directory, except for one
|
case). This feature allows you to, for example, ignore all files within a certain directory, except for one
|
||||||
particular one (see example below).
|
particular one (see example below).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
config:
|
config:
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ class CfgYaml:
|
|||||||
key_dotfile_noempty = 'ignoreempty'
|
key_dotfile_noempty = 'ignoreempty'
|
||||||
key_dotfile_template = 'template'
|
key_dotfile_template = 'template'
|
||||||
key_dotfile_chmod = 'chmod'
|
key_dotfile_chmod = 'chmod'
|
||||||
key_dotfile_ignore_missing = 'ignore_missing_in_dotdrop'
|
|
||||||
|
|
||||||
# profile
|
# profile
|
||||||
key_profile_dotfiles = 'dotfiles'
|
key_profile_dotfiles = 'dotfiles'
|
||||||
|
|||||||
@@ -226,7 +226,8 @@ def _dotfile_install(o, 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=o.install_force_chmod)
|
||||||
elif hasattr(dotfile, 'link') and \
|
elif hasattr(dotfile, 'link') and \
|
||||||
dotfile.link == LinkTypes.LINK_CHILDREN:
|
dotfile.link == LinkTypes.LINK_CHILDREN:
|
||||||
# link_children
|
# link_children
|
||||||
@@ -235,7 +236,8 @@ def _dotfile_install(o, dotfile, tmpdir=None):
|
|||||||
actionexec=pre_actions_exec,
|
actionexec=pre_actions_exec,
|
||||||
is_template=is_template,
|
is_template=is_template,
|
||||||
chmod=dotfile.chmod,
|
chmod=dotfile.chmod,
|
||||||
ignore=ignores)
|
ignore=ignores,
|
||||||
|
force_chmod=o.install_force_chmod)
|
||||||
else:
|
else:
|
||||||
# nolink
|
# nolink
|
||||||
src = dotfile.src
|
src = dotfile.src
|
||||||
@@ -256,7 +258,8 @@ def _dotfile_install(o, 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=o.install_force_chmod)
|
||||||
if tmp:
|
if tmp:
|
||||||
tmp = os.path.join(o.dotpath, tmp)
|
tmp = os.path.join(o.dotpath, tmp)
|
||||||
if os.path.exists(tmp):
|
if os.path.exists(tmp):
|
||||||
|
|||||||
@@ -66,7 +66,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=[], is_template=True,
|
ignore=[], is_template=True,
|
||||||
chmod=None):
|
chmod=None, force_chmod=False):
|
||||||
"""
|
"""
|
||||||
install src to dst
|
install src to dst
|
||||||
|
|
||||||
@@ -79,6 +79,7 @@ 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
|
||||||
@@ -171,7 +172,7 @@ class Installer:
|
|||||||
if dstperms != chmod:
|
if dstperms != chmod:
|
||||||
# apply mode
|
# apply mode
|
||||||
msg = 'chmod {} to {:o}'.format(dst, chmod)
|
msg = 'chmod {} to {:o}'.format(dst, chmod)
|
||||||
if self.safe and not self.log.ask(msg):
|
if not force_chmod and self.safe and not self.log.ask(msg):
|
||||||
r = False
|
r = False
|
||||||
err = 'aborted'
|
err = 'aborted'
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -257,6 +257,7 @@ class Options(AttrMonitor):
|
|||||||
self.install_default_actions_post = [a for a in self.default_actions
|
self.install_default_actions_post = [a for a in self.default_actions
|
||||||
if a.kind == Action.post]
|
if a.kind == Action.post]
|
||||||
self.install_ignore = self.instignore
|
self.install_ignore = self.instignore
|
||||||
|
self.install_force_chmod = self.force_chmod
|
||||||
|
|
||||||
# "compare" specifics
|
# "compare" specifics
|
||||||
self.compare_focus = self.args['--file']
|
self.compare_focus = self.args['--file']
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ class Settings(DictParser):
|
|||||||
key_func_file = 'func_file'
|
key_func_file = 'func_file'
|
||||||
key_filter_file = 'filter_file'
|
key_filter_file = 'filter_file'
|
||||||
key_diff_command = 'diff_command'
|
key_diff_command = 'diff_command'
|
||||||
|
key_force_chmod = 'force_chmod'
|
||||||
key_template_dotfile_default = 'template_dotfile_default'
|
key_template_dotfile_default = 'template_dotfile_default'
|
||||||
key_ignore_missing_in_dotdrop = 'ignore_missing_in_dotdrop'
|
key_ignore_missing_in_dotdrop = 'ignore_missing_in_dotdrop'
|
||||||
|
|
||||||
@@ -59,7 +60,8 @@ class Settings(DictParser):
|
|||||||
minversion=None, func_file=[], filter_file=[],
|
minversion=None, func_file=[], filter_file=[],
|
||||||
diff_command='diff -r -u {0} {1}',
|
diff_command='diff -r -u {0} {1}',
|
||||||
template_dotfile_default=True,
|
template_dotfile_default=True,
|
||||||
ignore_missing_in_dotdrop=False):
|
ignore_missing_in_dotdrop=False,
|
||||||
|
force_chmod=False):
|
||||||
self.backup = backup
|
self.backup = backup
|
||||||
self.banner = banner
|
self.banner = banner
|
||||||
self.create = create
|
self.create = create
|
||||||
@@ -87,6 +89,7 @@ class Settings(DictParser):
|
|||||||
self.diff_command = diff_command
|
self.diff_command = diff_command
|
||||||
self.template_dotfile_default = template_dotfile_default
|
self.template_dotfile_default = template_dotfile_default
|
||||||
self.ignore_missing_in_dotdrop = ignore_missing_in_dotdrop
|
self.ignore_missing_in_dotdrop = ignore_missing_in_dotdrop
|
||||||
|
self.force_chmod = force_chmod
|
||||||
|
|
||||||
def _serialize_seq(self, name, dic):
|
def _serialize_seq(self, name, dic):
|
||||||
"""serialize attribute 'name' into 'dic'"""
|
"""serialize attribute 'name' into 'dic'"""
|
||||||
@@ -111,6 +114,7 @@ class Settings(DictParser):
|
|||||||
self.key_diff_command: self.diff_command,
|
self.key_diff_command: self.diff_command,
|
||||||
self.key_template_dotfile_default: self.template_dotfile_default,
|
self.key_template_dotfile_default: self.template_dotfile_default,
|
||||||
self.key_ignore_missing_in_dotdrop: self.ignore_missing_in_dotdrop,
|
self.key_ignore_missing_in_dotdrop: self.ignore_missing_in_dotdrop,
|
||||||
|
self.key_force_chmod: self.force_chmod
|
||||||
}
|
}
|
||||||
self._serialize_seq(self.key_default_actions, dic)
|
self._serialize_seq(self.key_default_actions, dic)
|
||||||
self._serialize_seq(self.key_import_actions, dic)
|
self._serialize_seq(self.key_import_actions, dic)
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ config:
|
|||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
|
force_chmod: true
|
||||||
dotfiles:
|
dotfiles:
|
||||||
f_f777:
|
f_f777:
|
||||||
src: f777
|
src: f777
|
||||||
@@ -191,7 +192,8 @@ _EOF
|
|||||||
|
|
||||||
# install
|
# install
|
||||||
echo "first install round"
|
echo "first install round"
|
||||||
cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V
|
#cd ${ddpath} | ${bin} install -c ${cfg} -f -p p1 -V
|
||||||
|
cd ${ddpath} | ${bin} install -c ${cfg} -p p1 -V
|
||||||
|
|
||||||
has_rights "${tmpd}/f777" "777"
|
has_rights "${tmpd}/f777" "777"
|
||||||
has_rights "${tmpd}/link" "777"
|
has_rights "${tmpd}/link" "777"
|
||||||
|
|||||||
Reference in New Issue
Block a user