Author: alexander
Date: 2005-11-01 02:18:07 -0700 (Tue, 01 Nov 2005)
New Revision: 1020

Modified:
   branches/dm/Makefile
Log:
Modified Makefile in order to build the entire LFS on a loop device

WARNING: this Makefile is no longer compatible with old contents of /mnt/lfs.
WARNING: please do a fresh checkout into an empty /mnt/lfs/lfs-livecd directory

Reorganized creation of directories
Defined a minimal subset of BLFS for testing
Built everything up to lfs-bootscripts



Modified: branches/dm/Makefile
===================================================================
--- branches/dm/Makefile        2005-10-31 12:19:59 UTC (rev 1019)
+++ branches/dm/Makefile        2005-11-01 09:18:07 UTC (rev 1020)
@@ -1,3 +1,4 @@
+
 #
 # Makefiles for automating the LFS LiveCD build
 #
@@ -32,7 +33,8 @@
 # HTTPBLFS: Default http server for the BLFS packages
 
 export LFS-ARCH ?= x86
-export MP ?= /mnt/lfs
+export MPBASE ?= /mnt/lfs
+export MP ?= $(MPBASE)/image
 export timezone ?= GMT
 export pagesize ?= letter
 export ROOT ?= /lfs-livecd
@@ -49,6 +51,8 @@
 export PKG := packages
 export MKTREE := $(MP)$(ROOT)
 
+ROOTFS_MEGS := 1536
+
 export CROSSVARS := vars/vars.$(LFS-ARCH)
 
 include $(CROSSVARS)
@@ -109,16 +113,84 @@
        @if [ `whoami` != "root" ] ; then \
         echo "You must be logged in as root." && exit 1 ; fi
 
+# This image should be kept as clean as possible, i.e.:
+# avoid creating files on it that you will later delete,
+# preserve as many zeroed sectors as possible.
+root.ext2:
+       dd if=/dev/null of=root.ext2 bs=1M seek=$(ROOTFS_MEGS)
+       echo y | mke2fs root.ext2
+       tune2fs -c 0 -i 0 root.ext2
+
+# This target populates the root.ext2 image and sets up some mounts
+# Basically, replaces the prep-chroot and createdirs targets
+$(MP)$(ROOT): root.ext2
+       mkdir -p $(MP) $(MPBASE)$(SRC) $(MPBASE)$(WD)/bin $(MPBASE)/iso/boot
+       mount -o loop root.ext2 $(MP)
+       mkdir -p $(MP)$(ROOT) $(MP)$(SRC) $(MP)$(WD) $(MP)/boot
+       mount --bind $(MPBASE)$(ROOT) $(MP)$(ROOT)
+       mount --bind $(MPBASE)$(WD) $(MP)$(WD)
+       mount --bind $(MPBASE)$(SRC) $(MP)$(SRC)
+       mount --bind $(MPBASE)/iso/boot $(MP)/boot
+       mkdir -p $(MP)$(WD)/bin
+       mkdir -p $(MP)$(LFSSRC)
+       -ln -nsf $(MPBASE)$(WD) /
+       -ln -nsf $(MPBASE)$(SRC) /
+       -ln -nsf $(MPBASE)$(ROOT) /
+       -ln -nsf $(MP)$(LFSSRC) /
+ifdef CROSS
+       mkdir -p $(MPBASE)$(CROSS_WD)/bin $(MP)$(CROSS_WD)
+       mount --bind $(MPBASE)$(CROSS_WD) $(MP)$(CROSS_WD)
+       -ln -nsf $(MP)$(CROSS_WD) /
+endif
+       -mkdir -p $(MP)/{proc,sys,dev/shm,dev/pts}
+       -mount -t proc proc $(MP)/proc
+       -mount -t sysfs sysfs $(MP)/sys
+       -mount -t tmpfs tmpfs $(MP)/dev/shm
+       -mount -t devpts -o gid=4,mode=620 devpts $(MP)/dev/pts
+       -install -d $(MP)/{bin,etc/opt,home,lib,mnt}
+       -install -d $(MP)/{sbin,srv,usr/local,var,opt}
+       -install -d $(MP)/root -m 0750
+       -install -d $(MP)/tmp $(MP)/var/tmp -m 1777
+       -install -d $(MP)/media/{floppy,cdrom}
+       -install -d $(MP)/usr/{bin,include,lib,sbin,share,src}
+       -ln -s share/{man,doc,info} $(MP)/usr
+       -install -d $(MP)/usr/share/{doc,info,locale,man}
+       -install -d $(MP)/usr/share/{misc,terminfo,zoneinfo}
+       -install -d $(MP)/usr/share/man/man{1,2,3,4,5,6,7,8}
+       -install -d $(MP)/usr/local/{bin,etc,include,lib,sbin,share,src}
+       -ln -s share/{man,doc,info} $(MP)/usr/local
+       -install -d $(MP)/usr/local/share/{doc,info,locale,man}
+       -install -d $(MP)/usr/local/share/{misc,terminfo,zoneinfo}
+       -install -d $(MP)/usr/local/share/man/man{1,2,3,4,5,6,7,8}
+       -install -d $(MP)/var/{lock,log,mail,run,spool}
+       -install -d $(MP)/var/{opt,cache,lib/{misc,locate},local}
+       -install -d $(MP)/opt/{bin,doc,include,info}
+       -install -d $(MP)/opt/{lib,man/man{1,2,3,4,5,6,7,8}}
+ifdef CROSS
+       -install -d $(MP)/{,usr/{,local},opt}/$(LIB_MAYBE64)
+       -install -d /usr/lib/locale
+       -ln -s ../lib/locale /usr/$(LIB_MAYBE64)
+endif
+       # The "662" permissions in LFS are a security hole due to "loadkeys":
+       # A remote attacker can remap any key to "<CTRL+C>rm -rf /<ENTER>"
+       # and wait for root to press that key.
+       -mknod -m 600 $(MP)/dev/console c 5 1
+       -mknod -m 666 $(MP)/dev/null c 1 3
+       -mknod -m 666 $(MP)/dev/zero c 1 5
+       -mknod -m 666 $(MP)/dev/ptmx c 5 2
+       -mknod -m 666 $(MP)/dev/tty c 5 0
+       -mknod -m 444 $(MP)/dev/random c 1 8
+       -mknod -m 444 $(MP)/dev/urandom c 1 9
+       # No chown because this will not affect the permissions in any way.
+       -ln -s /proc/self/fd $(MP)/dev/fd
+       -ln -s /proc/self/fd/0 $(MP)/dev/stdin
+       -ln -s /proc/self/fd/1 $(MP)/dev/stdout
+       -ln -s /proc/self/fd/2 $(MP)/dev/stderr
+       -ln -s /proc/kcore $(MP)/dev/core
+
 # This target builds just a base LFS system, minus the kernel and bootscripts
 #==============================================================================
