Functions clean-up.

This commit is contained in:
Manuel Canales Esparcia 2006-11-11 21:20:15 +00:00
parent 195ed9f9a9
commit 8f2c0862e9
6 changed files with 12 additions and 52 deletions

View file

@ -357,17 +357,13 @@ chroot_Makefiles() { #
# Insert instructions for unpacking the package and changing directories # Insert instructions for unpacking the package and changing directories
# #
if [ "$pkg_tarball" != "" ] ; then if [ "$pkg_tarball" != "" ] ; then
case $this_script in CHROOT_Unpack "$pkg_tarball"
*util-linux) ROOT_Unpack "$pkg_tarball" ;;
*) CHROOT_Unpack "$pkg_tarball" ;;
esac
[[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
fi fi
# #
# Select a script execution method # Select a script execution method
case $this_script in case $this_script in
*kernfs) wrt_RunAsRoot "${this_script}" "${file}" ;; *kernfs) wrt_RunAsRoot "${file}" ;;
*util-linux) ROOT_RunAsRoot "${file}" ;;
*) CHROOT_wrt_RunAsRoot "${file}" ;; *) CHROOT_wrt_RunAsRoot "${file}" ;;
esac esac
# #
@ -456,8 +452,8 @@ boot_Makefiles() { #
case $this_script in case $this_script in
# The following 2 scripts are defined in the /boot directory but need # The following 2 scripts are defined in the /boot directory but need
# to be run as a root user. Set them up here but run them in another phase # to be run as a root user. Set them up here but run them in another phase
*changingowner*) wrt_RunAsRoot "${this_script}" "${file}" ;; *changingowner*) wrt_RunAsRoot "${file}" ;;
*devices*) wrt_RunAsRoot "${this_script}" "${file}" ;; *devices*) wrt_RunAsRoot "${file}" ;;
*fstab*) if [[ -n "$FSTAB" ]]; then *fstab*) if [[ -n "$FSTAB" ]]; then
LUSER_wrt_CopyFstab LUSER_wrt_CopyFstab
else else

View file

@ -391,7 +391,7 @@ bootable_Makefiles() { #
LUSER_wrt_RunAsUser "${file}" LUSER_wrt_RunAsUser "${file}"
fi fi
;; ;;
*chowning) wrt_RunAsRoot "${this_script}" "${file}" *chowning) wrt_RunAsRoot "${file}"
;; ;;
*) LUSER_wrt_RunAsUser "${file}" *) LUSER_wrt_RunAsUser "${file}"
;; ;;

View file

@ -385,7 +385,7 @@ bootable_Makefiles() { #
LUSER_wrt_RunAsUser "${file}" LUSER_wrt_RunAsUser "${file}"
fi fi
;; ;;
*chowning) wrt_RunAsRoot "${this_script}" "${file}" *chowning) wrt_RunAsRoot "${file}"
;; ;;
*) LUSER_wrt_RunAsUser "${file}" *) LUSER_wrt_RunAsUser "${file}"
;; ;;

View file

@ -362,7 +362,7 @@ chapter6_Makefiles() { # sysroot or chroot build phase
# In the mount of kernel filesystems we need to set HLFS and not to use chroot. # In the mount of kernel filesystems we need to set HLFS and not to use chroot.
case "${this_script}" in case "${this_script}" in
*kernfs* | *changingowner*) *kernfs* | *changingowner*)
wrt_RunAsRoot "${this_script}" "${file}" wrt_RunAsRoot "${file}"
;; ;;
*) # The rest of Chapter06 *) # The rest of Chapter06
CHROOT_wrt_RunAsRoot "${file}" CHROOT_wrt_RunAsRoot "${file}"

View file

