mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-07 11:03:31 +00:00
allow (dyn)variables in import for #89
This commit is contained in:
@@ -424,9 +424,12 @@ class Cfg:
|
|||||||
keys = []
|
keys = []
|
||||||
if self.key_profiles_imp not in self.lnk_profiles[profile]:
|
if self.key_profiles_imp not in self.lnk_profiles[profile]:
|
||||||
return keys
|
return keys
|
||||||
|
variables = self.get_variables(profile, debug=self.debug)
|
||||||
|
t = Templategen(variables=variables)
|
||||||
paths = self.lnk_profiles[profile][self.key_profiles_imp]
|
paths = self.lnk_profiles[profile][self.key_profiles_imp]
|
||||||
for path in paths:
|
for path in paths:
|
||||||
path = self._abs_path(path)
|
path = self._abs_path(path)
|
||||||
|
path = t.generate_string(path)
|
||||||
if self.debug:
|
if self.debug:
|
||||||
self.log.dbg('loading dotfiles from {}'.format(path))
|
self.log.dbg('loading dotfiles from {}'.format(path))
|
||||||
content = self._load_yaml(path)
|
content = self._load_yaml(path)
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ mkdir -p ${tmps}/dotfiles
|
|||||||
tmpd=`mktemp -d --suffix='-dotdrop-tests'`
|
tmpd=`mktemp -d --suffix='-dotdrop-tests'`
|
||||||
extdotfiles="${tmps}/df_p1.yaml"
|
extdotfiles="${tmps}/df_p1.yaml"
|
||||||
|
|
||||||
|
dynextdotfiles_name="d_uid_dynvar"
|
||||||
|
dynextdotfiles="${tmps}/ext_${dynextdotfiles_name}"
|
||||||
|
|
||||||
# create the config file
|
# create the config file
|
||||||
cfg="${tmps}/config.yaml"
|
cfg="${tmps}/config.yaml"
|
||||||
|
|
||||||
@@ -60,6 +63,8 @@ config:
|
|||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
dotpath: dotfiles
|
dotpath: dotfiles
|
||||||
|
dynvariables:
|
||||||
|
d_uid: "echo ${dynextdotfiles_name}"
|
||||||
dotfiles:
|
dotfiles:
|
||||||
f_abc:
|
f_abc:
|
||||||
dst: ${tmpd}/abc
|
dst: ${tmpd}/abc
|
||||||
@@ -70,12 +75,16 @@ dotfiles:
|
|||||||
f_xyz:
|
f_xyz:
|
||||||
dst: ${tmpd}/xyz
|
dst: ${tmpd}/xyz
|
||||||
src: xyz
|
src: xyz
|
||||||
|
f_dyn:
|
||||||
|
dst: ${tmpd}/dyn
|
||||||
|
src: dyn
|
||||||
profiles:
|
profiles:
|
||||||
p1:
|
p1:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
import:
|
import:
|
||||||
- $(basename ${extdotfiles})
|
- $(basename ${extdotfiles})
|
||||||
|
- "ext_{{@@ d_uid @@}}"
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
# create the external dotfile file
|
# create the external dotfile file
|
||||||
@@ -85,11 +94,17 @@ dotfiles:
|
|||||||
- f_xyz
|
- f_xyz
|
||||||
_EOF
|
_EOF
|
||||||
|
|
||||||
|
cat > ${dynextdotfiles} << _EOF
|
||||||
|
dotfiles:
|
||||||
|
- f_dyn
|
||||||
|
_EOF
|
||||||
|
|
||||||
# create the source
|
# create the source
|
||||||
mkdir -p ${tmps}/dotfiles/
|
mkdir -p ${tmps}/dotfiles/
|
||||||
echo "abc" > ${tmps}/dotfiles/abc
|
echo "abc" > ${tmps}/dotfiles/abc
|
||||||
echo "def" > ${tmps}/dotfiles/def
|
echo "def" > ${tmps}/dotfiles/def
|
||||||
echo "xyz" > ${tmps}/dotfiles/xyz
|
echo "xyz" > ${tmps}/dotfiles/xyz
|
||||||
|
echo "dyn" > ${tmps}/dotfiles/dyn
|
||||||
|
|
||||||
# install
|
# install
|
||||||
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
||||||
@@ -98,9 +113,11 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -V
|
|||||||
[ ! -e ${tmpd}/abc ] && exit 1
|
[ ! -e ${tmpd}/abc ] && exit 1
|
||||||
[ ! -e ${tmpd}/def ] && exit 1
|
[ ! -e ${tmpd}/def ] && exit 1
|
||||||
[ ! -e ${tmpd}/xyz ] && exit 1
|
[ ! -e ${tmpd}/xyz ] && exit 1
|
||||||
|
[ ! -e ${tmpd}/dyn ] && exit 1
|
||||||
grep 'abc' ${tmpd}/abc
|
grep 'abc' ${tmpd}/abc
|
||||||
grep 'def' ${tmpd}/def
|
grep 'def' ${tmpd}/def
|
||||||
grep 'xyz' ${tmpd}/xyz
|
grep 'xyz' ${tmpd}/xyz
|
||||||
|
grep 'dyn' ${tmpd}/dyn
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
rm -rf ${tmps} ${tmpd}
|
rm -rf ${tmps} ${tmpd}
|
||||||
|
|||||||
Reference in New Issue
Block a user