--- alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh 2008/06/28 00:37:45 531 +++ alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2015/07/23 08:48:15 6817 @@ -11,17 +11,19 @@ # Install Navigation Gui # -#images: (get ${CDIMAGENAME}) +# ignore environment! +LC_ALL=C + +MLIBDIR="/usr/lib/alxinstall-ng" + +# images: (get ${CDIMAGENAME}) source /mnt/cdrom/system/images.conf -#Includes -source /usr/lib/alxinstall-ng/functions/findhdd.sh > /dev/null -### bugfix ############################### -cdromdev="$(echo ${cdromdev} | sed 's/ //')" -######################################## +# includes +source ${MLIBDIR}/functions/hwdetection.sh ### System/Config Version -VERSION="0.3.1" +VERSION="%VERSIONTAG%" TITLE="alxinstall-ng - ${VERSION}" CDPATH="/mnt/cdrom" @@ -31,6 +33,23 @@ CURRENTLINE=0 #TOTALLINES=11072 # -> now in images.conf +# standard kernel opts +KERNELOPTS="quiet video=1024x768" + +# grub options +GRUBLEGACYOPTS="" +GRUB2OPTS="" +GRUB2GFXPAYLOAD="1024x768x16,1024x768" + +# fdisk options +FDISKPARTIONBELOW256MB=0 + +# default specialdevices +SPECIALDEVICE="" +FORMFACTOR="desktop" + +# target filesystem +FORMAT_FILESYSTEM="ext4" ################################################# # DIALOG BOXEN # @@ -78,7 +97,7 @@ Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 } -dialog_setup_hdd_info_flash() +dialog_setup_hdd_info_simple() { local SHDD="$(echo $HDD | sed 's/\/dev\///')" @@ -92,6 +111,19 @@ Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 } +dialog_setup_hdd_info_auto() +{ + local SHDD="$(echo $HDD | sed 's/\/dev\///')" + + dialog \ + --colors \ + --title "[ Festplatten Partitionierung ]" \ + --backtitle "${TITLE}" \ + --ok-label "Weiter" \ + --msgbox "\nAchtung!\n\ + Alle Daten werden von der Disk [ \Z3${HDD}\Zn ] gelöscht!" 12 81 +} + dialog_setup_system_menu() { local i @@ -102,74 +134,96 @@ --cancel-label "Abbrechen" \ --ok-label "Weiter" \ --stdout \ + --colors \ --menu "\nWaehlen Sie die Installations-Methode" 14 70 5 \ - "1" "Normale IDE-Disk" \ - "2" "Flash-Speicher") + "1" "Automatisches Setup (Empfohlen)" \ + "" "" \ + "" "\Z1Experten Modi:\Zn" \ + "2" "Normale IDE-Disk (Manuell)" \ + "3" "Flash-Speicher (Manuell)") RES=$? [[ ${RES} -eq 1 ]] && return 1 if [[ ${RES} -eq 0 ]] then case "${i}" in - "1") run_install_normal ;; - "2") run_install_flash ;; + "1") run_install_auto ;; + "2") run_install_normal ;; + "3") run_install_simple ;; + "") dialog_setup_system_menu;; esac fi } -dialog_setup_hdd_found_manuell() +dialog_hardware_detection() { local i + local hwtmp - [[ ! -z ${installdevs} ]] && installdevs="" + if [ -x $(which mktemp &> /dev/null) ] + then + hwtmp="$(mktemp)" + else + hwtmp="/tmp/hwtmp.sh" + fi + + run_hardware_detection_disks - echo "dialog \\" > /tmp/hddtmp.sh - echo "--backtitle \"${TITLE}\" \\" >> /tmp/hddtmp.sh - echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh - echo "--stdout \\" >> /tmp/hddtmp.sh - echo "--colors \\" >> /tmp/hddtmp.sh - echo "--msgbox \"Gefundene Hardware:\n\n \\" >> /tmp/hddtmp.sh - echo " Festplatten:\n \\" >> /tmp/hddtmp.sh + echo "dialog \\" > ${hwtmp} + echo "--backtitle \"${TITLE}\" \\" >> ${hwtmp} + echo "--ok-label \"Weiter\" \\" >> ${hwtmp} + echo "--stdout \\" >> ${hwtmp} + echo "--colors \\" >> ${hwtmp} + echo "--msgbox \"Gefundene Hardware:\n\n \\" >> ${hwtmp} + echo " Festplatten:\n \\" >> ${hwtmp} - if [[ ! -z ${scsidisks} ]] + if [[ ! -z ${ALL_DISKS} ]] then - for i in ${scsidisks} + for i in ${ALL_DISKS} do - if [[ ${i} != ${cdromdev} ]] - then - echo " \\Z7SCSI: \\Z3${i}\\Zn\n \\" >> /tmp/hddtmp.sh - installdevs="${installdevs} ${i}" - fi + echo " \\Z3${i}\\Zn\n \\" >> ${hwtmp} done fi - if [[ ! -z ${idedisks} ]] + if [[ ! -z ${ALL_CDROMS} ]] then - for i in ${idedisks} + echo " \n \\" >> ${hwtmp} + echo " CDROM Laufwerke:\n \\" >> ${hwtmp} + for i in ${ALL_CDROMS} do - if [[ ${i} != ${cdromdev} ]] - then - echo " \\Z7IDE: \\Z3${i}\\Zn\n \\" >> /tmp/hddtmp.sh - installdevs="${installdevs} ${i}" - fi + echo " \\Z3${i}\\Zn\n \\" >> ${hwtmp} done fi - if [[ ! -z ${cdromdev} ]] + # other devices + run_hardware_detection + case "${SPECIALDEVICE}" in + zotac*) echo " \n \\Z2Zotac Device erkannt.\\Zn \\" >> ${hwtmp} ;; + rangee) echo " \n \\Z2Rangee Device erkannt.\\Zn \\" >> ${hwtmp} ;; + maxdata) echo " \n \\Z2Maxdata Device erkannt.\\Zn \\" >> ${hwtmp} ;; + i845) echo " \n \\Z2Intel i845 Device erkannt.\\Zn \\" >> ${hwtmp} ;; + *) echo " \n \\ZnStandard Device erkannt.\\Zn \\" >> ${hwtmp} ;; + esac + if [[ ${FORMFACTOR} = laptop ]] + then + echo " \n \\ZnFormfactor Laptop, Powersave Modus 'ondemand' wird aktiviert.\\Zn \\" >> ${hwtmp} + fi + + echo " \" 14 70" >> ${hwtmp} + chmod a+x ${hwtmp} + ${hwtmp} + + # remove tmp file + if [[ -f ${hwtmp} ]] then - echo " \n \\" >> /tmp/hddtmp.sh - echo " \\Z7andere Laufwerke:\n \\" >> /tmp/hddtmp.sh - echo " CDROM: \\Z3${cdromdev}\\Zn\n \\" >> /tmp/hddtmp.sh - fi - echo " \" 13 70" >> /tmp/hddtmp.sh - chmod a+x /tmp/hddtmp.sh - /tmp/hddtmp.sh + rm ${hwtmp} + fi } dialog_setup_hdd_partitions_manuell() { local i - if [[ -z ${installdevs} ]] + if [[ -z ${ALL_DISKS} ]] then dialog \ --backtitle "${TITLE}" \ @@ -185,7 +239,7 @@ echo "--stdout \\" >> /tmp/hddtmp.sh echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh - for i in ${installdevs} + for i in ${ALL_DISKS} do echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh done @@ -203,11 +257,49 @@ fi } -dialog_setup_hdd_partitions_manuell_flash() +dialog_setup_hdd_partitions_manuell_simple() +{ + local i + + if [[ -z ${ALL_DISKS} ]] + then + dialog \ + --backtitle "${TITLE}" \ + --ok-label "Beenden" \ + --msgbox "Kein geeignetes Laufwerk gefunden.\nDie Installation ist fehlgeschlagen." 6 70 + exit 1 + else + + echo "dialog \\" > /tmp/hddtmp.sh + echo "--backtitle \"${TITLE}\" \\" >> /tmp/hddtmp.sh + echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh + echo "--cancel-label \"Beenden\" \\" >> /tmp/hddtmp.sh + echo "--stdout \\" >> /tmp/hddtmp.sh + echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh + + for i in ${ALL_DISKS} + do + echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh + done + echo -e "\n" >> /tmp/hddtmp.sh + + chmod a+x /tmp/hddtmp.sh + HDD="$(/tmp/hddtmp.sh)" + RES=$? + [[ ${RES} -eq 1 ]] && return 1 + if [[ ${RES} -eq 0 ]] + then + dialog_setup_hdd_info_simple + setup_hdd_partitions_manuell_simple + fi + fi +} + +dialog_setup_hdd_partitions_auto() { local i - if [[ -z ${installdevs} ]] + if [[ -z ${ALL_DISKS} ]] then dialog \ --backtitle "${TITLE}" \ @@ -223,7 +315,7 @@ echo "--stdout \\" >> /tmp/hddtmp.sh echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh - for i in ${installdevs} + for i in ${ALL_DISKS} do echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh done @@ -235,12 +327,20 @@ [[ ${RES} -eq 1 ]] && return 1 if [[ ${RES} -eq 0 ]] then - dialog_setup_hdd_info_flash - setup_hdd_partitions_manuell_flash + dialog_setup_hdd_info_auto + dialog_setup_hdd_create_partitions + setup_hdd_partitions_auto fi fi } +dialog_setup_hdd_create_partitions() +{ + dialog \ + --backtitle "${TITLE}" \ + --infobox "Erstelle Disk Partitionen ..." 3 70 +} + dialog_setup_hdd_format() { dialog \ @@ -322,8 +422,8 @@ if [[ ${RES} -eq 0 ]] then case ${METHOD} in - "1") dialog_setup_system_menu ;; - "2") dialog_setup_hdd_found_manuell ;; + "1") dialog_setup_system_menu ;; + "2") dialog_hardware_detection ;; "3") install_do_reboot ;; "4") /bin/bash --login -i ;; esac @@ -334,6 +434,176 @@ ################################################# # Install Komandos # ################################################# +run_hardware_detection() +{ + local hwinfo + + hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" + + # check for special devices/clients: + # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd + local removable=0 + if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] + then + for i in /sys/block/[hs]d*/removable + do + if [[ $(< ${i}) = 1 ]] + then + removable=1 + fi + done + + # only add this for grub legacy, grub2 detect these settings on its own + export GRUBLEGACYOPTS="rootdelay=8" + # there are two zotac types in the wild, nvidia based gfx and intel + if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] + then + export SPECIALDEVICE="zotac_nvidia" + else + export SPECIALDEVICE="zotac_intel" + fi + fi + + # check for special devices/clients: + # if a rangee and disk ist smaller then 256mb move partion one block further ahead + if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] + then + # for a rangee always define partion startblock +1 + export FDISKPARTIONBELOW256MB="1" + export SPECIALDEVICE="rangee" + export GRUBLEGACYOPTS="" + fi + + # check for special devices/clients: + # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer + if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]] + then + export SPECIALDEVICE="maxdata" + export GRUBLEGACYOPTS="" + fi + + # check for i845 Chipsets and disable KMS and use 915 drm driver + if [[ ! -z $(echo "${hwinfo}" | grep -i i845) ]] + then + export SPECIALDEVICE="i845" + # unset default video=1024x768 opt or the drm driver breaks + export KERNELOPTS="quiet" + export GRUBLEGACYOPTS="" + # enable full kms support + export GRUB2GFXPAYLOAD="keep" + fi + + # check for radeon gfxcards + if [[ ! -z $(echo "${hwinfo}" | grep -i radeon) ]] + then + # enable full kms support + export GRUB2GFXPAYLOAD="keep" + fi + + # check for special devices/clients: + # check for laptops and activate cpufreq scaling + if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]] + then + export FORMFACTOR="laptop" + export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand" + fi +} + +run_hardware_detection_disks() +{ + local bootdev + + # all disks but exclude ramdisks + export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d') + # remove the boot device from ALL_DISKS if it was an usbstick + if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]] + then + bootdev="$(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')" + export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}") + fi + export ALL_CDROMS="$(get_hwinfo cdrom)" +} + +hdd_size_below_256mb() +{ + local hdd="$1" + local size + local retval + [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!" + + size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') + if [[ ${size} -le 257000000 ]] + then + retval="0" + else + retval="1" + fi + + return "${retval}" +} + +setup_hdd_partitions_auto() +{ + ROOTHDD="${HDD}1" + + # run this only if FDISKPARTITIONBELOW256MB is not already 1 + if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] + then + if hdd_size_below_256mb ${HDD} + then + FDISKPARTIONBELOW256MB=1 + else + FDISKPARTIONBELOW256MB=0 + fi + fi + + ## delete disk + dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die + + if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] + then + ## setup one bootable partition + #1. n= new disk + #2. p= primary disk + #3. 1= first partition + #4. 2= default sector start // small disk needs more space for grub2 mbr sector + #5. ''= defaul sector end + #6. a= bootable flag + #7. 1= boot flag for partition 1 + #8. w= write/quit + fdisk ${HDD} &> /dev/null << EOF +n +p +1 +2 + +a +1 +w +EOF + else + ## setup one bootable partition + #1. n= new disk + #2. p= primary disk + #3. 1= first partition + #4. ''= default sector start + #5. ''= defaul sector end + #6. a= bootable flag + #7. 1= boot flag for partition 1 + #8. w= write/quit + fdisk ${HDD} &> /dev/null << EOF +n +p +1 + + +a +1 +w +EOF + fi +} + setup_hdd_partitions_manuell() { BOOTHDD="${HDD}1" @@ -344,7 +614,7 @@ cfdisk ${HDD} || die } -setup_hdd_partitions_manuell_flash() +setup_hdd_partitions_manuell_simple() { ROOTHDD="${HDD}1" @@ -359,7 +629,7 @@ mke2fs -j -q ${ROOTHDD} || die } -setup_hdd_format_flash() +setup_hdd_format_simple() { mke2fs -j -q ${ROOTHDD} || die } @@ -373,7 +643,7 @@ cd ${INSTALLPATH} || die } -install_mount_rootfs_flash() +install_mount_rootfs_simple() { mount ${ROOTHDD} ${INSTALLPATH} || die install -d ${INSTALLPATH}/boot || die @@ -387,32 +657,98 @@ install_bootsector_chroot() { - ### grubconf schreiben - source ${INSTALLPATH}/boot/kernelversion + local my_roothdd + local grubconf=${INSTALLPATH}/boot/grub/grub.conf + local grub2conf=/boot/grub/grub.cfg - #for alx only - if [ -e ${INSTALLPATH}/etc/alx_version ] + # check for grub2 + if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]] then - OLD_ALXVER="${ALXVER}" - source ${INSTALLPATH}/etc/alx_version - KRNVER="ALX-${ALXVER}" - ALXVER="${OLD_ALXVER}" - fi + # needed by grub-mkconfig on the first run + if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]] + then + install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die + fi + + # set kernelopts + if [[ -f ${INSTALLPATH}/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 + 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 + 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 - [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX" - [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd" + # grub-legacy + else + ### grubconf schreiben + source ${INSTALLPATH}/boot/kernelversion - echo "default 0" > ${INSTALLPATH}/boot/grub/grub.conf || die - echo "timeout 0" >> ${INSTALLPATH}/boot/grub/grub.conf ||die + #for alx only + if [ -e ${INSTALLPATH}/etc/alx_version ] + then + OLD_ALXVER="${ALXVER}" + source ${INSTALLPATH}/etc/alx_version + KRNVER="ALX-${ALXVER}" + ALXVER="${OLD_ALXVER}" + fi - echo -e "\ntitle=${KRNVER}" >> ${INSTALLPATH}/boot/grub/grub.conf || die - echo "root (hd0,0)" >> ${INSTALLPATH}/boot/grub/grub.conf || die - - echo "kernel /boot/vmlinuz root=${ROOTHDD} quiet" >> ${INSTALLPATH}/boot/grub/grub.conf || die - echo "initrd /boot/initrd" >> ${INSTALLPATH}/boot/grub/grub.conf || die - - # bootsector schreiben chrooted schreiben (lfs/magellan) - cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF + [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX" + [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd" + [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz" + + # uuid support + if is_uuid_supported + then + my_roothdd="UUID=$(get_uuid ${ROOTHDD})" + else + my_roothdd="${ROOTHDD}" + fi + + : > ${grubconf} || die + echo "default 0" >> ${grubconf} || die + echo "timeout 3" >> ${grubconf} || die + # 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 + if is_initrd_supported + then + echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die + 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 + if is_initrd_supported + then + echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die + 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 + if is_initrd_supported + then + echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die + fi + + # bootsector schreiben chrooted schreiben (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) @@ -420,22 +756,64 @@ EOF exit 0 CHROOTEOF + 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/.bashrc -i + chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i umount ${INSTALLPATH}/proc umount ${INSTALLPATH}/sys umount ${INSTALLPATH}/dev - rm ${INSTALLPATH}/root/.bashrc + rm ${INSTALLPATH}/root/.installrc } -install_mkinitrd_chroot() +is_initrd_supported() { - cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF -echo "MODULES=\"ext3 amd74xx piix sis5513 via82cxxx\"" > /etc/conf.d/mkinitrd + # only generate initrds if the cmd exists + [[ -x ${INSTALLPATH}/sbin/mkinitrd ]] && return 0 + return 1 +} + +install_initrd_chroot() +{ + # only generate initrds if the cmd exists + is_initrd_supported || return 0 + + DISKMODS="sd_mod" + OLDPATAMODS="amd74xx piix sis5513 via82cxxx" + PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" + SATAMODS="sata_via sata_sis sata_nv" + DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" + OTHERMODS="" + case ${SPECIALDEVICE} in + zotac_intel|i845) FBMODS=""; DRMMODS="i915" ;; + zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;; + rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards + # not working with kms enabled drivers -> segfaults + #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer + maxdata) FBMODS="" ;; + *) FBMODS="uvesafb" ;; + 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 + + # install an appropriate viafb.conf + echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die + + # 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 @@ -444,30 +822,88 @@ mount -t proc proc ${INSTALLPATH}/proc mount -t sysfs sysfs ${INSTALLPATH}/sys mount -o bind /dev ${INSTALLPATH}/dev - chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i + chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i umount ${INSTALLPATH}/proc umount ${INSTALLPATH}/sys umount ${INSTALLPATH}/dev - rm ${INSTALLPATH}/root/.bashrc + rm ${INSTALLPATH}/root/.installrc +} + +is_uuid_supported() +{ + if [[ -x $(which busybox.mkinitrd &> /dev/null) ]] + then + # only detect uuids if supported + if [[ ! -z $(busybox.mkinitrd | grep blkid) ]] + then + return 0 + fi + fi + + return 1 +} + +get_uuid() +{ + local UUID + local SEC_TYPE + local TYPE + + local dev="$1" + [[ -z ${dev} ]] && die "no dev given" + + # check if given device is already an UUID + if [[ ${dev/UUID=/}x != ${dev}x ]] + then + eval "${dev}" + else + eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //') + fi + echo "${UUID}" } install_system_settings() { # schreibe fstab - echo -e "${BOOTHDD}\t/boot\text3\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die - echo -e "${ROOTHDD}\t/\text3\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die - echo -e "${SWAPHDD}\tswap\tswap\tpri=1\t0 0" >> ${INSTALLPATH}/etc/fstab || die + if is_uuid_supported + 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 ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die + else + echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die + echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die + 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 # install network config skeleton install -m0644 ${INSTALLPATH}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLPATH}/etc/conf.d/ || die + + # intel framebufer quirk + if [[ -e /proc/fb ]] + then + if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] + then + 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 + fi + fi + fi } -install_system_settings_flash() +install_system_settings_simple() { # schreibe fstab - echo -e "${ROOTHDD}\t/\text3\tnoatime\t0 0" > ${INSTALLPATH}/etc/fstab || die + if is_uuid_supported + then + echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" > ${INSTALLPATH}/etc/fstab || die + else + echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" > ${INSTALLPATH}/etc/fstab || die + fi 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 } @@ -480,7 +916,7 @@ swapoff ${SWAPHDD} || die } -install_umount_rootfs_flash() +install_umount_rootfs_simple() { cd / umount ${INSTALLPATH} || die @@ -497,7 +933,7 @@ run_install_normal() { - dialog_setup_hdd_found_manuell + dialog_hardware_detection dialog_setup_hdd_partitions_manuell dialog_setup_hdd_format @@ -505,35 +941,59 @@ install_mount_rootfs (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image - dialog_install_bootsector - install_bootsector_chroot - dialog_install_settings sleep 1 install_system_settings - install_mkinitrd_chroot + install_initrd_chroot + + dialog_install_bootsector + install_bootsector_chroot + install_umount_rootfs dialog_install_successful } -run_install_flash() +run_install_simple() { - dialog_setup_hdd_found_manuell + dialog_hardware_detection - dialog_setup_hdd_partitions_manuell_flash + dialog_setup_hdd_partitions_manuell_simple dialog_setup_hdd_format - setup_hdd_format_flash > /dev/null - install_mount_rootfs_flash + setup_hdd_format_simple > /dev/null + install_mount_rootfs_simple (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image + dialog_install_settings + sleep 1 + install_system_settings_simple + install_initrd_chroot + dialog_install_bootsector install_bootsector_chroot + install_umount_rootfs_simple + dialog_install_successful +} + +run_install_auto() +{ + dialog_hardware_detection + + dialog_setup_hdd_partitions_auto + dialog_setup_hdd_format + setup_hdd_format_simple > /dev/null + install_mount_rootfs_simple + (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image + dialog_install_settings sleep 1 - install_system_settings_flash - install_mkinitrd_chroot - install_umount_rootfs_flash + install_system_settings_simple + install_initrd_chroot + + dialog_install_bootsector + install_bootsector_chroot + + install_umount_rootfs_simple dialog_install_successful }