[Rear-users] SF.net SVN: rear:[487] trunk/usr/share/rear

gdha at users.sourceforge.net gdha at users.sourceforge.net
Tue May 24 21:34:30 CEST 2011


Revision: 487
          http://rear.svn.sourceforge.net/rear/?rev=487&view=rev
Author:   gdha
Date:     2011-05-24 19:34:29 +0000 (Tue, 24 May 2011)

Log Message:
-----------
! add label workflow to format USB disks
fix the revision in mkvendorrpm
TODO: labeltape workflow is in my opinion obsolete (rear label follows the proper flows)

Modified Paths:
--------------
    trunk/usr/share/rear/contrib/mkvendorrpm

Added Paths:
-----------
    trunk/usr/share/rear/label/USB/
    trunk/usr/share/rear/label/USB/default/
    trunk/usr/share/rear/label/USB/default/05_check_NETFS_requirements.sh
    trunk/usr/share/rear/label/USB/default/20_check_usb_layout.sh
    trunk/usr/share/rear/label/USB/default/30_format_usb_disk.sh
    trunk/usr/share/rear/lib/label-workflow.sh

Modified: trunk/usr/share/rear/contrib/mkvendorrpm
===================================================================
--- trunk/usr/share/rear/contrib/mkvendorrpm	2011-05-24 11:25:33 UTC (rev 486)
+++ trunk/usr/share/rear/contrib/mkvendorrpm	2011-05-24 19:34:29 UTC (rev 487)
@@ -36,23 +36,9 @@
 if [ "$VERSION" = 0.0.0 -a -d "$rear_root/.svn" ] ; then
 	# try to set version from SVN
 	svn up "$rear_root" >&/dev/null
-	read junk rev < <(svn info .. | grep ^Revision)
+	read junk rev < <(svn info "$rear_root" | grep ^Revision)
 	VERSION="0.0.$rev"
 fi
-
-# If VERSION is still 0.0.0 then we will try to check some local files
-if [ "${VERSION}" = "0.0.0" ]; then
-	# 0.0.0 is the version nr of the trunk; extract the version nr from CHANGES or VERSION files
-	if [ -f $rear_root/usr/share/rear/VERSION ]; then
-		VERSION1=`cat $rear_root/usr/share/rear/VERSION`
-	else
-		VERSION1="0.0.0"
-	fi
-	if [ -f $rear_root/usr/share/rear/CHANGES ]; then
-		VERSION2=`grep -i ^version $rear_root/usr/share/rear/CHANGES | head -1 | awk '{print $2}'`
-		VERSION=`echo -e ${VERSION1}'\n'${VERSION2} | sort -n | tail -1`
-	fi
-fi
 }
 ##################### M A I N ####################
 EXITcode=0

Added: trunk/usr/share/rear/label/USB/default/05_check_NETFS_requirements.sh
===================================================================
--- trunk/usr/share/rear/label/USB/default/05_check_NETFS_requirements.sh	                        (rev 0)
+++ trunk/usr/share/rear/label/USB/default/05_check_NETFS_requirements.sh	2011-05-24 19:34:29 UTC (rev 487)
@@ -0,0 +1 @@
+link ../../../prep/NETFS/default/05_check_NETFS_requirements.sh
\ No newline at end of file


Property changes on: trunk/usr/share/rear/label/USB/default/05_check_NETFS_requirements.sh
___________________________________________________________________
Added: svn:special
   + *

