slitaz-arm annotate sat @ rev 19

mount /run as tmpfs (less disk acess and faster)
author Christophe Lincoln <pankso@slitaz.org>
date Sat Jun 02 12:48:53 2012 +0200 (2012-06-02)
parents 4dcfb253c8f7
children 432ac2334e26
rev   line source
pankso@1 1 #!/bin/sh
pankso@1 2 #
pankso@1 3 # Sat - SliTaz ARM Tool
pankso@1 4 #
pankso@13 5 # Copyright (C) 2012 SliTaz ARM - BSD License
pankso@1 6 # Author: Christophe Lincoln <pankso@slitaz.org>
pankso@1 7 #
pankso@1 8 . /lib/libtaz.sh
pankso@6 9 #. /usr/lib/slitaz/libpkg.sh
pankso@6 10 . /etc/slitaz/slitaz.conf
pankso@1 11
pankso@11 12 # Internal variables: libtaz.sh set: --work= --init=
pankso@11 13 [ "$work" ] || work="$(pwd)"
pankso@11 14 [ "$init" ] || init="gz"
pankso@11 15 initramfs="slitaz-arm.$init"
pankso@1 16 packages=$work/packages
pankso@1 17 distro=$work/distro
pankso@6 18 # http://mirror.slitaz.org/packages/cooking/arm/
pankso@6 19 mirror="http://cook.slitaz.org/cross/arm/packages/"
pankso@1 20
pankso@1 21 # Help and usage
pankso@1 22 usage() {
pankso@1 23 cat << EOT
pankso@1 24
pankso@1 25 $(boldify "Usage:") $(basename $0) [command|--options]
pankso@1 26
pankso@1 27 $(boldify "Commands:")
paul@17 28 gen Generate a distro cpio/gzip initramfs
pankso@1 29 clean Clean up the work directory
pankso@1 30 vdisk Create a virtual disk to be used by Qemu
pankso@1 31 emu Emulate the distro with qemu-system-arm
pankso@6 32 mirror Download or sync the SliTaz ARM mirror
pankso@1 33
pankso@1 34 $(boldify "Options:")
pankso@1 35 --spk Include Spk package manager in the distro
pankso@13 36 --kmap Include the system keymap config in the distro
pankso@1 37 --work= Path to work dir with packages and rootfs
pankso@1 38 --size= Specify optional vdisk size (default 20Mb)
pankso@13 39 --init= Specify the initramfs compression: gz xz
pankso@1 40
pankso@1 41 EOT
pankso@1 42 }
pankso@1 43
paul@17 44 # --> use libpkg.sh when released (function is shared with spk)
pankso@6 45 # Check mirror ID: return 1 if no changes or mirror unreachable
pankso@6 46 check_mirror_id() {
pankso@6 47 [ "$forced" ] && rm -f ID
pankso@6 48 [ -f "ID" ] || echo $$ > ID
pankso@6 49 mv ID ID.bak
pankso@6 50 if wget -qs ${mirror%/}/ID; then
pankso@6 51 wget -q ${mirror%/}/ID
pankso@6 52 else
pankso@6 53 gettext "Mirror is unreachable"; false
pankso@6 54 status && return 1
pankso@6 55 fi
pankso@6 56 if [ "$(cat ID)" == "$(cat ID.bak)" ]; then
pankso@6 57 gettext "Mirror is up-to-date"; true
pankso@6 58 status && return 1
pankso@6 59 fi
pankso@6 60 }
pankso@6 61
pankso@1 62 #
pankso@1 63 # Commands
pankso@1 64 #
pankso@1 65
pankso@1 66 case "$1" in
pankso@1 67 gen)
pankso@1 68 time=$(date +%s)
pankso@1 69 check_root
pankso@9 70 rm -rf $distro slitaz-arm.xz
pankso@1 71 mkdir -p $distro
pankso@1 72
paul@17 73 # Packages. Dep install is not well handled by tazpkg/spk actually.
paul@17 74 # So simply install all packages and don't resolve deps or use equiv.
pankso@1 75 cd $packages
pankso@1 76 for pkg in $packages/*.tazpkg
pankso@1 77 do
pankso@1 78 pkgdir=$(basename $pkg .tazpkg)
pankso@6 79 db=$distro/var/lib/tazpkg
pankso@1 80 echo -n "Installing: $(basename $pkg)"
pankso@1 81 tazpkg extract $pkg >/dev/null
pankso@1 82 . $pkgdir/receipt
pankso@6 83 mkdir -p $db/installed/$PACKAGE
pankso@1 84 cp $pkgdir/receipt $pkgdir/files.list \
pankso@6 85 $db/installed/$PACKAGE
pankso@1 86 cp -a $pkgdir/fs/* $distro && rm -rf $pkgdir
pankso@6 87 md5sum $(basename $pkg) >> $db/installed.md5
pankso@1 88 status
pankso@1 89 done
pankso@1 90
pankso@1 91 # Install spk if requested. Spk multiarch support must be tested
pankso@1 92 if [ "$spk" ]; then
pankso@1 93 hg=http://hg.slitaz.org
pankso@1 94 echo -n "Installing: spk ($hg)"
pankso@1 95 cd $work
pankso@1 96 [ -d "spk" ] || hg clone $hg/spk >/dev/null
pankso@7 97 cd $work/spk
pankso@1 98 [ "$noup" ] || hg pull -u >/dev/null
pankso@1 99 make DESTDIR=$distro install >/dev/null
pankso@1 100 status
pankso@1 101 fi
pankso@1 102
pankso@1 103 # Move kernel outside the distro
pankso@1 104 cd $work && mv -f $distro/boot/linux-* linux-arm
pankso@1 105
pankso@1 106 # SLITAZ_ARCH
pankso@1 107 echo -n "Setting SliTaz arch to: arm"
pankso@1 108 sed -i s"/SLITAZ_ARCH=.*/SLITAZ_ARCH=\"arm\"/" \
pankso@1 109 $distro/etc/slitaz/slitaz.conf
pankso@1 110 status
pankso@1 111
pankso@6 112 # Mirror
pankso@6 113 echo "$mirror" > $distro/var/lib/tazpkg/mirror
pankso@1 114
pankso@19 115 # /init & /run
pankso@1 116 cd $distro
pankso@1 117 rm init && ln -s /bin/busybox init
pankso@19 118 mkdir run
pankso@1 119
pankso@1 120 # Update modules.dep
pankso@1 121 depmod -b . 3.2.14-slitaz
pankso@1 122
pankso@11 123 # Custom rootfs: make sure all files belong to root.
pankso@1 124 if [ -d "$work/rootfs" ]; then
pankso@1 125 echo -n "Copying custom ARM rootfs..."
pankso@11 126 tmp=$work/tmp-$$
pankso@11 127 mkdir -p $tmp
pankso@11 128 cp -r $work/rootfs/* $tmp
pankso@13 129 if [ "$kmap" ]; then
pankso@13 130 cp /etc/keymap.conf $tmp/etc
pankso@13 131 fi
pankso@11 132 chown -R root.root $tmp
pankso@11 133 cp -a $tmp/* $distro && rm -rf $tmp
pankso@1 134 status
pankso@1 135 fi
pankso@1 136
pankso@11 137 # Rootfs cpio: gzip xz --> /usr/lib/slitaz/liblive.sh ???
pankso@11 138 echo -n "Compressing initramfs: $initramfs"
pankso@11 139 case $initramfs in
pankso@11 140 *.bz) find . | cpio -o -H newc | bzip2 > ../$initramfs ;;
pankso@11 141 *.gz) find . | cpio -o -H newc | gzip -9 > ../$initramfs ;;
pankso@11 142 *.xz) find . | cpio -o -H newc | xz -9 --format=lzma \
pankso@9 143 > ../$initramfs ;;
pankso@9 144 esac
pankso@1 145 status
pankso@1 146 time=$(($(date +%s) - $time))
pankso@1 147 echo "Build time : ${time}s"
pankso@1 148 echo -n "Distro size : "
pankso@9 149 cd $work && du -sh $initramfs | awk '{print $1}' ;;
pankso@1 150 clean)
pankso@1 151 check_root
pankso@9 152 for r in distro linux-arm *.*z spk; do
pankso@9 153 echo -n "Cleaning: $r"
pankso@9 154 rm -rf $work/$r && status
pankso@9 155 done ;;
pankso@1 156 vdisk)
paul@17 157 # Lets use and HD in Qemu to store files|packages|whatever
pankso@1 158 vdisk="vdisk.img"
pankso@1 159 : ${size=20}
pankso@1 160 cd $work
pankso@1 161 dd if=/dev/zero of=$vdisk bs=1M count=$size
pankso@1 162 mkfs.ext4 -q -T ext4 -L "SliTaz" -F $vdisk ;;
pankso@1 163 emu)
pankso@1 164 cd $work
pankso@1 165 [ -f "vdisk.img" ] && opts="-hda vdisk.img"
pankso@9 166 qemu-system-arm -m 256 $opts \
pankso@1 167 -M versatilepb -cpu arm1176 \
pankso@1 168 -kernel linux-arm \
pankso@9 169 -initrd $initramfs ;;
pankso@6 170 mirror)
pankso@6 171 #
pankso@6 172 # --> spk-mirror $mirror --sync --dest=/path ???
pankso@6 173 #
pankso@6 174 count=0
pankso@6 175 mkdir -p $work/mirror && cd $work/mirror
pankso@6 176 if ! check_mirror_id; then
pankso@6 177 exit 0
pankso@6 178 fi
pankso@6 179 for list in packages.list packages.desc packages.md5; do
pankso@6 180 echo -n "Fetching: $list"
pankso@6 181 rm -f $list && wget -q ${mirror%/}/$list
pankso@6 182 status
pankso@6 183 done
pankso@6 184 echo -n "Checking packages $SUM..."
pankso@6 185 for pkg in $(cat $work/mirror/packages.list); do
pankso@6 186 pkg=${pkg}.tazpkg
pankso@7 187 if [ ! -f "$pkg" ]; then
pankso@7 188 count=$(($count + 1))
pankso@7 189 [ "$count" == 1 ] && newline
pankso@7 190 echo -n "Fetching: ${pkg}.tazpkg"
pankso@7 191 wget -q ${mirror%/}/$pkg
pankso@7 192 status
pankso@7 193 fi
pankso@6 194 pkgsum=$($CHECKSUM $pkg)
pankso@6 195 debug "$pkgsum"
pankso@6 196 [ "$pkgsum" ] || pkgsum=$$
pankso@6 197 mirsum=$(fgrep -h $pkgsum packages.$SUM)
pankso@6 198 debug "$mirsum"
pankso@7 199 if [ ! "$pkgsum" == "$mirsum" ]; then
pankso@7 200 count=$(($count + 1))
pankso@6 201 [ "$count" == 1 ] && newline
pankso@6 202 echo -n "Fetching: ${pkg}.tazpkg"
pankso@6 203 rm -f $pkg
pankso@6 204 wget -q ${mirror%/}/$pkg
pankso@6 205 status
pankso@6 206 fi
pankso@6 207 done
pankso@6 208 [ "$count" == 0 ] && status
pankso@6 209 ;;
pankso@1 210 *) usage ;;
pankso@1 211 esac
pankso@1 212 exit 0