Changed the "if" test to use a cunstomized function.

Thanks to George B.
This commit is contained in:
Manuel Canales Esparcia 2005-10-24 19:21:09 +00:00
parent 49aea5ef15
commit e1093cd73b

101
jhalfs
View file

@ -3,7 +3,7 @@
# #
# Load the configuration file # Load the configuration file
# #
. jhalfs.conf source jhalfs.conf
version=" version="
@ -277,6 +277,18 @@ get_sources() {
fi fi
} }
#-----------------------------------------------#
_IS_() # Function to test build scripts names
#-----------------------------------------------#
{
# Returns substr $2 or null str
# Must use string testing
case $1 in
*$2*) echo "$2" ;;
*) echo "" ;;
esac
}
#----------------------------# #----------------------------#
chapter4_Makefiles() { chapter4_Makefiles() {
#----------------------------# #----------------------------#
@ -321,11 +333,7 @@ chapter5_Makefiles() {
# If no testsuites will be run, then TCL, Expect and DejaGNU isn't needed # If no testsuites will be run, then TCL, Expect and DejaGNU isn't needed
if [ "$TOOLCHAINTEST" = "0" ]; then if [ "$TOOLCHAINTEST" = "0" ]; then
if echo $i | grep -q "tcl" ; then if [[ `_IS_ $i tcl` ]] || [[ `_IS_ $i expect` ]] || [[ `_IS_ $i dejagnu` ]] ; then
continue
elif echo $i | grep -q "expect" ; then
continue
elif echo $i | grep -q "dejagnu" ; then
continue continue
fi fi
fi fi
@ -378,7 +386,7 @@ EOF
fi fi
# Dump the path to the Binutils or TCL sources directory. # Dump the path to the Binutils or TCL sources directory.
if [ ${i:4:8} = "binutils" -o ${i:4:3} = "tcl" ] ; then if [[ `_IS_ $i binutils` ]] || [[ `_IS_ $i tcl` ]] ; then
( (
cat << EOF cat << EOF
echo "\$(LFS)\$(SRC)/\$\$ROOT" > sources-dir echo "\$(LFS)\$(SRC)/\$\$ROOT" > sources-dir
@ -386,7 +394,7 @@ EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
# For the Adjusting phase we must to cd to the binutils-build directory. # For the Adjusting phase we must to cd to the binutils-build directory.
elif [ ${i:4:9} = "adjusting" ] ; then elif [[ `_IS_ $i adjusting` ]] ; then
( (
cat << EOF cat << EOF
@echo "PKGDIR=\$(LFS)\$(SRC)/binutils-build" > envars && \\ @echo "PKGDIR=\$(LFS)\$(SRC)/binutils-build" > envars && \\
@ -395,7 +403,7 @@ EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
# For the Expect build we need to set the TCLPATH envar. # For the Expect build we need to set the TCLPATH envar.
elif [ ${i:4:6} = "expect" ] ; then elif [[ `_IS_ $i expect` ]] ; then
( (
cat << EOF cat << EOF
echo "TCLPATH=\`cat sources-dir\`" >> envars && \\ echo "TCLPATH=\`cat sources-dir\`" >> envars && \\
@ -426,7 +434,7 @@ EOF
# (to can review config.cache, config.log, and like.) # (to can review config.cache, config.log, and like.)
# For Binutils and TCL the sources must be retained some time. # For Binutils and TCL the sources must be retained some time.
if [ "$vrs" != "" ] ; then if [ "$vrs" != "" ] ; then
if [ ${i:4:8} != "binutils" ] && [ ${i:4:3} != "tcl" ] ; then if [[ ! `_IS_ $i binutils` ]] && [[ ! `_IS_ $i tcl` ]] ; then
( (
cat << EOF cat << EOF
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
@ -440,7 +448,7 @@ EOF
fi fi
# Remove the Binutils pass 1 sources after a successful Adjusting phase. # Remove the Binutils pass 1 sources after a successful Adjusting phase.
if [ ${i:4:9} = "adjusting" ] ; then if [[ `_IS_ $i adjusting` ]] ; then
( (
cat << EOF cat << EOF
@rm -r \`cat sources-dir\` && \\ @rm -r \`cat sources-dir\` && \\
@ -451,7 +459,7 @@ EOF
fi fi
# Remove the TCL sources after a successful Expect build. # Remove the TCL sources after a successful Expect build.
if [ ${i:4:6} = "expect" ] ; then if [[ `_IS_ $i expect` ]] ; then
( (
cat << EOF cat << EOF
@rm -r \`cat sources-dir\` && \\ @rm -r \`cat sources-dir\` && \\
@ -482,7 +490,7 @@ chapter6_Makefiles() {
# We'll run the chroot commands differently than the others, so skip them in the # We'll run the chroot commands differently than the others, so skip them in the
# dependencies and target creation. # dependencies and target creation.
if echo $i | grep -q "chroot" ; then if [[ `_IS_ $i chroot` ]] ; then
continue continue
fi fi
@ -522,27 +530,25 @@ EOF
fi fi
# For the Re-Adjusting phase we must to cd to the binutils-build directory. # For the Re-Adjusting phase we must to cd to the binutils-build directory.
if [ ${i:4:11} = "readjusting" ] ; then if [[ `_IS_ $i readjusting` ]] ; then
( (
cat << EOF cat << EOF
@echo "PKGDIR=\$(SRC)/binutils-build" > envars && \\ @echo "PKGDIR=\$(SRC)/binutils-build" > envars && \\
echo "export PKGDIR" >> envars echo "export PKGDIR" >> envars
EOF EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
fi
# For Glibc we need to set TIMEZONE envar. # For Glibc we need to set TIMEZONE envar.
if [ ${i:4:5} = "glibc" ] ; then elif [[ `_IS_ $i glibc` ]] ; then
( (
cat << EOF cat << EOF
@echo "TIMEZONE=\$(TIMEZONE)" >> envars && \\ @echo "TIMEZONE=\$(TIMEZONE)" >> envars && \\
echo "export TIMEZONE" >> envars echo "export TIMEZONE" >> envars
EOF EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
fi
# For Groff we need to set PAGE envar. # For Groff we need to set PAGE envar.
if [ ${i:4:5} = "groff" ] ; then elif [[ `_IS_ $i groff` ]] ; then
( (
cat << EOF cat << EOF
@echo "PAGE=\$(PAGE)" >> envars && \\ @echo "PAGE=\$(PAGE)" >> envars && \\
@ -553,7 +559,7 @@ EOF
# In the mount of kernel filesystems we need to set LFS # In the mount of kernel filesystems we need to set LFS
# and not to use chroot. # and not to use chroot.
if [ ${i:4:6} = "kernfs" ] ; then if [[ `_IS_ $i kernfs` ]] ; then
( (
cat << EOF cat << EOF
@echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\ @echo -e "\n\`date\`\n\nKB: \`du -sk --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
@ -571,7 +577,6 @@ EOF
echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >>logs/$i
EOF EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
fi fi
# Remove the build directory(ies) except if the package build fails. # Remove the build directory(ies) except if the package build fails.
@ -588,7 +593,7 @@ EOF
fi fi
# Remove the Binutils pass 2 sources after a successful Re-Adjusting phase. # Remove the Binutils pass 2 sources after a successful Re-Adjusting phase.
if [ ${i:4:11} = "readjusting" ] ; then if [[ `_IS_ $i readjusting` ]] ; then
( (
cat << EOF cat << EOF
@rm -r \`cat sources-dir\` && \\ @rm -r \`cat sources-dir\` && \\
@ -618,21 +623,17 @@ chapter789_Makefiles() {
# Keep the script file name # Keep the script file name
i=`basename $file` i=`basename $file`
# Grub must be configured manually # Grub must be configured manually.
if echo $i | grep -q "grub" ; then # The filesystems can't be unmounted via Makefile and the user
continue # should to enter to the chroot environment to create the root
# The filesystems can't be unmounted yet due that the user must # password, edit several files and setup Grub,
# to enter to the chroot environment to create the root password, if [[ `_IS_ $i grub` ]] || [[ `_IS_ $i reboot` ]] ; then
# edit several files and setup Grub,
elif echo $i | grep -q "reboot" ; then
continue continue
fi fi
# If no .config file is supplied, the kernel build is skipped # If no .config file is supplied, the kernel build is skipped
if [ -z $CONFIG ] ; then if [ -z $CONFIG ] && [[ `_IS_ $i kernel` ]] ; then
if echo $i | grep -q "kernel" ; then continue
continue
fi
fi fi
# First append each name of the script files to a list (this will become # First append each name of the script files to a list (this will become
@ -650,11 +651,11 @@ EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
# Find the the bootscripts and kernel package names # Find the the bootscripts and kernel package names
if [ ${i:4:11} = "bootscripts" -o ${i:4:6} = "kernel" ] ; then if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
if [ ${i:4:11} = "bootscripts" ] ; then if [[ `_IS_ $i bootscripts` ]] ; then
vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` vrs=`grep "^lfs-bootscripts-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
FILE="lfs-bootscripts-$vrs.tar.bz2" FILE="lfs-bootscripts-$vrs.tar.bz2"
elif [ ${i:4:6} = "kernel" ] ; then elif [[ `_IS_ $i kernel` ]] ; then
vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'` vrs=`grep "^linux-version" $JHALFSDIR/packages | sed -e 's/.* //' -e 's/"//g'`
FILE="linux-$vrs.tar.bz2" FILE="linux-$vrs.tar.bz2"
fi fi
@ -669,7 +670,7 @@ EOF
fi fi
# Put in place the kernel .config file # Put in place the kernel .config file
if [ ${i:4:6} = "kernel" ] ; then if [[ `_IS_ $i kernel` ]] ; then
( (
cat << EOF cat << EOF
@cp $CONFIG \$(LFS)/sources/kernel-config @cp $CONFIG \$(LFS)/sources/kernel-config
@ -678,7 +679,7 @@ EOF
fi fi
# Check if we have a real /etc/fstab file # Check if we have a real /etc/fstab file
if [ ${i:4:5} = "fstab" ] && [ -n "$FSTAB" ] ; then if [[ `_IS_ $i fstab` ]] && [[ -n "$FSTAB" ]] ; then
( (
cat << EOF cat << EOF
@echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\ @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude={0,1}??-* \$(LFS)\`\n" >logs/$i && \\
@ -698,7 +699,7 @@ EOF
fi fi
# Remove the build directory except if the package build fails. # Remove the build directory except if the package build fails.
if [ ${i:4:11} = "bootscripts" -o ${i:4:6} = "kernel" ] ; then if [[ `_IS_ $i bootscripts` ]] || [[ `_IS_ $i kernel` ]] ; then
( (
cat << EOF cat << EOF
@ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\
@ -832,18 +833,6 @@ if [ "$UID" != "0" ] ; then
exit 1 exit 1
fi fi
# Find the download client to use, if not already specified.
if [ -z $DL ] ; then
if [ `type -p wget` ] ; then
DL=wget
elif [ `type -p curl` ] ; then
DL=curl
else
eval "$no_dl_client"
fi
fi
# Evaluate any command line switches # Evaluate any command line switches
while test $# -gt 0 ; do while test $# -gt 0 ; do
@ -965,6 +954,18 @@ while test $# -gt 0 ; do
shift shift
done done
# Find the download client to use, if not already specified.
if [ -z $DL ] ; then
if [ `type -p wget` ] ; then
DL=wget
elif [ `type -p curl` ] ; then
DL=curl
else
eval "$no_dl_client"
fi
fi
[[ ! -d $JHALFSDIR ]] && mkdir -pv $JHALFSDIR [[ ! -d $JHALFSDIR ]] && mkdir -pv $JHALFSDIR
[[ "$PWD" != "$JHALFSDIR" ]] && cp -v $0 $XSL $FILES $JHALFSDIR/ [[ "$PWD" != "$JHALFSDIR" ]] && cp -v $0 $XSL $FILES $JHALFSDIR/
[[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR [[ ! -d $LOGDIR ]] && mkdir -v $LOGDIR