source: projects/specs/trunk/m/mkinitrd/mkinitrd-6.0.93-tuxonice.patch @ 806

Revision 806, 9.5 KB checked in by daisuke, 14 years ago (diff)

mkinitrd: remove bash4ism (patch21), add vine patches to repo

  • mkinitrd-6.0.93/mkinitrd

    diff -up mkinitrd-6.0.93/mkinitrd.tuxonice mkinitrd-6.0.93/mkinitrd
    old new LD_SO_CONF=/etc/ld.so.conf 
    7474LD_SO_CONF_D=/etc/ld.so.conf.d/ 
    7575 
    7676[ -e /etc/sysconfig/mkinitrd ] && . /etc/sysconfig/mkinitrd 
     77[ -e /etc/sysconfig/mkinitrd-suspend2 ] && . /etc/sysconfig/mkinitrd-suspend2 
     78[ -e /etc/sysconfig/mkinitrd-tuxonice ] && . /etc/sysconfig/mkinitrd-tuxonice 
    7779 
    7880CONFMODS="$MODULES" 
    7981MODULES="" 
    modulefile=/etc/modules.conf 
    9193rc=0 
    9294nolvm="" 
    9395nodmraid="" 
    94  
     96tuxoniceuserui="none" 
     97tuxoniceversion="30001" 
     98tuxonicefwtarget="" 
     99splashtheme="suspend2" 
     100 
     101DSDT="/boot/DSDT.aml" 
     102SWSUSPPROC="/proc/suspend2" 
     103USERUIPROC="userui_program" 
     104FWLOCPROC="filewriter_target" 
     105RESUMETAR="resume2" 
     106FWIDENT="Suspend2" 
     107UIPREFIX="suspend2" 
    95108IMAGESIZE=8000 
    96109PRESCSIMODS="" 
    97110fstab="/etc/fstab" 
    usage () { 
    111124    $cmd "       [--image-version] [--force-raid-probe | --omit-raid-modules]" 
    112125    $cmd "       [--with=<module>] [--force-lvm-probe | --omit-lvm-modules]" 
    113126    $cmd "       [--builtin=<module>] [--omit-dmraid] [--net-dev=<interface>]" 
     127    $cmd "       [--tuxonice-userui=<none | auto | text | fb>]" 
     128    $cmd "       [--tuxonice-version=<version-string>] [--splash=<theme>]" 
     129    $cmd "       [--dsdt-location=<location of DSDT-file>]" 
    114130    $cmd "       [--fstab=<fstab>] [--nocompress] <initrd-image> <kernel-version>" 
    115131    $cmd "" 
    116132    $cmd "       (ex: `basename $0` /boot/initrd-2.2.5-15.img 2.2.5-15)" 
    handlegraphics() { 
    745761    qpopd 
    746762} 
    747763 
     764IsANumber() { 
     765    case "$1" in *[!0-9]*|"") return 1 ;; esac 
     766    return 0 
     767} 
     768 
     769check_filewriter() { 
     770    # Filewriterhandling for Software Suspend 2 
     771    # we will check for /etc/hibernate/hibernate.conf and the filewriter 
     772    # settings there 
     773    local resume2 fwlocopt fwloc fwsize oldtarget newresume2 
     774 
     775    if [ -e $1/$RESUMETAR ]; then 
     776      resume2=$(cat $1/$RESUMETAR) 
     777      # if filewriter is already active use that information 
     778      if [ $(echo "$resume2"X | dd bs=5 count=1 2>/dev/null) = "file:" ]; then tuxonicefwtarget=$resume2; return; fi 
     779    else 
     780      # if resume2 does not exist the current kernel is not Suspend 2 enabled, 
     781      # so there is no way to determine filewriters target information anyway 
     782      return 
     783    fi 
     784 
     785    if [ ! -e $1/$2 ]; then return; fi 
     786    if [ -e /etc/hibernate/tuxonice.conf ]; then 
     787        fwlocopt=$(egrep ^FilewriterLocation /etc/hibernate/tuxonice.conf|tail -n 1) 
     788    elif [ -e /etc/hibernate/suspend2.conf ]; then 
     789        fwlocopt=$(egrep ^FilewriterLocation /etc/hibernate/suspend2.conf|tail -n 1) 
     790    elif [ ! -e /etc/hibernate/hibernate.conf ]; then 
     791         return; 
     792    else 
     793        fwlocopt=$(egrep ^FilewriterLocation /etc/hibernate/hibernate.conf|tail -n 1) 
     794    fi 
     795 
     796    if [ ! "$fwlocopt" ]; then return; fi 
     797    fwloc=$(echo $fwlocopt | awk '{ print $2 }') 
     798    fwsize=$(echo $fwlocopt | awk '{ print $3 }') 
     799 
     800    if [ ! -e "$fwloc" ]; then 
     801      if ! IsANumber "$fwsize"; then return; fi 
     802      { 
     803        echo "$FWIDENT" 
     804        dd if=/dev/zero bs=1M count=$fwsize 2>/dev/null 
     805 
     806      } > "$fwloc" 
     807    fi 
     808       
     809    oldtarget=$(cat $1/$2) 
     810    sync 
     811    echo "$fwloc" > $1/$2 
     812    newresume2=$(cat $1/$RESUMETAR) 
     813    echo "$oldtarget" > $1/$2 
     814    echo "$resume2" > $1/$RESUMETAR 
     815     
     816    if [ $(echo $newresume2 | dd bs=5 count=1 2>/dev/null) = "file:" ]; then tuxonicefwtarget=$newresume2; fi 
     817} 
     818 
     819inst_tuxonice() { 
     820    # TuxOnIce stuff 
     821    emit "echo Activating tux on ice" 
     822    userui="$tuxoniceuserui"; 
     823    if [ "x$tuxoniceuserui" == "xauto" ]; then 
     824        if [ -f /sbin/${UIPREFIX}ui_fbsplash ]; then 
     825            userui="fb"; 
     826        elif [ -f /sbin/${UIPREFIX}ui_text ]; then 
     827            userui="text"; 
     828        else 
     829            userui="none"; 
     830        fi 
     831    fi 
     832    if [ "x$userui" != "xnone" ]; then 
     833        if [ "x$userui" == "xfb" ]; then 
     834            if [ -f /sbin/${UIPREFIX}ui_fbsplash ]; then 
     835                inst /sbin/${UIPREFIX}ui_fbsplash "$2" /bin/${UIPREFIX}ui_fbsplash 
     836                if [ -e /etc/splash/${splashtheme} ]; then 
     837                  mkdir "$2/etc/splash" 
     838                  cp -prH /etc/splash/${splashtheme}/ "$2/etc/splash/" 
     839                fi 
     840                # check if splashtheme is a symlink and add one to initrd if that is the case 
     841                if [ -L /etc/splash/${splashtheme} ]; then 
     842                  dlink=` find /etc/splash/${splashtheme} -printf '%l' ` 
     843                  dlink=$(basename $dlink) 
     844                  ln -sf ${splashtheme} "$2/etc/splash/$dlink" 
     845                fi 
     846                if [ -e $2/etc/splash/{$splashtheme} ]; then 
     847                  if [ ! -e $2/etc/splash/TuxOnIce ]; then 
     848                    ln -sf ${splashtheme} "$2/etc/splash/TuxOnIce" 
     849                  fi 
     850                  if [ ! -e $2/etc/splash/suspend2 ]; then 
     851                    ln -sf ${splashtheme} "$2/etc/splash/suspend2" 
     852                  fi 
     853                fi 
     854                if [ -f /sbin/splash_helper ]; then 
     855                  inst /sbin/splash_helper "$2" /bin/splash_helper 
     856                fi 
     857                emit "echo /bin/${UIPREFIX}ui_fbsplash > $1/$4" 
     858            else 
     859                error "WARNING: framebuffer UI for suspend not found, skipping." 
     860            fi 
     861        elif [ "x$userui" == "xtext" ]; then 
     862            if [ -f /sbin/${UIPREFIX}ui_text ]; then 
     863                inst /sbin/${UIPREFIX}ui_text "$2" /bin/${UIPREFIX}ui_text 
     864                emit "echo /bin/${UIPREFIX}ui_text > $1/$4" 
     865            else 
     866                error "WARNING: text UI for suspend not found, skipping." 
     867            fi 
     868        else 
     869            error "WARNING: unknown UI \"$userui\" specified." 
     870        fi 
     871    fi 
     872 
     873    # First try to resume with the parameter present on the kernel commandline 
     874    emit "echo Trying to resume from target specified as $RESUMETAR on cmdline." 
     875    emit "echo 1 > $1/do_resume" 
     876 
     877    # Then we will try the swapdevice/filetarget that was present while creating the initrd 
     878    emit "echo Trying to resume from $3." 
     879    emit "echo $3 > $1/$RESUMETAR" 
     880    emit "echo 1 > $1/do_resume" 
     881} 
     882 
    748883savedargs=$* 
    749884while [ $# -gt 0 ]; do 
    750885    case $1 in 
    while [ $# -gt 0 ]; do 
    9451080                shift 
    9461081            fi 
    9471082            ;; 
     1083        --splash*) 
     1084            if echo $1 | grep -q '=' ; then 
     1085                splashtheme=`echo $1 | sed 's/^--splash=//'` 
     1086            else 
     1087                splashtheme=$2 
     1088                shift 
     1089            fi 
     1090            ;; 
     1091        --tuxonice-userui*) 
     1092            if echo $1 | grep -q '=' ; then 
     1093                tuxoniceuserui=`echo $1 | sed 's/^--tuxonice-userui=//'` 
     1094            else 
     1095                tuxoniceuserui=$2 
     1096                shift 
     1097            fi 
     1098            ;; 
     1099        --tuxonice-version*) 
     1100            if echo $1 | grep -q '=' ; then 
     1101                tuxoniceversion=`echo $1 | sed 's/^--tuxonice-version=//'` 
     1102            else 
     1103                tuxoniceversion=$2 
     1104                shift 
     1105            fi 
     1106            ;; 
     1107        --suspend2-userui*) 
     1108            if echo $1 | grep -q '=' ; then 
     1109                tuxoniceuserui=`echo $1 | sed 's/^--suspend2-userui=//'` 
     1110            else 
     1111                tuxoniceuserui=$2 
     1112                shift 
     1113            fi 
     1114            ;; 
     1115        --suspend2-version*) 
     1116            if echo $1 | grep -q '=' ; then 
     1117                tuxoniceversion=`echo $1 | sed 's/^--suspend2-version=//'` 
     1118            else 
     1119                tuxoniceversion=$2 
     1120                shift 
     1121            fi 
     1122            ;; 
     1123        --dsdt-location*) 
     1124            if echo $1 | grep -q '=' ; then 
     1125                DSDT=`echo $1 | sed 's/^--dsdt-location=//'` 
     1126            else 
     1127                DSDT=$2 
     1128                shift 
     1129            fi 
     1130            ;; 
    9481131        --help) 
    9491132            usage -n 
    9501133            ;; 
    while [ $# -gt 0 ]; do 
    9621145    shift 
    9631146done 
    9641147 
     1148if [ "$tuxoniceversion" -lt "20108" ]; then 
     1149    SWSUSPPROC="/proc/software_suspend" 
     1150elif [ "$tuxoniceversion" -ge "20208" ]; then 
     1151    SWSUSPPROC="/sys/power/suspend2" 
     1152    USERUIPROC="user_interface/program" 
     1153    FWLOCPROC="filewriter/target" 
     1154fi 
     1155if [ "$tuxoniceversion" -ge "20211" ]; then 
     1156    RESUMETAR="resume" 
     1157fi 
     1158if [ "$tuxoniceversion" -ge "20212" ]; then 
     1159    SWSUSPPROC="/sys/power/tuxonice" 
     1160    FWIDENT="TuxOnIce" 
     1161    UIPREFIX="tuxonice" 
     1162fi 
     1163 
    9651164if [ -z "$target" -o -z "$kernel" ]; then 
    9661165    usage 
    9671166fi 
    fi 
    11861385mkdir -p $MNTIMAGE 
    11871386mkdir -p $MNTIMAGE/lib/firmware 
    11881387mkdir -p $MNTIMAGE/lib/modules/$kernel 
     1388mkdir -p $MNTIMAGE/lib/splash 
    11891389mkdir -p $MNTIMAGE/bin 
    11901390mkdir -p $MNTIMAGE/etc 
    11911391mkdir -p $MNTIMAGE/dev 
    excludemods() { 
    12201420    echo $output 
    12211421} 
    12221422 
     1423if [ -e "$DSDT" ]; then 
     1424    inst "$DSDT" "$MNTIMAGE/DSDT.aml" 
     1425fi 
     1426 
    12231427if [ -n "$excludemodules" ]; then 
    12241428    MODULES=$(excludemods $MODULES) 
    12251429    availmodules=$(excludemods $availmodules) 
    done 
    12531457mknod $MNTIMAGE/dev/tty c 5 0 
    12541458mknod $MNTIMAGE/dev/console c 5 1 
    12551459mknod $MNTIMAGE/dev/ptmx c 5 2 
     1460mknod $MNTIMAGE/dev/fb0 c 29 0 
    12561461 
    12571462if [ -n "$raiddevices" ]; then 
    12581463    inst /sbin/mdadm "$MNTIMAGE" 
    mknod /dev/console c 5 1 
    14961701mknod /dev/ptmx c 5 2 
    14971702mknod /dev/fb c 29 0 
    14981703mknod /dev/hvc0 c 229 0 
     1704mknod /dev/fb0 c 29 0 
    14991705EOF 
    15001706 
    15011707# XXX really we need to openvt too, in case someting changes the 
    for cryptdev in ${!cryptolv@} ; do 
    16281834    emitcrypto `eval echo '$'$cryptdev` 
    16291835done 
    16301836 
    1631 if [ -z "$noresume" -a -n "$thawdev" ]; then 
    1632     emit "resume $thawdev" 
     1837if [ -z "$noresume" ]; then 
     1838    if [ -n "$thawdev" ]; then 
     1839        emit "resume $thawdev" 
     1840    fi 
     1841    check_filewriter $SWSUSPPROC $FWLOCPROC 
     1842    swsuspdev="$thawdev" 
     1843    if [ -n "$tuxonicefwtarget" ]; then 
     1844        inst_tuxonice $SWSUSPPROC $MNTIMAGE $tuxonicefwtarget $USERUIPROC 
     1845    elif [ -n "$swsuspdev" ]; then 
     1846        if [[ "$swsuspdev" =~ ^(UUID=|LABEL=) ]]; then 
     1847            swsuspdev=$(resolve_device_name "$swsuspdev") 
     1848        fi 
     1849 
     1850        inst_tuxonice $SWSUSPPROC $MNTIMAGE swap:$swsuspdev $USERUIPROC 
     1851    fi 
    16331852fi 
    16341853 
    16351854if [ -n "$loopfs" ]; then 
Note: See TracBrowser for help on using the repository browser.