From 9e94a4e515c47dc79644ee1c512b5fe1e9fc562f Mon Sep 17 00:00:00 2001 From: emmett1 Date: Wed, 16 Oct 2019 17:23:02 +0800 Subject: [PATCH] updated --- 03-mkiso | 4 +- config | 2 +- ports/dhcpcd/Pkgfile | 6 +-- ports/filesystem/Pkgfile | 2 +- ports/filesystem/fstab | 3 -- ports/grub/Pkgfile | 5 ++- ports/grub/grub.default | 54 +++++++++++++++++++++++ ports/linux-firmware/Pkgfile | 4 +- ports/wpa_supplicant/Pkgfile | 10 ++--- rootfs/sbin/lfs-chroot | 85 ++++++++++++++++++++++++++++++++++++ rootfs/sbin/lfs-install | 33 ++++++++++++++ 11 files changed, 189 insertions(+), 19 deletions(-) create mode 100755 ports/grub/grub.default create mode 100755 rootfs/sbin/lfs-chroot create mode 100755 rootfs/sbin/lfs-install diff --git a/03-mkiso b/03-mkiso index 820c411..77f261c 100755 --- a/03-mkiso +++ b/03-mkiso @@ -55,6 +55,8 @@ source $CWD/config isolinux_files="chain.c32 isolinux.bin ldlinux.c32 libutil.c32 reboot.c32 menu.c32 libcom32.c32 poweroff.c32" +OUTPUT=$OUTPUT.iso + rm -fr $WDIR mkdir -p $WDIR @@ -81,7 +83,7 @@ cp $LFS/boot/vmlinuz-lfs $WDIR/boot/vmlinuz || die "failed copying kernel" cp files/livecd.hook $LFS/etc/mkinitramfs.d kernver=$(file $LFS/boot/vmlinuz-lfs | cut -d ' ' -f9) chroot_run mkinitramfs -k $kernver -a livecd -o /boot/initrd-lfs.img || die "failed create initramfs" -cp $LFS/boot/initrd-lfs.img $WDIR/boot/initrd || die "failed copying initrd" +mv $LFS/boot/initrd-lfs.img $WDIR/boot/initrd || die "failed copying initrd" printstep "Setup UEFI mode..." mkdir -p $WDIR/boot/{grub/{fonts,x86_64-efi},EFI} diff --git a/config b/config index 1e32a92..3293e3a 100755 --- a/config +++ b/config @@ -10,7 +10,7 @@ FILEDIR=$CWD/files WORKDIR=/tmp LABEL=LFSLIVECD -OUTPUT=lfslivecd.iso +OUTPUT=lfs-livecd-$(date +"%Y%m%d") WDIR=/tmp/lfsiso #MULTILIB=yes diff --git a/ports/dhcpcd/Pkgfile b/ports/dhcpcd/Pkgfile index cfbc02e..29dc158 100755 --- a/ports/dhcpcd/Pkgfile +++ b/ports/dhcpcd/Pkgfile @@ -23,9 +23,9 @@ build() { mkdir -p $PKG/etc/sysconfig/ cat > $PKG/etc/sysconfig/ifconfig.eth0 << "EOF" -#ONBOOT="yes" -#IFACE="eth0" -#SERVICE="dhcpcd" +ONBOOT="no" +IFACE="eth0" +SERVICE="dhcpcd" #DHCP_START="-b -q " #DHCP_STOP="-k " EOF diff --git a/ports/filesystem/Pkgfile b/ports/filesystem/Pkgfile index c80923b..e3135bb 100755 --- a/ports/filesystem/Pkgfile +++ b/ports/filesystem/Pkgfile @@ -70,7 +70,7 @@ build() { # /etc install -d $PKG/etc - for p in profile bashrc resolv.conf inputrc fstab hostname hosts shells passwd group; do + for p in profile bashrc resolv.conf inputrc fstab hostname hosts passwd group; do install -m0644 $p $PKG/etc done diff --git a/ports/filesystem/fstab b/ports/filesystem/fstab index b3b2b8b..fe28d8c 100755 --- a/ports/filesystem/fstab +++ b/ports/filesystem/fstab @@ -5,10 +5,7 @@ #/dev/ / defaults 1 1 #/dev/ swap swap pri=1 0 0 -proc /proc proc nosuid,noexec,nodev 0 0 -sysfs /sys sysfs nosuid,noexec,nodev 0 0 devpts /dev/pts devpts gid=5,mode=620 0 0 tmpfs /run tmpfs defaults 0 0 -devtmpfs /dev devtmpfs mode=0755,nosuid 0 0 # End /etc/fstab diff --git a/ports/grub/Pkgfile b/ports/grub/Pkgfile index ce872a5..f141bd5 100755 --- a/ports/grub/Pkgfile +++ b/ports/grub/Pkgfile @@ -6,8 +6,7 @@ name=grub version=2.04 release=1 -backup=(etc/default/grub) -source=(https://ftp.gnu.org/gnu/$name/$name-$version.tar.xz) +source=(https://ftp.gnu.org/gnu/$name/$name-$version.tar.xz grub.default) build() { cd $name-$version @@ -20,4 +19,6 @@ build() { --enable-grub-mount make make DESTDIR=$PKG install + + install -D -m0644 $SRC/grub.default $PKG/etc/default/grub } diff --git a/ports/grub/grub.default b/ports/grub/grub.default new file mode 100755 index 0000000..3bfaf22 --- /dev/null +++ b/ports/grub/grub.default @@ -0,0 +1,54 @@ +# GRUB boot loader configuration + +GRUB_DEFAULT=0 +GRUB_TIMEOUT=5 +GRUB_DISTRIBUTOR="Linux From Scratch" +GRUB_CMDLINE_LINUX_DEFAULT="quiet" +GRUB_CMDLINE_LINUX="" + +# Preload both GPT and MBR modules so that they are not missed +GRUB_PRELOAD_MODULES="part_gpt part_msdos" + +# Uncomment to enable booting from LUKS encrypted devices +#GRUB_ENABLE_CRYPTODISK=y + +# Uncomment to enable Hidden Menu, and optionally hide the timeout count +#GRUB_HIDDEN_TIMEOUT=5 +#GRUB_HIDDEN_TIMEOUT_QUIET=true + +# Uncomment to use basic console +GRUB_TERMINAL_INPUT=console + +# Uncomment to disable graphical terminal +#GRUB_TERMINAL_OUTPUT=console + +# The resolution used on graphical terminal +# note that you can use only modes which your graphic card supports via VBE +# you can see them in real GRUB with the command `vbeinfo' +GRUB_GFXMODE=auto + +# Uncomment to allow the kernel use the same resolution used by grub +GRUB_GFXPAYLOAD_LINUX=keep + +# Uncomment if you want GRUB to pass to the Linux kernel the old parameter +# format "root=/dev/xxx" instead of "root=/dev/disk/by-uuid/xxx" +#GRUB_DISABLE_LINUX_UUID=true + +# Uncomment to disable generation of recovery mode menu entries +GRUB_DISABLE_RECOVERY=true + +# Uncomment and set to the desired menu colors. Used by normal and wallpaper +# modes only. Entries specified as foreground/background. +#GRUB_COLOR_NORMAL="light-blue/black" +#GRUB_COLOR_HIGHLIGHT="light-cyan/blue" + +# Uncomment one of them for the gfx desired, a image background or a gfxtheme +#GRUB_BACKGROUND="/path/to/wallpaper" +#GRUB_THEME="/path/to/gfxtheme" + +# Uncomment to get a beep at GRUB start +#GRUB_INIT_TUNE="480 440 1" + +# Uncomment to make GRUB remember the last selection. This requires to +# set 'GRUB_DEFAULT=saved' above. +#GRUB_SAVEDEFAULT="true" diff --git a/ports/linux-firmware/Pkgfile b/ports/linux-firmware/Pkgfile index 7f68734..2bb8540 100755 --- a/ports/linux-firmware/Pkgfile +++ b/ports/linux-firmware/Pkgfile @@ -4,13 +4,11 @@ # Depends on: name=linux-firmware -version=20190717 +version=20190923 release=1 source=(https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/snapshot/linux-firmware-$version.tar.gz) build() { cd $name-$version - make DESTDIR=$PKG install - rm $PKG/lib/firmware/{Makefile,README,configure,GPL-3,*.txt,check_whence.py} } diff --git a/ports/wpa_supplicant/Pkgfile b/ports/wpa_supplicant/Pkgfile index 53bdc7b..c7b6897 100755 --- a/ports/wpa_supplicant/Pkgfile +++ b/ports/wpa_supplicant/Pkgfile @@ -67,14 +67,14 @@ EOF mkdir -p $PKG/etc/sysconfig cat > $PKG/etc/sysconfig/ifconfig.wifi0 << "EOF" -#ONBOOT="yes" -#IFACE="wlan0" -#SERVICE="wpa" +ONBOOT="no" +IFACE="wlan0" +SERVICE="wpa" # Additional arguments to wpa_supplicant -#WPA_ARGS="" +WPA_ARGS="" -#WPA_SERVICE="dhcpcd" +WPA_SERVICE="dhcpcd" #DHCP_START="-b -q " #DHCP_STOP="-k " EOF diff --git a/rootfs/sbin/lfs-chroot b/rootfs/sbin/lfs-chroot new file mode 100755 index 0000000..4f1f15a --- /dev/null +++ b/rootfs/sbin/lfs-chroot @@ -0,0 +1,85 @@ +#!/bin/bash + +printhelp() { + cat << EOF + +Usage: + $(basename $0) + +(omit command to chroot only) + +EOF +} + +msgerr() { + echo -e "ERROR: $@" +} + +if [ "$UID" != "0" ]; then + msgerr "$(basename $0) need root access!" + printhelp + exit 1 +fi + +LFS=$1 + +if [ -z $1 ]; then + msgerr "Please set directory for chroot!" + printhelp + exit 1 +fi + +if [ ! -d $LFS ]; then + msgerr "Directory '$LFS' not exist" + printhelp + exit 1 +fi + +shift + +CMD=$@ +if [ -z $2 ]; then + CMD="/bin/bash --login" +fi + +if [ -e /sys/firmware/efi/systab ]; then + EFI_SYSTEM=1 +fi + +pushd $LFS &>/dev/null + +mount --bind /dev $LFS/dev +mount -t devpts devpts $LFS/dev/pts -o gid=5,mode=620 +mount -t proc proc $LFS/proc +mount -t sysfs sysfs $LFS/sys +if [ -n "$EFI_SYSTEM" ]; then + mount --bind /sys/firmware/efi/efivars $LFS/sys/firmware/efi/efivars +fi +mount -t tmpfs tmpfs $LFS/run + +if [ -h $LFS/dev/shm ]; then + mkdir -p $LFS/$(readlink $LFS/dev/shm) +fi + +cp -L /etc/resolv.conf $LFS/etc + +chroot "$LFS" /usr/bin/env -i \ +HOME=/root \ +TERM="$TERM" \ +PS1='\u:\w\$ ' \ +PATH=/bin:/usr/bin:/sbin:/usr/sbin $CMD + +retval=$? + +popd &>/dev/null + +umount $LFS/dev/pts +umount $LFS/dev +umount $LFS/run +umount $LFS/proc +if [ -n "$EFI_SYSTEM" ]; then + umount $LFS/sys/firmware/efi/efivars +fi +umount $LFS/sys + +exit $retval diff --git a/rootfs/sbin/lfs-install b/rootfs/sbin/lfs-install new file mode 100755 index 0000000..680d569 --- /dev/null +++ b/rootfs/sbin/lfs-install @@ -0,0 +1,33 @@ +#!/bin/bash + +LFSMOUNT=$1 + +if [ ! "$LFSMOUNT" ]; then + echo "mounted location for install not define!" + exit 1 +fi + +if ! mountpoint -q $LFSMOUNT; then + echo "'$LFSMOUNT' is not a mountpoint!" + exit 1 +fi + +if [ -f "/run/initramfs/ram/root.sfs" ]; then + ROOTSFS="/run/initramfs/ram/root.sfs" +elif [ -f "/run/initramfs/medium/lfs/root.sfs" ]; then + ROOTSFS="/run/initramfs/medium/lfs/root.sfs" +else + echo "squashed image not found!" + exit 1 +fi + +unsquashfs -f -i -d $LFSMOUNT $ROOTSFS + +if [ "$?" = "0" ]; then + echo "Successfully installed to '$LFSMOUNT'" +else + echo "failed to install lfs system" + exit 1 +fi + +exit 0