[buildd-tools-devel] [PATCH 2/5] [ChrootInfoSchroot.pm] Support directory value

Jan-Marek Glogowski glogow at fbihome.de
Thu Sep 17 15:20:59 UTC 2009


---
 lib/Sbuild/ChrootInfoSchroot.pm |   31 ++++++++++++++++++++-----------
 1 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/lib/Sbuild/ChrootInfoSchroot.pm b/lib/Sbuild/ChrootInfoSchroot.pm
index 97d839c..4103db4 100644
--- a/lib/Sbuild/ChrootInfoSchroot.pm
+++ b/lib/Sbuild/ChrootInfoSchroot.pm
@@ -59,6 +59,15 @@ sub get_info {
     $ENV{'LC_ALL'} = 'C';
     $ENV{'LANGUAGE'} = 'C';
 
+    # Path <- Mount Location <- Directory <- Location (deprecated)
+    my @location_matches = ( 
+	'^\s*Path:?\s+(.+)$',
+	'^\s*Mount Location:?\s+(.+)$',
+	'^\s*Directory:?\s+(.+)$',
+	'^\s*Location:?\s+(.+)$' 
+	);
+    my $location_priority = 1 + scalar @location_matches;
+
     open CHROOT_DATA, '-|', $self->get_conf('SCHROOT'), '--info', '--chroot', $chroot
 	or die 'Can\'t run ' . $self->get_conf('SCHROOT') . ' to get chroot data';
     while (<CHROOT_DATA>) {
@@ -66,18 +75,18 @@ sub get_info {
 	if (/^\s*Type:?\s+(.*)$/) {
 	    $chroot_type = $1;
 	}
-	if (/^\s*Location:?\s+(.*)$/ &&
-	    $tmp{'Location'} eq "") {
-	    $tmp{'Location'} = $1;
-	}
-	if (/^\s*Mount Location:?\s+(.*)$/ &&
-	    $tmp{'Location'} eq "") {
-	    $tmp{'Location'} = $1;
-	}
-	# Path takes priority over Location and Mount Location.
-	if (/^\s*Path:?\s+(.*)$/) {
-	    $tmp{'Location'} = $1;
+
+	# Get the "best" location
+	my $priority = 0;
+	foreach my $match (@location_matches) {
+	    last if( $priority == $location_priority );
+	    if ($_ =~ /${match}/) {
+		$tmp{'Location'} = $1;
+		$location_priority = $priority;
+	    }
+	    $priority++;
 	}
+
 	if (/^\s*Priority:?\s+(\d+)$/) {
 	    $tmp{'Priority'} = $1;
 	}
-- 
1.6.4




More information about the Buildd-tools-devel mailing list