[Fai-commit] r5877 - in trunk: bin debian

Thomas Lange lange at alioth.debian.org
Tue Jul 27 03:11:25 UTC 2010


Author: lange
Date: 2010-07-27 03:11:13 +0000 (Tue, 27 Jul 2010)
New Revision: 5877

Modified:
   trunk/bin/fcopy
   trunk/debian/changelog
Log:
fcopy: do not copy file if preinst script fails (closes: #573044)
thanks to Andreas Schuldei for the patch

Modified: trunk/bin/fcopy
===================================================================
--- trunk/bin/fcopy	2010-07-27 02:39:45 UTC (rev 5876)
+++ trunk/bin/fcopy	2010-07-27 03:11:13 UTC (rev 5877)
@@ -142,8 +142,12 @@
       warn "preinst script found, copying $sourcefile to $tmpfile" if $debug;
       ewarn("copying $sourcefile for preinst processing failed !") unless
         _copy($sourcefile,$tmpfh);
-      runscript("preinst",$ps,$tmpfile,$class);
-    };
+      if (runscript("preinst",$ps,$tmpfile,$class)) {
+	ewarn("preinst for $sourcefile failed; not proceeding");
+	_unlink($tmpfile);
+	return 0;
+      }
+    }
 
     if ( compare($tmpfile,$destfile)) {
       $logcomment="\t# new (literal)";
@@ -217,14 +221,20 @@
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 sub runscript {
 
+  # returns 0 on success, 1 if the script failed
+
   my ($scriptname,$sourcefile,$destfile,$class) = @_;
-  return unless -x "$sourcefile/$scriptname";
+  return 1 unless -x "$sourcefile/$scriptname";
   warn "executing $sourcefile/$scriptname $class $destfile\n" if $debug;
-  return if $dryrun; # do not execute if -n or FCOPY_DRYRUN was given
+  return 0 if $dryrun; # do not execute if -n or FCOPY_DRYRUN was given
   system "$sourcefile/$scriptname $class $destfile";
   my $rc = $?>>8;
-  warn "ERROR: $scriptname returned code $rc\n" if $rc;
-  $error=1 if $rc;
+  if ($rc) {
+    warn "ERROR: $scriptname returned code $rc\n";
+    $error=1;
+    return 1;
+  }
+  return 0;
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 sub name2num {

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2010-07-27 02:39:45 UTC (rev 5876)
+++ trunk/debian/changelog	2010-07-27 03:11:13 UTC (rev 5877)
@@ -60,6 +60,8 @@
     remove test which is already done before
   * fai-cd.8: add option -G
   * make-fai-nfsroot: remove variable $FAI_BOOT
+  * fcopy: do not copy file if preinst script fails (closes: #573044)
+    thanks to Andreas Schuldei for the patch
   
   [ Michael Tautschnig ]
   * control: Move setup-storage to its own package (fai-setup-storage). Thanks




More information about the Fai-commit mailing list