bootdisk: vfjuggle (HEAD)

gotar gotar w pld.org.pl
Nie, 6 Kwi 2003, 14:16:57 CEST


Module name:	bootdisk
Changes by:	gotar	03/04/06 14:16:55

Modified files:
	vfjuggle

Log message:
- merged from poldek distribution:
 - extended trailing comment,
 - setting URI (cdid function) without sed,
 - removed unused variables: cddev and ans (mount_ function),
 - use directly CDID instead of id (mount_),
 - fixed umount message (mount_ function) (it's not $id disk),
 - use must_be_copied function and POLDEK_VFJUGGLE_CPMODE var,
 - cosmetics, reformated - if you have narrower terminal please
   decrease tabstop (vim) variable or Tab spacing (mcedit) option,
   but let it be real 0x09 tabs.

Index: vfjuggle
===================================================================
RCS file: /cvsroot/bootdisk/scripts/vfjuggle,v
diff -d -u -r1.6 -r1.7
--- vfjuggle	31 Oct 2002 20:21:35 -0000	1.6
+++ vfjuggle	6 Apr 2003 12:16:55 -0000	1.7
@@ -1,155 +1,166 @@
-#! /bin/ash
+#!/bin/ash
 # $Id$
 #
 # based on original vfjuggle from poldek distribution
 #
-# Enviroment: 
-# VF_MNTPOINT - the default is /src
-# VF_MNTDEV   - the default is empty
-# VF_EJECT    - e.g. VF_EJECT="ziptool -e /dev/zip", 
-#                    VF_EJECT="cdeject -d $VF_MNTDEV"
+# Enviroment:
+# VF_MNTDEV	- the default is empty
+#			VF_MNTDEV=/dev/hdd
+# VF_MNTPOINT	- the default is /src
+#			VF_MNTPOINT=/mnt/cdrom
+# VF_MOUNT	- the default is mount
+# VF_UMOUNT	- the default is umount
+# VF_EJECT	- the default is empty
+#			VF_EJECT="eject [$VF_MNTDEV]"
+#			VF_EJECT="ziptool -e /dev/zip",
+#			VF_EJECT="cdeject -d $VF_MNTDEV"
 
-cdid() 
-{
-    URI=`echo $1 | sed 's@^cdrom://@@'`
-    CDID=`echo $URI | sed 's@/.*@@'`
-    URI=`echo $URI | sed 's@[^/]*/@@'`
-    BN=`basename $URI`
-    
-    #echo "$1 -> uri $URI, id $CDID"
-    if [ -z "$URI" -o -z "$CDID" ]; then
-	echo "$1: URL syntax error"
-	exit 1
-    fi
+cdid() {
+	URI=${1#cdrom://}
+	CDID=`echo $URI | sed 's@/.*@@'`
+	URI=`echo $URI | sed 's@[^/]*/@@'`
+	BN=`basename $URI`
+
+	#echo "$1 -> uri $URI, id $CDID"
+	if [ -z "$URI" -o -z "$CDID" ]; then
+		echo "$1: URL syntax error"
+		exit 1
+	fi
 }
 
-mount_()
-{
-    local id=$1
-    local cddev
-    local ans
+mount_() {
+	# check what is the cdrom device
+	VF_MNTDEV=`grep " $VF_MNTPOINT" /proc/mounts | sed 's/ .*//'`
+	if test -z "$VF_MNTDEV"; then
+		echo "No cd already mounted - giving up!!!"
+		exit 1
+	fi
 
-    if [ -f "$VF_MNTPOINT/$id" ]; then
-	return 0
-    fi
+	#$VF_MOUNT -t iso9660 $VF_MNTDEV $VF_MNTPOINT 2>/dev/null
+	#if [ -f "$VF_MNTPOINT/$id" ]; then
+	#	return 0
+	#fi
 
-    # check what is the cdrom device
-    VF_MNTDEV=`grep " $VF_MNTPOINT" /proc/mounts | sed 's/ .*//'`
-    if test -z "$VF_MNTDEV"; then
-	echo "No cd already mounted - giving up!!!"
-	exit 1
-    fi
+	while true; do
+		echo "Umounting $VF_MNTPOINT..."
+		$VF_UMOUNT $VF_MNTPOINT
 
-    #$VF_MOUNT -t iso9660 $VF_MNTDEV $VF_MNTPOINT 2>/dev/null 
-    #if [ -f "$VF_MNTPOINT/$id" ]; then
-    #	return 0
-    #fi
-	    
-    while true; do
-	echo "Umounting $id $VF_MNTPOINT/$id $VF_MNTPOINT..."
-	$VF_UMOUNT $VF_MNTPOINT
-	
-	if [ -n "$VF_EJECT" ]; then
-	    "$VF_EJECT"
-	fi    
+		if [ -n "$VF_EJECT" ]; then
+			"$VF_EJECT"
+		fi
 
-	dml <<EOF 
-	    ${extra_message:+<br>}$extra_message
-	    <br>`nls "Please insert %s disk" "$id"`
-	    <meta title="$(nls "Disk change")">
-	    <br>`nls "(I need '%s')" "$URI"`
-	    <br><button>
+		dml <<EOF
+			${extra_message:+<br>}$extra_message
+			<br>`nls "Please insert %s disk" "$CDID"`
+			<meta title="$(nls "Disk change")">
+			<br>`nls "(I need '%s')" "$URI"`
+			<br><button>
 EOF
 
-	echo "Mounting $VF_MNTDEV $VF_MNTPOINT..."
-	$VF_MOUNT -t iso9660 $VF_MNTDEV $VF_MNTPOINT -o ro
-	local rc=$?
+		echo "Mounting $VF_MNTDEV $VF_MNTPOINT..."
+		$VF_MOUNT -t iso9660 $VF_MNTDEV $VF_MNTPOINT -o ro
+		local rc=$?
 
-	if [ -f "$VF_MNTPOINT/$id" ]; then
-	    return 0
-	elif [ $rc -eq 0 ]; then
-	    extra_message=$(nls "Not a %s disk" "$id")
-	else
-	    extra_message=$(nls "Disk mounting problem, try again")
-	fi    
-    done
+		if [ -f "$VF_MNTPOINT/$CDID" ]; then
+			return 0
+		elif [ $rc -eq 0 ]; then
+			extra_message=$(nls "Not a %s disk" "$CDID")
+		else
+			extra_message=$(nls "Disk mounting problem, try again")
+		fi
+	done
 }
 
-usage()
-{
-    echo "usage: `basename $0` DESTDIR [cdrom://DISK_ID_FILE/PATH...]"
+must_be_copied() {
+	case "$1" in
+		Packages*|packages.dir|packages.dir.*)
+			return 0
+			;;
+		*)
+			return 1
+	esac
+}
+
+usage() {
+	echo "usage: `basename $0` DESTDIR [cdrom://DISK_ID_FILE/PATH...]"
 }
 
 
 #
-# main 
-# 
+# main
+#
 
 if [ -f ~/.vfjugglerc ]; then
-  . ~/.vfjugglerc
+	. ~/.vfjugglerc
 fi
 
-#PATH="/bin:/usr/bin:/usr/sbin:/sbin"
+#PATH="/bin:/usr/bin:/sbin:/usr/sbin"
 # need nls
 . installer-functions
 
-
 VF_MNTPOINT=${VF_MNTPOINT:-"/src"}
 if [ ! -d "$VF_MNTPOINT" ]; then
-    echo "$VF_MNTPOINT: no such directory"
-    exit 1
+	echo "$VF_MNTPOINT: no such directory"
+	exit 1
 fi
 
-if [ -n "$VF_MNTDEV" ]; then #   by default run mount $VF_MNTPOINT only 
-    if [ ! -b "$VF_MNTDEV" ]; then
-	echo "$VF_MNTDEV: no such device"
-	exit 1
-    fi
+if [ -n "$VF_MNTDEV" ]; then #	by default run mount $VF_MNTPOINT only
+	if [ ! -b "$VF_MNTDEV" ]; then
+		echo "$VF_MNTDEV: no such device"
+		exit 1
+	fi
 fi
 
 VF_MOUNT=${VF_MOUNT:-"mount"}
 VF_UMOUNT=${VF_UMOUNT:-"umount"}
 
 if [ "$#" = 0 ]; then
-    usage
-    exit 0
+	usage
+	exit 0
 fi
 
-
 DESTDIR=$1; shift;
-if [ ! -d "$DESTDIR" ]; then 
-    echo "$DESTDIR: no such directory"
-    exit 1
+if [ ! -d "$DESTDIR" ]; then
+	echo "$DESTDIR: no such directory"
+	exit 1
 fi
 
+#echo "POLDEK_VFJUGGLE_CPMODE = $POLDEK_VFJUGGLE_CPMODE"
+while [ $# -gt 0 ]; do
+	URL=$1; shift;
+
+	cdid $URL
 
-while  [ $# -gt 0 ]; do
-    URL=$1; shift;
+	if [ -r $DESTDIR/$BN ]; then
+		continue
+	fi
 
-    cdid $URL
+	if [ ! -f "$VF_MNTPOINT/$CDID" ]; then
+		mount_
+	fi
 
-    if [ ! -f "$VF_MNTPOINT/$CDID" ]; then 
-	mount_ $CDID
-    fi
+	if [ ! -f "$VF_MNTPOINT/$URI" ]; then
+		echo "$VF_MNTPOINT/$URI: no such file"
+		exit 1
+	fi
 
-    if [ ! -f "$VF_MNTPOINT/$URI" ]; then
-	echo "$VF_MNTPOINT/$URI: no such file"
-	exit 1
-    fi
-   
-    case "$BN" in
-    packages.dir* | Packages* )
-         cp $VF_MNTPOINT/$URI $DESTDIR/
-	 ;;
-    *)
-	 ln -sf "$VF_MNTPOINT/$URI" "$DESTDIR/$FILE"
-	 ;;
-    esac
-	
-    if [ $? -ne 0 ]; then
-	exit 1
-    fi
-done
+	if must_be_copied $BN; then
+		POLDEK_VFJUGGLE_CPMODE="copy"
+	fi
+
+	if [ "$POLDEK_VFJUGGLE_CPMODE" = "copy" ]; then
+#		echo "cp -L --remove-destination $VF_MNTPOINT/$URI $DESTDIR/"
+		cp -L --remove-destination $VF_MNTPOINT/$URI $DESTDIR/
+	else
+#		echo "ln -sf $VF_MNTPOINT/$URI $DESTDIR/"
+		ln -sf $VF_MNTPOINT/$URI $DESTDIR/
+	fi
 
+	if [ $? -ne 0 ]; then
+		exit 1
+	fi
+done
 exit 0
-    
+
+# This must be the last line!
+# vi:ts=8



Więcej informacji o liście dyskusyjnej pld-installer