[Rear-users] SF.net SVN: rear:[744] trunk/usr/share/rear/layout/save/GNU/Linux/ 20_partition_layout.sh

jhoekx at users.sourceforge.net jhoekx at users.sourceforge.net
Thu Dec 1 11:30:18 CET 2011


Revision: 744
          http://rear.svn.sourceforge.net/rear/?rev=744&view=rev
Author:   jhoekx
Date:     2011-12-01 10:30:18 +0000 (Thu, 01 Dec 2011)
Log Message:
-----------
layout: only save partition flags parted knows about.

Modified Paths:
--------------
    trunk/usr/share/rear/layout/save/GNU/Linux/20_partition_layout.sh

Modified: trunk/usr/share/rear/layout/save/GNU/Linux/20_partition_layout.sh
===================================================================
--- trunk/usr/share/rear/layout/save/GNU/Linux/20_partition_layout.sh	2011-11-23 15:32:34 UTC (rev 743)
+++ trunk/usr/share/rear/layout/save/GNU/Linux/20_partition_layout.sh	2011-12-01 10:30:18 UTC (rev 744)
@@ -121,14 +121,23 @@
     fi
 
     ### find the flags given by parted.
-    declare flags
+    declare flags flaglist
     if [[ "$FEATURE_PARTED_MACHINEREADABLE" ]] ; then
         while read partition_nr size start junk ; do
-            flags=$(grep "^$partition_nr:" $TMP_DIR/parted | cut -d ":" -f "7" | tr -d " " | tr -d ";")
+            flaglist=$(grep "^$partition_nr:" $TMP_DIR/parted | cut -d ":" -f "7" | tr -d "," | tr -d ";")
+
+            ### only report flags parted can actually recreate
+            flags=""
+            for flag in $flaglist ; do
+                if [[ "$flag" = @(boot|root|swap|hidden|raid|lvm|lba|palo|legacy_boot|bios_grub) ]] ; then
+                    flags+="$flag,"
+                fi
+            done
+
             if [[ -z "$flags" ]] ; then
                 flags="none"
             fi
-            sed -i /^$partition_nr\ /s/$/\ $flags/ $TMP_DIR/partitions
+            sed -i /^$partition_nr\ /s/$/\ ${flags%,}/ $TMP_DIR/partitions
         done < $TMP_DIR/partitions-data
     else
         declare line line_length number numberfield
@@ -147,13 +156,21 @@
             fi
 
             number=$(get_columns "$line" "$numberfield" | tr -d " " | tr -d ";")
-            flags=$(get_columns "$line" "flags" | tr -d " " | tr -d ";")
+            flaglist=$(get_columns "$line" "flags" | tr -d "," | tr -d ";")
 
+            ### only report flags parted can actually recreate
+            flags=""
+            for flag in $flaglist ; do
+                if [[ "$flag" = @(boot|root|swap|hidden|raid|lvm|lba|palo|legacy_boot|bios_grub) ]] ; then
+                    flags+="$flag,"
+                fi
+            done
+
             if [[ -z "$flags" ]] ; then
                 flags="none"
             fi
 
-            sed -i /^$number\ /s/$/\ $flags/ $TMP_DIR/partitions
+            sed -i /^$number\ /s/$/\ ${flags%,}/ $TMP_DIR/partitions
         done < <(grep -E '^[ ]*[0-9]' $TMP_DIR/parted)
     fi
 

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