tazlito rev 254
Add tazlito-wiz - New GUI to create Live systems
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Wed Mar 14 00:12:03 2012 +0100 (2012-03-14) |
parents | 24b1f91ec9b2 |
children | e7ccdc5d2647 |
files | tazlito-wiz |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tazlito-wiz Wed Mar 14 00:12:03 2012 +0100 1.3 @@ -0,0 +1,201 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# Live system creation wizard in GTK using Yad. 1.7 +# 1.8 +# Copyright (C) 2012 SliTaz GNU/Linux - GNU gpl v2 1.9 +# 1.10 +# Authors : Christophe Lincoln <pankso@slitaz.org> 1.11 +# 1.12 + 1.13 +width="560" 1.14 +icon="/usr/share/pixmaps/slitaz-icon.png" 1.15 +opts="--height=300 --width=$width --image=$icon 1.16 +--image-on-top --window-icon=$icon --title=LiveWizard" 1.17 +rel=$(cat /etc/slitaz-release) 1.18 +[ "$rel" != "cooking" ] && rel=stable 1.19 +live=/home/slitaz/$rel/live 1.20 +db="/var/lib/tazpkg" 1.21 +list="distro-packages.list" 1.22 +distro="/home/slitaz/$rel/distro" 1.23 +addfiles="$distro/addfiles" 1.24 + 1.25 +# TazLito wizard is only for root. 1.26 +if test $(id -u) != 0 ; then 1.27 + exec tazbox su $0 1.28 + exit 0 1.29 +fi 1.30 + 1.31 +# I18n 1.32 +. /usr/bin/gettext.sh 1.33 +TEXTDOMAIN='tazlito-wiz' 1.34 +export TEXTDOMAIN 1.35 + 1.36 +# Sanity check. 1.37 +mkdir -p $live && cd $live 1.38 +#rm -rf * 1.39 + 1.40 +# 1.41 +# Functions 1.42 +# 1.43 + 1.44 +progress() { 1.45 + yad --progress --height="140" --width="$width" \ 1.46 + --image=$icon --image-on-top --window-icon=$icon \ 1.47 + --text="<b>$text</b>" --title="SliTaz Live progress" --auto-close 1.48 +} 1.49 + 1.50 +edit_list() { 1.51 + text=$(gettext "Edit the distro packages list") 1.52 + cat $live/$list | yad --list $opts --text="$text" \ 1.53 + --no-headers --print-all --separator="" \ 1.54 + --editable --column=0:TEXT > $live/list 1.55 + mv -f $live/list $live/$list 1.56 +} 1.57 + 1.58 +# Start page GUI 1.59 +start_main() { 1.60 + text=$(gettext "SliTaz Live system creator wizard") 1.61 + yad --form $opts --text="<b>$text</b>" \ 1.62 + --field="$(gettext "Distro name:")" \ 1.63 + --field="$(gettext "Based on:")":CB \ 1.64 + --button="TazPanel Live:2" \ 1.65 + --button="gtk-cancel:1" \ 1.66 + --button="gtk-ok:0" \ 1.67 + " " "core!gtkonly!justx!base" 1.68 +} 1.69 + 1.70 +# Start page handler 1.71 +start() { 1.72 + # Store box results 1.73 + main=$(start_main) 1.74 + # Deal with --button values 1.75 + case $? in 1.76 + 1) exit 0 ;; 1.77 + 2) tazweb http://tazpanel:82/live.cgi && exit 0 ;; 1.78 + *) continue ;; 1.79 + esac 1.80 + # Deal with $main values 1.81 + text=$(gettext "Getting flavor file and packages list...") 1.82 + (echo "30" && sleep 1 1.83 + name=$(echo $main | cut -d "|" -f 1) 1.84 + skel=$(echo $main | cut -d "|" -f 2) 1.85 + echo "$skel" > $live/skel 1.86 + echo "60" 1.87 + [ "$name" ] || name="custom" 1.88 + tazlito get-flavor $skel 1.89 + echo "90" && sleep 1 1.90 + sed -i s"/^ISO_NAME=.*/ISO_NAME=\"$name\"/" tazlito.conf 1.91 + sed -i s"/^VOLUM_NAME=.*/VOLUM_NAME=\"SliTaz $name\"/" \ 1.92 + tazlito.conf) | progress 1.93 +} 1.94 + 1.95 +# Packages page GUI 1.96 +pkgs_main() { 1.97 + pkgs=$(cat $list | wc -l) 1.98 + skel=$(cat $live/skel) 1.99 + text=$(eval_gettext "Packages - The \$skel have \$pkgs packages") 1.100 + yad --form $opts --text="<b>$text</b>" --separator=" " \ 1.101 + --field="$(gettext "Additionnal packages separate by space or one by line:")":TXT \ 1.102 + --button="$(gettext "Edit packages list"):2" \ 1.103 + --button="gtk-cancel:1" --button="gtk-ok:0" 1.104 +} 1.105 + 1.106 +# Packages page handler 1.107 +pkgs() { 1.108 + # Store box results 1.109 + main=$(pkgs_main) 1.110 + # Deal with --button values 1.111 + case $? in 1.112 + 1) exit 0 ;; 1.113 + 2) edit_list ;; 1.114 + *) continue ;; 1.115 + esac 1.116 + # Deal with $main values 1.117 + for pkg in $(echo $main | sed s'/\\n//'g) 1.118 + do 1.119 + vers=$(fgrep "$pkg |" $db/packages.desc | awk '{print $3}') 1.120 + if ! grep "^${pkg}$" $list; then 1.121 + echo "$pkg-$vers" >> $list 1.122 + fi 1.123 + done 1.124 +} 1.125 + 1.126 +# Wallpaper page GUI 1.127 +wallpaper_main() { 1.128 + text=$(gettext "SliTaz desktop wallpaper") 1.129 + yad --form $opts --text="<b>$text</b>" --separator="" \ 1.130 + --field="$(gettext "Wallpaper JPG image:")":FL 1.131 +} 1.132 + 1.133 +# Wallpaper page handler 1.134 +wallpaper() { 1.135 + # Store box results 1.136 + main=$(wallpaper_main) 1.137 + # Deal with --button values 1.138 + case $? in 1.139 + 1) exit 0 ;; 1.140 + *) continue ;; 1.141 + esac 1.142 + if echo "$main" | fgrep -q .jpg; then 1.143 + mkdir -p $addfiles/rootfs/usr/share/images 1.144 + cp -f $main $addfiles/rootfs/usr/share/images 1.145 + fi 1.146 +} 1.147 + 1.148 +# Last page GUI 1.149 +gen_distro_main() { 1.150 + info=$(gettext " 1.151 +Now it's time to generate the distro. Last chance to start over or stop. \ 1.152 +Creating a Live system use quiet a lot of resources and take some time.\n\n 1.153 +Note you can still add some file to the SliTaz root filesystem or on the \ 1.154 +cdrom.") 1.155 + text=$(gettext "<b>Generate the distribution</b>") 1.156 + echo "$info" | yad --text-info $opts --text="$text" \ 1.157 + --wrap --margins=20 1.158 +} 1.159 + 1.160 +# Last page handler 1.161 +gen_distro() { 1.162 + # Store box results 1.163 + main=$(gen_distro_main) 1.164 + # Deal with --button values 1.165 + case $? in 1.166 + 1) exit 0 ;; 1.167 + *) echo -e "\n" | tazlito gen-distro 2>1 | yad \ 1.168 + --text-info $opts --tail \ 1.169 + --text="<b>$(gettext "Building the Live system...")</b>" ;; 1.170 + esac 1.171 +} 1.172 + 1.173 +# Summary 1.174 +summary() { 1.175 + . tazlito.conf 1.176 + iso_size=$(du -sh $distro/$ISO_NAME.iso | awk '{print $1}') 1.177 + distro_size=$(du -sh $distro/rootfs | awk '{print $1}') 1.178 + text="$(gettext "Live system summary")" 1.179 + echo -e "\ 1.180 +$(gettext "Generated ISO ") \n$distro/$ISO_NAME.iso 1.181 +$(gettext "Image size") \n$iso_size 1.182 +$(gettext "Uncompressed size") \n$distro_size" | \ 1.183 + yad --list $opts --text="<b>$text</b>" \ 1.184 + --column="Information":0 --column="Value":1 \ 1.185 + --button="gtk-close":0 1.186 +} 1.187 + 1.188 +# 1.189 +# Script commands 1.190 +# 1.191 + 1.192 +case "$1" in 1.193 + usage) 1.194 + echo "Usage: $(basename $0) [command]" ;; 1.195 + *) 1.196 + start 1.197 + pkgs 1.198 + wallpaper 1.199 + gen_distro 1.200 + summary ;; 1.201 +esac 1.202 + 1.203 +exit 0 1.204 +