Ported LUSER code to 1.0 branch.
This commit is contained in:
parent
50c8292b0a
commit
9357c13af5
10 changed files with 251 additions and 288 deletions
|
@ -24,7 +24,7 @@ BOOK_Source() { #
|
|||
externals: none
|
||||
modifies: $BLFS_XML directory tree
|
||||
returns: nothing
|
||||
output:
|
||||
output:
|
||||
on error: exit
|
||||
on success: text messages
|
||||
inline_doc
|
||||
|
@ -32,7 +32,7 @@ inline_doc
|
|||
# Redundant definitions but this function may be reused
|
||||
local BLFS_XML=$1
|
||||
local DOC_MODE=$2
|
||||
|
||||
|
||||
if [[ -z "$BLFS_XML" ]] ; then
|
||||
echo -e "\n\tYou must to provide the name of the BLFS book sources directory.\n"
|
||||
exit 1
|
||||
|
@ -45,7 +45,7 @@ inline_doc
|
|||
echo -e "\n\t$BLFS_XML is not a directory\n"
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f $BLFS_XML/use-unzip.xml ]] ; then
|
||||
if [[ ! -f $BLFS_XML/x/x.xml ]] ; then
|
||||
echo -e "\n\tLooks like $BLFS_XML is not a BLFS book sources directory\n"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -61,7 +61,7 @@ inline_doc
|
|||
echo -e "\tSkipping BLFS sources update.\n"
|
||||
fi
|
||||
;;
|
||||
|
||||
|
||||
get )
|
||||
[[ ! -d $BLFS_XML ]] && mkdir -pv $BLFS_XML
|
||||
svn co $SVN/BLFS/trunk/BOOK $BLFS_XML 2>&1
|
||||
|
|
|
@ -38,6 +38,10 @@ TARGET=
|
|||
# NOTE: not all combinations are 'bootable' yet.
|
||||
METHOD=chroot
|
||||
|
||||
#--- Unprivileged user and group name
|
||||
LUSER=clfs
|
||||
LGROUP=clfs
|
||||
|
||||
#--- Location of fstab file (if empty, a template is created)
|
||||
FSTAB=
|
||||
|
||||
|
|
159
CLFS/master.sh
159
CLFS/master.sh
|
@ -41,43 +41,43 @@ cat << EOF
|
|||
|
||||
025-addinguser: 024-creatingcrossdir
|
||||
@\$(call echo_message, Building)
|
||||
@if [ ! -d /home/clfs ]; then \\
|
||||
groupadd clfs; \\
|
||||
useradd -s /bin/bash -g clfs -m -k /dev/null clfs; \\
|
||||
@if [ ! -d /home/\$(LUSER) ]; then \\
|
||||
groupadd \$(LGROUP); \\
|
||||
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
||||
else \\
|
||||
touch user-clfs-exist; \\
|
||||
touch luser-exist; \\
|
||||
fi;
|
||||
@chown clfs \$(MOUNT_PT) && \\
|
||||
chown clfs \$(MOUNT_PT)/tools && \\
|
||||
chown clfs \$(MOUNT_PT)/cross-tools && \\
|
||||
chown clfs \$(MOUNT_PT)/sources && \\
|
||||
@chown \$(LUSER) \$(MOUNT_PT) && \\
|
||||
chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
||||
chown \$(LUSER) \$(MOUNT_PT)/cross-tools && \\
|
||||
chown \$(LUSER) \$(MOUNT_PT)/sources && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
echo --------------------------------------------------------------------------------\$(WHITE)
|
||||
|
||||
026-settingenvironment: 025-addinguser
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/clfs/.bashrc -a ! -f /home/clfs/.bashrc.XXX ]; then \\
|
||||
mv /home/clfs/.bashrc /home/clfs/.bashrc.XXX; \\
|
||||
@if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
||||
mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
||||
fi;
|
||||
@if [ -f /home/clfs/.bash_profile -a ! -f /home/clfs/.bash_profile.XXX ]; then \\
|
||||
mv /home/clfs/.bash_profile /home/clfs/.bash_profile.XXX; \\
|
||||
@if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
||||
mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
|
||||
fi;
|
||||
@echo "set +h" > /home/clfs/.bashrc && \\
|
||||
echo "umask 022" >> /home/clfs/.bashrc && \\
|
||||
echo "CLFS=\$(MOUNT_PT)" >> /home/clfs/.bashrc && \\
|
||||
echo "LC_ALL=POSIX" >> /home/clfs/.bashrc && \\
|
||||
echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/clfs/.bashrc && \\
|
||||
echo "export CLFS LC_ALL PATH" >> /home/clfs/.bashrc && \\
|
||||
echo "" >> /home/clfs/.bashrc && \\
|
||||
echo "unset CFLAGS" >> /home/clfs/.bashrc && \\
|
||||
echo "unset CXXFLAGS" >> /home/clfs/.bashrc && \\
|
||||
echo "" >> /home/clfs/.bashrc && \\
|
||||
echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/clfs/.bashrc && \\
|
||||
echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/clfs/.bashrc && \\
|
||||
echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/clfs/.bashrc && \\
|
||||
echo "source $JHALFSDIR/envars" >> /home/clfs/.bashrc
|
||||
@chown clfs:clfs /home/clfs/.bashrc && \\
|
||||
@echo "set +h" > /home/\$(LUSER)/.bashrc && \\
|
||||
echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "CLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "PATH=/cross-tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "export CLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "unset CFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "unset CXXFLAGS" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "export CLFS_HOST=\"${CLFS_HOST}\"" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "export CLFS_TARGET=\"${TARGET}\"" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "export CLFS_TARGET32=\"${TARGET32}\"" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
|
||||
@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
||||
touch envars && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
|
@ -131,9 +131,9 @@ cross_tools_Makefiles() { #
|
|||
#
|
||||
# If $pkg_tarball isn't empty, we've got a package...
|
||||
#
|
||||
[[ "$pkg_tarball" != "" ]] && wrt_unpack_clfs "$pkg_tarball"
|
||||
[[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
|
||||
#
|
||||
wrt_run_as_clfs_su "${this_script}" "${file}"
|
||||
wrt_RunAsUser "${this_script}" "${file}"
|
||||
#
|
||||
[[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
|
||||
#
|
||||
|
@ -190,10 +190,10 @@ temptools_Makefiles() { #
|
|||
# If $pkg_tarball isn't empty, we've got a package...
|
||||
# Insert instructions for unpacking the package and to set the PKGDIR variable.
|
||||
#
|
||||
[[ "$pkg_tarball" != "" ]] && wrt_unpack_clfs "$pkg_tarball"
|
||||
[[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
|
||||
[[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
||||
#
|
||||
wrt_run_as_clfs_su "${this_script}" "${file}"
|
||||
wrt_RunAsUser "${this_script}" "${file}"
|
||||
#
|
||||
[[ "$pkg_tarball" != "" ]] && wrt_remove_build_dirs "${name}"
|
||||
#
|
||||
|
@ -262,20 +262,20 @@ boot_Makefiles() { #
|
|||
# If $pkg_tarball isn't empty, we've got a package...
|
||||
# Insert instructions for unpacking the package and changing directories
|
||||
#
|
||||
[[ "$pkg_tarball" != "" ]] && wrt_unpack_clfs "$pkg_tarball"
|
||||
[[ "$pkg_tarball" != "" ]] && wrt_unpack "$pkg_tarball"
|
||||
[[ "$pkg_tarball" != "" ]] && [[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
||||
#
|
||||
# Select a script execution method
|
||||
case $this_script in
|
||||
*changingowner*) wrt_run_as_clfs_root "${this_script}" "${file}" ;;
|
||||
*devices*) wrt_run_as_clfs_root "${this_script}" "${file}" ;;
|
||||
*changingowner*) wrt_RunAsRoot "${this_script}" "${file}" ;;
|
||||
*devices*) wrt_RunAsRoot "${this_script}" "${file}" ;;
|
||||
*fstab*) if [[ -n "$FSTAB" ]]; then
|
||||
wrt_copy_fstab "${this_script}"
|
||||
else
|
||||
wrt_run_as_clfs_su "${this_script}" "${file}"
|
||||
wrt_RunAsUser "${this_script}" "${file}"
|
||||
fi
|
||||
;;
|
||||
*) wrt_run_as_clfs_su "${this_script}" "${file}" ;;
|
||||
*) wrt_RunAsUser "${this_script}" "${file}" ;;
|
||||
esac
|
||||
#
|
||||
# Housekeeping...remove any build directory(ies) except if the package build fails.
|
||||
|
@ -332,7 +332,7 @@ chroot_Makefiles() { #
|
|||
#
|
||||
if [ "$pkg_tarball" != "" ] ; then
|
||||
case $this_script in
|
||||
*util-linux) wrt_unpack_clfs "$pkg_tarball" ;;
|
||||
*util-linux) wrt_unpack "$pkg_tarball" ;;
|
||||
*) wrt_unpack2 "$pkg_tarball" ;;
|
||||
esac
|
||||
[[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
||||
|
@ -340,9 +340,9 @@ chroot_Makefiles() { #
|
|||
#
|
||||
# Select a script execution method
|
||||
case $this_script in
|
||||
*kernfs) wrt_run_as_clfs_root "${this_script}" "${file}" ;;
|
||||
*util-linux) wrt_run_as_clfs_su "${this_script}" "${file}" ;;
|
||||
*) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
|
||||
*kernfs) wrt_RunAsRoot "${this_script}" "${file}" ;;
|
||||
*util-linux) wrt_RunAsUser "${this_script}" "${file}" ;;
|
||||
*) wrt_run_as_chroot1 "${this_script}" "${file}" ;;
|
||||
esac
|
||||
#
|
||||
# Housekeeping...remove the build directory(ies), except if the package build fails.
|
||||
|
@ -1012,6 +1012,8 @@ $HEADER
|
|||
SRC= /sources
|
||||
MOUNT_PT= $BUILDDIR
|
||||
PKG_LST= $PKG_LST
|
||||
LUSER= $LUSER
|
||||
LGROUP= $LGROUP
|
||||
|
||||
include makefile-functions
|
||||
|
||||
|
@ -1020,15 +1022,20 @@ EOF
|
|||
|
||||
# Add chroot commands
|
||||
if [ "$METHOD" = "chroot" ] ; then
|
||||
chroot=`cat chroot/*chroot* | sed -e '/#!\/tools\/bin\/bash/d' \
|
||||
-e '/^export/d' \
|
||||
-e '/^logout/d' \
|
||||
-e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
||||
-e 's|\\$|&&|g' \
|
||||
-e 's|exit||g' \
|
||||
-e 's|$| -c|' \
|
||||
-e 's|"$$CLFS"|$(MOUNT_PT)|'\
|
||||
-e 's|set -e||'`
|
||||
CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
||||
chroot=`cat chroot/*chroot* | \
|
||||
sed -e "s@chroot@$CHROOT_LOC@" \
|
||||
-e '/#!\/tools\/bin\/bash/d' \
|
||||
-e '/^export/d' \
|
||||
-e '/^logout/d' \
|
||||
-e 's@ \\\@ @g' | \
|
||||
tr -d '\n' | \
|
||||
sed -e 's/ */ /g' \
|
||||
-e 's|\\$|&&|g' \
|
||||
-e 's|exit||g' \
|
||||
-e 's|$| -c|' \
|
||||
-e 's|"$$CLFS"|$(MOUNT_PT)|'\
|
||||
-e 's|set -e||'`
|
||||
echo -e "CHROOT1= $chroot\n" >> $MKFILE
|
||||
fi
|
||||
|
||||
|
@ -1046,7 +1053,7 @@ chapter3: chapter2 $cross_tools
|
|||
|
||||
chapter4: chapter3 $temptools
|
||||
|
||||
chapter5: chapter4 $chroottools $testsuitetools
|
||||
chapter5: chapter4 $chroottools restore-luser-env $testsuitetools
|
||||
|
||||
chapter6: chapter5 $basicsystem
|
||||
|
||||
|
@ -1063,20 +1070,20 @@ restart:
|
|||
@echo "This feature does not exist for the CLFS makefile. (yet)"
|
||||
|
||||
clean-chapter2:
|
||||
-if [ ! -f user-clfs-exist ]; then \\
|
||||
userdel clfs; \\
|
||||
rm -rf /home/clfs; \\
|
||||
-if [ ! -f luser-exist ]; then \\
|
||||
userdel \$(LUSER); \\
|
||||
rm -rf /home/\$(LUSER); \\
|
||||
fi;
|
||||
rm -rf \$(MOUNT_PT)/tools
|
||||
rm -f /tools
|
||||
rm -rf \$(MOUNT_PT)/cross-tools
|
||||
rm -f /cross-tools
|
||||
rm -f envars user-clfs-exist
|
||||
rm -f envars luser-exist
|
||||
rm -f 02* logs/02*.log
|
||||
|
||||
clean-chapter3:
|
||||
rm -rf \$(MOUNT_PT)/tools/*
|
||||
rm -f $cross_tools restore-clfs-env sources-dir
|
||||
rm -f $cross_tools sources-dir
|
||||
cd logs && rm -f $cross_tools && cd ..
|
||||
|
||||
clean-chapter4:
|
||||
|
@ -1090,15 +1097,15 @@ clean-chapter4:
|
|||
cd logs && rm -f $temptools && cd ..
|
||||
|
||||
|
||||
restore-clfs-env:
|
||||
restore-luser-env:
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/clfs/.bashrc.XXX ]; then \\
|
||||
mv -f /home/clfs/.bashrc.XXX /home/clfs/.bashrc; \\
|
||||
@if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
||||
mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
||||
fi;
|
||||
@if [ -f /home/clfs/.bash_profile.XXX ]; then \\
|
||||
mv /home/clfs/.bash_profile.XXX /home/clfs/.bash_profile; \\
|
||||
@if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
||||
mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
||||
fi;
|
||||
@chown clfs:clfs /home/clfs/.bash* && \\
|
||||
@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
echo --------------------------------------------------------------------------------\$(WHITE)
|
||||
|
@ -1109,9 +1116,9 @@ do-housekeeping:
|
|||
@-umount \$(MOUNT_PT)/dev
|
||||
@-umount \$(MOUNT_PT)/sys
|
||||
@-umount \$(MOUNT_PT)/proc
|
||||
@-if [ ! -f user-clfs-exist ]; then \\
|
||||
userdel clfs; \\
|
||||
rm -rf /home/clfs; \\
|
||||
@-if [ ! -f luser-exist ]; then \\
|
||||
userdel \$(LUSER); \\
|
||||
rm -rf /home/\$(LUSER); \\
|
||||
fi;
|
||||
|
||||
EOF
|
||||
|
@ -1129,7 +1136,7 @@ makeboot: 023-creatingtoolsdir 024-creatingcrossdir 025-addinguser 026-settingen
|
|||
$cross_tools\
|
||||
$temptools \
|
||||
$chroottools \
|
||||
$boottools
|
||||
$boottools restore-luser-env
|
||||
@\$(call echo_boot_finished,$VERSION)
|
||||
|
||||
makesys: $testsuitetools $basicsystem $bootscripttools $bootabletools
|
||||
|
@ -1145,21 +1152,21 @@ restart:
|
|||
@echo "This feature does not exist for the CLFS makefile. (yet)"
|
||||
|
||||
clean-jhalfs:
|
||||
-if [ ! -f user-clfs-exist ]; then \\
|
||||
userdel clfs; \\
|
||||
rm -rf /home/clfs; \\
|
||||
-if [ ! -f luser-exist ]; then \\
|
||||
userdel \$(LUSER); \\
|
||||
rm -rf /home/\$(LUSER); \\
|
||||
fi;
|
||||
rm -rf \$(MOUNT_PT)/tools
|
||||
rm -f /tools
|
||||
rm -rf \$(MOUNT_PT)/cross-tools
|
||||
rm -f /cross-tools
|
||||
rm -f envars user-clfs-exist
|
||||
rm -f envars luser-exist
|
||||
rm -f 02* logs/02*.log
|
||||
|
||||
clean-makeboot:
|
||||
rm -rf /tools/*
|
||||
rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools
|
||||
rm -f restore-clfs-env sources-dir
|
||||
rm -f restore-luser-env sources-dir
|
||||
cd logs && rm -f $cross_tools && rm -f $temptools && rm -f $chroottools && rm -f $boottools && cd ..
|
||||
|
||||
clean-makesys:
|
||||
|
@ -1175,15 +1182,15 @@ clean-makesys:
|
|||
cd logs && rm -f $basicsystem && rm -f $bootscripttools && rm -f $bootabletools && cd ..
|
||||
|
||||
|
||||
restore-clfs-env:
|
||||
restore-luser-env:
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/clfs/.bashrc.XXX ]; then \\
|
||||
mv -fv /home/clfs/.bashrc.XXX /home/clfs/.bashrc; \\
|
||||
@if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
||||
mv -fv /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
||||
fi;
|
||||
@if [ -f /home/clfs/.bash_profile.XXX ]; then \\
|
||||
mv -v /home/clfs/.bash_profile.XXX /home/clfs/.bash_profile; \\
|
||||
@if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
||||
mv -v /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
||||
fi;
|
||||
@chown clfs:clfs /home/clfs/.bash* && \\
|
||||
@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
echo --------------------------------------------------------------------------------\$(WHITE)
|
||||
|
|
|
@ -12,6 +12,10 @@ MODEL=glibc
|
|||
#--- The host system has grsecurity options enabled? 0(no)/1(yes)
|
||||
GRSECURITY_HOST=0
|
||||
|
||||
#--- Unprivileged user and group name
|
||||
LUSER=hlfs
|
||||
LGROUP=hlfs
|
||||
|
||||
#--- Location of fstab file (if empty, a template is created)
|
||||
FSTAB=
|
||||
|
||||
|
|
163
HLFS/master.sh
163
HLFS/master.sh
|
@ -7,58 +7,6 @@ set -e # Enable error trapping
|
|||
### FUNCTIONS ###
|
||||
###################################
|
||||
|
||||
#----------------------------------#
|
||||
wrt_ExecuteAsUser() { # Execute the file ($3) under the users account ($1), log in $2
|
||||
#----------------------------------#
|
||||
local this_user=$1
|
||||
local this_script=$2
|
||||
local file=$3
|
||||
|
||||
(
|
||||
cat << EOF
|
||||
@( time { su - ${this_user} -c "source /home/${this_user}/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>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
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_Unpack_SetOwner() { # Unpack and set owner. Assign 'ROOT' var
|
||||
#----------------------------------#
|
||||
local USER_ACCT=$1
|
||||
local FILE=$2
|
||||
local optSAVE_PREVIOUS=$3
|
||||
|
||||
if [ "${optSAVE_PREVIOUS}" != "1" ]; then
|
||||
wrt_remove_existing_dirs "$FILE"
|
||||
fi
|
||||
(
|
||||
cat << EOF
|
||||
@\$(call unpack,$FILE)
|
||||
@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
||||
chown -R ${USER_ACCT} \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
#----------------------------------#
|
||||
wrt_RunAsRoot() { # Some scripts must be run as root..
|
||||
#----------------------------------#
|
||||
local user_ACCT=$(echo $1 | tr [a-z] [A-Z])
|
||||
local this_script=$2
|
||||
local file=$3
|
||||
|
||||
(
|
||||
cat << EOF
|
||||
@( time { export ${user_ACCT}=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>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
|
||||
}
|
||||
|
||||
|
||||
#----------------------------#
|
||||
process_toolchain() { # embryo,cocoon and butterfly need special handling
|
||||
#----------------------------#
|
||||
|
@ -101,11 +49,11 @@ cat << EOF
|
|||
@echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)" > envars
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
wrt_ExecuteAsUser "hlfs" "$toolchain" "$this_script"
|
||||
wrt_RunAsUser "$toolchain" "$this_script"
|
||||
;;
|
||||
esac
|
||||
#
|
||||
# Safe method to remove packages unpacked outside the toolchain
|
||||
# Safe method to remove packages unpacked while inside the toolchain script
|
||||
pkg_tarball=$(get_package_tarball_name "binutils")
|
||||
wrt_remove_existing_dirs "$pkg_tarball"
|
||||
pkg_tarball=$(get_package_tarball_name "gcc-core")
|
||||
|
@ -136,7 +84,7 @@ chapter3_Makefiles() { # Initialization of the system
|
|||
TARGET="pc-linux-gnu"; LOADER="ld-linux.so.2"
|
||||
fi
|
||||
|
||||
# If /home/hlfs is already present in the host, we asume that the
|
||||
# If /home/$LUSER is already present in the host, we asume that the
|
||||
# hlfs user and group are also presents in the host, and a backup
|
||||
# of their bash init files is made.
|
||||
(
|
||||
|
@ -156,38 +104,38 @@ cat << EOF
|
|||
|
||||
021-addinguser: 020-creatingtoolsdir
|
||||
@\$(call echo_message, Building)
|
||||
@if [ ! -d /home/hlfs ]; then \\
|
||||
groupadd hlfs; \\
|
||||
useradd -s /bin/bash -g hlfs -m -k /dev/null hlfs; \\
|
||||
@if [ ! -d /home/\$(LUSER) ]; then \\
|
||||
groupadd \$(LGROUP); \\
|
||||
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
||||
else \\
|
||||
touch user-hlfs-exist; \\
|
||||
touch luser-exist; \\
|
||||
fi;
|
||||
@chown hlfs \$(MOUNT_PT)/tools && \\
|
||||
chown hlfs \$(MOUNT_PT)/sources && \\
|
||||
@chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
||||
chown \$(LUSER) \$(MOUNT_PT)/sources && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
echo --------------------------------------------------------------------------------\$(WHITE)
|
||||
|
||||
022-settingenvironment: 021-addinguser
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/hlfs/.bashrc -a ! -f /home/hlfs/.bashrc.XXX ]; then \\
|
||||
mv /home/hlfs/.bashrc /home/hlfs/.bashrc.XXX; \\
|
||||
@if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
||||
mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
||||
fi;
|
||||
@if [ -f /home/hlfs/.bash_profile -a ! -f /home/hlfs/.bash_profile.XXX ]; then \\
|
||||
mv /home/hlfs/.bash_profile /home/hlfs/.bash_profile.XXX; \\
|
||||
@if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
||||
mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
|
||||
fi;
|
||||
@echo "set +h" > /home/hlfs/.bashrc && \\
|
||||
echo "umask 022" >> /home/hlfs/.bashrc && \\
|
||||
echo "HLFS=\$(MOUNT_PT)" >> /home/hlfs/.bashrc && \\
|
||||
echo "LC_ALL=POSIX" >> /home/hlfs/.bashrc && \\
|
||||
echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/hlfs/.bashrc && \\
|
||||
echo "export HLFS LC_ALL PATH" >> /home/hlfs/.bashrc && \\
|
||||
echo "" >> /home/hlfs/.bashrc && \\
|
||||
echo "target=$(uname -m)-${TARGET}" >> /home/lfs/.bashrc && \\
|
||||
echo "ldso=/tools/lib/${LOADER}" >> /home/lfs/.bashrc && \\
|
||||
echo "export target ldso" >> /home/lfs/.bashrc && \\
|
||||
echo "source $JHALFSDIR/envars" >> /home/hlfs/.bashrc && \\
|
||||
chown hlfs:hlfs /home/hlfs/.bashrc && \\
|
||||
@echo "set +h" > /home/\$(LUSER)/.bashrc && \\
|
||||
echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "HLFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "export HLFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "target=$(uname -m)-${TARGET}" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "ldso=/tools/lib/${LOADER}" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "export target ldso" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc && \\
|
||||
chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
||||
touch envars && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
|
@ -262,13 +210,13 @@ chapter5_Makefiles() { # Bootstrap or temptools phase
|
|||
# If $pkg_tarball isn't empty, we've got a package...
|
||||
if [ "$pkg_tarball" != "" ] ; then
|
||||
# Insert instructions for unpacking the package and to set the PKGDIR variable.
|
||||
wrt_Unpack_SetOwner "hlfs" "$pkg_tarball"
|
||||
wrt_unpack "$pkg_tarball"
|
||||
# If using optimizations, write the instructions
|
||||
[[ "$OPTIMIZE" = "2" ]] && wrt_optimize "$name" && wrt_makeflags "$name"
|
||||
fi
|
||||
# Insert date and disk usage at the top of the log file, the script run
|
||||
# and date and disk usage again at the bottom of the log file.
|
||||
wrt_ExecuteAsUser "hlfs" "$this_script" "${file}"
|
||||
wrt_RunAsUser "$this_script" "${file}"
|
||||
|
||||
# Remove the build directory(ies) except if the package build fails
|
||||
# (so we can review config.cache, config.log, etc.)
|
||||
|
@ -395,7 +343,7 @@ chapter6_Makefiles() { # sysroot or chroot build phase
|
|||
# In the mount of kernel filesystems we need to set HLFS and not to use chroot.
|
||||
case "${this_script}" in
|
||||
*kernfs*)
|
||||
wrt_RunAsRoot "hlfs" "${this_script}" "${file}"
|
||||
wrt_RunAsRoot "${this_script}" "${file}"
|
||||
;;
|
||||
*) # The rest of Chapter06
|
||||
wrt_run_as_chroot1 "${this_script}" "${file}"
|
||||
|
@ -537,6 +485,8 @@ $HEADER
|
|||
SRC= /sources
|
||||
MOUNT_PT= $BUILDDIR
|
||||
PKG_LST= $PKG_LST
|
||||
LUSER= $LUSER
|
||||
LGROUP= $LGROUP
|
||||
|
||||
include makefile-functions
|
||||
|
||||
|
@ -545,17 +495,22 @@ EOF
|
|||
|
||||
|
||||
# Add chroot commands
|
||||
CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
||||
i=1
|
||||
for file in chapter06/*chroot* ; do
|
||||
chroot=`cat $file | sed -e '/#!\/bin\/sh/d' \
|
||||
-e '/^export/d' \
|
||||
-e '/^logout/d' \
|
||||
-e 's@ \\\@ @g' | tr -d '\n' | sed -e 's/ */ /g' \
|
||||
-e 's|\\$|&&|g' \
|
||||
-e 's|exit||g' \
|
||||
-e 's|$| -c|' \
|
||||
-e 's|"$$HLFS"|$(MOUNT_PT)|'\
|
||||
-e 's|set -e||'`
|
||||
chroot=`cat $file | \
|
||||
sed -e "s@chroot@$CHROOT_LOC@" \
|
||||
-e '/#!\/bin\/sh/d' \
|
||||
-e '/^export/d' \
|
||||
-e '/^logout/d' \
|
||||
-e 's@ \\\@ @g' | \
|
||||
tr -d '\n' | \
|
||||
sed -e 's/ */ /g' \
|
||||
-e 's|\\$|&&|g' \
|
||||
-e 's|exit||g' \
|
||||
-e 's|$| -c|' \
|
||||
-e 's|"$$HLFS"|$(MOUNT_PT)|'\
|
||||
-e 's|set -e||'`
|
||||
echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
|
@ -569,7 +524,7 @@ all: chapter3 chapter5 chapter6 chapter7 do-housekeeping
|
|||
|
||||
chapter3: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
||||
|
||||
chapter5: chapter3 $chapter5 restore-hlfs-env
|
||||
chapter5: chapter3 $chapter5 restore-luser-env
|
||||
|
||||
chapter6: chapter5 $chapter6
|
||||
|
||||
|
@ -583,18 +538,18 @@ clean: clean-chapter7 clean-chapter6 clean-chapter5 clean-chapter3
|
|||
restart: restart_code all
|
||||
|
||||
clean-chapter3:
|
||||
-if [ ! -f user-hlfs-exist ]; then \\
|
||||
userdel hlfs; \\
|
||||
rm -rf /home/hlfs; \\
|
||||
-if [ ! -f luser-exist ]; then \\
|
||||
userdel \$(LUSER); \\
|
||||
rm -rf /home/\$(LUSER); \\
|
||||
fi;
|
||||
rm -rf \$(MOUNT_PT)/tools
|
||||
rm -f /tools
|
||||
rm -f envars user-hlfs-exist
|
||||
rm -f envars luser-exist
|
||||
rm -f 02* logs/02*.log
|
||||
|
||||
clean-chapter5:
|
||||
rm -rf \$(MOUNT_PT)/tools/*
|
||||
rm -f $chapter5 restore-hlfs-env sources-dir
|
||||
rm -f $chapter5 restore-luser-env sources-dir
|
||||
cd logs && rm -f $chapter5 && cd ..
|
||||
|
||||
clean-chapter6:
|
||||
|
@ -611,15 +566,15 @@ clean-chapter7:
|
|||
rm -f $chapter7
|
||||
cd logs && rm -f $chapter7 && cd ..
|
||||
|
||||
restore-hlfs-env:
|
||||
restore-luser-env:
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/hlfs/.bashrc.XXX ]; then \\
|
||||
mv -f /home/hlfs/.bashrc.XXX /home/hlfs/.bashrc; \\
|
||||
@if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
||||
mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
||||
fi;
|
||||
@if [ -f /home/hlfs/.bash_profile.XXX ]; then \\
|
||||
mv /home/hlfs/.bash_profile.XXX /home/hlfs/.bash_profile; \\
|
||||
@if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
||||
mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
||||
fi;
|
||||
@chown hlfs:hlfs /home/hlfs/.bash* && \\
|
||||
@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
echo --------------------------------------------------------------------------------\$(WHITE)
|
||||
|
@ -630,9 +585,9 @@ do-housekeeping:
|
|||
@-umount \$(MOUNT_PT)/dev
|
||||
@-umount \$(MOUNT_PT)/sys
|
||||
@-umount \$(MOUNT_PT)/proc
|
||||
@-if [ ! -f user-hlfs-exist ]; then \\
|
||||
userdel hlfs; \\
|
||||
rm -rf /home/hlfs; \\
|
||||
@-if [ ! -f luser-exist ]; then \\
|
||||
userdel \$(LUSER); \\
|
||||
rm -rf /home/\$(LUSER); \\
|
||||
fi;
|
||||
|
||||
restart_code:
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#
|
||||
#####
|
||||
|
||||
#--- Unprivileged user and group name
|
||||
LUSER=lfs
|
||||
LGROUP=lfs
|
||||
|
||||
#--- Location of fstab file (if empty, a template is created)
|
||||
FSTAB=
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ chapter4_Makefiles() {
|
|||
#----------------------------#
|
||||
echo "${tab_}${GREEN}Processing... ${L_arrow}Chapter4${R_arrow}"
|
||||
|
||||
# If /home/lfs is already present in the host, we asume that the
|
||||
# If /home/$LUSER is already present in the host, we asume that the
|
||||
# lfs user and group are also presents in the host, and a backup
|
||||
# of their bash init files is made.
|
||||
(
|
||||
|
@ -29,13 +29,13 @@ chapter4_Makefiles() {
|
|||
|
||||
021-addinguser: 020-creatingtoolsdir
|
||||
@\$(call echo_message, Building)
|
||||
@if [ ! -d /home/lfs ]; then \\
|
||||
groupadd lfs; \\
|
||||
useradd -s /bin/bash -g lfs -m -k /dev/null lfs; \\
|
||||
@if [ ! -d /home/\$(LUSER) ]; then \\
|
||||
groupadd \$(LGROUP); \\
|
||||
useradd -s /bin/bash -g \$(LGROUP) -m -k /dev/null \$(LUSER); \\
|
||||
else \\
|
||||
touch user-lfs-exist; \\
|
||||
touch luser-exist; \\
|
||||
fi;
|
||||
@chown lfs \$(MOUNT_PT)/tools && \\
|
||||
@chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
||||
chmod a+wt \$(MOUNT_PT)/sources && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
|
@ -43,20 +43,20 @@ chapter4_Makefiles() {
|
|||
|
||||
022-settingenvironment: 021-addinguser
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/lfs/.bashrc -a ! -f /home/lfs/.bashrc.XXX ]; then \\
|
||||
mv /home/lfs/.bashrc /home/lfs/.bashrc.XXX; \\
|
||||
@if [ -f /home/\$(LUSER)/.bashrc -a ! -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
||||
mv /home/\$(LUSER)/.bashrc /home/\$(LUSER)/.bashrc.XXX; \\
|
||||
fi;
|
||||
@if [ -f /home/lfs/.bash_profile -a ! -f /home/lfs/.bash_profile.XXX ]; then \\
|
||||
mv /home/lfs/.bash_profile /home/lfs/.bash_profile.XXX; \\
|
||||
@if [ -f /home/\$(LUSER)/.bash_profile -a ! -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
||||
mv /home/\$(LUSER)/.bash_profile /home/\$(LUSER)/.bash_profile.XXX; \\
|
||||
fi;
|
||||
@echo "set +h" > /home/lfs/.bashrc && \\
|
||||
echo "umask 022" >> /home/lfs/.bashrc && \\
|
||||
echo "LFS=\$(MOUNT_PT)" >> /home/lfs/.bashrc && \\
|
||||
echo "LC_ALL=POSIX" >> /home/lfs/.bashrc && \\
|
||||
echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/lfs/.bashrc && \\
|
||||
echo "export LFS LC_ALL PATH" >> /home/lfs/.bashrc && \\
|
||||
echo "source $JHALFSDIR/envars" >> /home/lfs/.bashrc && \\
|
||||
chown lfs:lfs /home/lfs/.bashrc && \\
|
||||
@echo "set +h" > /home/\$(LUSER)/.bashrc && \\
|
||||
echo "umask 022" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "LFS=\$(MOUNT_PT)" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "LC_ALL=POSIX" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "PATH=/tools/bin:/bin:/usr/bin" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "export LFS LC_ALL PATH" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc && \\
|
||||
chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
||||
touch envars && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
|
@ -122,8 +122,8 @@ chapter5_Makefiles() {
|
|||
# and date and disk usage again at the bottom of the log file.
|
||||
# The changingowner script must be run as root.
|
||||
case "${this_script}" in
|
||||
*changingowner) wrt_run_as_root "${this_script}" "$file" ;;
|
||||
*) wrt_run_as_su "${this_script}" "$file" ;;
|
||||
*changingowner) wrt_RunAsRoot "${this_script}" "$file" ;;
|
||||
*) wrt_RunAsUser "${this_script}" "$file" ;;
|
||||
esac
|
||||
|
||||
# Remove the build directory(ies) except if the package build fails
|
||||
|
@ -231,7 +231,7 @@ chapter6_Makefiles() {
|
|||
# In the mount of kernel filesystems we need to set LFS
|
||||
# and not to use chroot.
|
||||
case "${this_script}" in
|
||||
*kernfs) wrt_run_as_root "${this_script}" "$file" ;;
|
||||
*kernfs) wrt_RunAsRoot "${this_script}" "$file" ;;
|
||||
*) wrt_run_as_chroot1 "${this_script}" "$file" ;;
|
||||
esac
|
||||
|
||||
|
@ -365,6 +365,8 @@ $HEADER
|
|||
SRC= /sources
|
||||
MOUNT_PT= $BUILDDIR
|
||||
PKG_LST= $PKG_LST
|
||||
LUSER= $LUSER
|
||||
LGROUP= $LGROUP
|
||||
|
||||
include makefile-functions
|
||||
|
||||
|
@ -373,11 +375,20 @@ EOF
|
|||
|
||||
|
||||
# Add chroot commands
|
||||
CHROOT_LOC="`whereis -b chroot | cut -d " " -f2`"
|
||||
i=1
|
||||
for file in chapter06/*chroot* ; do
|
||||
chroot=`cat $file | sed -e '/#!\/bin\/sh/d' -e 's@ \\\@ @g' | tr -d '\n' | sed \
|
||||
-e 's/ */ /g' -e 's|\\$|&&|g' -e 's|exit||g' -e 's|$| -c|' \
|
||||
-e 's|"$$LFS"|$(MOUNT_PT)|' -e 's|set -e||'`
|
||||
chroot=`cat $file | \
|
||||
sed -e "s@chroot@$CHROOT_LOC@" \
|
||||
-e '/#!\/bin\/sh/d' \
|
||||
-e 's@ \\\@ @g' | \
|
||||
tr -d '\n' | \
|
||||
sed -e 's/ */ /g' \
|
||||
-e 's|\\$|&&|g' \
|
||||
-e 's|exit||g' \
|
||||
-e 's|$| -c|' \
|
||||
-e 's|"$$LFS"|$(MOUNT_PT)|' \
|
||||
-e 's|set -e||'`
|
||||
echo -e "CHROOT$i= $chroot\n" >> $MKFILE
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
|
@ -391,7 +402,7 @@ all: chapter4 chapter5 chapter6 chapter789 do_housekeeping
|
|||
|
||||
chapter4: 020-creatingtoolsdir 021-addinguser 022-settingenvironment
|
||||
|
||||
chapter5: chapter4 $chapter5 restore-lfs-env
|
||||
chapter5: chapter4 $chapter5 restore-luser-env
|
||||
|
||||
chapter6: chapter5 $chapter6
|
||||
|
||||
|
@ -405,18 +416,18 @@ clean: clean-chapter789 clean-chapter6 clean-chapter5 clean-chapter4
|
|||
restart: restart_code all
|
||||
|
||||
clean-chapter4:
|
||||
-if [ ! -f user-lfs-exist ]; then \\
|
||||
userdel lfs; \\
|
||||
rm -rf /home/lfs; \\
|
||||
-if [ ! -f luser-exist ]; then \\
|
||||
userdel \$(LUSER); \\
|
||||
rm -rf /home/\$(LUSER); \\
|
||||
fi;
|
||||
rm -rf \$(MOUNT_PT)/tools
|
||||
rm -f /tools
|
||||
rm -f envars user-lfs-exist
|
||||
rm -f envars luser-exist
|
||||
rm -f 02* logs/02*.log
|
||||
|
||||
clean-chapter5:
|
||||
rm -rf \$(MOUNT_PT)/tools/*
|
||||
rm -f $chapter5 restore-lfs-env sources-dir
|
||||
rm -f $chapter5 restore-luser-env sources-dir
|
||||
cd logs && rm -f $chapter5 && cd ..
|
||||
|
||||
clean-chapter6:
|
||||
|
@ -433,15 +444,15 @@ clean-chapter789:
|
|||
rm -f $chapter789
|
||||
cd logs && rm -f $chapter789 && cd ..
|
||||
|
||||
restore-lfs-env:
|
||||
restore-luser-env:
|
||||
@\$(call echo_message, Building)
|
||||
@if [ -f /home/lfs/.bashrc.XXX ]; then \\
|
||||
mv -f /home/lfs/.bashrc.XXX /home/lfs/.bashrc; \\
|
||||
@if [ -f /home/\$(LUSER)/.bashrc.XXX ]; then \\
|
||||
mv -f /home/\$(LUSER)/.bashrc.XXX /home/\$(LUSER)/.bashrc; \\
|
||||
fi;
|
||||
@if [ -f /home/lfs/.bash_profile.XXX ]; then \\
|
||||
mv /home/lfs/.bash_profile.XXX /home/lfs/.bash_profile; \\
|
||||
@if [ -f /home/\$(LUSER)/.bash_profile.XXX ]; then \\
|
||||
mv /home/\$(LUSER)/.bash_profile.XXX /home/\$(LUSER)/.bash_profile; \\
|
||||
fi;
|
||||
@chown lfs:lfs /home/lfs/.bash* && \\
|
||||
@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bash* && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
echo --------------------------------------------------------------------------------\$(WHITE)
|
||||
|
@ -452,9 +463,9 @@ do_housekeeping:
|
|||
@-umount \$(MOUNT_PT)/dev/shm
|
||||
@-umount \$(MOUNT_PT)/dev/pts
|
||||
@-umount \$(MOUNT_PT)/dev
|
||||
@-if [ ! -f user-lfs-exist ]; then \\
|
||||
userdel lfs; \\
|
||||
rm -rf /home/lfs; \\
|
||||
@-if [ ! -f luser-exist ]; then \\
|
||||
userdel \$(LUSER); \\
|
||||
rm -rf /home/\$(LUSER); \\
|
||||
fi;
|
||||
|
||||
restart_code:
|
||||
|
|
11
README
11
README
|
@ -137,9 +137,10 @@ $Id$
|
|||
A. Yes, it is. This tool, jhalfs, is for those who understand the LFS books
|
||||
and wish to automate the build. 99% of any problems that arise can be
|
||||
solved by reading the book(s).
|
||||
|
||||
|
||||
Q. "It doesn't work!"
|
||||
A. Yes it does, try ./lfs --help
|
||||
Remember you must either be 'root' to run this script or have 'sudo' privileges.
|
||||
|
||||
Q. "It still doesn't work"
|
||||
A. jhalfs was designed to work against the developement versions of the LFS
|
||||
|
@ -182,6 +183,14 @@ $Id$
|
|||
simple and reliable method of doing so. This method also handles the CLFS
|
||||
build method where the final build may be done on a separate machine.
|
||||
|
||||
Q. "What is the function of LUSER and LGROUP? There is no cmd line switch"
|
||||
A. If you are running jhalfs from a low or non-priveledged account you may not
|
||||
have the priv to create/delete accounts. These variables are adjustable
|
||||
when invoking make.
|
||||
make LUSER=myaccount LGROUP=mygroup
|
||||
Then only changes to your account will be the creation of a NEW .bashrc after
|
||||
saving your original to .bashrc.XXX
|
||||
|
||||
Q. "When I try to build 'xxx' with clfs the makefile fails at the mid-point"
|
||||
A. There could be numerous reasons for the failure but the most likely reason
|
||||
is you are doing a cross-build using the 'chroot' method and the target is
|
||||
|
|
|
@ -241,8 +241,9 @@ get_package_tarball_name() { #
|
|||
# hopefully this will not cause problems.
|
||||
#
|
||||
case $script_name in
|
||||
tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
||||
*) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
||||
tcl) echo $(grep "^tcl" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
||||
linux-headers) echo $(grep "^linux-headers.*.bz2" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
||||
*) echo $(grep "^$script_name-[[:digit:]]" $JHALFSDIR/pkg_tarball_list | head -n1 ) ;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
@ -297,27 +298,7 @@ cat << EOF
|
|||
@\$(call unpack,$FILE)
|
||||
@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
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_unpack_clfs() { # 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 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
echo "export PKGDIR=\$(MOUNT_PT)\$(SRC)/\$\$ROOT" > envars && \\
|
||||
chown -R clfs \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
||||
chown -R \$(LUSER) \$(MOUNT_PT)\$(SRC)/\$\$ROOT
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
@ -367,7 +348,7 @@ wrt_test_log() { # Initialize testsuite log file
|
|||
(
|
||||
cat << EOF
|
||||
@echo "export TEST_LOG=$TESTLOGDIR/$TESTLOGFILE" >> envars && \\
|
||||
su - lfs -c "echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE"
|
||||
su - \$(LUSER) -c "echo -e '\n\`date\`\n' >$TESTLOGDIR/$TESTLOGFILE"
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
@ -398,13 +379,13 @@ EOF
|
|||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_run_as_su() { # Execute script inside time { }, footer to log file
|
||||
wrt_RunAsUser() { # Execute script inside time { }, footer to log file
|
||||
#----------------------------------#
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
(
|
||||
cat << EOF
|
||||
@( time { su - lfs -c "source /home/lfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
||||
@( time { su - \$(LUSER) -c "source /home/\$(LUSER)/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>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
|
||||
|
@ -412,41 +393,24 @@ EOF
|
|||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_run_as_root() { # Some scripts must be run as root..
|
||||
wrt_RunAsRoot() { # Some scripts must be run as root..
|
||||
#----------------------------------#
|
||||
local ENV_MOUNT
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
|
||||
case ${PROGNAME} in
|
||||
lfs ) MOUNT_ENV="LFS" ;;
|
||||
blfs ) MOUNT_ENV="BLFS" ;;
|
||||
clfs ) MOUNT_ENV="CLFS" ;;
|
||||
clfs2 ) MOUNT_ENV="CLFS" ;;
|
||||
hlfs ) MOUNT_ENV="HLFS" ;;
|
||||
*) echo "undefined progname $PROGNAME"; exit 1
|
||||
esac
|
||||
|
||||
(
|
||||
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=${SCRIPT_ROOT} \$(MOUNT_PT)\`\n" >>logs/$this_script
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_run_as_clfs_su() { # Execute script inside time { }, footer to log file
|
||||
#----------------------------------#
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
(
|
||||
cat << EOF
|
||||
@( time { su - clfs -c "source /home/clfs/.bashrc && $JHALFSDIR/${PROGNAME}-commands/$file" >>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
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_run_as_clfs_root() { # Some scripts must be run as root..
|
||||
#----------------------------------#
|
||||
local this_script=$1
|
||||
local file=$2
|
||||
(
|
||||
cat << EOF
|
||||
@( time { export CLFS=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>logs/$this_script 2>&1 ; } ) 2>>logs/$this_script && \\
|
||||
@( time { export ${MOUNT_ENV}=\$(MOUNT_PT) && ${PROGNAME}-commands/$file >>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
|
||||
|
@ -467,7 +431,6 @@ EOF
|
|||
}
|
||||
|
||||
|
||||
|
||||
#----------------------------------#
|
||||
wrt_run_as_chroot1() { #
|
||||
#----------------------------------#
|
||||
|
@ -526,9 +489,9 @@ wrt_remove_build_dirs() { #
|
|||
(
|
||||
cat << EOF
|
||||
@ROOT=\`head -n1 \$(MOUNT_PT)\$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
rm -r \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
||||
rm -rf \$(MOUNT_PT)\$(SRC)/\$\$ROOT && \\
|
||||
if [ -e \$(MOUNT_PT)\$(SRC)/$name-build ]; then \\
|
||||
rm -r \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
||||
rm -rf \$(MOUNT_PT)\$(SRC)/$name-build; \\
|
||||
fi;
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
|
@ -542,9 +505,9 @@ wrt_remove_build_dirs2() { #
|
|||
(
|
||||
cat << EOF
|
||||
@ROOT=\`head -n1 \$(SRC)/\$(PKG_LST) | sed 's@^./@@;s@/.*@@'\` && \\
|
||||
rm -r \$(SRC)/\$\$ROOT && \\
|
||||
rm -rf \$(SRC)/\$\$ROOT && \\
|
||||
if [ -e \$(SRC)/$name-build ]; then \\
|
||||
rm -r \$(SRC)/$name-build; \\
|
||||
rm -rf \$(SRC)/$name-build; \\
|
||||
fi;
|
||||
EOF
|
||||
) >> $MKFILE.tmp
|
||||
|
|
|
@ -84,9 +84,9 @@ validate_config() { # Are the config values sane (within reason)
|
|||
inline_doc
|
||||
|
||||
# First internal variables, then the ones that change the book's flavour, and lastly system configuration variables
|
||||
local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE MODEL GRSECURITY_HOST TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG GETKERNEL KEYMAP PAGE TIMEZONE LANG LC_ALL"
|
||||
local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE METHOD ARCH TARGET TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG GETKERNEL KEYMAP VIMLANG PAGE TIMEZONE LANG"
|
||||
local -r lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG GETKERNEL VIMLANG PAGE TIMEZONE LANG"
|
||||
local -r hlfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE MODEL GRSECURITY_HOST TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG GETKERNEL KEYMAP PAGE TIMEZONE LANG LC_ALL LUSER LGROUP"
|
||||
local -r clfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE METHOD ARCH TARGET TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB BOOT_CONFIG CONFIG GETKERNEL KEYMAP VIMLANG PAGE TIMEZONE LANG LUSER LGROUP"
|
||||
local -r lfs_PARAM_LIST="BOOK BUILDDIR SRC_ARCHIVE GETPKG RUNMAKE TEST BOMB_TEST OPTIMIZE REPORT COMPARE RUN_ICA RUN_FARCE ITERATIONS STRIP FSTAB CONFIG GETKERNEL VIMLANG PAGE TIMEZONE LANG LUSER LGROUP"
|
||||
|
||||
local -r ERROR_MSG_pt1='The variable \"${L_arrow}${config_param}${R_arrow}\" value ${L_arrow}${BOLD}${!config_param}${R_arrow} is invalid,'
|
||||
local -r ERROR_MSG_pt2=' check the config file ${BOLD}${GREEN}\<$(echo $PROGNAME | tr [a-z] [A-Z])/config\> or \<common/config\>${OFF}'
|
||||
|
@ -211,6 +211,12 @@ inline_doc
|
|||
METHOD) validate_against_str "xchrootx xbootx" ;;
|
||||
ARCH) validate_against_str "xx86x xx86_64x xx86_64-64x xsparcx xsparc64x xsparc64-64x xmipsx xmips64x xmips64-64x xppcx xppc64x xalphax" ;;
|
||||
TARGET) validate_target ;;
|
||||
LUSER) echo -e "`eval echo $PARAM_VALS`"
|
||||
[[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
|
||||
;;
|
||||
LGROUP) echo -e "`eval echo $PARAM_VALS`"
|
||||
[[ "${!config_param}" = "**EDIT ME**" ]] && write_error_and_die
|
||||
;;
|
||||
GRSECURITY_HOST) validate_against_str "x0x x1x" ;;
|
||||
|
||||
# BOOK validation. Very ugly, need be fixed
|
||||
|
|
Reference in a new issue