- Timestamp:
- 08/08/2006 05:26:40 PM (18 years ago)
- Branches:
- 2.3, 2.3.x, 2.4, ablfs, ablfs-more, legacy, new_features, trunk
- Children:
- daa9b6c
- Parents:
- 983db9f
- Location:
- HLFS
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
HLFS/config
r983db9f r6ad5a2f 12 12 #--- The host system has grsecurity options enabled? 0(no)/1(yes) 13 13 GRSECURITY_HOST=0 14 15 #--- Unprivileged user and group name 16 LUSER=hlfs 17 LGROUP=hlfs 14 18 15 19 #--- Location of fstab file (if empty, a template is created) -
HLFS/master.sh
r983db9f r6ad5a2f 7 7 ### FUNCTIONS ### 8 8 ################################### 9 10 #----------------------------------#11 wrt_ExecuteAsUser() { # Execute the file ($3) under the users account ($1), log in $212 #----------------------------------#13 local this_user=$114 local this_script=$215 local file=$316 17 (18 cat << EOF19 @( time { su - ${this_user} -c "source /home/${this_user}/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\20 echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script21 EOF22 ) >> $MKFILE.tmp23 }24 25 26 #----------------------------------#27 wrt_Unpack_SetOwner() { # Unpack and set owner. Assign 'ROOT' var28 #----------------------------------#29 local USER_ACCT=$130 local FILE=$231 local optSAVE_PREVIOUS=$332 33 if [ "${optSAVE_PREVIOUS}" != "1" ]; then34 wrt_remove_existing_dirs "$FILE"35 fi36 (37 cat << EOF38 @\$(call unpack,$FILE)39 @ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\40 echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\41 chown -R ${USER_ACCT} \$(MOUNT_PT)\$(SRC)/\$\$ROOT42 EOF43 ) >> $MKFILE.tmp44 }45 46 #----------------------------------#47 wrt_RunAsRoot() { # Some scripts must be run as root..48 #----------------------------------#49 local user_ACCT=$(echo $1 | tr [a-z] [A-Z])50 local this_script=$251 local file=$352 53 (54 cat << EOF55 @( time { export ${user_ACCT}=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\56 echo -e "\nKB: \`du -skx --exclude=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script57 EOF58 ) >> $MKFILE.tmp59 }60 61 9 62 10 #----------------------------# … … 102 50 EOF 103 51 ) >> $MKFILE.tmp 104 wrt_ ExecuteAsUser "hlfs""$toolchain" "$this_script"52 wrt_RunAsUser "$toolchain" "$this_script" 105 53 ;; 106 54 esac 107 55 # 108 # Safe method to remove packages unpacked outside the toolchain56 # Safe method to remove packages unpacked while inside the toolchain script 109 57 pkg_tarball=$(get_package_tarball_name "binutils") 110 58 wrt_remove_existing_dirs "$pkg_tarball" … … 137 85 fi 138 86 139 # If /home/ hlfsis already present in the host, we asume that the87 # If /home/$LUSER is already present in the host, we asume that the 140 88 # hlfs user and group are also presents in the host, and a backup 141 89 # of their bash init files is made. … … 157 105 021-addinguser: 020-creatingtoolsdir 158 106 @\$(call echo_message, Building) 159 @if [ ! -d /home/ hlfs]; then \\160 groupadd hlfs; \\161 useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\107 @if [ ! -d /home/\$(LUSER) ]; then \\ 108 groupadd \$(LGROUP); \\ 109 useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\ 162 110 else \\ 163 touch user-hlfs-exist; \\164 fi; 165 @chown hlfs\$(MOUNT_PT)/tools && \\166 chown hlfs\$(MOUNT_PT)/sources && \\111 touch luser-exist; \\ 112 fi; 113 @chown \$(LUSER) \$(MOUNT_PT)/tools && \\ 114 chown \$(LUSER) \$(MOUNT_PT)/sources && \\ 167 115 touch \$@ && \\ 168 116 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ … … 171 119 022-settingenvironment: 021-addinguser 172 120 @\$(call echo_message, Building) 173 @if [ -f /home/ hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\174 mv /home/ hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\175 fi; 176 @if [ -f /home/ hlfs/.bash_profile -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\177 mv /home/ hlfs/.bash_profile /home/hlfs/.bash_profile.XXX; \\178 fi; 179 @echo "set +h" > /home/ hlfs/.bashrc && \\180 echo "umask 022" >> /home/ hlfs/.bashrc && \\181 echo "HLFS=\$(MOUNT_PT)" >> /home/ hlfs/.bashrc && \\182 echo "LC_ALL=POSIX" >> /home/ hlfs/.bashrc && \\183 echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/ hlfs/.bashrc && \\184 echo "export HLFS LC_ALL PATH" >> /home/ hlfs/.bashrc && \\185 echo "" >> /home/ hlfs/.bashrc && \\186 echo "target=$(uname -m)-${TARGET}" >> /home/ lfs/.bashrc && \\187 echo "ldso=/tools/lib/${LOADER}" >> /home/ lfs/.bashrc && \\188 echo "export target ldso" >> /home/ lfs/.bashrc && \\189 echo "source $JHALFSDIR/envars" >> /home/ hlfs/.bashrc && \\190 chown hlfs:hlfs /home/hlfs/.bashrc && \\121 @if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\ 122 mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\ 123 fi; 124 @if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\ 125 mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\ 126 fi; 127 @echo "set +h" > /home/\$(LUSER)/.bashrc && \\ 128 echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\ 129 echo "HLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\ 130 echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\ 131 echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\ 132 echo "export HLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\ 133 echo "" >> /home/\$(LUSER)/.bashrc && \\ 134 echo "target=$(uname -m)-${TARGET}" >> /home/\$(LUSER)/.bashrc && \\ 135 echo "ldso=/tools/lib/${LOADER}" >> /home/\$(LUSER)/.bashrc && \\ 136 echo "export target ldso" >> /home/\$(LUSER)/.bashrc && \\ 137 echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc && \\ 138 chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\ 191 139 touch envars && \\ 192 140 touch \$@ && \\ … … 263 211 if [ "$pkg_tarball" != "" ] ; then 264 212 # Insert instructions for unpacking the package and to set the PKGDIR variable. 265 wrt_ Unpack_SetOwner "hlfs""$pkg_tarball"213 wrt_unpack "$pkg_tarball" 266 214 # If using optimizations, write the instructions 267 215 [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name" … … 269 217 # Insert date and disk usage at the top of the log file, the script run 270 218 # and date and disk usage again at the bottom of the log file. 271 wrt_ ExecuteAsUser "hlfs""$this_script" "${file}"219 wrt_RunAsUser "$this_script" "${file}" 272 220 273 221 # Remove the build directory(ies) except if the package build fails … … 396 344 case "${this_script}" in 397 345 *kernfs*) 398 wrt_RunAsRoot " hlfs" "${this_script}" "${file}"346 wrt_RunAsRoot "${this_script}" "${file}" 399 347 ;; 400 348 *) # The rest of Chapter06 … … 538 486 MOUNT_PT= $BUILDDIR 539 487 PKG_LST= $PKG_LST 488 LUSER= $LUSER 489 LGROUP= $LGROUP 540 490 541 491 include makefile-functions … … 546 496 547 497 # Add chroot commands 498 CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`" 548 499 i=1 549 500 for file in chapter06/*chroot* ; do 550 chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \ 551 -e '/^export/d' \ 552 -e '/^logout/d' \ 553 -e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \ 554 -e 's|\\$|&&|g' \ 555 -e 's|exit||g' \ 556 -e 's|$| -c|' \ 557 -e 's|"$$HLFS"|$(MOUNT_PT)|'\ 558 -e 's|set -e||'` 501 chroot=`cat $file | \ 502 sed -e "s@chroot@$CHROOT_LOC@" \ 503 -e '/#!\/bin\/sh/d' \ 504 -e '/^export/d' \ 505 -e '/^logout/d' \ 506 -e 's@ \\\@ @g' | \ 507 tr -d '\n' | \ 508 sed -e 's/ */ /g' \ 509 -e 's|\\$|&&|g' \ 510 -e 's|exit||g' \ 511 -e 's|$| -c|' \ 512 -e 's|"$$HLFS"|$(MOUNT_PT)|'\ 513 -e 's|set -e||'` 559 514 echo -e "CHROOT$i= $chroot\n" >> $MKFILE 560 515 i=`expr $i + 1` … … 570 525 chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment 571 526 572 chapter5: chapter3 $chapter5 restore- hlfs-env527 chapter5: chapter3 $chapter5 restore-luser-env 573 528 574 529 chapter6: chapter5 $chapter6 … … 584 539 585 540 clean-chapter3: 586 -if [ ! -f user-hlfs-exist ]; then \\587 userdel hlfs; \\588 rm -rf /home/ hlfs; \\541 -if [ ! -f luser-exist ]; then \\ 542 userdel \$(LUSER); \\ 543 rm -rf /home/\$(LUSER); \\ 589 544 fi; 590 545 rm -rf \$(MOUNT_PT)/tools 591 546 rm -f /tools 592 rm -f envars user-hlfs-exist547 rm -f envars luser-exist 593 548 rm -f 02* logs/02*.log 594 549 595 550 clean-chapter5: 596 551 rm -rf \$(MOUNT_PT)/tools/* 597 rm -f $chapter5 restore- hlfs-env sources-dir552 rm -f $chapter5 restore-luser-env sources-dir 598 553 cd logs && rm -f $chapter5 && cd .. 599 554 … … 612 567 cd logs && rm -f $chapter7 && cd .. 613 568 614 restore- hlfs-env:569 restore-luser-env: 615 570 @\$(call echo_message, Building) 616 @if [ -f /home/ hlfs/.bashrc.XXX ]; then \\617 mv -f /home/ hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\618 fi; 619 @if [ -f /home/ hlfs/.bash_profile.XXX ]; then \\620 mv /home/ hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\621 fi; 622 @chown hlfs:hlfs /home/hlfs/.bash* && \\571 @if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\ 572 mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\ 573 fi; 574 @if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\ 575 mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\ 576 fi; 577 @chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\ 623 578 touch \$@ && \\ 624 579 echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\ … … 631 586 @-umount \$(MOUNT_PT)/sys 632 587 @-umount \$(MOUNT_PT)/proc 633 @-if [ ! -f user-hlfs-exist ]; then \\634 userdel hlfs; \\635 rm -rf /home/ hlfs; \\588 @-if [ ! -f luser-exist ]; then \\ 589 userdel \$(LUSER); \\ 590 rm -rf /home/\$(LUSER); \\ 636 591 fi; 637 592
Note:
See TracChangeset
for help on using the changeset viewer.