Makefile envars and fuctions revised.

This commit is contained in:
Manuel Canales Esparcia 2007-09-27 20:41:58 +00:00
parent 111d25a4a5
commit aafcfa9fbd
3 changed files with 41 additions and 82 deletions

View file

@ -100,13 +100,13 @@ chapter5_Makefiles() {
# #
# Drop in the name of the target on a new line, and the previous target # Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function. # as a dependency. Also call the echo_message function.
LUSER_wrt_target "${this_script}" "$PREV" wrt_target "${this_script}" "$PREV"
# Run the script. # Run the script.
# The changingowner script must be run as root. # The changingowner script must be run as root.
case "${this_script}" in case "${this_script}" in
*changingowner) wrt_RunAsRoot "$file" ;; *changingowner) wrt_RunAsRoot "$file" ;;
*) LUSER_wrt_RunAsUser "$file" ;; *) wrt_RunScript "$file" ;;
esac esac
# Include a touch of the target name so make can check # Include a touch of the target name so make can check
@ -185,29 +185,24 @@ chapter6_Makefiles() {
# #
# Drop in the name of the target on a new line, and the previous target # Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function. # as a dependency. Also call the echo_message function.
# In the mount of kernel filesystems we need to set LFS wrt_target "${this_script}" "$PREV"
# and not to use chroot.
case "${this_script}" in
*kernfs) LUSER_wrt_target "${this_script}" "$PREV" ;;
*) CHROOT_wrt_target "${this_script}" "$PREV" ;;
esac
# Touch timestamp file if installed files logs will be created. # Touch timestamp file if installed files logs will be created.
# But only for the firt build when running iterative builds. # But only for the firt build when running iterative builds.
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
CHROOT_wrt_TouchTimestamp wrt_TouchTimestamp
fi fi
# 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.
case "${this_script}" in case "${this_script}" in
*kernfs) wrt_RunAsRoot "$file" ;; *kernfs) wrt_RunAsRoot "$file" ;;
*) CHROOT_wrt_RunAsRoot "$file" ;; *) wrt_RunScript "$file" ;;
esac esac
# Write installed files log # Write installed files log
if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then if [ "$name" != "" ] && [ "${INSTALL_LOG}" = "y" ] && [ "x${N}" = "x" ] ; then
CHROOT_wrt_LogNewFiles "$name" wrt_LogNewFiles "$name"
fi fi
# Include a touch of the target name so make can check # Include a touch of the target name so make can check
@ -254,33 +249,31 @@ chapter78_Makefiles() {
# #
# Drop in the name of the target on a new line, and the previous target # Drop in the name of the target on a new line, and the previous target
# as a dependency. Also call the echo_message function. # as a dependency. Also call the echo_message function.
CHROOT_wrt_target "${this_script}" "$PREV" wrt_target "${this_script}" "$PREV"
# For bootscripts and kernel, start INSTALL_LOG if requested # For bootscripts and kernel, start INSTALL_LOG if requested
case "${this_script}" in case "${this_script}" in
*bootscripts | *kernel ) if [ "${INSTALL_LOG}" = "y" ] ; then *bootscripts | *kernel ) if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_TouchTimestamp wrt_TouchTimestamp
fi ;; fi ;;
esac esac
# Check if we have a real /etc/fstab file # Check if we have a real /etc/fstab file
case "${this_script}" in case "${this_script}" in
*fstab) if [[ -n $FSTAB ]]; then *fstab) if [[ -n $FSTAB ]]; then
CHROOT_wrt_CopyFstab wrt_CopyFstab
else else
CHROOT_wrt_RunAsRoot "$file" wrt_RunScript "$file"
fi fi ;;
;; *) wrt_RunScript "$file" ;;
*) CHROOT_wrt_RunAsRoot "$file"
;;
esac esac
case "${this_script}" in case "${this_script}" in
*bootscripts) if [ "${INSTALL_LOG}" = "y" ] ; then *bootscripts) if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_LogNewFiles "lfs-bootscripts" wrt_LogNewFiles "lfs-bootscripts"
fi ;; fi ;;
*kernel) if [ "${INSTALL_LOG}" = "y" ] ; then *kernel) if [ "${INSTALL_LOG}" = "y" ] ; then
CHROOT_wrt_LogNewFiles "linux" wrt_LogNewFiles "linux"
fi ;; fi ;;
esac esac

View file

