--- alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2015/07/23 11:37:03 6827 +++ alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2015/07/23 12:49:52 6837 @@ -10,6 +10,7 @@ source /mnt/cdrom/system/images.conf # includes +source ${MLIBDIR}/functions/generic.sh source ${MLIBDIR}/functions/hwdetection.sh ### System/Config Version @@ -18,7 +19,7 @@ # locations CDPATH="/mnt/cdrom" -INSTALLPATH="/mnt/magellan" +INSTALL_ROOT="/mnt/magellan" # default system settings # standard kernel opts @@ -45,6 +46,7 @@ FORMAT_FILESYSTEM="" FDISKPARTIONBELOW256MB=0 SPECIALDEVICE="" +FLASHDISK=0 ### linecount of system.tar.gz -1 ! CURRENTLINE=0 #TOTALLINES=11072 # -> now in images.conf @@ -58,6 +60,7 @@ ERROR=$1 RETVAL=$? dialog_install_failure + trap_exit exit 1 } @@ -88,6 +91,7 @@ ;; normal) dialog_setup_hdd_info_normal ;; single) dialog_setup_hdd_info_single ;; + flash) dialog_setup_hdd_info_flash ;; esac } @@ -121,6 +125,21 @@ Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 } +dialog_setup_hdd_info_flash() +{ + local SHDD="$(echo ${HDD} | sed 's/\/dev\///')" + + dialog \ + --colors \ + --title "[ Festplatten Partitionierung ]" \ + --backtitle "${TITLE}" \ + --ok-label "Weiter" \ + --msgbox "\nBitte legen Sie 2 Partitionen an.\n\n\ + [ \Z3${SHDD}1\Zn ] Typ: \Z3Linux\Zn mit ca. 50MB\n\ + [ \Z3${SHDD}2\Zn ] Typ: \Z3Linux \Zn mit dem Rest (min. 256MB)\n\n\ + Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 +} + dialog_setup_hdd_info_auto() { local SHDD="$(echo $HDD | sed 's/\/dev\///')" @@ -150,7 +169,8 @@ "" "" \ "" "\Z1Experten Modi:\Zn" \ "2" "Normale IDE-Disk (Manuell)" \ - "3" "Normale IDE Disk (Single)") + "3" "Normale IDE Disk (Single)" \ + "4" "Flash SDHC/NAND oder USBStick (Manuell)") RES=$? [[ ${RES} -eq 1 ]] && return 1 if [[ ${RES} -eq 0 ]] @@ -159,6 +179,7 @@ "1") run_install auto ;; "2") run_install normal ;; "3") run_install single ;; + "3") run_install flash ;; "") dialog_setup_system_menu;; esac fi @@ -217,6 +238,10 @@ then echo " \n \\ZnFormfactor Laptop, Powersave Modus 'ondemand' wird aktiviert.\\Zn \\" >> ${hwtmp} fi + if [[ ${FLASHDISK} = 1 ]] + then + echo " \n \\ZnFlash Speicher erkannt, F2FS wird als Dateisystem benutzt.\\Zn \\" >> ${hwtmp} + fi echo " \" 14 70" >> ${hwtmp} chmod a+x ${hwtmp} @@ -381,6 +406,8 @@ if [[ $(< ${i}) = 1 ]] then removable=1 + # we assume that all removable disks are flash disks + export FLASHDISK=1 fi done @@ -487,6 +514,12 @@ SWAPHDD="" ROOTHDD="${HDD}1" ;; + + flash) + BOOTHDD="${HDD}1" + SWAPHDD="" + ROOTHDD="${HDD}2" + ;; esac if [[ ${INSTALL_METHOD} = auto ]] @@ -561,77 +594,91 @@ fi if [[ -n ${BOOTHDD} ]] then - mke2fs -j -q ${BOOTHDD} || die + # f2fs is not grub/grub2 compatible + if [[ ${FORMAT_FILESYSTEM} = f2fs ]] + then + mkfs.ext2 -q ${BOOTHDD} || die + else + mkfs.${FORMAT_FILESYSTEM} -q ${BOOTHDD} || die + fi fi if [[ -n ${ROOTHDD} ]] then - mke2fs -j -q ${ROOTHDD} || die + mkfs.${FORMAT_FILESYSTEM} -q ${ROOTHDD} || die fi } install_mount_rootfs() { + local opts + if [[ -n ${SWAPHDD} ]] then swapon ${SWAPHDD} || die fi if [[ -n ${ROOTHDD} ]] then - mount ${ROOTHDD} ${INSTALLPATH} || die + # be safe here, append file system type to mount + # just in case the f2fs module was not autoloaded + [[ ${FORMAT_FILESYSTEM} = f2fs ]] && opts="-t fs2fs" + mount ${opts} ${ROOTHDD} ${INSTALL_ROOT} || die fi if [[ -n ${BOOTHDD} ]] then - install -d ${INSTALLPATH}/boot || die - mount ${BOOTHDD} ${INSTALLPATH}/boot || die + install -d ${INSTALL_ROOT}/boot || die + mount ${BOOTHDD} ${INSTALL_ROOT}/boot || die fi - cd ${INSTALLPATH} || die + cd ${INSTALL_ROOT} || die } install_system_image() { - tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALLPATH} + tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALL_ROOT} } install_bootsector_chroot() { local my_roothdd - local grubconf=${INSTALLPATH}/boot/grub/grub.conf + local grubconf=${INSTALL_ROOT}/boot/grub/grub.conf local grub2conf=/boot/grub/grub.cfg + local CONFIG # check for grub2 - if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]] + if [[ -f ${INSTALL_ROOT}/sbin/grub-mkconfig ]] then # needed by grub-mkconfig on the first run - if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]] + if [[ ! -f ${INSTALL_ROOT}/boot/grub/video.lst ]] then - install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die + install -m0644 ${INSTALL_ROOT}/lib/grub/*/video.lst ${INSTALL_ROOT}/boot/grub/video.lst || die fi # set kernelopts - if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]] + if [[ -f ${INSTALL_ROOT}/etc/conf.d/grub ]] then - sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die - sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALLPATH}/etc/conf.d/grub || die + sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die + sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die else - echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALLPATH}/etc/conf.d/grub || die - echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >> ${INSTALLPATH}/etc/conf.d/grub || die + echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALL_ROOT}/etc/conf.d/grub || die + echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >> ${INSTALL_ROOT}/etc/conf.d/grub || die fi - echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die - echo "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die - echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die - echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die + CONFIG=${INSTALL_ROOT}/.installrc + clearconfig + addconfig 'grub-mkdevicemap' + addconfig "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" + addconfig "grub-install --no-floppy ${HDD} &> /dev/null" + addconfig "exit 0" # grub-legacy else ### grubconf schreiben - source ${INSTALLPATH}/boot/kernelversion + source ${INSTALL_ROOT}/boot/kernelversion #for alx only - if [ -e ${INSTALLPATH}/etc/alx_version ] + if [ -e ${INSTALL_ROOT}/etc/alx_version ] then OLD_ALXVER="${ALXVER}" - source ${INSTALLPATH}/etc/alx_version + source ${INSTALL_ROOT}/etc/alx_version KRNVER="ALX-${ALXVER}" ALXVER="${OLD_ALXVER}" fi @@ -648,77 +695,71 @@ my_roothdd="${ROOTHDD}" fi - : > ${grubconf} || die - echo "default 0" >> ${grubconf} || die - echo "timeout 3" >> ${grubconf} || die + CONFIG="${grubconf}" + clearconfig + addconfig "default 0" + addconfig "timeout 3" # using current root password - echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)" >> ${grubconf} || die - - echo >> ${grubconf} || die - echo "# normal boot" >> ${grubconf} || die - echo "title ${KRNVER}" >> ${grubconf} || die - echo "root (hd0,0)" >> ${grubconf} || die - echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die + addconfig "password --md5 $(cat ${INSTALL_ROOT}/etc/shadow | grep root | cut -d: -f2)" + addconfig + addconfig "# normal boot" + addconfig "title ${KRNVER}" + addconfig "root (hd0,0)" + addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" if is_initrd_supported then - echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die + addconfig "initrd /boot/${KRNINITRD}" fi - - echo >> ${grubconf} || die - echo "# admin boot" >> ${grubconf} || die - echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die - echo "lock" >> ${grubconf} || die - echo "root (hd0,0)" >> ${grubconf} || die - echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || die + addconfig + addconfig "# admin boot" + addconfig "title ${KRNVER} - Re-run hardware-detection" + addconfig "lock" + addconfig "root (hd0,0)" + addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" if is_initrd_supported then - echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die + addconfig "initrd /boot/${KRNINITRD}" fi - - echo >> ${grubconf} || die - echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die - echo "lock" >> ${grubconf} || die - echo "root (hd0,0)" >> ${grubconf} || die - echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || die + addconfig + addconfig "title ${KRNVER} - Reset *all* local settings" + addconfig "lock" + addconfig "root (hd0,0)" + addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" if is_initrd_supported then - echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die + addconfig "initrd /boot/${KRNINITRD}" fi # write bootsector chrooted (lfs/magellan) - cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF -/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null -root (hd0,0) -setup (hd0) -quit -EOF -exit 0 -CHROOTEOF + CONFIG=${INSTALL_ROOT}/.installrc + clearconfig + addconfig '/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null' + addconfig 'root (hd0,0)' + addconfig 'setup (hd0)' + addconfig 'quit' + addconfig 'EOF' + addconfig 'exit 0' fi - ## enters chroot - mount -t proc proc ${INSTALLPATH}/proc - mount -t sysfs sysfs ${INSTALLPATH}/sys - mount -o bind /dev ${INSTALLPATH}/dev - chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i - umount ${INSTALLPATH}/proc - umount ${INSTALLPATH}/sys - umount ${INSTALLPATH}/dev - rm ${INSTALLPATH}/root/.installrc + ## enter chroot + enter_chroot_installrc } is_initrd_supported() { # only generate initrds if the cmd exists - [[ -x ${INSTALLPATH}/sbin/mkinitrd ]] && return 0 + [[ -x ${INSTALL_ROOT}/sbin/mkinitrd ]] && return 0 return 1 } install_initrd_chroot() { + local CONFIG + # only generate initrds if the cmd exists is_initrd_supported || return 0 + FSMODS="${FORMAT_FILESYSTEM}" DISKMODS="sd_mod" OLDPATAMODS="amd74xx piix sis5513 via82cxxx" PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" @@ -735,46 +776,58 @@ *) FBMODS="uvesafb" ;; esac + # add a filesystems recoqnized by the bootloader if the current ${FORMAT_FILESYSTEM} is not supported + case "${FORMAT_FILESYSTEM}" in + f2fs) FSMODS+=" ext2" ;; + esac + if [[ ${FORMFACTOR} = laptop ]] then OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave" fi # install an appropriate uvesafb.conf - install -d ${INSTALLPATH}/etc/modprobe.d || die - echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die + CONFIG=${INSTALL_ROOT}/etc/modprobe.d/uvesafb.conf + clearconfig + addconfig "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" # install an appropriate viafb.conf - echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die + CONFIG=${INSTALL_ROOT}/etc/modprobe.d/viafb.conf + clearconfig + addconfig "options viafb viafb_mode=1024x768 viafb_refresh=60" # install an appropriate i810fb.conf - echo "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60" > ${INSTALLPATH}/etc/modprobe.d/i810fb.conf || die - - cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF -echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd -mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null -exit 0 -CHROOTEOF - - ## enters chroot - mount -t proc proc ${INSTALLPATH}/proc - mount -t sysfs sysfs ${INSTALLPATH}/sys - mount -o bind /dev ${INSTALLPATH}/dev - chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i - umount ${INSTALLPATH}/proc - umount ${INSTALLPATH}/sys - umount ${INSTALLPATH}/dev - rm ${INSTALLPATH}/root/.installrc + CONFIG=${INSTALL_ROOT}/etc/modprobe.d/i810fb.conf + clearconfig + addconfig "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60" + + CONFIG=${INSTALL_ROOT}/.installrc + clearconfig + addconfig 'echo "MODULES=\"${FSMODS} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd' + addconfig 'mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null' + addconfig 'exit 0' + ## enter chroot + enter_chroot_installrc } is_uuid_supported() { - if [[ -x $(which busybox.mkinitrd &> /dev/null) ]] + # f2fs needs special treatments as the old busybox does not support this fs + # use the blkid from util-linux instead of busybox + if [[ ${FORMAT_FILESYSTEM} = f2fs ]] then - # only detect uuids if supported - if [[ ! -z $(busybox.mkinitrd | grep blkid) ]] + if [[ -x $(which blkid &> /dev/null) ]] + then + return 0 + fi + else + if [[ -x $(which busybox.mkinitrd &> /dev/null) ]] then - return 0 + # only detect uuids if supported + if [[ ! -z $(busybox.mkinitrd | grep blkid) ]] + then + return 0 + fi fi fi @@ -786,6 +839,7 @@ local UUID local SEC_TYPE local TYPE + local blkidcmd local dev="$1" [[ -z ${dev} ]] && die "no dev given" @@ -795,7 +849,15 @@ then eval "${dev}" else - eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //') + # f2fs needs special treatments as the old busybox does not support this fs + # use the blkid from util-linux instead of busybox + if [[ ${FORMAT_FILESYSTEM} = f2fs ]] + then + blkidcmd="blkid" + else + blkidcmd="busybox.mkinitrd blkid" + fi + eval $(${blkidcmd} ${dev} | grep "${dev}:" | sed 's/.*:\ //') fi echo "${UUID}" } @@ -807,29 +869,29 @@ then if [[ -n ${BOOTHDD} ]] then - echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die + echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALL_ROOT}/etc/fstab || die fi if [[ -n ${ROOTHDD} ]] then - echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die + echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die fi else if [[ -n ${BOOTHDD} ]] then - echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die + echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALL_ROOT}/etc/fstab || die fi if [[ -n ${ROOTHDD} ]] then - echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die + echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die fi fi # not needed busybox loads all with swapon -a, even if not mentioned in fstab - #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALLPATH}/etc/fstab || die - echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die - echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die + #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die + echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die + echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die # install network config skeleton - install -m0644 ${INSTALLPATH}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLPATH}/etc/conf.d/ || die + install -m0644 ${INSTALL_ROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALL_ROOT}/etc/conf.d/ || die # intel framebufer quirk if [[ -e /proc/fb ]] @@ -839,7 +901,7 @@ fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') if [[ ${fbdev} != 0 ]] then - sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLPATH}/etc/splash/splash.conf || die + sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALL_ROOT}/etc/splash/splash.conf || die fi fi fi @@ -850,11 +912,11 @@ cd / if [[ -n ${BOOTHDD} ]] then - umount ${INSTALLPATH}/boot || die + umount ${INSTALL_ROOT}/boot || die fi if [[ -n ${ROOTHDD} ]] then - umount ${INSTALLPATH} || die + umount ${INSTALL_ROOT} || die fi if [[ -n ${SWAPHDD} ]] then @@ -893,6 +955,10 @@ single) export INSTALL_METHOD="${method}" ;; + flash) + export FORMAT_FILESYSTEM="f2fs" + export INSTALL_METHOD="${method}" + ;; *) echo "Unknown install method '${method}', aborting." exit 1 @@ -919,6 +985,9 @@ dialog_install_successful } +# set some proper traps +trap "trap_exit" SIGINT SIGQUIT + dialog_main exit 0