-lfs-base: lfsuser
-       @if [ ! -d $(MP)$(WD)/bin ] ; then mkdir -p $(MP)$(WD)/bin ; fi
-       @if [ ! -d $(MP)$(SRC) ] ; then mkdir $(MP)$(SRC) ; fi
-       @if [ ! -d $(MP)$(LFSSRC) ] ; then mkdir $(MP)$(LFSSRC) ; fi
-       @-ln -nsf $(MP)$(WD) /
-       @-ln -nsf $(MP)$(SRC) /
-       @-ln -nsf $(MP)$(ROOT) /
-       @-ln -nsf $(MP)$(LFSSRC) /
+lfs-base: $(MP)$(ROOT) lfsuser
 ifndef CROSS
        @-make unamemod
        @-chown -R lfs $(WD) $(MP)$(WD) $(WD)/bin \
@@ -126,12 +198,8 @@
        @cp $(ROOT)/scripts/unpack $(WD)/bin
        @su - lfs -c "$(lfsenv) '$(lfsbash) && $(MAKE) tools'"
        @touch $(PKG)/wget/.pass2
-       @make prep-chroot
-       @-mkdir $(MP)/etc
        @install -m644 -oroot -groot $(ROOT)/etc/{group,passwd} $(MP)/etc
-       @-mkdir $(MP)/bin
-       @if [ ! -f $(MP)/bin/bash ] ; then if [ ! -d $(MP) ] ; then \
-        mkdir $(MP)/bin ; fi ; ln -s ${WD}/bin/bash ${MP}/bin/bash ; fi
+       @-ln -s $(WD)/bin/bash $(MP)/bin/bash
        @chroot "$(MP)" $(chenv-pre-bash) 'set +h && \
         chown -R 0:0 $(WD) $(SRC) $(ROOT) && \
         cd $(ROOT) && make pre-bash $(chbash-pre-bash)'
