Changeset 6ad5a2f for CLFS2


Ignore:
Timestamp:
08/08/2006 05:26:40 PM (18 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
2.3, 2.3.x, 2.4, ablfs, ablfs-more, legacy, new_features, trunk
Children:
daa9b6c
Parents:
983db9f
Message:

Ported LUSER code and last CLFS2 fix from experimental.

Location:
CLFS2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CLFS2/config

    r983db9f r6ad5a2f  
    2121#--------------------------------
    2222# >>>> MULTILIB 32/64 <<<<
     23
     24#--- Unprivileged user and group name
     25LUSER=clfs
     26LGROUP=clfs
    2327
    2428#--- Location of fstab file (if empty, a template is created)
  • CLFS2/master.sh

    r983db9f r6ad5a2f  
    55###          FUNCTIONS          ###
    66###################################
    7 
    8 #----------------------------------#
    9 wrt_ExecuteAsUser() {              # Execute the file ($3) under the users account ($1), log in $2
    10 #----------------------------------#
    11   local this_user=$1
    12   local this_script=$2
    13   local file=$3
    14 (
    15 cat << EOF
    16         @( time { su - ${this_user} -c "source /home/${this_user}/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
    17         echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
    18 EOF
    19 ) >> $MKFILE.tmp
    20 }
    21 
    22 
    23 #----------------------------------#
    24 wrt_Unpack_SetOwner() {            # Unpack and set owner. Assign 'ROOT' var
    25 #----------------------------------#
    26   local USER_ACCT=$1
    27   local FILE=$2
    28   local optSAVE_PREVIOUS=$3
    29 
    30   if [ "${optSAVE_PREVIOUS}" != "1" ]; then
    31     wrt_remove_existing_dirs "$FILE"
    32   fi
    33 (
    34 cat << EOF
    35         @\$(call unpack,$FILE)
    36         @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
    37         echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
    38         chown -R ${USER_ACCT} \$(MOUNT_PT)\$(SRC)/\$\$ROOT
    39 EOF
    40 ) >> $MKFILE.tmp
    41 }
    427
    438
     
    6833025-addinguser:  023-creatingtoolsdir
    6934        @\$(call echo_message, Building)
    70         @if [ ! -d /home/clfs ]; then \\
    71                 groupadd clfs; \\
    72                 useradd -s /bin/bash -g clfs -m -k /dev/null clfs; \\
     35        @if [ ! -d /home/\$(LUSER) ]; then \\
     36                groupadd \$(LGROUP); \\
     37                useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
    7338        else \\
    74                 touch user-clfs-exist; \\
    75         fi;
    76         @chown clfs \$(MOUNT_PT) && \\
    77         chown clfs \$(MOUNT_PT)/tools && \\
    78         chown clfs \$(MOUNT_PT)/sources
     39                touch luser-exist; \\
     40        fi;
     41        @chown \$(LUSER) \$(MOUNT_PT) && \\
     42        chown \$(LUSER) \$(MOUNT_PT)/tools && \\
     43        chown \$(LUSER) \$(MOUNT_PT)/sources
    7944        @touch \$@ && \\
    8045        echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
     
    8348026-settingenvironment:  025-addinguser
    8449        @\$(call echo_message, Building)
    85         @if [ -f /home/clfs/.bashrc -a ! -f /home/clfs/.bashrc.XXX ]; then \\
    86                 mv /home/clfs/.bashrc /home/clfs/.bashrc.XXX; \\
    87         fi;
    88         @if [ -f /home/clfs/.bash_profile  -a ! -f /home/clfs/.bash_profile.XXX ]; then \\
    89                 mv /home/clfs/.bash_profile /home/clfs/.bash_profile.XXX; \\
    90         fi;
    91         @echo "set +h" > /home/clfs/.bashrc && \\
    92         echo "umask 022" >> /home/clfs/.bashrc && \\
    93         echo "CLFS=\$(MOUNT_PT)" >> /home/clfs/.bashrc && \\
    94         echo "LC_ALL=POSIX" >> /home/clfs/.bashrc && \\
    95         echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> /home/clfs/.bashrc && \\
    96         echo "export CLFS LC_ALL PATH" >> /home/clfs/.bashrc && \\
    97         echo "" >> /home/clfs/.bashrc && \\
    98         echo "unset CFLAGS" >> /home/clfs/.bashrc && \\
    99         echo "unset CXXFLAGS" >> /home/clfs/.bashrc && \\
    100         echo "" >> /home/clfs/.bashrc && \\
    101         echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/clfs/.bashrc && \\
    102         echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/clfs/.bashrc && \\
    103         echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/clfs/.bashrc && \\
    104         echo "source $JHALFSDIR/envars" >> /home/clfs/.bashrc
    105         @chown clfs:clfs /home/clfs/.bashrc && \\
     50        @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
     51                mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
     52        fi;
     53        @if [ -f /home/\$(LUSER)/.bash_profile  -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
     54                mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
     55        fi;
     56        @echo "set +h" > /home/\$(LUSER)/.bashrc && \\
     57        echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
     58        echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
     59        echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
     60        echo "PATH=\$(MOUNT_PT)/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
     61        echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
     62        echo "" >> /home/\$(LUSER)/.bashrc && \\
     63        echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\
     64        echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\
     65        echo "" >> /home/\$(LUSER)/.bashrc && \\
     66        echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\
     67        echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\
     68        echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\
     69        echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
     70        @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
    10671        touch envars
    10772        @touch \$@ && \\
     
    154119        @touch \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/{btmp,lastlog,wtmp}
    155120        @chmod 664 \$(MOUNT_PT)/var/run/utmp \$(MOUNT_PT)/var/log/lastlog
    156         @chown -R clfs \$(MOUNT_PT)
     121        @chown -R \$(LUSER) \$(MOUNT_PT)
    157122
    158123        @touch \$@ && \\
     
    163128) >> $MKFILE.tmp
    164129}
    165 
    166130
    167131
     
    176140    #
    177141    # Skip this script...
     142    # NOTE.. the book indicated you only needed to install groff or file if the host
     143    #   had older versions. The packages would be installed in the target directory
     144    #   and not the host.
    178145    case $this_script in
    179146      *cflags* | *variables* )  # work done in host_prep_Makefiles
    180          continue; ;;
     147              continue ;;
     148      *file ) FileVer=`file --version | head -n1 | cut -d " " -f1`
     149              [[ "$FileVer" = "file-4.17" ]] && continue
     150        ;;
     151      *groff) GroffVer=`groff --version | head -n1 | cut -d " " -f4`
     152              [[ "$GroffVer" = "1.19.2" ]] && continue
     153        ;;
    181154      *) ;;
    182155    esac
     156
    183157    #
    184158    # Set the dependency for the first target.
     
    200174    esac
    201175    pkg_tarball=$(get_package_tarball_name $name)
    202 
    203176    #--------------------------------------------------------------------#
    204177    #         >>>>>>>> START BUILDING A Makefile ENTRY <<<<<<<<          #
     
    211184    # If $pkg_tarball isn't empty, we've got a package...
    212185    if [ "$pkg_tarball" != "" ] ; then
    213        wrt_Unpack_SetOwner "clfs" "$pkg_tarball"
     186       wrt_unpack "$pkg_tarball"
    214187       # If using optimizations, write the instructions
    215188       [[ "$OPTIMIZE" != "0" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
    216189    fi
    217190    #
    218     wrt_ExecuteAsUser "clfs" "${this_script}" "${file}"
     191    wrt_RunAsUser "${this_script}" "${file}"
    219192    #
    220193    [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
     
    276249    # If $pkg_tarball isn't empty, we've got a package...
    277250    if [ "$pkg_tarball" != "" ] ; then
    278       wrt_Unpack_SetOwner "clfs" "$pkg_tarball"
     251      wrt_unpack "$pkg_tarball"
    279252      # If using optimizations, write the instructions
    280253      [[ "$OPTIMIZE" != "0" ]] &&  wrt_optimize "$name" && wrt_makeflags "$name"
    281254    fi
    282255    #
    283     wrt_ExecuteAsUser "clfs" "${this_script}" "${file}"
     256    wrt_RunAsUser "${this_script}" "${file}"
    284257    #
    285258    [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
     
    340313    #
    341314    # If $pkg_tarball isn't empty, we've got a package...
    342     [[ "$pkg_tarball" != "" ]] && wrt_Unpack_SetOwner "clfs" "$pkg_tarball"
    343     #
    344     wrt_ExecuteAsUser "clfs" "${this_script}" "${file}"
     315    [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
     316    #
     317    wrt_RunAsUser "${this_script}" "${file}"
    345318    #
    346319    [[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
     
    402375    #
    403376    # If $pkg_tarball isn't empty, we've got a package...
    404     [[ "$pkg_tarball" != "" ]] && wrt_Unpack_SetOwner "clfs" "$pkg_tarball"
     377    [[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
    405378    #
    406379    # Select a script execution method
     
    409382                  wrt_copy_fstab "${this_script}"
    410383                else
    411                   wrt_ExecuteAsUser "clfs" "${this_script}" "${file}"
     384                  wrt_RunAsUser "${this_script}" "${file}"
    412385                fi
    413386          ;;
    414       *)  wrt_ExecuteAsUser "clfs"  "${this_script}" "${file}"
    415           ;;
     387      *chowning)  wrt_RunAsRoot "${this_script}" "${file}"
     388          ;;
     389              *)  wrt_RunAsUser "${this_script}" "${file}"
     390          ;;
    416391    esac
    417392    #
     
    461436MOUNT_PT= $BUILDDIR
    462437PKG_LST= $PKG_LST
     438LUSER= $LUSER
     439LGROUP= $LGROUP
    463440
    464441include makefile-functions
     
    471448(
    472449        cat << EOF
    473 all:  chapter2 chapter3 chapter4 chapter5 chapter6 do-housekeeping
     450all:  chapter2 chapter3 chapter4 chapter5 chapter6 restore-luser-env do-housekeeping
    474451        @\$(call echo_finished,$VERSION)
    475452
     
    492469        @echo "This feature does not exist for the CLFS makefile. (yet)"
    493470
    494 restore-clfs-env:
    495         @\$(call echo_message, Building)
    496         @if [ -f /home/clfs/.bashrc.XXX ]; then \\
    497                 mv -f /home/clfs/.bashrc.XXX /home/clfs/.bashrc; \\
    498         fi;
    499         @if [ -f /home/clfs/.bash_profile.XXX ]; then \\
    500                 mv /home/clfs/.bash_profile.XXX /home/clfs/.bash_profile; \\
    501         fi;
    502         @chown clfs:clfs /home/clfs/.bash* && \\
     471restore-luser-env:
     472        @\$(call echo_message, Building)
     473        @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
     474                mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
     475        fi;
     476        @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
     477                mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
     478        fi;
     479        @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
    503480        touch \$@ && \\
    504481        echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
     
    506483
    507484do-housekeeping:
    508         @-if [ ! -f user-clfs-exist ]; then \\
    509                 userdel clfs; \\
    510                 rm -rf /home/clfs; \\
     485        @-if [ ! -f luser-exist ]; then \\
     486                userdel \$(LUSER); \\
     487                rm -rf /home/\$(LUSER); \\
    511488        fi;
    512489
Note: See TracChangeset for help on using the changeset viewer.