r2030 - jhalfs/trunk

manuel at linuxfromscratch.org manuel at linuxfromscratch.org
Fri Sep 30 11:51:32 PDT 2005


Author: manuel
Date: 2005-09-30 12:51:32 -0600 (Fri, 30 Sep 2005)
New Revision: 2030

Modified:
   jhalfs/trunk/jhalfs
Log:
Added Makefile dependencies.
Fixed the clean targets.
Remove sources directories even if the build fails (not full tested yet).
Automatically execute make after Makefile creation.

Modified: jhalfs/trunk/jhalfs
===================================================================
--- jhalfs/trunk/jhalfs	2005-09-29 22:05:00 UTC (rev 2029)
+++ jhalfs/trunk/jhalfs	2005-09-30 18:51:32 UTC (rev 2030)
@@ -285,9 +285,13 @@
   # and binutils in chapter 5)
   name=`echo $i | sed -e 's@[0-9]\{3\}-@@' -e 's at -pass[0-9]\{1\}@@'`
 
-  # Drop in the name of the target on a new line.
-  echo -e "\n$i:" >> $MKFILE.tmp
+  # Set the dependency for the first target.
+  if [ -z $PREV ] ; then PREV=chapter4 ; fi
 
+  # Drop in the name of the target on a new line, and the
+  # pevious target as a dependency.
+  echo -e "\n$i: $PREV" >> $MKFILE.tmp
+
   # Find the version of the command files, if it corresponds with the building of
   # a specific package
   vrs=`grep "^$name-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
@@ -303,28 +307,36 @@
     # Insert instructions for unpacking the package and to set
     # the PKGDIR variable.
     echo -e "\t\$(call unpack-lfs,$FILE)" >> $MKFILE.tmp
-    echo -e "\tROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
+    echo -e "\t-ROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
     echo -e "\tchown -R lfs \$(LFS)\$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
     echo -e "\techo \"PKGDIR=\$(LFS)\$(SRC)/\$\$ROOT\" > envars && \\" >> $MKFILE.tmp
     echo -e "\techo \"export PKGDIR\" >> envars && \\" >> $MKFILE.tmp
   fi
 
   # Insert the script run
-  echo -e "\tsu - lfs -c \". /home/lfs/.bashrc && $JHALFSDIR/commands/$file\" >\$(LOGDIR)/$i.log 2>&1 && \\" >> $MKFILE.tmp
+  echo -e "\tsu - lfs -c \". /home/lfs/.bashrc && $JHALFSDIR/commands/$file\" >\$(LOGDIR)/$i 2>&1 && \\" >> $MKFILE.tmp
 
-  # Remove the build directory(ies).
-  # (How could it be deleted even if the package build fails?)
+  # Include a touch of the target name so make can check
+  # if it's already been made.
+  echo -e "\ttouch \$@" >> $MKFILE.tmp
+
+  # Remove the build directory(ies) even if the package build fails.
   if [ "$vrs" != "" ] ; then
+    echo -e "\tROOT=\`head -n1 /tmp/unpacked | sed 's@/.*@@'\` && \\" >> $MKFILE.tmp
     echo -e "\trm -r \$(LFS)\$(SRC)/\$\$ROOT && \\" >> $MKFILE.tmp
     echo -e "\tif [ -e \$(LFS)\$(SRC)/*-build ]; then \\" >> $MKFILE.tmp
-    echo -e "\t\t rm -r \$(LFS)\$(SRC)/*-build; \\" >> $MKFILE.tmp
+    echo -e "\t\trm -r \$(LFS)\$(SRC)/*-build; \\" >> $MKFILE.tmp
     echo -e "\tfi;" >> $MKFILE.tmp
   fi
 
-  # Include a touch of the target name so make can check
-  # if it's already been made.
-  echo -e "\ttouch \$@" >> $MKFILE.tmp
+  # Check if the package has been sucessfully build.
+  echo -e "\tif [ ! -e \$@ ] ; then \\" >> $MKFILE.tmp
+  echo -e "\t\techo \"The build of \$@ has failed\" && exit 1; \\" >> $MKFILE.tmp
+  echo -e "\tfi;" >> $MKFILE.tmp
 
+  # Keep the script file name in a second variable for Makefile dependencies.
+  PREV=$i
+
   done
 
   # Stick variables and some defines at the top of the real makefile
@@ -342,21 +354,27 @@
   # as a dependency.
   echo -e "all:  chapter4 chapter5\n" >> $MKFILE
   echo -e "chapter4:  020-creatingtoolsdir 021-addinguser 022-settingenvironment\n" >> $MKFILE
-  echo -e "chapter5: $chapter5\n" >> $MKFILE
+  echo -e "chapter5:  chapter4 $chapter5\n" >> $MKFILE
 
   # Clean targets
-  echo "clean:  clean-chapter5 clean-chapter4" >> $MKFILE
+  echo "clean-all:  clean" >> $MKFILE
+  echo -e "\trm -rfv ./*\n" >> $MKFILE
 
+  echo -e "clean:  clean-chapter5 clean-chapter4\n" >> $MKFILE
+
   echo "clean-chapter4:" >> $MKFILE
-  echo -e "\tuserdel lfs && \\" >> $MKFILE
-  echo -e "\trm -r /home/lfs && \\" >> $MKFILE
-  echo -e "\trm -r \$(LFS)/tools && \\" >> $MKFILE
-  echo -e "\trm /tools" >> $MKFILE
-  echo -e "\trm 02*\n" >> $MKFILE
+  echo -e "\t-userdel lfs" >> $MKFILE
+  echo -e "\trm -rfv /home/lfs" >> $MKFILE
+  echo -e "\trm -rfv \$(LFS)/tools" >> $MKFILE
+  echo -e "\trm -fv /tools" >> $MKFILE
+  echo -e "\trm -fv envars" >> $MKFILE
+  echo -e "\trm -fv 02* logs/02*.log\n" >> $MKFILE
 
   echo "clean-chapter5:" >> $MKFILE
-  echo -e "\trm -r \$(LFS)/tools/* && \\" >> $MKFILE
-  echo -e "\trm -f $chapter5\n" >> $MKFILE
+  echo -e "\trm -rfv \$(LFS)/tools/*" >> $MKFILE
+  echo -e "\trm -fv envars" >> $MKFILE
+  echo -e "\trm -fv $chapter5" >> $MKFILE
+  echo -e "\tcd logs && rm -fv $chapter5 && cd ..\n" >> $MKFILE
 
   # The chapter4 sub-targets are hard-coded to can create the lfs user,
   # to make the scripts executables, and to create a clean environment
@@ -366,7 +384,7 @@
   echo -e "\tln -sv \$(LFS)/tools / && \\" >> $MKFILE
   echo -e "\ttouch \$@\n" >> $MKFILE
 
-  echo "021-addinguser:" >> $MKFILE
+  echo "021-addinguser:  020-creatingtoolsdir" >> $MKFILE
   echo -e "\tgroupadd lfs && \\" >> $MKFILE
   echo -e "\tuseradd -s /bin/bash -g lfs -m -k /dev/null lfs && \\" >> $MKFILE
   echo -e "\tchown lfs \$(LFS)/tools && \\" >> $MKFILE
@@ -375,7 +393,7 @@
   echo -e "\tchmod -R +x $JHALFSDIR/commands && \\" >> $MKFILE
   echo -e "\ttouch \$@\n" >> $MKFILE
 
-  echo "022-settingenvironment:" >> $MKFILE
+  echo "022-settingenvironment:  021-addinguser" >> $MKFILE
   echo -e "\techo \"exec env -i HOME=\\\$\$HOME TERM=\\\$\$TERM PS1='\u:\w\$$ ' /bin/bash\" > /home/lfs/.bash_profile && \\" >> $MKFILE
   echo -e "\techo \"set +h\" > /home/lfs/.bashrc && \\" >> $MKFILE
   echo -e "\techo \"umask 022\" >> /home/lfs/.bashrc && \\" >> $MKFILE
@@ -413,3 +431,4 @@
 
 get_book
 build_Makefile
+#make
\ No newline at end of file




More information about the alfs-log mailing list