slitaz-arm rev 6
sat: add mirror command
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri May 25 00:27:28 2012 +0200 (2012-05-25) |
parents | 44ff1bd1fa6d |
children | 41bdd0275ceb |
files | .hgignore sat |
line diff
1.1 --- a/.hgignore Thu May 24 22:33:13 2012 +0200 1.2 +++ b/.hgignore Fri May 25 00:27:28 2012 +0200 1.3 @@ -1,3 +1,4 @@ 1.4 +mirror/ 1.5 packages/ 1.6 spk/ 1.7 linux-arm
2.1 --- a/sat Thu May 24 22:33:13 2012 +0200 2.2 +++ b/sat Fri May 25 00:27:28 2012 +0200 2.3 @@ -6,11 +6,15 @@ 2.4 # Author: Christophe Lincoln <pankso@slitaz.org> 2.5 # 2.6 . /lib/libtaz.sh 2.7 +#. /usr/lib/slitaz/libpkg.sh 2.8 +. /etc/slitaz/slitaz.conf 2.9 2.10 # Internal variables. 2.11 : ${work=$(pwd)} 2.12 packages=$work/packages 2.13 distro=$work/distro 2.14 +# http://mirror.slitaz.org/packages/cooking/arm/ 2.15 +mirror="http://cook.slitaz.org/cross/arm/packages/" 2.16 2.17 # Help and usage 2.18 usage() { 2.19 @@ -23,6 +27,7 @@ 2.20 clean Clean up the work directory 2.21 vdisk Create a virtual disk to be used by Qemu 2.22 emu Emulate the distro with qemu-system-arm 2.23 + mirror Download or sync the SliTaz ARM mirror 2.24 2.25 $(boldify "Options:") 2.26 --kmap Dump current keymap and include it in distro 2.27 @@ -33,6 +38,24 @@ 2.28 EOT 2.29 } 2.30 2.31 +# --> use libpkg.sh when release (function is shared with spk) 2.32 +# Check mirror ID: return 1 if no changes or mirror unreachable 2.33 +check_mirror_id() { 2.34 + [ "$forced" ] && rm -f ID 2.35 + [ -f "ID" ] || echo $$ > ID 2.36 + mv ID ID.bak 2.37 + if wget -qs ${mirror%/}/ID; then 2.38 + wget -q ${mirror%/}/ID 2.39 + else 2.40 + gettext "Mirror is unreachable"; false 2.41 + status && return 1 2.42 + fi 2.43 + if [ "$(cat ID)" == "$(cat ID.bak)" ]; then 2.44 + gettext "Mirror is up-to-date"; true 2.45 + status && return 1 2.46 + fi 2.47 +} 2.48 + 2.49 # 2.50 # Commands 2.51 # 2.52 @@ -50,13 +73,15 @@ 2.53 for pkg in $packages/*.tazpkg 2.54 do 2.55 pkgdir=$(basename $pkg .tazpkg) 2.56 + db=$distro/var/lib/tazpkg 2.57 echo -n "Installing: $(basename $pkg)" 2.58 tazpkg extract $pkg >/dev/null 2.59 . $pkgdir/receipt 2.60 - mkdir -p $distro/var/lib/tazpkg/installed/$PACKAGE 2.61 + mkdir -p $db/installed/$PACKAGE 2.62 cp $pkgdir/receipt $pkgdir/files.list \ 2.63 - $distro/var/lib/tazpkg/installed/$PACKAGE 2.64 + $db/installed/$PACKAGE 2.65 cp -a $pkgdir/fs/* $distro && rm -rf $pkgdir 2.66 + md5sum $(basename $pkg) >> $db/installed.md5 2.67 status 2.68 done 2.69 2.70 @@ -94,11 +119,8 @@ 2.71 $distro/etc/slitaz/slitaz.conf 2.72 status 2.73 2.74 - # Mirror --> http://mirror.slitaz.org/packages/cooking/arm/ 2.75 - echo 'http://cook.slitaz.org/cross/arm/packages/' \ 2.76 - > $distro/var/lib/tazpkg/mirror 2.77 - #wget -q http://cook.slitaz.org/cross/arm/packages/packages.desc \ 2.78 - #-O $distro/var/lib/tazpkg/packages.desc 2.79 + # Mirror 2.80 + echo "$mirror" > $distro/var/lib/tazpkg/mirror 2.81 2.82 # /usr/cross/arm/lib: Must be FIXED when cross-compiling 2.83 # Only used by Busybox before LD_LIBRARY_PATH is set. 2.84 @@ -149,6 +171,41 @@ 2.85 -M versatilepb -cpu arm1176 \ 2.86 -kernel linux-arm \ 2.87 -initrd distro-arm.gz ;; 2.88 + mirror) 2.89 + # 2.90 + # --> spk-mirror $mirror --sync --dest=/path ??? 2.91 + # 2.92 + # Just dl lists/packages for now, we can add a --rsync option to 2.93 + # have all mirrored packages locally to build distro's. 2.94 + count=0 2.95 + mkdir -p $work/mirror && cd $work/mirror 2.96 + if ! check_mirror_id; then 2.97 + exit 0 2.98 + fi 2.99 + for list in packages.list packages.desc packages.md5; do 2.100 + echo -n "Fetching: $list" 2.101 + rm -f $list && wget -q ${mirror%/}/$list 2.102 + status 2.103 + done 2.104 + echo -n "Checking packages $SUM..." 2.105 + for pkg in $(cat $work/mirror/packages.list); do 2.106 + pkg=${pkg}.tazpkg 2.107 + pkgsum=$($CHECKSUM $pkg) 2.108 + debug "$pkgsum" 2.109 + [ "$pkgsum" ] || pkgsum=$$ 2.110 + mirsum=$(fgrep -h $pkgsum packages.$SUM) 2.111 + debug "$mirsum" 2.112 + if [ ! "$pkgsum" == "$mirsum" ] || [ ! -f "$pkg" ] ; then 2.113 + count=$($count + 1) 2.114 + [ "$count" == 1 ] && newline 2.115 + echo -n "Fetching: ${pkg}.tazpkg" 2.116 + rm -f $pkg 2.117 + wget -q ${mirror%/}/$pkg 2.118 + status 2.119 + fi 2.120 + done 2.121 + [ "$count" == 0 ] && status 2.122 + ;; 2.123 *) usage ;; 2.124 esac 2.125 exit 0