On Mon, May 21, at 09:49 M.Canales.es wrote:
>
> But of course, the time call is forked during the full package build, while
> the others not ...
>
> Maybe we should to implement both, the "time by perl" and "bc by perl"
> changes
> at the same time.
>
> Could one of you create a new patch implementing both changes? I can try do
> it, but maybe not until the next weekend.
>
Ok, the patch attached.
All the changes (included Dan's patch with some corrections) are
integrated into this one.
Please review it carefully (especially the common/libs/func_validate_configs.sh)
as I don't have the time to test it thoroughly.
In a quick test seems to works.
Index: common/create-sbu_du-report.sh
===================================================================
--- common/create-sbu_du-report.sh (revision 3356)
+++ common/create-sbu_du-report.sh (working copy)
@@ -6,6 +6,8 @@
LOGSDIR=$1
VERSION=$2
+LINE="================================================================================"
+
# Make sure that we have a directory as first argument
[[ ! -d "$LOGSDIR" ]] && \
echo -e "\nUSAGE: create-sbu_du-report.sh logs_directory [book_version]\n"
&& exit
@@ -25,6 +27,8 @@
# Set the report file
REPORT="$VERSION"-SBU_DU-$(date --iso-8601).report
+[ -f $REPORT ] && : >$REPORT
+
# Dump generation time stamp and book version
echo -e "\n`date`\n" > "$REPORT"
echo -e "Book version is:\t$VERSION\n" >> "$REPORT"
@@ -44,82 +48,74 @@
free >> "$REPORT"
# Parse only that logs that have time data
-BUILDLOGS=`grep -l "^real\>" $LOGSDIR/*`
+BUILDLOGS="`grep -l "^Totalseconds:" ${LOGSDIR}/*`"
# Match the first timed log to extract the SBU unit value from it
-BASELOG=`grep -l "^real\>" $LOGSDIR/* | head -n1`
-echo -e "\n\nUsing $BASELOG to obtain the SBU unit value." >> "$REPORT"
-BASEMINUTES=`grep "^real\>" $BASELOG | cut -f2 | sed -e 's/m.*//'`
-BASESECONDS=`grep "^real\>" $BASELOG | cut -f2 | sed -e 's/.*m//;s/s//'`
-SBU_UNIT=`echo "scale=3; $BASEMINUTES * 60 + $BASESECONDS" | bc`
-echo -e "The SBU unit value is equal to $SBU_UNIT seconds.\n" >> "$REPORT"
+BASELOG=`grep -l "^Totalseconds:" $LOGSDIR/* | head -n1`
+echo -e "\nUsing ${BASELOG#*[[:digit:]]-} to obtain the SBU unit value."
+SBU_UNIT=`sed -n 's/^Totalseconds:\s\([[:digit:]]*\)$/\1/p' $BASELOG`
+echo -e "\nThe SBU unit value is equal to $SBU_UNIT seconds.\n"
+echo -e "\n\n$LINE\n\nThe SBU unit value is equal to $SBU_UNIT seconds.\n" >>
"$REPORT"
# Set the first value to 0 for grand totals calculation
SBU2=0
INSTALL2=0
INSTALLMB2=0
+# Start the loop
for log in $BUILDLOGS ; do
-#Start SBU calculation
- # Build time
- BUILDTIME=`grep "^real\>" $log | cut -f2`
- # Build time in seconds
- MINUTES=`grep "^real\>" $log | cut -f2 | sed -e 's/m.*//'`
- SECS=`grep "^real\>" $log | cut -f2 | sed -e 's/.*m//;s/s//'`
- TIME=`echo "scale=3; $MINUTES * 60 + $SECS" | bc`
- # Calculate build time in SBU
- SBU=`echo "scale=3; $TIME / $SBU_UNIT" | bc`
- # Append SBU value to SBU2 for grand total
- SBU2="$SBU2 + $SBU"
+# Strip the filename
+ PACKAGE="${log#*[[:digit:]]*-}"
-#Start disk usage calculation
- # Disk usage before unpacking the package
+# Start SBU calculation
+# Build time
+ TIME=`sed -n 's/^Totalseconds:\s\([[:digit:]]*\)$/\1/p' $log`
+ SECS=`perl -e 'print ('$TIME' % '60', "\n")';`
+ MINUTES=`perl -e 'print (('$TIME' - '$SECS') / '60', "\n")';`
+ SBU=`perl -e 'printf "%.3f\n" , ('$TIME' / '$SBU_UNIT')';`
+
+# Append SBU value to SBU2 for grand total
+ SBU2=`perl -e 'printf "%.3f\n" , ('$SBU2' + '$SBU')';`
+
+# Start disk usage calculation
+# Disk usage before unpacking the package
DU1=`grep "^KB: " $log | head -n1 | cut -f1 | sed -e 's/KB: //'`
- DU1MB=`echo "scale=2; $DU1 / 1024" | bc`
- # Disk usage before deleting the source and build dirs
+ DU1MB=`perl -e 'printf "%.3f\n" , ('$DU1' / '1024')';`
+# Disk usage before deleting the source and build dirs
DU2=`grep "^KB: " $log | tail -n1 | cut -f1 | sed -e 's/KB: //'`
- DU2MB=`echo "scale=2; $DU2 / 1024" | bc`
- # Calculate disk space required to do the build
- REQUIRED1=`echo "$DU2 - $DU1" | bc`
- REQUIRED2=`echo "scale=2; $DU2MB - $DU1MB" | bc`
+ DU2MB=`perl -e 'printf "%.3f\n" , ('$DU2' / '1024')';`
+# Calculate disk space required to do the build
+ REQUIRED1=`perl -e 'print ('$DU2' - '$DU1', "\n")';`
+ REQUIRED2=`perl -e 'printf "%.3f\n" , ('$DU2MB' - '$DU1MB')';`
- # Append installed files disk usage to the previous entry,
- # except for the first parsed log
+# Append installed files disk usage to the previous entry,
+# except for the first parsed log
if [ "$log" != "$BASELOG" ] ; then
- INSTALL=`echo "$DU1 - $DU1PREV" | bc`
- INSTALLMB=`echo "scale=2; $DU1MB - $DU1MBPREV" | bc`
- echo -e "Installed files disk usage:\t\t\t\t$INSTALL KB or $INSTALLMB
MB\n" >> "$REPORT"
+ INSTALL=`perl -e 'print ('$DU1' - '$DU1PREV', "\n")';`
+ INSTALLMB=`perl -e 'printf "%.3f\n" , ('$DU1MB' - '$DU1MBPREV')';`
+ echo -e "Installed files disk usage:\t\t\t\t$INSTALL KB or $INSTALLMB
MB\n" >> $REPORT
# Append install values for grand total
- INSTALL2="$INSTALL2 + $INSTALL"
- INSTALLMB2="$INSTALLMB2 + $INSTALLMB"
+ INSTALL2=`perl -e 'printf "%.3f\n" , ('$INSTALL2' + '$INSTALL')';`
+ INSTALLMB2=`perl -e 'printf "%.3f\n" , ('$INSTALLMB2' + '$INSTALLMB')';`
fi
- # Set variables to calculate installed files disk usage
+# Set variables to calculate installed files disk usage
DU1PREV=$DU1
DU1MBPREV=$DU1MB
- # Append log name
- echo -e "\n\t$log" >> "$REPORT"
+# Dump time and disk usage values
+ echo -e "$LINE\n\t\t\t\t[$PACKAGE]\n" >> $REPORT
+ echo -e "Build time is:\t\t\t\t\t\t$MINUTES minutes and $SECS seconds" >>
$REPORT
+ echo -e "Build time in seconds is:\t\t\t\t$TIME" >> $REPORT
+ echo -e "Approximate SBU time is:\t\t\t\t$SBU" >> $REPORT
+ echo -e "Disk usage before unpacking the package:\t\t$DU1 KB or $DU1MB MB"
>> $REPORT
+ echo -e "Disk usage before deleting the source and build dirs:\t$DU2 KB or
$DU2MB MB" >> $REPORT
+ echo -e "Required space to build the package:\t\t\t$REQUIRED1 KB or
$REQUIRED2 MB" >> $REPORT
- # Dump time values
- echo -e "Build time is:\t\t\t$BUILDTIME" >> "$REPORT"
- echo -e "Build time in seconds is\t$TIME" >> "$REPORT"
- echo -e "Approximate SBU time is:\t$SBU" >> "$REPORT"
-
- # Dump disk usage values
- echo -e "\nDisk usage before unpacking the package:\t\t$DU1 KB or $DU1MB MB"
>> "$REPORT"
- echo -e "Disk usage before deleting the source and build dirs:\t$DU2 KB or
$DU2MB MB" >> "$REPORT"
- echo -e "Required space to build the package:\t\t\t$REQUIRED1 KB or
$REQUIRED2 MB\n" >> "$REPORT"
-
done
# Dump grand totals
-TOTALSBU=`echo "scale=3; ${SBU2}" | bc`
-echo -e "\nTotal time required to build the systen:\t$TOTALSBU SBU\n" >>
"$REPORT"
-TOTALINSTALL=`echo "${INSTALL2}" | bc`
-TOTALINSTALLMB=`echo "scale=2; ${INSTALLMB2}" | bc`
-echo -e "Total Installed files disk usage
- (including /tools but not /sources):\t$TOTALINSTALL KB or $TOTALINSTALLMB
MB\n" >> "$REPORT"
-
-
+echo -e "\n$LINE\n\nTotal time required to build the systen:\t\t$SBU2 SBU" >>
$REPORT
+# Total disk usage: including /tools but not /sources.
+echo -e "Total Installed files disk usage:\t\t\t$INSTALL2 KB or $INSTALLMB2
MB" >> $REPORT
Index: common/libs/func_wrt_Makefile
===================================================================
--- common/libs/func_wrt_Makefile (revision 3356)
+++ common/libs/func_wrt_Makefile (working copy)
@@ -230,21 +230,25 @@
(
cat << EOF
- @( time { export ${MOUNT_ENV}=\$(MOUNT_PT) &&
${PROGNAME}-commands/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
- \$(PRT_DU) >>logs/\$@
+ @start=\`date +%s\` && \\
+ { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname
$file`/\$@ >>logs/\$@ 2>&1 ; } && \\
+ end=\`date +%s\` && \\
+ perl -e "print \"Totalseconds: \", \$\$end - \$\$start, \"\n\""
>>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/\$@ && \\
- \$(PRT_DU) >> logs/\$@
+ @start=\`date +%s\` && \\
+ { source ~/.bashrc && \$(CMDSDIR)/`dirname $file`/\$@ >> logs/\$@ 2>&1;
} && \\
+ end=\`date +%s\` && \\
+ perl -e "print \"Totalseconds: \", \$\$end - \$\$start, \"\n\""
>>logs/\$@
EOF
) >> $MKFILE.tmp
}
@@ -255,8 +259,10 @@
local file=$1
(
cat << EOF
- @( time { source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@
2>&1 ; } ) 2>>logs/\$@ && \\
- \$(PRT_DU_CR) >>logs/\$@
+ @start=\`date +%s\` && \\
+ { source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 ;
} && \\
+ end=\`date +%s\` && \\
+ perl -e "print \"Totalseconds: \", \$\$end - \$\$start, \"\n\""
>>logs/\$@
EOF
) >> $MKFILE.tmp
@@ -272,7 +278,10 @@
#----------------------------------#
(
cat << EOF
- @( time { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab
>>logs/\$@ 2>&1 ; } ) 2>>logs/\$@
+ @start=\`date +%s\` && \\
+ { cp -v \$(MOUNT_PT)/sources/fstab \$(MOUNT_PT)/etc/fstab >>logs/\$@
2>&1 ; } && \\
+ end=\`date +%s\` && \\
+ perl -e "print \"Totalseconds: \", \$\$end - \$\$start, \"\n\""
>>logs/\$@
EOF
) >> $MKFILE.tmp
}
@@ -282,7 +291,10 @@
#----------------------------------#
(
cat << EOF
- @( time { cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 ; } )
2>>logs/\$@
+ @start=\`date +%s\` && \\
+ { cp -v /sources/fstab /etc/fstab >>logs/\$@ 2>&1 ; } && \\
+ end=\`date +%s\` && \\
+ perl -e "print \"Totalseconds: \", \$\$end - \$\$start, \"\n\""
>>logs/\$@
EOF
) >> $MKFILE.tmp
}
Index: common/libs/func_validate_configs.sh
===================================================================
--- common/libs/func_validate_configs.sh (revision 3356)
+++ common/libs/func_validate_configs.sh (working copy)
@@ -138,25 +138,13 @@
LGROUP) echo -e "`eval echo $PARAM_VALS`"
[[ "${!config_param}" = "**EDIT ME**" ]] &&
write_error_and_die
;;
- REPORT) echo -e "`eval echo $PARAM_VALS`"
- if [[ "${!config_param}" = "y" ]]; then
- if [[ `type -p bc` ]]; then
- continue
- else
- echo -e " ${BOLD}The bc binary was not found${OFF}"
- echo -e " The SBU and disk usage report creation will
be skiped"
- REPORT=n
- continue
- fi
- fi ;;
-
# BOOK validation. Very ugly, need be fixed
BOOK) if [[ "${WORKING_COPY}" = "y" ]] ; then
validate_dir -z -d
else
echo -e "`eval echo $PARAM_VALS`"
- fi ;;
-
+ fi
+ ;;
# Validate directories, testable states:
# fatal -z -d -w,
# warning -z+ -w+
Index: custom/examples/997-nasm
===================================================================
--- custom/examples/997-nasm (revision 3356)
+++ custom/examples/997-nasm (working copy)
@@ -1,5 +1,5 @@
#
-# $Id:$
+# $Id$
# NASM (Netwide Assembler) is an 80x86 assembler designed
# for portability and modularity. It includes a
# disassembler as well.
--
http://linuxfromscratch.org/mailman/listinfo/alfs-discuss
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page