@ -136,7 +136,7 @@ chapter5_Makefiles() {
# and date and disk usage again at the bottom of the log file. # and date and disk usage again at the bottom of the log file.
# 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 "${this_script}" "$file" ;; *changingowner) wrt_RunAsRoot "$file" ;;
*) LUSER_wrt_RunAsUser "$file" ;; *) LUSER_wrt_RunAsUser "$file" ;;
esac esac
@ -252,7 +252,7 @@ chapter6_Makefiles() {
# 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 "${this_script}" "$file" ;; *kernfs) wrt_RunAsRoot "$file" ;;
*) CHROOT_wrt_RunAsRoot "$file" ;; *) CHROOT_wrt_RunAsRoot "$file" ;;
esac esac

View file

@ -125,28 +125,6 @@ EOF
#======== UNPACK ======= #======== UNPACK =======
#----------------------------------#
ROOT_Unpack() { # An alias, for clairity
#----------------------------------#
local FILE=$1
local optSAVE_PREVIOUS=$2
if [[ "${optSAVE_PREVIOUS}" != "1" ]]; then
(
cat << EOF
@\$(call remove_existing_dirs,$FILE)
EOF
) >> $MKFILE.tmp
fi
(
cat << EOF
@\$(call unpack,$FILE)
@\$(call get_pkg_root_LUSER)
EOF
) >> $MKFILE.tmp
}
#----------------------------------# #----------------------------------#
LUSER_wrt_unpack() { # Unpack and set 'ROOT' var LUSER_wrt_unpack() { # Unpack and set 'ROOT' var
#----------------------------------# #----------------------------------#
@ -213,7 +191,7 @@ CHROOT_wrt_test_log() { #
local TESTLOGFILE=$1 local TESTLOGFILE=$1
( (
cat << EOF cat << EOF
@echo "export TEST_LOG=/\$(SCRIPT_ROOT)/test-logs/$TESTLOGFILE" >> envars && \\ @echo "export TEST_LOG=\$(crTESTLOGDIR)/$TESTLOGFILE" >> envars && \\
echo "\$(nl_)\`date\`\$(nl_)" >test-logs/$TESTLOGFILE echo "\$(nl_)\`date\`\$(nl_)" >test-logs/$TESTLOGFILE
EOF EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
@ -228,12 +206,10 @@ EOF
wrt_RunAsRoot() { # Some scripts must be run as root.. wrt_RunAsRoot() { # Some scripts must be run as root..
#----------------------------------# #----------------------------------#
local MOUNT_ENV local MOUNT_ENV
local this_script=$1 local file=$1
local file=$2
case ${PROGNAME} in case ${PROGNAME} in
lfs ) MOUNT_ENV="LFS" ;; lfs ) MOUNT_ENV="LFS" ;;
blfs ) MOUNT_ENV="BLFS" ;;
clfs ) MOUNT_ENV="CLFS" ;; clfs ) MOUNT_ENV="CLFS" ;;
clfs2 ) MOUNT_ENV="CLFS" ;; clfs2 ) MOUNT_ENV="CLFS" ;;
clfs3 ) MOUNT_ENV="CLFS" ;; clfs3 ) MOUNT_ENV="CLFS" ;;
@ -249,18 +225,6 @@ EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp
} }
#----------------------------------#
ROOT_RunAsRoot() { #
#----------------------------------#
local file=$1
(
cat << EOF
@( time { source envars && \$(CMDSDIR)/$file >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
\$(PRT_DU_CR) >>logs/\$@
EOF
) >> $MKFILE.tmp
}
#----------------------------------# #----------------------------------#
LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file LUSER_wrt_RunAsUser() { # Execute script inside time { }, footer to log file
#----------------------------------# #----------------------------------#
@ -280,7 +244,7 @@ CHROOT_wrt_RunAsRoot() { #
local file=$1 local file=$1
( (
cat << EOF cat << EOF
@( time { source envars && \$(crCMDSDIR)/$file >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\ @( time { source envars && \$(crCMDSDIR)/`dirname $file`/\$@ >>logs/\$@ 2>&1 ; } ) 2>>logs/\$@ && \\
\$(PRT_DU_CR) >>logs/\$@ \$(PRT_DU_CR) >>logs/\$@
EOF EOF
) >> $MKFILE.tmp ) >> $MKFILE.tmp