|
a/trunk/wharfie/lib/makefile.py |
|
b/trunk/wharfie/lib/makefile.py |
|
... |
|
... |
57 |
# write all targets |
57 |
# write all targets |
58 |
for target in makeTargets: |
58 |
for target in makeTargets: |
59 |
if 'comment' in target: |
59 |
if 'comment' in target: |
60 |
f.write("# %s\n" % target['comment']); |
60 |
f.write("# %s\n" % target['comment']); |
61 |
f.write("%s: %s\n" % (target['name'], " ".join(target['dep']))); |
61 |
f.write("%s: %s\n" % (target['name'], " ".join(target['dep']))); |
62 |
f.write("\t${Q}-mkdir $$(basename $@ .tar)\n"); |
62 |
# target and host commands have to extract and repack always. |
|
|
63 |
# simple commands don't do that. |
|
|
64 |
if 'trgcmd' in target or 'hostcmd' in target: |
|
|
65 |
f.write("\t${Q}-mkdir $$(basename $@ .tar)\n"); |
63 |
|
66 |
|
64 |
if 'trgcmd' in target: |
67 |
if 'trgcmd' in target: |
65 |
cmd = templateTrgCmd % (target['trgcmd'].replace('$', '\\$$').replace('"', '\\"')); |
68 |
cmd = templateTrgCmd % (target['trgcmd'].replace('$', '\\$$').replace('"', '\\"')); |
66 |
f.write("\t${Q}echo '******************************'\n"); |
69 |
f.write("\t${Q}echo '******************************'\n"); |
67 |
f.write("\t${Q}echo '%s'\n" % target['comment']); |
70 |
f.write("\t${Q}echo '%s'\n" % target['comment']); |
68 |
f.write("\t${Q}echo '******************************'\n"); |
71 |
f.write("\t${Q}echo '******************************'\n"); |
69 |
f.write("\t${Q}(echo -e \"%s\") | tee ./$$(basename $@ .tar)/.trg.sh\n" % cmd.replace('\\n', '\\\\\\n').replace('\n', '\\n').replace('!', '"\'!\'"')); |
72 |
f.write("\t${Q}(echo -e \"%s\") | tee ./$$(basename $@ .tar)/.trg.sh\n" % cmd.replace('\\n', '\\\\\\n').replace('\n', '\\n').replace('!', '"\'!\'"')); |
70 |
f.write("\t${Q}chmod a+x ./$$(basename $@ .tar)/.trg.sh\n"); |
73 |
f.write("\t${Q}chmod a+x ./$$(basename $@ .tar)/.trg.sh\n"); |
71 |
|
74 |
|
72 |
if 'hostcmd' in target: |
75 |
if 'hostcmd' in target: |
73 |
cmd = templateHostCmd % (target['hostcmd'].replace('$', '\\$$').replace('"', '\\"')); |
76 |
cmd = templateHostCmd % (target['hostcmd'].replace('$', '\\$$').replace('"', '\\"')); |
74 |
f.write("\t${Q}echo '******************************'\n"); |
77 |
f.write("\t${Q}echo '******************************'\n"); |
75 |
f.write("\t${Q}echo '%s'\n" % target['comment']); |
78 |
f.write("\t${Q}echo '%s'\n" % target['comment']); |
76 |
f.write("\t${Q}echo '******************************'\n"); |
79 |
f.write("\t${Q}echo '******************************'\n"); |
77 |
f.write("\t${Q}(echo -e \"%s\") | tee ./$$(basename $@ .tar)/.hst.sh\n" % cmd.replace('\\n', '\\\\\\\\n').replace('\n', '\\n').replace('!', '"\'!\'"')); |
80 |
f.write("\t${Q}(echo -e \"%s\") | tee ./$$(basename $@ .tar)/.hst.sh\n" % cmd.replace('\\n', '\\\\\\\\n').replace('\n', '\\n').replace('!', '"\'!\'"')); |
78 |
f.write("\t${Q}chmod a+x ./$$(basename $@ .tar)/.hst.sh\n"); |
81 |
f.write("\t${Q}chmod a+x ./$$(basename $@ .tar)/.hst.sh\n"); |
79 |
|
82 |
|
80 |
# start command here ... |
83 |
# start command here ... |
81 |
f.write("\t${Q}${SUDO} bash -c \""); |
84 |
f.write("\t${Q}${SUDO} bash -c \""); |
82 |
|
85 |
|
83 |
f.write("cd $$(basename $@ .tar); tar -xf ../$<; "); |
86 |
f.write("cd $$(basename $@ .tar); tar -xf ../$<; "); |
84 |
if not dry_run: |
87 |
if not dry_run: |
85 |
f.write("if [ -f .trg.sh ]; then chroot . ./.trg.sh || exit 1; fi; rm -f ./.trg.sh;"); |
88 |
f.write("if [ -f .trg.sh ]; then chroot . ./.trg.sh || exit 1; fi; rm -f ./.trg.sh;"); |
86 |
f.write("if [ -f .hst.sh ]; then ./.hst.sh || exit 1; fi; rm -f ./.hst.sh;"); |
89 |
f.write("if [ -f .hst.sh ]; then ./.hst.sh || exit 1; fi; rm -f ./.hst.sh;"); |
87 |
if not 'temporary' in target or not target['temporary']: |
90 |
if not 'temporary' in target or not target['temporary']: |
88 |
f.write("tar -cf '../$@' .;"); |
91 |
f.write("tar -cf '../$@' .;"); |
89 |
f.write("\"\n"); |
92 |
f.write("\"\n"); |
90 |
# ... end command |
93 |
# ... end command |
91 |
|
94 |
|
92 |
|
95 |
|
93 |
if 'temporary' in target and target['temporary']: |
96 |
if 'temporary' in target and target['temporary']: |
94 |
f.write("\t${Q}cp $< $@\n"); |
97 |
f.write("\t${Q}cp $< $@\n"); |
95 |
|
98 |
|
96 |
f.write("\t${Q}-${SUDO} rm -Rf ./$$(basename $@ .tar)\n"); |
99 |
f.write("\t${Q}-${SUDO} rm -Rf ./$$(basename $@ .tar)\n"); |
|
|
100 |
# |
|
|
101 |
# end of target/host commands. |
|
|
102 |
# we keep it open that those command types can still be combined |
|
|
103 |
# with a simple command. |
|
|
104 |
# |
|
|
105 |
|
|
|
106 |
if 'simplecmd' in target: |
|
|
107 |
# note, that a simple command has full control |
|
|
108 |
# over make. it can contain references to the maketarget |
|
|
109 |
# and to make variables. Therefore we don't replace anything |
|
|
110 |
# in those commands (contrary to target-/host commands). |
|
|
111 |
# Also verbose mode can't be supported, because we want to |
|
|
112 |
# support multiline commands |
|
|
113 |
for line in iter(target['simplecmd'].splitlines()): |
|
|
114 |
f.write("\t%s\n" % line) |
|
|
115 |
|
97 |
f.write("\n"); |
116 |
f.write("\n"); |
98 |
|
117 |
|
99 |
# write footer |
118 |
# write footer |
100 |
f.write("include %s/wharfie.mk\n" % installpath); |
119 |
f.write("include %s/wharfie.mk\n" % installpath); |
101 |
if installpath != '.': |
120 |
if installpath != '.': |