wok rev 1725

Add mirror-tools
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Nov 19 10:32:58 2008 +0000 (2008-11-19)
parents 245d1bc622b8
children c2bda74f53db
files mirror-tools/receipt mirror-tools/stuff/etc/rsyncd.conf mirror-tools/stuff/etc/rsyncd.motd mirror-tools/stuff/etc/tazwok.conf mirror-tools/stuff/slitaz/INSTALL mirror-tools/stuff/usr/bin/mkpkgiso
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/mirror-tools/receipt	Wed Nov 19 10:32:58 2008 +0000
     1.3 @@ -0,0 +1,15 @@
     1.4 +# SliTaz package receipt.
     1.5 +
     1.6 +PACKAGE="mirror-tools"
     1.7 +VERSION="1.0"
     1.8 +CATEGORY="extra"
     1.9 +SHORT_DESC="Mirrors toolset."
    1.10 +MAINTAINER="pascal.bellard@slitaz.org"
    1.11 +WEB_SITE="http://www.slitaz.org/"
    1.12 +
    1.13 +# Rules to gen a SliTaz package suitable for Tazpkg.
    1.14 +genpkg_rules()
    1.15 +{
    1.16 +	cp -a stuff/* $fs
    1.17 +}
    1.18 +
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/mirror-tools/stuff/etc/rsyncd.conf	Wed Nov 19 10:32:58 2008 +0000
     2.3 @@ -0,0 +1,25 @@
     2.4 +# rsynd configuration for SliTaz mirror
     2.5 +#
     2.6 +motd file=/etc/rsyncd.motd
     2.7 +log file=/var/log/rsyncd
     2.8 +pid file=/var/run/rsyncd.pid
     2.9 +
    2.10 +
    2.11 +[slitaz]
    2.12 +
    2.13 +	comment = SliTaz GNU/Linux mirror
    2.14 +	path = /var/www/slitaz/mirror
    2.15 +	use chroot = yes
    2.16 +	max connections = 5
    2.17 +	lock file = /var/lock/rsyncd
    2.18 +	read only = yes
    2.19 +	list = yes
    2.20 +	uid = nobody
    2.21 +	gid = nogroup
    2.22 +	strict modes = yes
    2.23 +	ignore errors = no
    2.24 +	ignore nonreadable = yes
    2.25 +	transfer logging = no
    2.26 +	timeout = 600
    2.27 +	refuse options = checksum dry-run
    2.28 +	dont compress = *.gz *.tgz *.zip *.iso *.bz2 *.tazpkg
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/mirror-tools/stuff/etc/rsyncd.motd	Wed Nov 19 10:32:58 2008 +0000
     3.3 @@ -0,0 +1,12 @@
     3.4 +===============================================================================
     3.5 +
     3.6 +	SliTaz GNU/Linux mirror - http://www.slitaz.org/
     3.7 +
     3.8 +===============================================================================
     3.9 +
    3.10 +modules: 
    3.11 +
    3.12 + * slitaz      		--> ISO, packages, boot... all stuff 
    3.13 +
    3.14 +===============================================================================
    3.15 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/mirror-tools/stuff/etc/tazwok.conf	Wed Nov 19 10:32:58 2008 +0000
     4.3 @@ -0,0 +1,31 @@
     4.4 +# tazwok.conf: Tazwok configuration file.
     4.5 +#
     4.6 +
     4.7 +# Wok directory/tree to find receipts and build packages.
     4.8 +# By default on SliTaz the directory is /home/slitaz/wok.
     4.9 +WOK="/slitaz/home/slitaz/wok"
    4.10 +
    4.11 +# The path to the sources tarballs of the binaries packages.
    4.12 +SOURCES_REPOSITORY="/slitaz/home/slitaz/src"
    4.13 +
    4.14 +# This path set the binaries packages repository. It's where all
    4.15 +# the gen *.tazpkg will be stored when using gen-repository command.
    4.16 +PACKAGES_REPOSITORY="/var/www/slitaz/mirror/packages/cooking"
    4.17 +
    4.18 +# Default arguments for GNU configure.
    4.19 +CONFIGURE_ARGS="--build=i486-pc-linux-gnu --host=i486-pc-linux-gnu"
    4.20 +
    4.21 +# Translation files to include in packages, note that you can specifiy
    4.22 +# several locale.
    4.23 +LOCALE="fr"
    4.24 +
    4.25 +# Mirrors URLs. To downloads source next from your location.
    4.26 +# GNU mirror :
    4.27 +#
    4.28 +GNU_MIRROR="ftp://sunsite.cnlab-switch.ch/mirror/gnu"
    4.29 +# SourceForge mirror :
    4.30 +#
    4.31 +SF_MIRROR="http://switch.dl.sourceforge.net/sourceforge"
    4.32 +# Xorg mirror :
    4.33 +#
    4.34 +XORG_MIRROR="ftp://ftp.solnet.ch/mirror/x.org/pub/individual"
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/mirror-tools/stuff/slitaz/INSTALL	Wed Nov 19 10:32:58 2008 +0000
     5.3 @@ -0,0 +1,14 @@
     5.4 +#!/bin/sh
     5.5 +DIR=$(dirname $0)
     5.6 +MOUNTS="/proc /sys /dev/pts /dev/shm"
     5.7 +cp /etc/resolv.conf etc
     5.8 +for i in $MOUNTS; do
     5.9 +  [ -d $i ] && mount --bind $i $DIR/$i
    5.10 +done
    5.11 +#mount --bind /var/tmp tmp
    5.12 +mount --bind /tmp tmp || mount -t tmpfs tmpfs tmp
    5.13 +SHELL=/bin/ash chroot $DIR /bin/ash -
    5.14 +umount tmp
    5.15 +for i in $MOUNTS; do
    5.16 +  umount $DIR/$i
    5.17 +done
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/mirror-tools/stuff/usr/bin/mkpkgiso	Wed Nov 19 10:32:58 2008 +0000
     6.3 @@ -0,0 +1,204 @@
     6.4 +#!/bin/sh
     6.5 +# mkpkgiso, build packages ISO image.
     6.6 +# (C) 2007-TODAY SliTaz - GNU General Public License v3.
     6.7 +#
     6.8 +# Authors : Eric Joseph-Alexandre <erjo@slitaz.org>
     6.9 +#	    Pascal Bellard <pascal.bellard@slitaz.org>
    6.10 +
    6.11 +VERSION=0.2
    6.12 +
    6.13 +ROOT=/home/slitaz/iso
    6.14 +TEMP_DIR=${ROOT}/_iso.$$
    6.15 +PKG_VER=$1
    6.16 +shift
    6.17 +OPTIONS=$@
    6.18 +PKG_DIR=$TEMP_DIR/packages/$PKG_VER
    6.19 +REPOS=/var/www/slitaz/mirror/packages/$PKG_VER
    6.20 +ISO_DIR=/var/www/slitaz/mirror/iso/$PKG_VER
    6.21 +LOG=$PWD/$(basename $0).log
    6.22 +
    6.23 +#
    6.24 +VOLUME_ID="packages-${PKG_VER}"
    6.25 +PUBLISHER="SliTaz http://www.slitaz.org/"
    6.26 +IMAGE="packages-${PKG_VER}.iso"
    6.27 +OUTPUT="$ROOT/$IMAGE"
    6.28 +
    6.29 +# Check command line option.
    6.30 +if [ -z $PKG_VER ]; then
    6.31 +	echo "Usage: $(basename $0) <Version> [--boot|--webboot][--filter]"
    6.32 +	exit 1
    6.33 +fi
    6.34 +
    6.35 +# Check if we provide a valide version
    6.36 +if [ ! -d $REPOS ]; then
    6.37 +	echo "Boooh! $PKG_VER is not a valid version."
    6.38 +	exit 1
    6.39 +fi
    6.40 +
    6.41 +# Status function.
    6.42 +status()
    6.43 +{
    6.44 +    local CHECK=$?
    6.45 +    echo -en "\\033[70G[ "
    6.46 +    if [ $CHECK = 0 ]; then
    6.47 +        echo -en "\\033[1;33mOK"
    6.48 +    else
    6.49 +        echo -en "\\033[1;31mFailed"
    6.50 +    fi
    6.51 +    echo -e "\\033[0;39m ]"
    6.52 +}
    6.53 +
    6.54 +# Create temp directory
    6.55 +mkdir -p $TEMP_DIR/packages/$PKG_VER
    6.56 +
    6.57 +# Prepare evrything for ISO
    6.58 +
    6.59 +echo ""
    6.60 +echo "Building ISO for packages  $PKG_VER"
    6.61 +echo "==============================================================================="
    6.62 +echo -n "Creating working dir $(basename $TEMP_DIR)"
    6.63 +status 
    6.64 +echo -n "Creating symlink"
    6.65 +status
    6.66 +
    6.67 +# Link every packages to temp dir
    6.68 +cd $PKG_DIR
    6.69 +for i in $REPOS/*
    6.70 +do
    6.71 +	ln -s $i >> $LOG 2>&1
    6.72 +done
    6.73 +
    6.74 +echo -n "Creating install script"
    6.75 +# Create install script as suggested by Pascal.
    6.76 +cat >$TEMP_DIR/install.sh<<EOF
    6.77 +#!/bin/sh
    6.78 +#
    6.79 +
    6.80 +DIR=\$(cd \$(dirname \$0); pwd)
    6.81 +
    6.82 +[ -d /var/cache/tazpkg ] || mkdir -p /var/cache/tazpkg
    6.83 +ls -d \$DIR/packages/* > /var/lib/tazpkg/mirror
    6.84 +ln -fs \$DIR/packages/*/*.tazpkg /var/cache/tazpkg/
    6.85 +ln -fs \$DIR/packages/*/packages.* /var/lib/tazpkg
    6.86 +EOF
    6.87 +[ -e files.list.lzma ] && cat >>$TEMP_DIR/install.sh<<EOF
    6.88 +ln -fs \$DIR/packages/*/files.list.lzma /var/lib/tazpkg
    6.89 +EOF
    6.90 +
    6.91 +status
    6.92 +chmod 755  $TEMP_DIR/install.sh
    6.93 +
    6.94 +case " $OPTIONS " in
    6.95 +*\ --filter\ *)
    6.96 +	SIZE=0
    6.97 +	for i in *.tazpkg; do
    6.98 +		while read f; do
    6.99 +			case "$i" in
   6.100 +			$f*) continue 2;;
   6.101 +			esac
   6.102 +		done < packages.list
   6.103 +		echo -n "Filter out $i ($(du -hs $(readlink $i) | awk '{ print $1 }'))..."
   6.104 +		SIZE=$(( $SIZE + $(stat -c %s $(readlink $i)) ))
   6.105 +		rm $i
   6.106 +		status
   6.107 +	done
   6.108 +	UNIT=" bytes"
   6.109 +	if [ $SIZE -gt 10240 ]; then
   6.110 +		SIZE=$(( $SIZE / 1024 ))
   6.111 +		UNIT="K"
   6.112 +	fi
   6.113 +	if [ $SIZE -gt 10240 ]; then
   6.114 +		SIZE=$(( $SIZE / 1024 ))
   6.115 +		UNIT="M"
   6.116 +	fi
   6.117 +	echo "$SIZE$UNIT removed.";;
   6.118 +esac
   6.119 +case " $OPTIONS " in
   6.120 +*\ --website\ *)
   6.121 +	if [ -d /slitaz/home/slitaz/hg/website ]; then
   6.122 +		echo -n "Adding web site"
   6.123 +		mkdir $TEMP_DIR/website
   6.124 +		cp -a /slitaz/home/slitaz/hg/website/* $TEMP_DIR/website
   6.125 +		cat >>$TEMP_DIR/install.sh<<EOF
   6.126 +[ -d /var/www ] || mkdir -p /var/www
   6.127 +ln -s \$DIR/website /var/www
   6.128 +EOF
   6.129 +		status
   6.130 +		echo "$(du -hs $TEMP_DIR/website | awk '{ print $1 }') used by web site."
   6.131 +	fi;;
   6.132 +esac
   6.133 +
   6.134 +# Extract boot package function
   6.135 +extract_boot()
   6.136 +{
   6.137 +f=$(ls $REPOS/$1-[0-9]*.tazpkg 2> /dev/null)
   6.138 +[ -f "$f" ] || return 1
   6.139 +[ -d $TEMP_DIR/boot ] || mkdir $TEMP_DIR/boot
   6.140 +( cd $TEMP_DIR/boot ; cpio -i fs.cpio.gz < $f 2> /dev/null ) 
   6.141 +( cd $TEMP_DIR/boot ; zcat fs.cpio.gz | cpio -id 2> /dev/null )
   6.142 +mv $TEMP_DIR/boot/fs/boot/* $TEMP_DIR/boot
   6.143 +rm -rf $TEMP_DIR/boot/fs.cpio.gz $TEMP_DIR/boot/fs
   6.144 +return 0
   6.145 +}
   6.146 +
   6.147 +# Gen boot part
   6.148 +BOOT_OPT=""
   6.149 +iso=$ISO_DIR/slitaz-$PKG_VER.iso
   6.150 +case " $OPTIONS " in
   6.151 +*\ --boot\ *)
   6.152 +    echo -n "Creating boot tree"
   6.153 +	isoinfo -R -l -i $iso | awk '/^Directory/ { path=$4 } /^-/ { print path$12  }' | while read file; do
   6.154 +		[ "$file" = "/boot/isolinux/boot.cat" ] && continue
   6.155 +		[ -d "$(dirname $TEMP_DIR/$file)" ] ||
   6.156 +			mkdir -p "$(dirname $TEMP_DIR/$file)"
   6.157 +		isoinfo -R -x "$file" -i $iso > "$TEMP_DIR/$file"
   6.158 +	done
   6.159 +	status
   6.160 +	BOOT_OPT="-b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
   6.161 +-no-emul-boot -boot-load-size 4 -boot-info-table"
   6.162 +	;;
   6.163 +*\ --webboot\ *)
   6.164 +	if extract_boot gpxe; then
   6.165 +    	echo -n "Creating web boot tree"
   6.166 +		mkdir $TEMP_DIR/boot/isolinux/
   6.167 +		isoinfo -x "/BOOT/ISOLINUX/ISOLINUX.BIN;1" -i $iso > \
   6.168 +			$TEMP_DIR/boot/isolinux/isolinux.bin
   6.169 +		mv $TEMP_DIR/boot/gpxe $TEMP_DIR/boot/isolinux
   6.170 +		cat > $TEMP_DIR/boot/isolinux/isolinux.cfg <<EOT
   6.171 +default gpxe
   6.172 +append http://mirror.slitaz.org/pxe/pxelinux.0
   6.173 +EOT
   6.174 +		status
   6.175 +		BOOT_OPT="-b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
   6.176 +-no-emul-boot -boot-load-size 4 -boot-info-table"
   6.177 +	fi
   6.178 +	;;
   6.179 +esac
   6.180 +
   6.181 +if [ -n "$BOOT_OPT" ]; then
   6.182 +	echo "$(du -hs $TEMP_DIR/boot | awk '{ print $1 }') used by boot."
   6.183 +fi
   6.184 +
   6.185 +# Gen ISO
   6.186 +echo -n "Generating iso image"
   6.187 +/usr/bin/genisoimage -R -J -f -V $VOLUME_ID \
   6.188 + -P "$PUBLISHER" -md5-list $REPOS/packages.md5 \
   6.189 + -quiet -o $OUTPUT $BOOT_OPT $TEMP_DIR
   6.190 +status 
   6.191 +
   6.192 +echo "$(du -hs $OUTPUT | awk '{ print $1 }') used by iso image."
   6.193 +
   6.194 +echo -n "Calculate md5sum"
   6.195 +cd ${ROOT}
   6.196 +/usr/bin/md5sum $IMAGE > $(basename $IMAGE .iso).md5
   6.197 +status
   6.198 +
   6.199 +echo -n "Moving file to mirror"
   6.200 +mv $IMAGE $ISO_DIR
   6.201 +mv $(basename $IMAGE .iso).md5 $ISO_DIR
   6.202 +status
   6.203 +
   6.204 +
   6.205 +# Cleaning temp files
   6.206 +rm -rf $TEMP_DIR
   6.207 +