@@ -139,20 +207,14 @@
         make post-bash $(chbash-post-bash)'
        @-ln -s $(WD)/bin/wget $(MP)/usr/bin/wget
 else
-       @if [ ! -d $(MP)$(CROSS_WD)/bin ] ; then mkdir -p $(MP)$(CROSS_WD)/bin 
; fi
-       @-ln -nsf $(MP)$(CROSS_WD) /
        @-chown -R lfs $(WD) $(MP)$(WD) $(WD)/bin $(CROSS_WD) $(MP)$(CROSS_WD) 
$(CROSS_WD)/bin \
         $(LFSSRC) $(MP)$(LFSSRC) $(SRC) $(MP)$(SRC) $(MKTREE)
        @cp $(ROOT)/scripts/unpack $(WD)/bin
        @cp $(ROOT)/scripts/unpack $(CROSS_WD)/bin
        @su - lfs -c "$(crossenv) '$(lfsbash) && $(MAKE) cross-tools'"
        @su - lfs -c "$(lfsenv) '$(lfsbash) && $(MAKE) tools'"
-       @make prep-chroot
-       @-mkdir $(MP)/etc
        @install -m644 -oroot -groot $(ROOT)/etc/{group,passwd} $(MP)/etc
-       @-mkdir $(MP)/bin
-       @if [ ! -f $(MP)/bin/bash ] ; then if [ ! -d $(MP) ] ; then \
-        mkdir $(MP)/bin ; fi ; ln -s ${WD}/bin/bash ${MP}/bin/bash ; fi
+       @-ln -s $(WD)/bin/bash $(MP)/bin/bash
        @chroot "$(MP)" $(chenv-pre-bash) 'set +h && \
         chown -R 0:0 $(WD) $(SRC) $(ROOT) && \
         cd $(ROOT) && make cross-pre-bash $(chbash-pre-bash)'
@@ -161,12 +223,15 @@
        @-ln -s $(WD)/bin/wget $(MP)/usr/bin/wget
 endif
 
-extend-lfs: prep-chroot
+stop-here:
+       exit 1
+
+extend-lfs: $(MP)$(ROOT)
        @cp $(WD)/bin/which $(MP)/usr/bin
        @cp $(ROOT)/scripts/unpack $(MP)/bin
 ifndef CROSS
        @chroot "$(MP)" $(chenv-blfs) 'set +h && cd $(ROOT) && \
-        make blfs $(chbash-post-bash)'
+        make minimal-blfs $(chbash-post-bash)'
 else
 ifeq ($(LFS-ARCH),sparc64)
        @chroot "$(MP)" $(chenv-blfs) 'set +h && cd $(ROOT) && \
@@ -196,10 +261,9 @@
        @-ln -s $(WD)/bin/wget $(CROSS_WD)/bin
 endif
        @touch $@
-       
+
 unamemod:
-       @if [ ! -d ${WD}/bin ] ; then mkdir ${WD}/bin ; fi
-       @install -m 755 uname/uname ${WD}/bin/
+       @install -m 755 uname/uname $(WD)/bin/
        @touch $@
 
 cross-tools: pre-which pre-wget lfs-linux-libc-headers-scpt lfs-binutils-cross 
\
@@ -224,17 +288,7 @@
        @cp /etc/resolv.conf $(WD)/etc
 endif
 
-
-prep-chroot:
-       @-mkdir -p $(MP)/{proc,sys}
-       @-mount -t proc proc $(MP)/proc
-       @-mount -t sysfs sysfs $(MP)/sys
-       @-mount -f -t tmpfs none $(MP)/dev
-       @-mount -f -t tmpfs tmpfs $(MP)/dev/shm
-       @-mount -f -t devpts -o gid=4,mode=620 devpts $(MP)/dev/pts
-       @touch $@
-
-pre-bash: createdirs createfiles popdev ch-linux-libc-headers ch-man-pages \
+pre-bash: createfiles ch-linux-libc-headers ch-man-pages \
        ch-glibc re-adjust-toolchain ch-binutils ch-gcc ch-coreutils \
        ch-zlib ch-mktemp ch-iana-etc ch-findutils ch-gawk \
        ch-m4 ch-bison ch-gpm ch-ncurses ch-readline ch-vim ch-less ch-groff \
@@ -246,7 +300,7 @@
        ch-module-init-tools ch-patch ch-procps ch-psmisc ch-shadow \
        ch-sysklogd ch-sysvinit ch-tar ch-udev ch-util-linux final-environment
 
