Changes made to allow the generated makefile to be run from any account (with sudo privs)
This commit is contained in:
parent
786e86c71d
commit
7d4cc81f34
7 changed files with 98 additions and 25 deletions
|
@ -171,6 +171,7 @@ cat << EOF
|
|||
echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
|
||||
@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
||||
touch envars && \\
|
||||
chmod -R a+wt \$(MOUNT_PT) && \\
|
||||
chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
|
@ -319,9 +320,9 @@ chroot_Makefiles() { #
|
|||
# First append each name of the script files to a list (this will become
|
||||
# the names of the targets in the Makefile
|
||||
case "${this_script}" in
|
||||
*util-linux) : ;;
|
||||
*kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
||||
*) chroottools="$chroottools $this_script" ;;
|
||||
*util-linux) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
||||
*kernfs) orphan_scripts="${orphan_scripts} ${this_script}" ;;
|
||||
*) chroottools="$chroottools $this_script" ;;
|
||||
esac
|
||||
|
||||
# Grab the name of the target, strip id number, XXX-script
|
||||
|
@ -1181,9 +1182,18 @@ if [[ "${METHOD}" = "chroot" ]]; then
|
|||
(
|
||||
cat << EOF
|
||||
|
||||
all: mk_SETUP mk_CROSS mk_TEMP restore_luser_env mk_SYSTOOLS mk_FINAL mk_BOOTSCRIPT mk_BOOTABLE do-housekeeping
|
||||
all: ck_UID mk_SETUP mk_CROSS mk_TEMP mk_SUDO mk_SYSTOOLS mk_FINAL mk_BOOTSCRIPT mk_BOOTABLE
|
||||
@sudo make do-housekeeping
|
||||
@\$(call echo_finished,$VERSION)
|
||||
|
||||
ck_UID:
|
||||
@if [ \`id -u\` = "0" ]; then \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
echo "You cannot run this makefile from the root account"; \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
exit 1; \\
|
||||
fi
|
||||
|
||||
#---------------AS ROOT
|
||||
mk_SETUP:
|
||||
@\$(call echo_SU_request)
|
||||
|
@ -1193,14 +1203,18 @@ mk_SETUP:
|
|||
#---------------AS LUSER
|
||||
mk_CROSS: mk_SETUP
|
||||
@\$(call echo_PHASE,Cross Tool)
|
||||
@( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make CROSS" )
|
||||
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make CROSS" )
|
||||
@touch \$@
|
||||
|
||||
mk_TEMP: mk_CROSS
|
||||
@\$(call echo_PHASE,Temporary Tools)
|
||||
@( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make TEMP" )
|
||||
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make TEMP" )
|
||||
@sudo make restore-luser-env
|
||||
@touch \$@
|
||||
|
||||
mk_SUDO: mk_TEMP
|
||||
@sudo make SUDO
|
||||
@touch \$@
|
||||
#
|
||||
# The convoluted piece of code below is necessary to provide 'make' with a valid shell in the
|
||||
# chroot environment. (Unless someone knows a different way)
|
||||
|
@ -1209,7 +1223,7 @@ mk_TEMP: mk_CROSS
|
|||
# pre-existing links.
|
||||
|
||||
#---------------CHROOT JAIL
|
||||
mk_SYSTOOLS: mk_TEMP $orphan_scripts
|
||||
mk_SYSTOOLS: mk_SUDO
|
||||
@mkdir \$(MOUNT_PT)/bin && \\
|
||||
cd \$(MOUNT_PT)/bin && \\
|
||||
ln -sf /tools/bin/bash bash; ln -sf bash sh
|
||||
|
@ -1245,12 +1259,22 @@ if [[ "${METHOD}" = "boot" ]]; then
|
|||
(
|
||||
cat << EOF
|
||||
|
||||
all: mk_SETUP mk_CROSS mk_TEMP mk_SYSTOOLS $orphan_scripts restore-luser-env
|
||||
all: ck_UID mk_SETUP mk_CROSS mk_TEMP mk_SYSTOOLS mk_SUDO
|
||||
@sudo make restore-luser-env
|
||||
@\$(call echo_boot_finished,$VERSION)
|
||||
|
||||
makesys: mk_FINAL mk_BOOTSCRIPT mk_BOOTABLE
|
||||
@\$(call echo_finished,$VERSION)
|
||||
|
||||
|
||||
ck_UID:
|
||||
@if [ \`id -u\` = "0" ]; then \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
echo "You cannot run this makefile from the root account"; \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
exit 1; \\
|
||||
fi
|
||||
|
||||
#---------------AS ROOT
|
||||
|
||||
mk_SETUP:
|
||||
|
@ -1262,17 +1286,21 @@ mk_SETUP:
|
|||
|
||||
mk_CROSS: mk_SETUP
|
||||
@\$(call echo_PHASE,Cross Tool)
|
||||
@( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make CROSS" )
|
||||
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make CROSS" )
|
||||
@touch \$@
|
||||
|
||||
mk_TEMP: mk_CROSS
|
||||
@\$(call echo_PHASE,Temporary Tools)
|
||||
@( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make TEMP" )
|
||||
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make TEMP" )
|
||||
@touch \$@
|
||||
|
||||
mk_SYSTOOLS: mk_TEMP
|
||||
@\$(call echo_PHASE,Minimal Boot system)
|
||||
@( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SYSTOOLS" )
|
||||
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make SYSTOOLS" )
|
||||
@touch \$@
|
||||
|
||||
mk_SUDO: mk_SYSTOOLS
|
||||
@sudo make SUDO
|
||||
@touch \$@
|
||||
|
||||
#---------------AS ROOT
|
||||
|
@ -1302,6 +1330,7 @@ fi
|
|||
SETUP: $host_prep
|
||||
CROSS: $cross_tools
|
||||
TEMP: $temptools
|
||||
SUDO: $orphan_scripts
|
||||
SYSTOOLS: ${chroottools}${boottools}
|
||||
FINAL: $testsuitetools $basicsystem
|
||||
BOOTSCRIPT: $bootscripttools
|
||||
|
|
|
@ -65,7 +65,8 @@ cat << EOF
|
|||
echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc
|
||||
@chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
||||
touch envars && \\
|
||||
chown \$(LUSER):\$(LGROUP) envars
|
||||
chown \$(LUSER):\$(LGROUP) envars && \\
|
||||
chmod -R a+wt \$(MOUNT_PT)
|
||||
@touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
echo --------------------------------------------------------------------------------\$(WHITE)
|
||||
|
@ -465,9 +466,18 @@ EOF
|
|||
(
|
||||
cat << EOF
|
||||
|
||||
all: mk_SETUP mk_LUSER mk_ROOT
|
||||
all: ck_UID mk_SETUP mk_LUSER mk_ROOT
|
||||
@sudo do_housekeeping
|
||||
@\$(call echo_finished,$VERSION)
|
||||
|
||||
ck_UID:
|
||||
@if [ \`id -u\` = "0" ]; then \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
echo "You cannot run this makefile from the root account"; \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
exit 1; \\
|
||||
fi
|
||||
|
||||
mk_SETUP:
|
||||
@\$(call echo_SU_request)
|
||||
@sudo make SETUP
|
||||
|
@ -475,7 +485,8 @@ mk_SETUP:
|
|||
|
||||
mk_LUSER: mk_SETUP
|
||||
@\$(call echo_SULUSER_request)
|
||||
@( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
|
||||
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
|
||||
@sudo restore-luser-env
|
||||
@touch \$@
|
||||
|
||||
mk_ROOT:
|
||||
|
|
|
@ -707,6 +707,7 @@ menu "--- Advanced Features"
|
|||
#--- End ICA/farce
|
||||
|
||||
#--- Optimizations
|
||||
if !BOOK_CLFS2
|
||||
config CONFIG_OPTIMIZE
|
||||
bool "Use optimization (see help)"
|
||||
default n
|
||||
|
@ -740,6 +741,7 @@ menu "--- Advanced Features"
|
|||
default "0" if !CONFIG_OPTIMIZE
|
||||
default "1" if OPT_1
|
||||
default "2" if OPT_2
|
||||
endif
|
||||
#--- End Optimizations
|
||||
|
||||
#-- Internal Settings
|
||||
|
|
|
@ -153,6 +153,7 @@ cat << EOF
|
|||
echo "export target ldso" >> /home/\$(LUSER)/.bashrc && \\
|
||||
echo "source $JHALFSDIR/envars" >> /home/\$(LUSER)/.bashrc && \\
|
||||
chown \$(LUSER):\$(LGROUP) /home/\$(LUSER)/.bashrc && \\
|
||||
chmod -R a+wt \$(MOUNT_PT) && \\
|
||||
touch envars && \\
|
||||
chown \$(LUSER) envars && \\
|
||||
touch \$@ && \\
|
||||
|
@ -555,9 +556,17 @@ EOF
|
|||
(
|
||||
cat << EOF
|
||||
|
||||
all: mk_SETUP mk_LUSER mk_CHROOT mk_BOOT do-housekeeping
|
||||
all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT
|
||||
@sudo make do-housekeeping
|
||||
@\$(call echo_finished,$VERSION)
|
||||
|
||||
ck_UID:
|
||||
@if [ \`id -u\` = "0" ]; then \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
echo "You cannot run this makefile from the root account"; \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
exit 1; \\
|
||||
fi
|
||||
|
||||
mk_SETUP:
|
||||
@\$(call echo_SU_request)
|
||||
|
@ -566,10 +575,15 @@ mk_SETUP:
|
|||
|
||||
mk_LUSER: mk_SETUP
|
||||
@\$(call echo_SULUSER_request)
|
||||
@( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
|
||||
@(sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
|
||||
@sudo make restore-luser-env
|
||||
@touch \$@
|
||||
|
||||
mk_CHROOT: mk_LUSER 060-kernfs 062-changingowner
|
||||
mk_SUDO: mk_LUSER
|
||||
@sudo make SUDO
|
||||
@touch \$@
|
||||
|
||||
mk_CHROOT: mk_SUDO
|
||||
@mkdir \$(MOUNT_PT)/bin && \
|
||||
cd \$(MOUNT_PT)/bin && \
|
||||
ln -sf /tools/bin/bash bash; ln -sf bash sh
|
||||
|
@ -588,6 +602,8 @@ SETUP: $chapter3
|
|||
|
||||
LUSER: $chapter5
|
||||
|
||||
SUDO: 060-kernfs 062-changingowner
|
||||
|
||||
CHROOT: $chapter6
|
||||
|
||||
BOOT: $chapter7
|
||||
|
|
|
@ -39,7 +39,7 @@ chapter4_Makefiles() { #
|
|||
fi;
|
||||
@chown \$(LUSER) \$(MOUNT_PT)/tools && \\
|
||||
chown -R \$(LUSER) \$(MOUNT_PT)/\$(SCRIPT_ROOT) && \\
|
||||
chmod a+wt \$(MOUNT_PT)/sources && \\
|
||||
chmod -R a+wt \$(MOUNT_PT) && \\
|
||||
touch \$@ && \\
|
||||
echo " "\$(BOLD)Target \$(BLUE)\$@ \$(BOLD)OK && \\
|
||||
echo --------------------------------------------------------------------------------\$(WHITE)
|
||||
|
@ -435,10 +435,18 @@ EOF
|
|||
(
|
||||
cat << EOF
|
||||
|
||||
all: mk_SETUP mk_LUSER mk_CHROOT mk_BOOT
|
||||
all: ck_UID mk_SETUP mk_LUSER mk_SUDO mk_CHROOT mk_BOOT
|
||||
@sudo housekeeping
|
||||
@\$(call echo_finished,$VERSION)
|
||||
|
||||
|
||||
ck_UID:
|
||||
@if [ \`id -u\` = "0" ]; then \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
echo "You cannot run this makefile from the root account"; \\
|
||||
echo "--------------------------------------------------"; \\
|
||||
exit 1; \\
|
||||
fi
|
||||
|
||||
mk_SETUP:
|
||||
@\$(call echo_SU_request)
|
||||
@sudo make SETUP
|
||||
|
@ -446,8 +454,12 @@ mk_SETUP:
|
|||
|
||||
mk_LUSER: mk_SETUP
|
||||
@\$(call echo_SULUSER_request)
|
||||
@( \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
|
||||
@( sudo \$(SU_LUSER) "source .bashrc && cd \$(MOUNT_PT)/\$(SCRIPT_ROOT) && make LUSER" )
|
||||
@touch \$@
|
||||
|
||||
mk_SUDO: mk_LUSER
|
||||
@sudo make SUDO
|
||||
touch \$@
|
||||
#
|
||||
# The convoluted piece of code below is necessary to provide 'make' with a valid shell in the
|
||||
# chroot environment. (Unless someone knows a different way)
|
||||
|
@ -455,13 +467,14 @@ mk_LUSER: mk_SETUP
|
|||
# Also change the original symlink creation to include (f)orce to prevent failure due to
|
||||
# pre-existing links.
|
||||
#
|
||||
mk_CHROOT: mk_LUSER 057-changingowner 059-kernfs
|
||||
mk_CHROOT: mk_LUSER
|
||||
@mkdir \$(MOUNT_PT)/bin && \\
|
||||
cd \$(MOUNT_PT)/bin && \\
|
||||
ln -sf /tools/bin/bash bash; ln -sf bash sh
|
||||
@sed -e 's|^ln -sv|ln -svf|' -i \$(CMDSDIR)/chapter06/063-createfiles
|
||||
@\$(call echo_CHROOT_request)
|
||||
@( sudo \$(CHROOT1) "cd \$(SCRIPT_ROOT) && make CHROOT")
|
||||
@sudo restore-luser-env
|
||||
@touch \$@
|
||||
|
||||
mk_BOOT: mk_CHROOT
|
||||
|
@ -474,6 +487,8 @@ SETUP: $chapter4
|
|||
|
||||
LUSER: $chapter5
|
||||
|
||||
SUDO: 057-changingowner 059-kernfs
|
||||
|
||||
CHROOT: $chapter6
|
||||
|
||||
BOOT: $chapter789
|
||||
|
|
|
@ -343,8 +343,8 @@ run_make() { #
|
|||
# Test if make must be run.
|
||||
if [ "$RUNMAKE" = "y" ] ; then
|
||||
# Test to make sure we're running the build as root
|
||||
if [ "$UID" != "0" ] ; then
|
||||
echo "You must be logged in as root to successfully build the system."
|
||||
if [ "$UID" = "0" ] ; then
|
||||
echo "You must not be logged in as root to build the system."
|
||||
exit 1
|
||||
fi
|
||||
# Build the system
|
||||
|
|
|
@ -26,7 +26,7 @@ define echo_SU_request
|
|||
@echo $(BOLD)--------------------------------------------------------------------------------
|
||||
@echo $(BLUE)$@
|
||||
@echo $(WHITE)ROOT privilege is required to perform a number commands
|
||||
@echo sudo will request a password to all high privelege cmds to execut correctly
|
||||
@echo sudo will request a password to all high privilege cmds to execute correctly
|
||||
endef
|
||||
|
||||
define echo_SULUSER_request
|
||||
|
|
Reference in a new issue