--- a/trunk/wharfie/lib/makefile.py +++ b/trunk/wharfie/lib/makefile.py @@ -81,6 +81,8 @@ # write all targets for target in makeTargets: + postpath = '' + if 'comment' in target: f.write("# %s\n" % target['comment']); if 'trgcmd' in target or 'hostcmd' in target or 'temporary' in target: @@ -112,6 +114,17 @@ f.write("\t${Q}(echo -e \"%s\") | ${SUDO} tee .trg.sh\n" % cmd.replace('\\n', '\\\\\\n').replace('\n', '\\n').replace('!', '"\'!\'"')); f.write("\t${Q}${SUDO} chmod a+x .trg.sh\n"); + if 'trgcmdpost' in target: + cmd = templateTrgCmd % (target['trgcmdpost'].replace('$', '\\$$').replace('"', '\\"')); + f.write("\t${Q}echo '******************************'\n"); + f.write("\t${Q}echo '%s: %s'\n" % (target['name'], target['comment'])); + f.write("\t${Q}echo '******************************'\n"); + f.write("\t${Q}(echo -e \"%s\") | ${SUDO} tee .trg-post.sh\n" % cmd.replace('\\n', '\\\\\\n').replace('\n', '\\n').replace('!', '"\'!\'"')); + f.write("\t${Q}${SUDO} chmod a+x .trg-post.sh\n"); + + if 'trgcmdpostpath' in target: + postpath = target['trgcmdpostpath'] + if 'hostcmd' in target: cmd = templateHostCmd % (target['hostcmd'].replace('$', '\\$$').replace('"', '\\"')); f.write("\t${Q}echo '******************************'\n"); @@ -119,6 +132,14 @@ f.write("\t${Q}echo '******************************'\n"); f.write("\t${Q}(echo -e \"%s\") | ${SUDO} tee .hst.sh\n" % cmd.replace('\\n', '\\\\\\\\n').replace('\n', '\\n').replace('!', '"\'!\'"')); f.write("\t${Q}${SUDO} chmod a+x .hst.sh\n"); + + if 'hostcmdpost' in target: + cmd = templateHostCmd % (target['hostcmdpost'].replace('$', '\\$$').replace('"', '\\"')); + f.write("\t${Q}echo '******************************'\n"); + f.write("\t${Q}echo '%s: %s'\n" % (target['name'], target['comment'])); + f.write("\t${Q}echo '******************************'\n"); + f.write("\t${Q}(echo -e \"%s\") | ${SUDO} tee .hst-post.sh\n" % cmd.replace('\\n', '\\\\\\\\n').replace('\n', '\\n').replace('!', '"\'!\'"')); + f.write("\t${Q}${SUDO} chmod a+x .hst-post.sh\n"); # start command here ... f.write("\t${Q}${SUDO} bash -c \""); @@ -148,8 +169,19 @@ f.write("if [ -f ../.trg.sh ]; then mv ../.trg.sh .; chroot . ./.trg.sh || exit 1; fi; rm -f ./.trg.sh;"); if proc: f.write("if [ -d proc ]; then umount proc || umount -l proc; fi;"); + # - host f.write("if [ -f ../.hst.sh ]; then ../.hst.sh || exit 1; fi; rm -f ../.hst.sh;"); + + # - target post + if proc: + f.write("if [ -d proc ]; then mount -t proc proc proc; fi;"); + f.write("if [ -f ../.trg-post.sh ]; then mv ../.trg-post.sh ./%s; chroot ./%s ./.trg-post.sh || exit 1; fi; rm -f ./.trg-post.sh;" % (postpath, postpath)); + if proc: + f.write("if [ -d proc ]; then umount proc || umount -l proc; fi;"); + + # - host post + f.write("if [ -f ../.hst-post.sh ]; then ../.hst-post.sh || exit 1; fi; rm -f ../.hst-post.sh;"); # pack result