tazlito rev 12
pave the road to flavors. Download packages support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Dec 11 19:15:58 2007 +0100 (2007-12-11) |
parents | 6310380198f9 |
children | 685b1188fff4 |
files | tazlito |
line diff
1.1 --- a/tazlito Tue Dec 11 19:14:12 2007 +0100 1.2 +++ b/tazlito Tue Dec 11 19:15:58 2007 +0100 1.3 @@ -22,6 +22,8 @@ 1.4 LZMA_INITRAMFS=rootfs.lz 1.5 LOCALSTATE=/var/lib/tazpkg 1.6 INSTALLED=$LOCALSTATE/installed 1.7 +CACHE_DIR=/var/cache/tazpkg 1.8 +MIRROR=$LOCALSTATE/mirror 1.9 1.10 # Try to include config file, continue if command is gen-config or exit. 1.11 # The main config used by default is in /etc/tazlito. 1.12 @@ -85,11 +87,30 @@ 1.13 fi 1.14 echo -e "\\033[0;39m ]" 1.15 } 1.16 + 1.17 +yesorno() 1.18 +{ 1.19 + echo -n "$1" 1.20 + case "$DEFAULT_ANSWER" in 1.21 + Y|y) answer="y";; 1.22 + N|n) answer="n";; 1.23 + *) read answer;; 1.24 + esac 1.25 +} 1.26 + 1.27 todomsg() 1.28 { 1.29 echo -e "\\033[70G[ \\033[1;31mTODO\\033[0;39m ]" 1.30 } 1.31 1.32 +# Download a file trying each mirror 1.33 +download() 1.34 +{ 1.35 + for i in $(cat $MIRROR); do 1.36 + wget $i$@ 1.37 + done 1.38 +} 1.39 + 1.40 # Check if user is root. 1.41 check_root() 1.42 { 1.43 @@ -205,6 +226,9 @@ 1.44 # Path to the directory contening additional files 1.45 # to copy into the rootfs and rootcd of the LiveCD. 1.46 ADDFILES="$DISTRO/addfiles" 1.47 + 1.48 +# Default answer for binary question (Y or N) 1.49 +DEFAULT_ANSWER="ASK" 1.50 EOF 1.51 } 1.52 1.53 @@ -408,7 +432,11 @@ 1.54 if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ] ; then 1.55 echo -e "\nUnable to find $pkg in the repository." 1.56 echo -e "Path : $PACKAGES_REPOSITORY\n" 1.57 - exit 0 1.58 + if [ -f $MIRROR ]; then 1.59 + yesorno "Download packages from mirror (Y/n) ? " 1.60 + [ "$answer" = "n" ] || break 1.61 + fi 1.62 + exit 1 1.63 fi 1.64 done 1.65 # Root fs stuff. 1.66 @@ -421,6 +449,19 @@ 1.67 # First copy and extract the package in tmp dir. 1.68 pkg=${pkg%.tazpkg} 1.69 mkdir -p $TMP_DIR 1.70 + if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then 1.71 + # look for package in cache 1.72 + if [ -f $CACHE_DIR/$pkg.tazpkg ]; then 1.73 + ln -s $CACHE_DIR/$pkg.tazpkg $PACKAGES_REPOSITORY 1.74 + else 1.75 + # get package from mirror 1.76 + download $pkg.tazpkg && mv $pkg.tazpkg $PACKAGE_REPOSITORY 1.77 + fi 1.78 + fi 1.79 + if [ ! -f $PACKAGES_REPOSITORY/$pkg.tazpkg ]; then 1.80 + echo "Missing package $pkg." 1.81 + exit 1 1.82 + fi 1.83 cp $PACKAGES_REPOSITORY/$pkg.tazpkg $TMP_DIR && cd $TMP_DIR 1.84 echo "" 1.85 echo -n "Installing $PACKAGE... " 1.86 @@ -609,7 +650,7 @@ 1.87 echo "ISO image : $iso" 1.88 echo "================================================================================" 1.89 echo "" 1.90 - echo -n "Burn ISO image (y/N) ? "; read answer 1.91 + yesorno "Burn ISO image (y/N) ? " 1.92 if [ "$answer" == "y" ]; then 1.93 echo "" 1.94 echo "Starting Wodim to burn the iso..." && sleep 2