@ -17,26 +17,18 @@ wrt_Makefile_header() { #
SHELL = /bin/bash SHELL = /bin/bash
SRC = /sources
MOUNT_PT = $BUILDDIR MOUNT_PT = $BUILDDIR
SCRIPT_ROOT = $SCRIPT_ROOT
CMDSDIR = $PROGNAME-commands
SRC = /sources
SRCSDIR = \$(MOUNT_PT)\$(SRC)
FILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
LUSER = $LUSER LUSER = $LUSER
LGROUP = $LGROUP LGROUP = $LGROUP
LHOME = $LHOME LHOME = $LHOME
SCRIPT_ROOT = $SCRIPT_ROOT
BASEDIR = \$(MOUNT_PT)
SRCSDIR = \$(BASEDIR)/sources
CMDSDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$PROGNAME-commands
LOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$LOGDIRBASE
TESTLOGDIR = \$(BASEDIR)/\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
crCMDSDIR = /\$(SCRIPT_ROOT)/$PROGNAME-commands
crLOGDIR = /\$(SCRIPT_ROOT)/$LOGDIRBASE
crTESTLOGDIR = /\$(SCRIPT_ROOT)/$TESTLOGDIRBASE
crFILELOGDIR = /\$(SCRIPT_ROOT)/$FILELOGDIRBASE
SU_LUSER = su - \$(LUSER) -c
LUSER_HOME = \$(LHOME)/\$(LUSER) LUSER_HOME = \$(LHOME)/\$(LUSER)
SU_LUSER = su - \$(LUSER) -c
ADD_REPORT = $REPORT ADD_REPORT = $REPORT
ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS ADD_CUSTOM_TOOLS = $CUSTOM_TOOLS
@ -57,22 +49,7 @@ EOF
#==== TARGET HEADER ==== #==== TARGET HEADER ====
#----------------------------------# #----------------------------------#
LUSER_wrt_target() { # Create target wrt_target() { # Create target
#----------------------------------#
local i=$1
local PREV=$2
(
cat << EOF
$i: $PREV
@\$(call echo_message, Building)
@export BASHBIN=\$(SHELL) && \$(SHELL) progress_bar.sh \$@ \$\$PPID &
EOF
) >> $MKFILE.tmp
}
#----------------------------------#
CHROOT_wrt_target() { #
#----------------------------------# #----------------------------------#
local i=$1 local i=$1
local PREV=$2 local PREV=$2
@ -89,10 +66,10 @@ EOF
#======================= #=======================
#======== RUN AS ======= #======== RUN THE SCRIPT =======
#----------------------------------# #----------------------------------#
wrt_RunAsRoot() { # Some scripts must be run as root.. wrt_RunAsRoot() { # Some not-chroot scripts must be run as root..
#----------------------------------# #----------------------------------#
local MOUNT_ENV local MOUNT_ENV
local file=$1 local file=$1
@ -108,13 +85,13 @@ wrt_RunAsRoot() { # Some scripts must be run as root..
( (
cat << EOF cat << EOF
@export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1 @export ${MOUNT_ENV}=\$(MOUNT_PT) && \$(CMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
EOF EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
} }
#----------------------------------# #----------------------------------#
LUSER_wrt_RunAsUser() { # wrt_RunScript() { #
#----------------------------------# #----------------------------------#
local file=$1 local file=$1
@ -125,25 +102,13 @@ EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
} }
#----------------------------------#
CHROOT_wrt_RunAsRoot() { #
#----------------------------------#
local file=$1
(
cat << EOF
@\$(crCMDSDIR)/`dirname $file`/\$@ > $LOGDIRBASE/\$@ 2>&1
EOF
) >> $MKFILE.tmp
}
#======================= #=======================
#====== COPY FSTAB ===== #====== COPY FSTAB =====
#----------------------------------# #----------------------------------#
LUSER_wrt_CopyFstab() { # LUSER_wrt_CopyFstab() { # Needed for CLFS Sysroot and Embedded
#----------------------------------# #----------------------------------#
( (
cat << EOF cat << EOF
@ -153,7 +118,7 @@ EOF
} }
#----------------------------------# #----------------------------------#
CHROOT_wrt_CopyFstab() { # wrt_CopyFstab() { #
#----------------------------------# #----------------------------------#
( (
cat << EOF cat << EOF
@ -168,7 +133,7 @@ EOF
#==== INSTALLED FILES LOGS ==== #==== INSTALLED FILES LOGS ====
#----------------------------------# #----------------------------------#
LUSER_wrt_TouchTimestamp() { # LUSER_wrt_TouchTimestamp() { # Needed for CLFS Sysroot and Embedded
#----------------------------------# #----------------------------------#
( (
cat << EOF cat << EOF
@ -178,7 +143,7 @@ EOF
} }
#----------------------------------# #----------------------------------#
CHROOT_wrt_TouchTimestamp() { # wrt_TouchTimestamp() { #
#----------------------------------# #----------------------------------#
( (
cat << EOF cat << EOF
@ -188,7 +153,7 @@ EOF
} }
#----------------------------------# #----------------------------------#
LUSER_wrt_LogNewFiles() { # LUSER_wrt_LogNewFiles() { # Needed for CLFS Sysroot and Embedded
#----------------------------------# #----------------------------------#
local name=$1 local name=$1
( (
@ -199,7 +164,7 @@ EOF
} }
#----------------------------------# #----------------------------------#
CHROOT_wrt_LogNewFiles() { # wrt_LogNewFiles() { #
#----------------------------------# #----------------------------------#
local name=$1 local name=$1
( (

View file

@ -83,13 +83,13 @@ endef
define log_new_files define log_new_files
@find / -xdev ! -path "/$(SCRIPT_ROOT)/*" ! -path "/tmp/*" ! -path "$(SRC)/*" \ @find / -xdev ! -path "/$(SCRIPT_ROOT)/*" ! -path "/tmp/*" ! -path "$(SRC)/*" \
-newer $(SRC)/timestamp-marker -not -type d \ -newer $(SRC)/timestamp-marker -not -type d \
-printf "%p\t%s\t%u:%g\t%m\t%l\n" | sort > $(crFILELOGDIR)/$(1) -printf "%p\t%s\t%u:%g\t%m\t%l\n" | sort > $(FILELOGDIR)/$(1)
endef endef
define log_new_files_LUSER define log_new_files_LUSER
@find $(BASEDIR) -xdev ! -path "$(BASEDIR)/$(SCRIPT_ROOT)/*" ! -path "$(BASEDIR)/tmp/*" ! -path "$(SRCSDIR)/*" \ @find $(MOUNT_PT) -xdev ! -path "$(MOUNT_PT)/$(SCRIPT_ROOT)/*" ! -path "$(MOUNT_PT)/tmp/*" ! -path "$(SRCSDIR)/*" \
-newer $(SRCSDIR)/timestamp-marker -not -type d \ -newer $(SRCSDIR)/timestamp-marker -not -type d \
-printf "%p\t%s\t%u:%g\t%m\t%l\n" | sort > $(BASEDIR)$(crFILELOGDIR)/$(1) -printf "%p\t%s\t%u:%g\t%m\t%l\n" | sort > $(MOUNT_PT)$(FILELOGDIR)/$(1)
endef endef
#======================= #=======================
@ -101,8 +101,9 @@ define echo_report
echo ; \ echo ; \
echo $(BOLD) The report file $(BLUE)$(1)$(BOLD) has been created ; \ echo $(BOLD) The report file $(BLUE)$(1)$(BOLD) has been created ; \
echo ; \ echo ; \
echo $(WHITE)Please send the $(BOLD)$(MOUNT_PT)/jhalfs/$(1)$(WHITE) ; \ echo $(WHITE)If this is a development book build, please send the ; \
echo file to $(BOLD)manuel@linuxfromscratch.org$(WHITE) ; \ echo $(BOLD)$(MOUNT_PT)/$(SCRIPT_ROOT)/$(1)$(WHITE) file to ; \
echo $(BOLD)manuel@linuxfromscratch.org$(WHITE) ; \
echo ; \ echo ; \
echo That will help us to keep more accurate SBU and ; \ echo That will help us to keep more accurate SBU and ; \
echo disk usage values into the book. Thanks. ; \ echo disk usage values into the book. Thanks. ; \
@ -167,7 +168,7 @@ define echo_boot_finished
@echo 1.If it is necessary, transfer the newly created partition to the target machine @echo 1.If it is necessary, transfer the newly created partition to the target machine
@echo 2.Boot the new partition. @echo 2.Boot the new partition.
@echo 3.Once you are logged in issue the following commands @echo 3.Once you are logged in issue the following commands
@echo $(tab_) $(BOLD)cd /jhalfs @echo $(tab_) $(BOLD)cd /$(SCRIPT_ROOT)
@echo $(tab_) $(BOLD)make makesys @echo $(tab_) $(BOLD)make makesys
@echo The build process should resume. Follow any instructions that appear. @echo The build process should resume. Follow any instructions that appear.
@echo -------------------------------------------------------------------------------- @echo --------------------------------------------------------------------------------