tazlito annotate tazlito-wiz @ rev 262
tazlito-wiz: Small redirection fix
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri Mar 16 12:06:01 2012 +0100 (2012-03-16) |
parents | eccb6026959e |
children | 95ee294e4147 |
rev | line source |
---|---|
pankso@254 | 1 #!/bin/sh |
pankso@254 | 2 # |
pankso@254 | 3 # Live system creation wizard in GTK using Yad. |
pankso@254 | 4 # |
pankso@254 | 5 # Copyright (C) 2012 SliTaz GNU/Linux - GNU gpl v2 |
pankso@254 | 6 # Authors : Christophe Lincoln <pankso@slitaz.org> |
pankso@254 | 7 # |
pankso@254 | 8 |
pankso@254 | 9 width="560" |
pankso@254 | 10 icon="/usr/share/pixmaps/slitaz-icon.png" |
pankso@254 | 11 opts="--height=300 --width=$width --image=$icon |
pankso@254 | 12 --image-on-top --window-icon=$icon --title=LiveWizard" |
pankso@254 | 13 rel=$(cat /etc/slitaz-release) |
pankso@254 | 14 [ "$rel" != "cooking" ] && rel=stable |
pankso@254 | 15 live=/home/slitaz/$rel/live |
pankso@254 | 16 db="/var/lib/tazpkg" |
pankso@254 | 17 list="distro-packages.list" |
pankso@254 | 18 distro="/home/slitaz/$rel/distro" |
pankso@254 | 19 addfiles="$distro/addfiles" |
pankso@254 | 20 |
pankso@254 | 21 # TazLito wizard is only for root. |
pankso@254 | 22 if test $(id -u) != 0 ; then |
pankso@254 | 23 exec tazbox su $0 |
pankso@254 | 24 exit 0 |
pankso@254 | 25 fi |
pankso@254 | 26 |
pankso@254 | 27 # I18n |
pankso@254 | 28 . /usr/bin/gettext.sh |
pankso@254 | 29 TEXTDOMAIN='tazlito-wiz' |
pankso@254 | 30 export TEXTDOMAIN |
pankso@254 | 31 |
pankso@254 | 32 # Sanity check. |
pankso@254 | 33 mkdir -p $live && cd $live |
pankso@254 | 34 #rm -rf * |
pankso@254 | 35 |
pankso@254 | 36 # |
pankso@254 | 37 # Functions |
pankso@254 | 38 # |
pankso@254 | 39 |
pankso@254 | 40 progress() { |
pankso@254 | 41 yad --progress --height="140" --width="$width" \ |
pankso@254 | 42 --image=$icon --image-on-top --window-icon=$icon \ |
pankso@254 | 43 --text="<b>$text</b>" --title="SliTaz Live progress" --auto-close |
pankso@254 | 44 } |
pankso@254 | 45 |
pankso@254 | 46 edit_list() { |
pankso@254 | 47 text=$(gettext "Edit the distro packages list") |
pankso@254 | 48 cat $live/$list | yad --list $opts --text="$text" \ |
pankso@254 | 49 --no-headers --print-all --separator="" \ |
pankso@254 | 50 --editable --column=0:TEXT > $live/list |
pankso@254 | 51 mv -f $live/list $live/$list |
pankso@254 | 52 } |
pankso@254 | 53 |
pankso@254 | 54 # Start page GUI |
pankso@254 | 55 start_main() { |
pankso@254 | 56 text=$(gettext "SliTaz Live system creator wizard") |
pankso@254 | 57 yad --form $opts --text="<b>$text</b>" \ |
pankso@254 | 58 --field="$(gettext "Distro name:")" \ |
pankso@254 | 59 --field="$(gettext "Based on:")":CB \ |
pankso@254 | 60 --button="TazPanel Live:2" \ |
pankso@254 | 61 --button="gtk-cancel:1" \ |
pankso@254 | 62 --button="gtk-ok:0" \ |
pankso@254 | 63 " " "core!gtkonly!justx!base" |
pankso@254 | 64 } |
pankso@254 | 65 |
pankso@254 | 66 # Start page handler |
pankso@254 | 67 start() { |
pankso@254 | 68 # Store box results |
pankso@254 | 69 main=$(start_main) |
pankso@254 | 70 # Deal with --button values |
pankso@254 | 71 case $? in |
pankso@254 | 72 1) exit 0 ;; |
pankso@254 | 73 2) tazweb http://tazpanel:82/live.cgi && exit 0 ;; |
pankso@254 | 74 *) continue ;; |
pankso@254 | 75 esac |
pankso@254 | 76 # Deal with $main values |
pankso@254 | 77 text=$(gettext "Getting flavor file and packages list...") |
pankso@254 | 78 (echo "30" && sleep 1 |
pankso@254 | 79 name=$(echo $main | cut -d "|" -f 1) |
pankso@254 | 80 skel=$(echo $main | cut -d "|" -f 2) |
pankso@254 | 81 echo "$skel" > $live/skel |
pankso@254 | 82 echo "60" |
pankso@254 | 83 [ "$name" ] || name="custom" |
pankso@254 | 84 tazlito get-flavor $skel |
pankso@254 | 85 echo "90" && sleep 1 |
pankso@254 | 86 sed -i s"/^ISO_NAME=.*/ISO_NAME=\"$name\"/" tazlito.conf |
pankso@254 | 87 sed -i s"/^VOLUM_NAME=.*/VOLUM_NAME=\"SliTaz $name\"/" \ |
pankso@254 | 88 tazlito.conf) | progress |
pankso@254 | 89 } |
pankso@254 | 90 |
pankso@254 | 91 # Packages page GUI |
pankso@254 | 92 pkgs_main() { |
pankso@254 | 93 pkgs=$(cat $list | wc -l) |
pankso@254 | 94 skel=$(cat $live/skel) |
paul@261 | 95 text=$(eval_gettext "Packages - The \$skel has \$pkgs packages") |
pankso@254 | 96 yad --form $opts --text="<b>$text</b>" --separator=" " \ |
paul@261 | 97 --field="$(gettext "Additional packages separated by space or by line:")":TXT \ |
pankso@254 | 98 --button="$(gettext "Edit packages list"):2" \ |
pankso@254 | 99 --button="gtk-cancel:1" --button="gtk-ok:0" |
pankso@254 | 100 } |
pankso@254 | 101 |
pankso@254 | 102 # Packages page handler |
pankso@254 | 103 pkgs() { |
pankso@254 | 104 # Store box results |
pankso@254 | 105 main=$(pkgs_main) |
pankso@254 | 106 # Deal with --button values |
pankso@254 | 107 case $? in |
pankso@254 | 108 1) exit 0 ;; |
pankso@254 | 109 2) edit_list ;; |
pankso@254 | 110 *) continue ;; |
pankso@254 | 111 esac |
pankso@254 | 112 # Deal with $main values |
pankso@254 | 113 for pkg in $(echo $main | sed s'/\\n//'g) |
pankso@254 | 114 do |
pankso@254 | 115 vers=$(fgrep "$pkg |" $db/packages.desc | awk '{print $3}') |
pankso@254 | 116 if ! grep "^${pkg}$" $list; then |
pankso@254 | 117 echo "$pkg-$vers" >> $list |
pankso@254 | 118 fi |
pankso@254 | 119 done |
pankso@254 | 120 } |
pankso@254 | 121 |
pankso@254 | 122 # Wallpaper page GUI |
pankso@254 | 123 wallpaper_main() { |
pankso@254 | 124 text=$(gettext "SliTaz desktop wallpaper") |
pankso@254 | 125 yad --form $opts --text="<b>$text</b>" --separator="" \ |
pankso@254 | 126 --field="$(gettext "Wallpaper JPG image:")":FL |
pankso@254 | 127 } |
pankso@254 | 128 |
pankso@254 | 129 # Wallpaper page handler |
pankso@254 | 130 wallpaper() { |
pankso@254 | 131 # Store box results |
pankso@254 | 132 main=$(wallpaper_main) |
pankso@254 | 133 # Deal with --button values |
pankso@254 | 134 case $? in |
pankso@254 | 135 1) exit 0 ;; |
pankso@254 | 136 *) continue ;; |
pankso@254 | 137 esac |
pankso@254 | 138 if echo "$main" | fgrep -q .jpg; then |
pankso@254 | 139 mkdir -p $addfiles/rootfs/usr/share/images |
pankso@254 | 140 cp -f $main $addfiles/rootfs/usr/share/images |
pankso@254 | 141 fi |
pankso@254 | 142 } |
pankso@254 | 143 |
pankso@254 | 144 # Last page GUI |
pankso@254 | 145 gen_distro_main() { |
pankso@254 | 146 info=$(gettext " |
pankso@254 | 147 Now it's time to generate the distro. Last chance to start over or stop. \ |
paul@261 | 148 Creating a Live system uses quite a lot of resources and takes some time. |
paul@261 | 149 Note you can still add some files to the SliTaz root filesystem or on the \ |
pankso@254 | 150 cdrom.") |
pankso@254 | 151 text=$(gettext "<b>Generate the distribution</b>") |
pankso@254 | 152 echo "$info" | yad --text-info $opts --text="$text" \ |
pankso@254 | 153 --wrap --margins=20 |
pankso@254 | 154 } |
pankso@254 | 155 |
pankso@254 | 156 # Last page handler |
pankso@254 | 157 gen_distro() { |
pankso@254 | 158 # Store box results |
pankso@254 | 159 main=$(gen_distro_main) |
pankso@254 | 160 # Deal with --button values |
pankso@254 | 161 case $? in |
pankso@254 | 162 1) exit 0 ;; |
pankso@262 | 163 *) echo -e "\n" | tazlito gen-distro 2>&1 | yad \ |
pankso@254 | 164 --text-info $opts --tail \ |
pankso@254 | 165 --text="<b>$(gettext "Building the Live system...")</b>" ;; |
pankso@254 | 166 esac |
pankso@254 | 167 } |
pankso@254 | 168 |
pankso@254 | 169 # Summary |
pankso@254 | 170 summary() { |
pankso@254 | 171 . tazlito.conf |
pankso@254 | 172 iso_size=$(du -sh $distro/$ISO_NAME.iso | awk '{print $1}') |
pankso@254 | 173 distro_size=$(du -sh $distro/rootfs | awk '{print $1}') |
pankso@254 | 174 text="$(gettext "Live system summary")" |
pankso@254 | 175 echo -e "\ |
pankso@254 | 176 $(gettext "Generated ISO ") \n$distro/$ISO_NAME.iso |
pankso@254 | 177 $(gettext "Image size") \n$iso_size |
pankso@254 | 178 $(gettext "Uncompressed size") \n$distro_size" | \ |
pankso@254 | 179 yad --list $opts --text="<b>$text</b>" \ |
pankso@254 | 180 --column="Information":0 --column="Value":1 \ |
pankso@254 | 181 --button="gtk-close":0 |
pankso@254 | 182 } |
pankso@254 | 183 |
pankso@254 | 184 # |
pankso@254 | 185 # Script commands |
pankso@254 | 186 # |
pankso@254 | 187 |
pankso@254 | 188 case "$1" in |
pankso@254 | 189 usage) |
pankso@254 | 190 echo "Usage: $(basename $0) [command]" ;; |
pankso@254 | 191 *) |
pankso@254 | 192 start |
pankso@254 | 193 pkgs |
pankso@254 | 194 wallpaper |
pankso@254 | 195 gen_distro |
pankso@254 | 196 summary ;; |
pankso@254 | 197 esac |
pankso@254 | 198 |
pankso@254 | 199 exit 0 |
pankso@254 | 200 |