[Mud-builder-commits] r328 - trunk/lib/MUD

gcobb at garage.maemo.org gcobb at garage.maemo.org
Sun Sep 27 18:13:24 EEST 2009


Author: gcobb
Date: 2009-09-27 18:13:22 +0300 (Sun, 27 Sep 2009)
New Revision: 328

Modified:
   trunk/lib/MUD/Build.pm
Log:
Disable optification if maemo-optify not installed

Modified: trunk/lib/MUD/Build.pm
===================================================================
--- trunk/lib/MUD/Build.pm	2009-09-27 13:17:59 UTC (rev 327)
+++ trunk/lib/MUD/Build.pm	2009-09-27 15:13:22 UTC (rev 328)
@@ -228,7 +228,7 @@
     
     # -- Include maemo-optify...
     #
-    $rules =~ s/^\tdh_gencontrol$/$&\n\tif which maemo-optify >\/dev\/null ; then maemo-optify ; fi/mg if $self->{data}->optify;
+    $rules =~ s/^\tdh_gencontrol$/$&\n\tif which maemo-optify >\/dev\/null ; then maemo-optify ; fi/mg if $self->optifyCheck();
 
     # -- Append configure flags...
     #
@@ -565,7 +565,7 @@
     # in the package file.  If they are to be automatically calculated they are added later on.
     my $bdeps = $self->{data}->buildDepends;
     if ($bdeps) {
-	if ($self->{data}->optify) {
+	if ($self->optifyCheck()) {
 	    $bdeps .= ', maemo-optify';
 	}
 	MUD::Package::setField($control, "Build-Depends", $bdeps);
@@ -591,6 +591,25 @@
     system('echo 4 >debian/compat');
 }
 
+# If 'optify' is set, check whether maemo-optify is present
+sub optifyCheck {
+    my $self = shift;
+
+    return $self->{data}->optify unless $self->{data}->optify;
+
+    # See if we have already checked
+    return $self->{optifyCheck} if defined $self->{optifyCheck};
+
+    # Check to see if maemo-optify has been installed
+    my $dpkg = `dpkg -s maemo-optify 2>/dev/null`;
+    $self->{optifyCheck} = $dpkg =~ /Status: install ok installed/;
+    if (!$self->{optifyCheck}) {
+	print "+++ Optification disabled as maemo-optify not installed +++\n";
+	print $dpkg;
+    }
+    return $self->{optifyCheck};    
+}
+
 =back
 
 =head1 COPYRIGHT



More information about the Mud-builder-commits mailing list