mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-15 18:30:05 +00:00
fix dotfile src/dst not expanded with ext variables (#177)
This commit is contained in:
@@ -214,11 +214,23 @@ class CfgYaml:
|
|||||||
|
|
||||||
def _resolve_dotfile_paths(self):
|
def _resolve_dotfile_paths(self):
|
||||||
"""resolve dotfile paths"""
|
"""resolve dotfile paths"""
|
||||||
|
t = Templategen(variables=self.variables)
|
||||||
|
|
||||||
for dotfile in self.dotfiles.values():
|
for dotfile in self.dotfiles.values():
|
||||||
|
# src
|
||||||
src = dotfile[self.key_dotfile_src]
|
src = dotfile[self.key_dotfile_src]
|
||||||
|
new = t.generate_string(src)
|
||||||
|
if new != src and self.debug:
|
||||||
|
self.log.dbg('dotfile: {} -> {}'.format(src, new))
|
||||||
|
src = new
|
||||||
src = os.path.join(self.settings[self.key_settings_dotpath], src)
|
src = os.path.join(self.settings[self.key_settings_dotpath], src)
|
||||||
dotfile[self.key_dotfile_src] = self._norm_path(src)
|
dotfile[self.key_dotfile_src] = self._norm_path(src)
|
||||||
|
# dst
|
||||||
dst = dotfile[self.key_dotfile_dst]
|
dst = dotfile[self.key_dotfile_dst]
|
||||||
|
new = t.generate_string(dst)
|
||||||
|
if new != dst and self.debug:
|
||||||
|
self.log.dbg('dotfile: {} -> {}'.format(dst, new))
|
||||||
|
dst = new
|
||||||
dotfile[self.key_dotfile_dst] = self._norm_path(dst)
|
dotfile[self.key_dotfile_dst] = self._norm_path(dst)
|
||||||
|
|
||||||
def _rec_resolve_vars(self, variables):
|
def _rec_resolve_vars(self, variables):
|
||||||
@@ -292,15 +304,6 @@ class CfgYaml:
|
|||||||
"""template any needed parts of the config"""
|
"""template any needed parts of the config"""
|
||||||
t = Templategen(variables=self.variables)
|
t = Templategen(variables=self.variables)
|
||||||
|
|
||||||
# dotfiles src/dst/actions keys
|
|
||||||
for k, v in self.dotfiles.items():
|
|
||||||
# src
|
|
||||||
src = v.get(self.key_dotfile_src)
|
|
||||||
v[self.key_dotfile_src] = t.generate_string(src)
|
|
||||||
# dst
|
|
||||||
dst = v.get(self.key_dotfile_dst)
|
|
||||||
v[self.key_dotfile_dst] = t.generate_string(dst)
|
|
||||||
|
|
||||||
# import_actions
|
# import_actions
|
||||||
new = []
|
new = []
|
||||||
entries = self.settings.get(self.key_import_actions, [])
|
entries = self.settings.get(self.key_import_actions, [])
|
||||||
|
|||||||
@@ -78,10 +78,14 @@ dotfiles:
|
|||||||
f_abc:
|
f_abc:
|
||||||
dst: ${tmpd}/abc
|
dst: ${tmpd}/abc
|
||||||
src: abc
|
src: abc
|
||||||
|
f_def:
|
||||||
|
dst: ${tmpd}/{{@@ theprofile @@}}
|
||||||
|
src: def
|
||||||
profiles:
|
profiles:
|
||||||
p1:
|
p1:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
|
- f_def
|
||||||
variables:
|
variables:
|
||||||
varx: profvarx
|
varx: profvarx
|
||||||
provar: provar
|
provar: provar
|
||||||
@@ -107,6 +111,8 @@ echo "evar1: {{@@ evar1 @@}}" >> ${tmps}/dotfiles/abc
|
|||||||
echo "provar: {{@@ provar @@}}" >> ${tmps}/dotfiles/abc
|
echo "provar: {{@@ provar @@}}" >> ${tmps}/dotfiles/abc
|
||||||
echo "theprofile: {{@@ theprofile @@}}" >> ${tmps}/dotfiles/abc
|
echo "theprofile: {{@@ theprofile @@}}" >> ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
|
echo "theprofile: {{@@ theprofile @@}}" > ${tmps}/dotfiles/def
|
||||||
|
|
||||||
#cat ${tmps}/dotfiles/abc
|
#cat ${tmps}/dotfiles/abc
|
||||||
|
|
||||||
# install
|
# install
|
||||||
@@ -123,6 +129,10 @@ grep '^evar1: extevar1' ${tmpd}/abc >/dev/null
|
|||||||
grep '^provar: provar' ${tmpd}/abc >/dev/null
|
grep '^provar: provar' ${tmpd}/abc >/dev/null
|
||||||
grep '^theprofile: p1' ${tmpd}/abc >/dev/null
|
grep '^theprofile: p1' ${tmpd}/abc >/dev/null
|
||||||
|
|
||||||
|
# check def
|
||||||
|
[ ! -e ${tmpd}/p1 ] && echo "def not created" && exit 1
|
||||||
|
grep '^theprofile: p1' ${tmpd}/p1 >/dev/null
|
||||||
|
|
||||||
rm -f ${tmpd}/abc
|
rm -f ${tmpd}/abc
|
||||||
|
|
||||||
#cat ${tmpd}/abc
|
#cat ${tmpd}/abc
|
||||||
|
|||||||
Reference in New Issue
Block a user