[jhalfs] branch trunk updated: Various fixes for create-sbu_du-report.sh

"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.automated
Message-ID <164528001070.10541.9058241186327271153@rivendell.linuxfromscratch.org>
This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch trunk
in repository jhalfs.

The following commit(s) were added to refs/heads/trunk by this push:
     new 03b24b2  Various fixes for create-sbu_du-report.sh
03b24b2 is described below

commit 03b24b2a456839770c528d81bce4787c6b18be3e
Author: Pierre Labastie <[email protected]>
AuthorDate: Sat Feb 19 15:08:37 2022 +0100

    Various fixes for create-sbu_du-report.sh
    
    - Check that there is enough material to calculate a SBU (!)
    - Prevent an error if REALSBU does not occur in jhalfs.config
    - Remove double square bracket: they change semantics and
      I cannot memorize what the change is (but e.g. file* is not
      expanded even if there is some filexxx in the dir).
---
 common/create-sbu_du-report.sh | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/common/create-sbu_du-report.sh b/common/create-sbu_du-report.sh
index fc8ddd7..a1371cb 100755
--- a/common/create-sbu_du-report.sh
+++ b/common/create-sbu_du-report.sh
@@ -9,26 +9,30 @@ DATE=$3
 LINE="================================================================================"
 
 # Make sure that we have a directory as first argument
-[[ ! -d "$LOGSDIR" ]] && \
+[ ! -d "$LOGSDIR" ] && \
   echo -e "\nUSAGE: create-sbu_du-report.sh logs_directory [book_version] [date]\n" && exit
 
 # Make sure that the first argument is a jhalfs logs directory
-[[ ! -f "$LOGSDIR"/000-masterscript.log ]] && \
+[ ! -f "$LOGSDIR"/000-masterscript.log ] && \
   echo -e "\nLooks like $LOGSDIR isn't a jhalfs logs directory.\n" && exit
 
+# Make sure something has been built otherwise no need for report :)
+[ ! -f "$LOGSDIR"/???-binutils-pass1* ] && \
+  echo -e "\nLooks like nothing has been built yet. Aborting report.\n" && exit
+
 # If this script is run manually, the book version may be unknown
-[[ -z "$VERSION" ]] && VERSION=unknown
-[[ -z "$DATE" ]] && DATE=$(date --iso-8601)
+[ -z "$VERSION" ] && VERSION=unknown
+[ -z "$DATE" ] && DATE=$(date --iso-8601)
 
 # If there is iteration logs directories, copy the logs inside iteration-1
 # to the top level dir
-[[ -d "$LOGSDIR"/build_1 ]] && \
+[ -d "$LOGSDIR"/build_1 ] && \
   cp $LOGSDIR/build_1/* $LOGSDIR
 
 # Set the report file
 REPORT="$VERSION"-SBU_DU-"$DATE".report
 
-[ -f $REPORT ] && : >$REPORT
+[ -f "$REPORT" ] && : >$REPORT
 
 # Dump generation time stamp and book version
 echo -e "\n`date`\n" > "$REPORT"
@@ -59,15 +63,14 @@ echo -e "\nUsing ${BASELOG#*[[:digit:]]-} to obtain the SBU unit value."
 SBU_UNIT=`sed -n 's/^Totalseconds:\s\([[:digit:]]*\)$/\1/p' $BASELOG`
 popd
 # Get the -j value of the SBU
-if [ $(sed -n '/REALSBU/s/.*\([yn]\).*/\1/p' "$REPORT") = y ]; then
+if [ "$(sed -n '/REALSBU/s/.*\([yn]\).*/\1/p' "$REPORT")" = y ]; then
     J_VALUE="1"
 else
     J_VALUE=$(sed -n '/N_PARALLEL/s/.*<\([^>]*\).*/\1/p' "$REPORT")
 fi
 # if jhalfs.config does not exist, or OPTIMIZE is 0, then J_VALUE is
 # still empty. Assume 1 in that case
-if [ -z "$J_VALUE" ]; then J_VALUE=1; fi
-echo -e "\nThe SBU unit value is equal to $SBU_UNIT seconds at -j$J_VALUE.\n"
+echo -e "\nThe SBU unit value is equal to $SBU_UNIT seconds at -j${J_VALUE:=1}.\n"
 echo -e "\n\n$LINE\n\nThe SBU unit value is equal to $SBU_UNIT seconds at -j$J_VALUE.\n" >> "$REPORT"
 
 # Set the first value to 0 for grand totals calculation

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

-- 
http://lists.linuxfromscratch.org/sympa/info/alfs-discuss
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.