Added: trunk/usr/share/rear/label/USB/default/20_check_usb_layout.sh
===================================================================
--- trunk/usr/share/rear/label/USB/default/20_check_usb_layout.sh	                        (rev 0)
+++ trunk/usr/share/rear/label/USB/default/20_check_usb_layout.sh	2011-05-24 19:34:29 UTC (rev 487)
@@ -0,0 +1,46 @@
+[ "$USB_DEVICE" ]
+ProgressStopIfError $? "USB device (\$USB_DEVICE) is not set."
+[ -b "$USB_DEVICE" ]
+ProgressStopIfError $? "USB device '$USB_DEVICE' is not a block device"
+
+# Attempt to find the real USB device by trying its parent
+# Return a proper short device name using udev
+REAL_USB_DEVICE=$(readlink -f $USB_DEVICE)
+
+[ "$REAL_USB_DEVICE" -a -b "$REAL_USB_DEVICE" ]
+ProgressStopIfError $? "Unable to determine real USB device based on USB device '$USB_DEVICE'."
+
+# We cannot use the layout dependency code in the backup phase (yet)
+#RAW_USB_DEVICE=$(find_disk $REAL_USB_DEVICE)
+
+# Try to find the parent device (as we don't want to write MBR to a partition)
+# the udevinfo query yields something like /devices/pci0000:00/0000:00:10.0/host2/target2:0:1/2:0:1:0/block/sdb/sdb1
+# we want the "sdb" part of it.
+TEMP_USB_DEVICE=$(basename $(dirname $(my_udevinfo -q path -n "$REAL_USB_DEVICE")))
+if [ "$TEMP_USB_DEVICE" -a -b "/dev/$TEMP_USB_DEVICE" ]; then
+    RAW_USB_DEVICE="/dev/$(my_udevinfo -q name -n "$TEMP_USB_DEVICE")"
+elif [ "$TEMP_USB_DEVICE" -a -d "/sys/block/$TEMP_USB_DEVICE" ]; then
+    RAW_USB_DEVICE="/dev/$(my_udevinfo -q name -p "$TEMP_USB_DEVICE")"
+elif [ -z "$TEMP_USB_DEVICE" ]; then
+    RAW_USB_DEVICE="/dev/$(my_udevinfo -q name -n "$REAL_USB_DEVICE")"
+else
+    BugError "Unable to determine raw USB device for $REAL_USB_DEVICE"
+fi
+
+[ "$RAW_USB_DEVICE" -a -b "$RAW_USB_DEVICE" ]
+ProgressStopIfError $? "Unable to determine raw USB device for $REAL_USB_DEVICE"
+
+answer=""
+
+ID_FS_TYPE=
+eval $(vol_id "$REAL_USB_DEVICE")
+ProgressStopIfError $? "Could not determine filesystem info for '$REAL_USB_DEVICE'"
+[[ "$ID_FS_TYPE" == @(btr*|ext*) ]]
+if [ $? -ne 0 ]; then
+	echo "USB device $REAL_USB_DEVICE must be formatted with ext2/3/4 or btrfs file system"
+	echo "Please type Yes to format $REAL_USB_DEVICE in ext3 format:"
+	read answer
+	if [ "$answer" != "Yes" ]; then 
+		ProgressStopIfError 1 "Abort USB format process by user"
+	fi
+fi

Added: trunk/usr/share/rear/label/USB/default/30_format_usb_disk.sh
===================================================================
--- trunk/usr/share/rear/label/USB/default/30_format_usb_disk.sh	                        (rev 0)
+++ trunk/usr/share/rear/label/USB/default/30_format_usb_disk.sh	2011-05-24 19:34:29 UTC (rev 487)
@@ -0,0 +1,11 @@
+# $answer is filled by 20_check_usb_layout.sh
+if [ "$answer" == "Yes" ]; then
+	umount $REAL_USB_DEVICE >/dev/null 2>&1
+	parted $RAW_USB_DEVICE mkpart primary 0 100%
+	ProgressStopIfError $? "Could not create a primary partition on '$REAL_USB_DEVICE'"
+	parted $RAW_USB_DEVICE set 1 boot on
+	ProgressStopIfError $? "Could not make primary partition boot-able on '$REAL_USB_DEVICE'"
+
+	mkfs.ext3 $REAL_USB_DEVICE 1>&8
+	ProgressStopIfError $? "Could not format '$REAL_USB_DEVICE' with ext3 layout"
+fi

Added: trunk/usr/share/rear/lib/label-workflow.sh
===================================================================
--- trunk/usr/share/rear/lib/label-workflow.sh	                        (rev 0)
+++ trunk/usr/share/rear/lib/label-workflow.sh	2011-05-24 19:34:29 UTC (rev 487)
@@ -0,0 +1,19 @@
+# label-workflow.sh
+#
+
+WORKFLOW_label_DESCRIPTION="Label tape for OBDR or USB device used in ReaR."
+WORKFLOWS=( ${WORKFLOWS[@]} label )
+WORKFLOW_label () {
+	for arg in "${ARGS[@]}" ; do
+		key=OPT_"${arg%%=*}"
+		val="${arg#*=}"
+		declare $key="$val"
+		Log "Setting $key=$val"
+	done
+
+	SourceStage "label/tape"
+	SourceStage "label/USB"
+
+	SourceStage "cleanup"
+
+}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rear-users mailing list