slitaz-arm rev 195

piboot: add savedefault
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Nov 16 10:42:30 2014 +0100 (2014-11-16)
parents 99ef615a944a
children 2fe7d33c6d4c
files rpi/piboot
line diff
     1.1 --- a/rpi/piboot	Sun Nov 16 00:36:16 2014 +0100
     1.2 +++ b/rpi/piboot	Sun Nov 16 10:42:30 2014 +0100
     1.3 @@ -52,13 +52,16 @@
     1.4  	eval KERNEL="\$KERNEL_$1"
     1.5  	eval INITRD="\$INITRD_$1"
     1.6  	eval CMDLINE="\$CMDLINE_$1"
     1.7 +	extra="--extra-button --extra-label ${msgsave:-Save}"
     1.8 +	[ "$READONLY" ] && extra=''
     1.9  
    1.10  	exec 3>&1
    1.11  	value=$($DIALOG  --clear \
    1.12  		--title "${edittitle:-Edit menu}" \
    1.13 -		--ok-label "Edit" \
    1.14 -		--cancel-label "Done" \
    1.15 +		--ok-label "${msgedit:-Edit}" \
    1.16 +		--cancel-label "${msgdone:-Done}" \
    1.17  		--menu "" 20 72 14 \
    1.18 +		$extra \
    1.19  		Kernel "$KERNEL" \
    1.20  		Initramfs "$INITRD" \
    1.21  		Cmdline "$CMDLINE" 2>&1 1>&3 )
    1.22 @@ -67,18 +70,26 @@
    1.23  	
    1.24  	case $retval in
    1.25  	1|255) return ;;
    1.26 +	3)	cp $mnt/$KEYWORD/config.txt /tmp/config.txt
    1.27 +		sed -i '/^kernel/d;/^initrd/d;/^cmdline/d' /tmp/config.txt
    1.28 +		echo "kernel=$KERNEL" >> /tmp/config.txt
    1.29 +		[ "$INITRD" ] && echo "initrd $INITRD" >> /tmp/config.txt
    1.30 +		[ "$CMDLINE" ] && echo "cmdline=$CMDLINE" >> /tmp/config.txt
    1.31 +		mount -o remount,rw $mnt
    1.32 +		cp /tmp/config.txt $mnt/$KEYWORD/config.txt
    1.33 +		mount -o remount,ro $mnt ;;
    1.34  	esac
    1.35  
    1.36  	exec 3>&1
    1.37  	case $value in
    1.38  	Kernel)
    1.39 -		data=$($DIALOG  --clear --title "Select the kernel" \
    1.40 +		data=$($DIALOG  --clear --title "${msgselectkernel:-Select the kernel}" \
    1.41  			 --fselect "$mnt/$KEYWORD/$KERNEL" 10 72 2>&1 1>&3) ;;
    1.42  	Initramfs)
    1.43 -		data=$($DIALOG  --clear --title "Select the initramfs" \
    1.44 +		data=$($DIALOG  --clear --title "${msgselectinitrd:-Select the initramfs}" \
    1.45  			 --fselect "$mnt/$KEYWORD/$INITRD" 10 72 2>&1 1>&3) ;;
    1.46  	Cmdline)
    1.47 -		data=$($DIALOG  --clear --title "Edit $value" \
    1.48 +		data=$($DIALOG  --clear --title "${msgeditcmdline:-Edit cmdline}" \
    1.49  			 --inputbox "Cmdline" 20 72 2>&1 "$CMDLINE" 1>&3) ;;
    1.50  	esac
    1.51  	retval=$?
    1.52 @@ -174,11 +185,28 @@
    1.53  editbutton='--extra-button --extra-label "Edit"'
    1.54  grep -qs ^noedit i$mnt/menu.txt && editbutton=
    1.55  
    1.56 +READONLY=
    1.57 +grep -qs ^readonly i$mnt/menu.txt && READONLY=ON
    1.58 +
    1.59 +USING_WEBBOOT=
    1.60 +grep -qs ^nowebboot i$mnt/menu.txt && USING_WEBBOOT=1
    1.61 +
    1.62  kmap=$(get kmap $mnt/menu.txt)
    1.63  [ "$kmap" ] && ! loadkeys $kmap && loadkmap < /usr/share/kmap/$kmap.kmap
    1.64  
    1.65  edittitle=$(get edittitle $mnt/menu.txt)
    1.66  
    1.67 +# Get locale
    1.68 +
    1.69 +msgsave=$(get msgsave $mnt/menu.txt)
    1.70 +msgedit=$(get msgedit $mnt/menu.txt)
    1.71 +msgdone=$(get msgdone $mnt/menu.txt)
    1.72 +msgboot=$(get msgboot $mnt/menu.txt)
    1.73 +msghalt=$(get msghalt $mnt/menu.txt)
    1.74 +msgselectkernel=$(get msgselectkernel $mnt/menu.txt)
    1.75 +msgselectinitrd=$(get msgselectinitrd $mnt/menu.txt)
    1.76 +msgeditcmdline=$(get msgeditcmdline $mnt/menu.txt)
    1.77 +msgkexec=$(get msgkexec $mnt/menu.txt)
    1.78  
    1.79  # Get OS variables
    1.80  
    1.81 @@ -189,6 +217,7 @@
    1.82  	eval KERNEL_$n="\$(get kernel \$i/config.txt)"
    1.83  	eval INITRD_$n="\$(get initramfs \$i/config.txt)"
    1.84  	eval CMDLINE_$n="\$(cat \$i/cmdline.txt)"
    1.85 +	eval SAVEDEFAULT_$n="\$(get savedefault \$i/config.txt)"
    1.86  	eval KEYWORD_$n="\$(basename \$i)"
    1.87  	eval ENTRY_$n="\$(get entry \$i/menu.txt)"
    1.88  done
    1.89 @@ -203,12 +232,12 @@
    1.90  	$DIALOG  --clear \
    1.91  		--title "${title:-Boot menu}" \
    1.92  		$editbutton \
    1.93 -		--ok-label "Boot" \
    1.94 -		--cancel-label "Halt" \
    1.95 +		--ok-label "${msgboot:-Boot}" \
    1.96 +		--cancel-label "${msghalt:-Halt}" \
    1.97  		--timeout $timeout \
    1.98  		--menu "${subtitle:-Default boot in $timeout seconds}" 20 72 14 \
    1.99  		$(list_entry) $(web_boot_entry) \
   1.100 -		Continue "Execute SliTaz boot sequence"
   1.101 +		Continue "${msgkexec:-Execute SliTaz boot sequence}"
   1.102  EOT
   1.103  )
   1.104  	retval=$?
   1.105 @@ -256,6 +285,7 @@
   1.106  	eval KERNEL="\$KERNEL_$n"
   1.107  	eval INITRD="\$INITRD_$n"
   1.108  	eval CMDLINE="\$CMDLINE_$n"
   1.109 +	eval SAVEDEFAULT="\$SAVEDEFAULT_$n"
   1.110  
   1.111  	if [ "$webprefix" ]; then
   1.112  		cd /root
   1.113 @@ -280,6 +310,14 @@
   1.114  		done
   1.115  		cd /root
   1.116  	fi
   1.117 +	if [ -z "$READONLY" ] && [ "$SAVEDEFAULT" ] &&
   1.118 +	   [ -s $mnt/$SAVEDEFAULT/config.txt ]; then
   1.119 +	   	cp $mnt/menu.txt /tmp
   1.120 +		sed -i '/^default/d' /tmp/menu.txt
   1.121 +		echo "default=$SAVEDEFAULT" >> /tmp/menu.txt
   1.122 +		mount -o remount,rw $mnt
   1.123 +		cp /tmp/menu.txt $mnt/menu.txt
   1.124 +	fi
   1.125  	[ "$INITRD" ] && INITRD="--initrd rootfs.gz"
   1.126  	[ "$CMDLINE" ] && CMDLINE="--command-line \"$CMDLINE\""
   1.127