-cross-pre-bash: createdirs createfiles popdev lfs-tcl-scpt lfs-expect-scpt \
+cross-pre-bash: createfiles lfs-tcl-scpt lfs-expect-scpt \
        lfs-dejagnu-scpt lfs-perl-scpt lfs-texinfo-scpt ch-linux-libc-headers \
        ch-man-pages ch-glibc-32 ch-glibc adjusting-toolchain ch-binutils 
ch-gcc \
        ch-coreutils ch-zlib ch-iana-etc ch-findutils ch-gawk ch-ncurses 
ch-readline \
@@ -261,6 +315,13 @@
        make ch-grub
 endif
 
+minimal-blfs: ch-openssl ch-wget ch-reiserfsprogs ch-xfsprogs \
+       ch-lynx ch-libxml2 ch-expat ch-subversion stop-here ch-lfs-bootscripts \
+       ch-docbook-xml ch-libxslt ch-docbook-xsl ch-html_tidy ch-LFS-BOOK \
+       ch-dhcpcd ch-cpio ch-eject ch-nALFS ch-dialog ch-device-mapper \
+       ch-linux ch-initramfs ch-cdrtools ch-zisofs-tools ch-initramfs \
+       ch-syslinux ch-nALFS-profile
+
 blfs: ch-openssl ch-wget ch-reiserfsprogs ch-xfsprogs ch-nano ch-joe \
        ch-screen ch-curl ch-zip ch-unzip ch-lynx ch-libxml2 ch-expat \
        ch-subversion ch-lfs-bootscripts ch-docbook-xml ch-libxslt \
@@ -323,11 +384,11 @@
        @su - lfs -c "$(lfsenv) '$(lfsbash) && $(MAKE) lfs-$*-pass2'"
 
 # The following takes the form 'make [package name]-only-ch'   
-%-only-ch: prep-chroot
+%-only-ch: $(MP)$(ROOT)
        make -C $(PKG)/$* chroot
        make unmount
 
-gvim: prep-chroot
+gvim: $(MP)$(ROOT)
        make -C $(PKG)/vim chroot3
        make unmount
 
@@ -341,64 +402,19 @@
 # scripts internally.
 #==============================================================================
 
-createdirs:
-       @-$(WD)/bin/install -d /{bin,boot,dev,etc/opt,home,lib,mnt}
-       @-$(WD)/bin/install -d /{sbin,srv,usr/local,var,opt}
-       @-$(WD)/bin/install -d /root -m 0750
-       @-$(WD)/bin/install -d /tmp /var/tmp -m 1777
-       @-$(WD)/bin/install -d /media/{floppy,cdrom}
-       @-$(WD)/bin/install -d /usr/{bin,include,lib,sbin,share,src}
-       @-$(WD)/bin/ln -s share/{man,doc,info} /usr
-       @-$(WD)/bin/install -d /usr/share/{doc,info,locale,man}
-       @-$(WD)/bin/install -d /usr/share/{misc,terminfo,zoneinfo}
-       @-$(WD)/bin/install -d /usr/share/man/man{1,2,3,4,5,6,7,8}
-       @-$(WD)/bin/install -d /usr/local/{bin,etc,include,lib,sbin,share,src}
-       @-$(WD)/bin/ln -s share/{man,doc,info} /usr/local
-       @-$(WD)/bin/install -d /usr/local/share/{doc,info,locale,man}
-       @-$(WD)/bin/install -d /usr/local/share/{misc,terminfo,zoneinfo}
-       @-$(WD)/bin/install -d /usr/local/share/man/man{1,2,3,4,5,6,7,8}
-       @-$(WD)/bin/install -d /var/{lock,log,mail,run,spool}
-       @-$(WD)/bin/install -d /var/{opt,cache,lib/{misc,locate},local}
-       @-$(WD)/bin/install -d /opt/{bin,doc,include,info}
-       @-$(WD)/bin/install -d /opt/{lib,man/man{1,2,3,4,5,6,7,8}}
+createfiles:
        @-$(WD)/bin/ln -s $(WD)/bin/{bash,cat,pwd,stty} /bin
        @-$(WD)/bin/ln -s $(WD)/bin/perl /usr/bin
        @-$(WD)/bin/ln -s $(WD)/lib/libgcc_s.so{,.1} /usr/lib
        @-$(WD)/bin/ln -s bash /bin/sh
 ifdef CROSS
