diff --git a/docs/howto/sensitive-dotfiles.md b/docs/howto/sensitive-dotfiles.md index aea420e..a4e03f0 100644 --- a/docs/howto/sensitive-dotfiles.md +++ b/docs/howto/sensitive-dotfiles.md @@ -47,6 +47,8 @@ $ cp dotfiles/secret * commit and push the changes +See [transformations](../config-details.md#entry-transformations). + ## Load passphrase from file Passphrase is retrieved using a script: @@ -64,3 +66,5 @@ variables: trans_read: _gpg: "gpg2 --batch --yes --passphrase-file <(cat {{@@ gpg_password_file @@}}) -q --for-your-eyes-only --no-tty -d {0} > {1}" ``` + +See [transformations](../config-details.md#entry-transformations). diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index 0d0f346..6616578 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -245,6 +245,11 @@ def _dotfile_install(o, dotfile, tmpdir=None): if not tmp: return False, dotfile.key, None src = tmp + # make sure to re-evaluate if is template + is_template = dotfile.template and Templategen.is_template( + src, + ignore=ignores, + ) r, err = inst.install(t, src, dotfile.dst, LinkTypes.NOLINK, actionexec=pre_actions_exec, diff --git a/tests-ng/notemplate.sh b/tests-ng/notemplate.sh index 4e5a72c..389f7d7 100755 --- a/tests-ng/notemplate.sh +++ b/tests-ng/notemplate.sh @@ -123,11 +123,13 @@ echo "{{@@ header() @@}}" > ${tmps}/dotfiles/fl # create the normal dotfile echo "before" > ${tmps}/dotfiles/fn -echo "{#@@ should not be stripped @@#}" >> ${tmps}/dotfiles/fn +echo "{#@@ should be stripped @@#}" >> ${tmps}/dotfiles/fn echo "after" >> ${tmps}/dotfiles/fn # install +echo "installing" cd ${ddpath} | ${bin} install -f --showdiff -c ${cfg} -p p1 -V +echo "comparing" cd ${ddpath} | ${bin} compare -c ${cfg} -p p1 -V # simple file @@ -170,7 +172,7 @@ grep 'header' ${tmpd}/f1 || (echo "header stripped" && exit 1) # normal dotfile echo "* normal dotfile" [ ! -e ${tmpd}/fn ] && echo 'not installed' && exit 1 -grep 'should not be stripped' ${tmpd}/fn && echo "no templated" && exit 1 +grep 'should be stripped' ${tmpd}/fn && echo "not templated" && exit 1 # test backup done echo "before" > ${tmps}/dotfiles/f1 diff --git a/tests-ng/transformations-template.sh b/tests-ng/transformations-template.sh index 4c3bafc..a33f604 100755 --- a/tests-ng/transformations-template.sh +++ b/tests-ng/transformations-template.sh @@ -61,6 +61,7 @@ cat > ${cfg} << _EOF trans_read: r_echo_abs_src: echo "\$(cat {0}); {{@@ _dotfile_abs_src @@}}" > {1} r_echo_var: echo "\$(cat {0}); {{@@ r_var @@}}" > {1} + reverse_it: cat {0} | rev > {1} trans_write: w_echo_key: echo "\$(cat {0}); {{@@ _dotfile_key @@}}" > {1} w_echo_var: echo "\$(cat {0}); {{@@ w_var @@}}" > {1} @@ -85,12 +86,17 @@ dotfiles: src: ghi trans_read: r_echo_var trans_write: w_echo_var + f_rev: + dst: ${tmpd}/rev + src: rev + trans_read: reverse_it profiles: p1: dotfiles: - f_abc - f_def - f_ghi + - f_rev _EOF #cat ${cfg} @@ -98,6 +104,7 @@ _EOF echo 'abc' > ${tmps}/dotfiles/abc echo 'marker' > ${tmps}/dotfiles/def echo 'ghi' > ${tmps}/dotfiles/ghi +echo '{{@@ profile @@}}' | rev > ${tmps}/dotfiles/rev ########################### # test install and compare @@ -110,11 +117,14 @@ cd ${ddpath} | ${bin} install -f -c ${cfg} -p p1 -b -V [ ! -e ${tmpd}/def ] && exit 1 [ ! -e ${tmpd}/abc ] && exit 1 [ ! -e ${tmpd}/ghi ] && exit 1 +[ ! -e ${tmpd}/rev ] && exit 1 grep marker ${tmpd}/def cat ${tmpd}/abc grep "^abc; ${tmps}/dotfiles/abc$" ${tmpd}/abc cat ${tmpd}/ghi grep "^ghi; readvar$" ${tmpd}/ghi +cat ${tmpd}/rev +grep "^p1$" ${tmpd}/rev ########################### # test update @@ -127,6 +137,7 @@ cd ${ddpath} | ${bin} update -f -k -c ${cfg} -p p1 -b -V [ ! -e ${tmps}/dotfiles/def ] && exit 1 [ ! -e ${tmps}/dotfiles/abc ] && exit 1 [ ! -e ${tmps}/dotfiles/ghi ] && exit 1 +[ ! -e ${tmps}/dotfiles/rev ] && exit 1 grep marker ${tmps}/dotfiles/def cat ${tmps}/dotfiles/abc grep "^abc; ${tmps}/dotfiles/abc; f_abc$" ${tmps}/dotfiles/abc