On 2/14/07, Dan Nicholson <[EMAIL PROTECTED]> wrote:
On 2/14/07, George Boudreau <[EMAIL PROTECTED]> wrote:
> Most of the changes I made were for the pretty stuff. Dash does not have
> 'echo -e' and the 'time' function does not work like the Bash version.
> Therefore I had to force bash to be the shell.
Here's a patch to not use 'echo -e'. Basically, it removes the use of
\n by calling echo multiple times. Tested with bash and dash on a
dummy Makefile.
Another patch. This uses shell variables and perl to calculate the
time. It's a little ugly and definitely breaks the sbu generator. The
printf could be tweaked to what's wanted. It seems to work with bash
and dash for a dummy Makefile.
--
Dan
Index: common/libs/func_wrt_Makefile
===================================================================
--- common/libs/func_wrt_Makefile (revision 3295)
+++ common/libs/func_wrt_Makefile (working copy)
@@ -226,20 +226,26 @@
(
cat << EOF
- @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
+ @start=\`date +%s.%N\` && \\
+ { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } && \\
+ end=\`date +%s.%N\` && \\
+ perl -e "printf \"time %.3f\n\", \$\$end - \$\$start" >>logs/\$@ && \\
\$(PRT_DU) >>logs/\$@
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
-LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file
+LUSER_wrt_RunAsUser() { # Calculate time with perl, footer to log file
#----------------------------------#
local file=$1
(
cat << EOF
- @( time { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } ) 2>> logs/\$@ && \\
+ @start=\`date +%s.%N\` && \\
+ { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1; } && \\
+ end=\`date +%s.%N\` && \\
+ perl -e "printf \"time %.3f\n\", \$\$end - \$\$start" >>logs/\$@ && \\
\$(PRT_DU) >> logs/\$@
EOF
) >> $MKFILE.tmp
@@ -251,7 +257,10 @@
local file=$1
(
cat << EOF
- @( time { source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
+ @start=\`date +%s.%N\` && \\
+ { source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } && \\
+ end=\`date +%s.%N\` && \\
+ perl -e "printf \"time %.3f\n\", \$\$end - \$\$start" >>logs/\$@ && \\
\$(PRT_DU_CR) >>logs/\$@
EOF
) >> $MKFILE.tmp
@@ -268,7 +277,10 @@
#----------------------------------#
(
cat << EOF
- @( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
+ @start=\`date +%s.%N\` && \\
+ { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@ 2>&1 ; } && \\
+ end=\`date +%s.%N\` && \\
+ perl -e "printf \"time %.3f\n\", \$\$end - \$\$start" >>logs/\$@
EOF
) >> $MKFILE.tmp
}
@@ -278,7 +290,10 @@
#----------------------------------#
(
cat << EOF
- @( time { cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
+ @start=\`date +%s.%N\` && \\
+ { cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 ; } && \\
+ end=\`date +%s.%N\` && \\
+ perl -e "printf \"time %.3f\n\", \$\$end - \$\$start" >>logs/\$@
EOF
) >> $MKFILE.tmp
}
--
http://linuxfromscratch.org/mailman/listinfo/alfs-discuss
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page