-       @-$(WD)/bin/install -d /{,usr/{,local},opt}/lib64
-       @-$(WD)/bin/install -d /usr/lib/locale
-       @-$(WD)/bin/ln -s ../lib/locale /usr/lib64
        @-$(WD)/bin/ln -s $(WD)/lib64/libgcc_s.so{,.1} /usr/lib64
 endif
-
-createfiles:
        @touch /var/run/utmp /var/log/{btmp,lastlog,wtmp}
        @chgrp utmp /var/run/utmp /var/log/lastlog
        @chmod 664 /var/run/utmp /var/log/lastlog
        @mv $(WD)/etc/resolv.conf /etc
 
-popdev:
-       @if [ ! -c /dev/console ] ; then mknod -m 600 /dev/console c 5 1 && \
-        mknod -m 666 /dev/null c 1 3 ; fi
-       @if ! tail -n 3 /proc/mounts | grep -q "dev tmpfs" ; then \
-        mount -n -t tmpfs tmpfs /dev && \
-        mknod -m 662 /dev/console c 5 1 ; \
-        mknod -m 666 /dev/null c 1 3 ; \
-        mknod -m 666 /dev/zero c 1 5 ; \
-        mknod -m 666 /dev/ptmx c 5 2 ; \
-        mknod -m 666 /dev/tty c 5 0 ; \
-        mknod -m 444 /dev/random c 1 8 ; \
-        mknod -m 444 /dev/urandom c 1 9 ; \
-        chown root:tty /dev/{console,ptmx,tty} ; \
-        ln -s /proc/self/fd /dev/fd ; \
-        ln -s /proc/self/fd/0 /dev/stdin ; \
-        ln -s /proc/self/fd/1 /dev/stdout ; \
-        ln -s /proc/self/fd/2 /dev/stderr ; \
-        ln -s /proc/kcore /dev/core ; \
-        mkdir /dev/pts && mount -t devpts -o gid=4,mode=620 none /dev/pts ; \
-        mkdir /dev/shm && mount -t tmpfs none /dev/shm ; fi
-
 # Do not call the targets below manually! They are used internally and must be
 # called by other targets.
 #==============================================================================
@@ -433,10 +449,10 @@
        @-rm -rf $(WD)/{doc,info,man}
        @touch $@
 
-ch-%: popdev
+ch-%:
        make -C $(PKG)/$* stage2
 
-ch-glibc-32: popdev
+ch-glibc-32:
        make -C $(PKG)/glibc stage2-32
 
 re-adjust-toolchain:
@@ -550,7 +566,7 @@
        @-userdel lfs
        @-groupdel lfs
        @-rm -rf /home/lfs
-       @-rm 
{prepiso,lfsuser,unamemod,prep-chroot,lfs-base,extend-lfs,lfs-strip,}
+       @-rm {prepiso,lfsuser,unamemod,lfs-base,extend-lfs,lfs-strip,}
        @-rm {sqfs.log,lfs-strip,pre-wget}
        @-rm $(PKG)/binutils/{,re-}adjust-toolchain
        @-for i in `ls $(PKG)` ; do $(MAKE) -C $(PKG)/$$i clean ; done
@@ -579,13 +595,18 @@
 unmount:
        @-umount $(MP)/dev/shm
        @-umount $(MP)/dev/pts
-       @-umount $(MP)/dev
        @-umount $(MP)/proc
        @-umount $(MP)/sys
-       @rm -f $(ROOT)/prep-chroot
+       @-umount $(MP)/boot
+       @-umount $(MP)$(SRC)
+       @-umount $(MP)$(WD)
+       @-umount $(MP)$(ROOT)
+       @-umount $(MP)
+       @-rmdir $(MP)$(SRC) $(MP)$(WD) $(MP)$(ROOT)
 
+
 .PHONY: unmount clean_sources scrub clean iso chroot-gvim update-fontsdir \
        final-environment re-adjust-toolchain ch-% ch-glibc-32 
lfs-adjust-toolchain \
-       lfs-%-scpt lfs-%-scpt-32 lfs-%-pass1 lfs-%-pass2 popdev createfiles 
createdirs \
+       lfs-%-scpt lfs-%-scpt-32 lfs-%-pass1 lfs-%-pass2 createfiles \
        gvim %-only-ch lfs-%-only lfs-%-only-pass1 lfs-%-only-pass2 lfs-wget \
        lfs-rm-wget blfs post-bash pre-bash tools pre-which

-- 
http://linuxfromscratch.org/mailman/listinfo/livecd
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to