From 460ea6306b0a8ace7ef8d19264c4cb7385c383ff Mon Sep 17 00:00:00 2001 From: Manuel Canales Esparcia Date: Fri, 2 Jun 2006 17:53:17 +0000 Subject: [PATCH] Merged r2734:2745 from trunk. --- CLFS/master.sh | 1 + HLFS/master.sh | 14 +++++-- LFS/master.sh | 5 ++- common/common-functions | 81 +++++++++++++++++++++++++++++++-------- common/config | 6 ++- common/func_compare.sh | 10 ++--- common/makefile-functions | 6 +-- common/progress_bar.sh | 15 ++++++++ master.sh | 4 +- 9 files changed, 110 insertions(+), 32 deletions(-) create mode 100755 common/progress_bar.sh diff --git a/CLFS/master.sh b/CLFS/master.sh index 4e5a258..0c28f03 100755 --- a/CLFS/master.sh +++ b/CLFS/master.sh @@ -991,6 +991,7 @@ $HEADER SRC= /sources MOUNT_PT= $BUILDDIR +PKG_LST= $PKG_LST include makefile-functions diff --git a/HLFS/master.sh b/HLFS/master.sh index 55021fb..1e2b13d 100755 --- a/HLFS/master.sh +++ b/HLFS/master.sh @@ -141,7 +141,12 @@ chapter5_Makefiles() { # Bootstrap or temptools phase *) FILE="$name-$vrs.tar.*" ;; esac # Insert instructions for unpacking the package and to set the PKGDIR variable. - wrt_unpack "$FILE" + case $this_script in + *binutils* ) + wrt_unpack "$FILE" 1 ;; # Do not delete an existing package directories + *) + wrt_unpack "$FILE" ;; + esac [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" fi @@ -149,7 +154,7 @@ chapter5_Makefiles() { # Bootstrap or temptools phase *binutils* ) # Dump the path to sources directory for later removal ( cat << EOF - @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ echo "\$(MOUNT_PT)\$(SRC)/\$\$ROOT" >> sources-dir EOF ) >> $MKFILE.tmp @@ -429,7 +434,7 @@ chapter7_Makefiles() { # Create a bootable system.. kernel, bootscripts..e *bootscripts*) ( cat << EOF - @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT @rm -r \`cat sources-dir\` && \\ rm sources-dir @@ -478,6 +483,7 @@ $HEADER SRC= /sources MOUNT_PT= $BUILDDIR +PKG_LST= $PKG_LST include makefile-functions @@ -571,7 +577,7 @@ do-housekeeping: userdel lfs; \\ rm -rf /home/lfs; \\ fi; - + EOF ) >> $MKFILE diff --git a/LFS/master.sh b/LFS/master.sh index f41c0fc..f5aecb3 100755 --- a/LFS/master.sh +++ b/LFS/master.sh @@ -355,6 +355,7 @@ $HEADER SRC= /sources MOUNT_PT= $BUILDDIR +PKG_LST= $PKG_LST include makefile-functions @@ -431,7 +432,7 @@ restore-lfs-env: fi; @chown lfs:lfs /home/lfs/.bash* && \\ touch \$@ - + do_housekeeping: -umount \$(MOUNT_PT)/sys -umount \$(MOUNT_PT)/proc @@ -442,7 +443,7 @@ do_housekeeping: userdel lfs; \\ rm -rf /home/lfs; \\ fi; - + EOF ) >> $MKFILE diff --git a/common/common-functions b/common/common-functions index 1e6b40f..287e02e 100644 --- a/common/common-functions +++ b/common/common-functions @@ -57,7 +57,7 @@ ${BOLD} -B, --book VER${OFF} ${BOLD} -D --directory DIR${OFF} use DIR directory for building ${BOLD}$(echo $PROGNAME | tr [a-z] [A-Z])${OFF}; all files jhalfs-X produces - will be in the directory DIR/jhalfs. + will be in the directory DIR/${SCRIPT_ROOT}. The current setting for BUILDDIR is "$BUILDDIR" ${BOLD} -G, --get-packages${OFF} @@ -201,20 +201,62 @@ cat << EOF $i: $PREV @\$(call echo_message, Building) - @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >logs/$LOGFILE + @./progress_bar.sh \$@ & + @echo -e "\n\`date\`\n\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >logs/$LOGFILE EOF ) >> $MKFILE.tmp } +#----------------------------------# +wrt_remove_existing_dirs() { # +#----------------------------------# + local PKG_NAME=$1 +( +cat << EOF + @PKG_PATH=\`ls -t \$(MOUNT_PT)\$(SRC)/${PKG_NAME} | head -n1\` && \\ + ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\ + [[ -n \$\$ROOT ]] && \\ + rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\ + if [ -e \$(MOUNT_PT)\$(SRC)/${PKG_NAME%%-*}-build ]; then \\ + rm -rf \$(MOUNT_PT)\$(SRC)/${PKG_NAME%%-*}-build; \\ + fi; +EOF +) >> $MKFILE.tmp +} + +#----------------------------------# +wrt_remove_existing_dirs2() { # +#----------------------------------# + local PKG_NAME=$1 +( +cat << EOF + @PKG_PATH=\`ls -t \$(SRC)/${PKG_NAME} | head -n1\` && \\ + ROOT=\`tar -tf \$\$PKG_PATH | head -n1 | sed -e 's@^./@@;s@/.*@@'\` && \\ + [[ -n \$\$ROOT ]] && \\ + rm -rf \$(SRC)/\$\$ROOT && \\ + if [ -e \$(SRC)/${PKG_NAME%%-*}-build ]; then \\ + rm -rf \$(SRC)/${PKG_NAME%%-*}-build; \\ + fi; +EOF +) >> $MKFILE.tmp +} + + + #----------------------------------# wrt_unpack() { # Unpack and set 'ROOT' var #----------------------------------# local FILE=$1 + local optSAVE_PREVIOUS=$2 + + if [ "${optSAVE_PREVIOUS}" != "1" ]; then + wrt_remove_existing_dirs "$FILE" + fi ( cat << EOF @\$(call unpack,$FILE) - @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\ chown -R lfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT EOF @@ -226,10 +268,15 @@ EOF wrt_unpack2() { # #----------------------------------# local FILE=$1 + local optSAVE_PREVIOUS=$2 + + if [ "${optSAVE_PREVIOUS}" != "1" ]; then + wrt_remove_existing_dirs "$FILE" + fi ( cat << EOF @\$(call unpack2,$FILE) - @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars EOF ) >> $MKFILE.tmp @@ -240,16 +287,20 @@ EOF wrt_unpack3() { # #----------------------------------# local FILE=$1 + local optSAVE_PREVIOUS=$2 + + if [ "${optSAVE_PREVIOUS}" != "1" ]; then + wrt_remove_existing_dirs2 "$FILE" + fi ( cat << EOF @\$(call unpack3,$FILE) - @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ echo "export PKGDIR=\$(SRC)/\$\$ROOT" > envars EOF ) >> $MKFILE.tmp } - #----------------------------------# wrt_target_vars() { # Target vars for hlfs (cross-build method) #----------------------------------# @@ -271,7 +322,7 @@ wrt_run_as_su() { # Execute script inside time { }, footer to l ( cat << EOF @( time { su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\ - echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script + echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script EOF ) >> $MKFILE.tmp } @@ -285,7 +336,7 @@ wrt_run_as_root() { # Some scripts must be run as root.. ( cat << EOF @( time { export LFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\ - echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/$this_script + echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script EOF ) >> $MKFILE.tmp } @@ -299,7 +350,7 @@ wrt_run_as_root2() { # ( cat << EOF @( time { source envars && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\ - echo -e "\nKB: \`du -skx --exclude=jhalfs \`\n" >>logs/$this_script + echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \`\n" >>logs/$this_script EOF ) >> $MKFILE.tmp } @@ -313,8 +364,8 @@ wrt_run_as_chroot1() { # local file=$2 ( cat << EOF - @( time { \$(CHROOT1) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\ - echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script} + @( time { \$(CHROOT1) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\ + echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/${this_script} EOF ) >> $MKFILE.tmp } @@ -327,8 +378,8 @@ wrt_run_as_chroot2() { # local file=$2 ( cat << EOF - @( time { \$(CHROOT2) 'cd /jhalfs && source envars && /jhalfs/${PROGNAME}-commands/$file >>/jhalfs/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\ - echo -e "\nKB: \`du -skx --exclude=jhalfs \$(MOUNT_PT)\`\n" >>logs/${this_script} + @( time { \$(CHROOT2) 'cd /${SCRIPT_ROOT} && source envars && /${SCRIPT_ROOT}/${PROGNAME}-commands/$file >>/${SCRIPT_ROOT}/logs/${this_script} 2>&1' ; } ) 2>>logs/$this_script && \\ + echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/${this_script} EOF ) >> $MKFILE.tmp } @@ -363,7 +414,7 @@ wrt_remove_build_dirs() { # local name=$1 ( cat << EOF - @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\ if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\ rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\ @@ -379,7 +430,7 @@ wrt_remove_build_dirs2() { # local name=$1 ( cat << EOF - @ROOT=\`head -n1 /tmp/unpacked | sed 's@^./@@;s@/.*@@'\` && \\ + @ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\ rm -r \$(SRC)/\$\$ROOT && \\ if [ -e \$(SRC)/$name-build ]; then \\ rm -r \$(SRC)/$name-build; \\ diff --git a/common/config b/common/config index 7a01da1..53409b8 100644 --- a/common/config +++ b/common/config @@ -88,9 +88,13 @@ RUN_FARCE=0 # Don't edit it unless you know what you are doing #--- Working directories -JHALFSDIR=$BUILDDIR/jhalfs +SCRIPT_ROOT=jhalfs +JHALFSDIR=$BUILDDIR/$SCRIPT_ROOT LOGDIR=$JHALFSDIR/logs +#--- File listing package contents (from where package sources dir is extracted) +PKG_LST=unpacked + #--- ICA report log directory ICALOGDIR=$LOGDIR/ICA diff --git a/common/func_compare.sh b/common/func_compare.sh index e4ff4f7..4dc0707 100644 --- a/common/func_compare.sh +++ b/common/func_compare.sh @@ -43,17 +43,17 @@ wrt_compare_work() { # #----------------------------------# local ITERATION=$1 local PREV_IT=$2 - local PRUNEPATH="/dev /home /jhalfs /lost+found /media /mnt /opt /proc \ + local PRUNEPATH="/dev /home /${SCRIPT_ROOT} /lost+found /media /mnt /opt /proc \ /sources /root /srv /sys /tmp /tools /usr/local /usr/src /var/log/paco" if [[ "$PROGNAME" = "clfs" ]] && [[ "$METHOD" = "boot" ]] ; then local ROOT_DIR=/ - local DEST_TOPDIR=/jhalfs - local ICALOGDIR=/jhalfs/logs/ICA - local FARCELOGDIR=/jhalfs/logs/farce + local DEST_TOPDIR=/${SCRIPT_ROOT} + local ICALOGDIR=/${SCRIPT_ROOT}/logs/ICA + local FARCELOGDIR=/${SCRIPT_ROOT}/logs/farce else local ROOT_DIR=$BUILDDIR - local DEST_TOPDIR=$BUILDDIR/jhalfs + local DEST_TOPDIR=$BUILDDIR/${SCRIPT_ROOT} fi if [[ "$RUN_ICA" = "1" ]] ; then diff --git a/common/makefile-functions b/common/makefile-functions index e0975d6..c3fc21a 100644 --- a/common/makefile-functions +++ b/common/makefile-functions @@ -17,17 +17,17 @@ endef define unpack @cd $(MOUNT_PT)$(SRC) && \ - tar -xvf `ls -t $(1) | head -n1` > /tmp/unpacked + tar -xvf `ls -t $(1) | head -n1` > $(PKG_LST) endef define unpack2 @cd $(MOUNT_PT)$(SRC) && \ - /tools/bin/tar -xvf `ls -t $(1) | head -n1` > /tmp/unpacked + /tools/bin/tar -xvf `ls -t $(1) | head -n1` > $(PKG_LST) endef define unpack3 @cd $(SRC) && \ - tar -xvf `ls -t $(1) | head -n1` > /tmp/unpacked + tar -xvf `ls -t $(1) | head -n1` > $(PKG_LST) endef define echo_report diff --git a/common/progress_bar.sh b/common/progress_bar.sh new file mode 100755 index 0000000..04303ef --- /dev/null +++ b/common/progress_bar.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# $Id$ + +set -e + +[[ -z $1 ]] && exit + +if [ ! -f $1 ] ; then + while fuser -v . 2>&1 | grep make >/dev/null ; do + echo -n "." + sleep 1 + [[ -f $1 ]] && exit + done +fi diff --git a/master.sh b/master.sh index 81352de..79df1e0 100755 --- a/master.sh +++ b/master.sh @@ -136,7 +136,7 @@ while test $# -gt 0 ; do ;; * ) BUILDDIR=$1 - JHALFSDIR=$BUILDDIR/jhalfs + JHALFSDIR=$BUILDDIR/${SCRIPT_ROOT} LOGDIR=$JHALFSDIR/logs MKFILE=$JHALFSDIR/Makefile ;; @@ -481,7 +481,7 @@ fi # # if [[ "$PWD" != "$JHALFSDIR" ]]; then - cp $COMMON_DIR/makefile-functions $JHALFSDIR/ + cp $COMMON_DIR/{makefile-functions,progress_bar.sh} $JHALFSDIR/ [[ "$OPTIMIZE" != "0" ]] && cp optimize/opt_override $JHALFSDIR/ if [[ "$COMPARE" != "0" ]] ; then mkdir -p $JHALFSDIR/extras