mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-12 03:38:59 +00:00
fix fake dotfiles actions not executed
This commit is contained in:
@@ -298,7 +298,7 @@ def cmd_install(o):
|
|||||||
if o.install_temporary:
|
if o.install_temporary:
|
||||||
tmpdir = get_tmpdir()
|
tmpdir = get_tmpdir()
|
||||||
|
|
||||||
installed = 0
|
installed = []
|
||||||
|
|
||||||
# execute profile pre-action
|
# execute profile pre-action
|
||||||
if o.debug:
|
if o.debug:
|
||||||
@@ -317,43 +317,29 @@ def cmd_install(o):
|
|||||||
|
|
||||||
wait_for = []
|
wait_for = []
|
||||||
for dotfile in dotfiles:
|
for dotfile in dotfiles:
|
||||||
if not dotfile.src or not dotfile.dst:
|
j = ex.submit(_dotfile_install, o, dotfile, tmpdir=tmpdir)
|
||||||
# fake dotfile are always considered installed
|
wait_for.append(j)
|
||||||
if o.debug:
|
|
||||||
LOG.dbg('fake dotfile installed')
|
|
||||||
installed += 1
|
|
||||||
else:
|
|
||||||
j = ex.submit(_dotfile_install, o, dotfile, tmpdir=tmpdir)
|
|
||||||
wait_for.append(j)
|
|
||||||
# check result
|
# check result
|
||||||
for f in futures.as_completed(wait_for):
|
for f in futures.as_completed(wait_for):
|
||||||
r, key, err = f.result()
|
r, key, err = f.result()
|
||||||
if r:
|
if r:
|
||||||
installed += 1
|
installed.append(key)
|
||||||
elif err:
|
elif err:
|
||||||
LOG.err('installing \"{}\" failed: {}'.format(key,
|
LOG.err('installing \"{}\" failed: {}'.format(key,
|
||||||
err))
|
err))
|
||||||
else:
|
else:
|
||||||
# sequentially
|
# sequentially
|
||||||
for dotfile in dotfiles:
|
for dotfile in dotfiles:
|
||||||
if not dotfile.src or not dotfile.dst:
|
r, key, err = _dotfile_install(o, dotfile, tmpdir=tmpdir)
|
||||||
# fake dotfile are always considered installed
|
|
||||||
if o.debug:
|
|
||||||
LOG.dbg('fake dotfile installed')
|
|
||||||
key = dotfile.key
|
|
||||||
r = True
|
|
||||||
err = None
|
|
||||||
else:
|
|
||||||
r, key, err = _dotfile_install(o, dotfile, tmpdir=tmpdir)
|
|
||||||
# check result
|
# check result
|
||||||
if r:
|
if r:
|
||||||
installed += 1
|
installed.append(key)
|
||||||
elif err:
|
elif err:
|
||||||
LOG.err('installing \"{}\" failed: {}'.format(key,
|
LOG.err('installing \"{}\" failed: {}'.format(key,
|
||||||
err))
|
err))
|
||||||
|
|
||||||
# execute profile post-action
|
# execute profile post-action
|
||||||
if installed > 0 or o.install_force_action:
|
if len(installed) > 0 or o.install_force_action:
|
||||||
if o.debug:
|
if o.debug:
|
||||||
msg = 'run {} profile post actions'
|
msg = 'run {} profile post actions'
|
||||||
LOG.dbg(msg.format(len(pro_post_actions)))
|
LOG.dbg(msg.format(len(pro_post_actions)))
|
||||||
@@ -362,11 +348,11 @@ def cmd_install(o):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
if o.debug:
|
if o.debug:
|
||||||
LOG.dbg('install done - {} installed'.format(installed))
|
LOG.dbg('install done: installed \"{}\"'.format(','.join(installed)))
|
||||||
|
|
||||||
if o.install_temporary:
|
if o.install_temporary:
|
||||||
LOG.log('\ninstalled to tmp \"{}\".'.format(tmpdir))
|
LOG.log('\ninstalled to tmp \"{}\".'.format(tmpdir))
|
||||||
LOG.log('\n{} dotfile(s) installed.'.format(installed))
|
LOG.log('\n{} dotfile(s) installed.'.format(len(installed)))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,6 +85,11 @@ class Installer:
|
|||||||
- False, error_msg : error
|
- False, error_msg : error
|
||||||
- False, None : ignored
|
- False, None : ignored
|
||||||
"""
|
"""
|
||||||
|
if not src or not dst:
|
||||||
|
# fake dotfile
|
||||||
|
self.log.dbg('fake dotfile installed')
|
||||||
|
self._exec_pre_actions(actionexec)
|
||||||
|
return True, None
|
||||||
if self.debug:
|
if self.debug:
|
||||||
msg = 'installing \"{}\" to \"{}\" (link: {})'
|
msg = 'installing \"{}\" to \"{}\" (link: {})'
|
||||||
self.log.dbg(msg.format(src, dst, str(linktype)))
|
self.log.dbg(msg.format(src, dst, str(linktype)))
|
||||||
|
|||||||
@@ -62,11 +62,13 @@ actions:
|
|||||||
pre:
|
pre:
|
||||||
preaction: echo 'pre' > ${tmpa}/pre
|
preaction: echo 'pre' > ${tmpa}/pre
|
||||||
preaction2: echo 'pre2' > ${tmpa}/pre2
|
preaction2: echo 'pre2' > ${tmpa}/pre2
|
||||||
|
fake_pre: echo 'fake pre' > ${tmpa}/fake_pre
|
||||||
post:
|
post:
|
||||||
postaction: echo 'post' > ${tmpa}/post
|
postaction: echo 'post' > ${tmpa}/post
|
||||||
postaction2: echo 'post2' > ${tmpa}/post2
|
postaction2: echo 'post2' > ${tmpa}/post2
|
||||||
nakedaction: echo 'naked' > ${tmpa}/naked
|
nakedaction: echo 'naked' > ${tmpa}/naked
|
||||||
_silentaction: echo 'silent'
|
_silentaction: echo 'silent'
|
||||||
|
fakeaction: echo 'fake' > ${tmpa}/fake
|
||||||
config:
|
config:
|
||||||
backup: true
|
backup: true
|
||||||
create: true
|
create: true
|
||||||
@@ -82,10 +84,17 @@ dotfiles:
|
|||||||
- preaction2
|
- preaction2
|
||||||
- postaction2
|
- postaction2
|
||||||
- _silentaction
|
- _silentaction
|
||||||
|
f_fake:
|
||||||
|
dst:
|
||||||
|
src:
|
||||||
|
actions:
|
||||||
|
- fakeaction
|
||||||
|
- fake_pre
|
||||||
profiles:
|
profiles:
|
||||||
p1:
|
p1:
|
||||||
dotfiles:
|
dotfiles:
|
||||||
- f_abc
|
- f_abc
|
||||||
|
- f_fake
|
||||||
_EOF
|
_EOF
|
||||||
#cat ${cfg}
|
#cat ${cfg}
|
||||||
|
|
||||||
@@ -111,6 +120,12 @@ grep "executing \"echo 'naked' > ${tmpa}/naked" ${tmpa}/log >/dev/null
|
|||||||
grep "executing \"echo 'silent'" ${tmpa}/log >/dev/null && false
|
grep "executing \"echo 'silent'" ${tmpa}/log >/dev/null && false
|
||||||
grep "executing silent action \"_silentaction\"" ${tmpa}/log >/dev/null
|
grep "executing silent action \"_silentaction\"" ${tmpa}/log >/dev/null
|
||||||
|
|
||||||
|
# fake action
|
||||||
|
[ ! -e ${tmpa}/fake ] && echo 'fake post action not executed' && exit 1
|
||||||
|
grep fake ${tmpa}/fake >/dev/null
|
||||||
|
[ ! -e ${tmpa}/fake_pre ] && echo 'fake pre action not executed' && exit 1
|
||||||
|
grep 'fake pre' ${tmpa}/fake_pre >/dev/null
|
||||||
|
|
||||||
## CLEANING
|
## CLEANING
|
||||||
rm -rf ${tmps} ${tmpd} ${tmpa}
|
rm -rf ${tmps} ${tmpd} ${tmpa}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user