Package: fai-client
Severity: wishlist
Tags: patch

with this patch fcopy can fail if the preinst script fails. in
that case it wont install the file at hand. 

the patch adds a new command line option -e to allow the new
behaviou (which should become default in the long run!)

=============== patch


Index: fcopy
===================================================================
--- fcopy       (revision 5728)
+++ fcopy       (working copy)
@@ -53,6 +53,7 @@
 my $logfile;
 my @classes;
 my $dryrun;
+my $no_clobber_on_failure;
 
 my @opt_modes;
 my @rlist;
@@ -67,7 +68,7 @@
 # getopts:
 our ($opt_s, $opt_t, $opt_r, $opt_m, $opt_M, $opt_v, $opt_d, $opt_D, $opt_i);
 our ($opt_B, $opt_c, $opt_C, $opt_h, $opt_F, $opt_l, $opt_L, $opt_P, $opt_b);
-our ($opt_I, $opt_U, $opt_n);
+our ($opt_I, $opt_U, $opt_n, $opt_e);
 
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 sub copy_one {
@@ -144,7 +145,10 @@
       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) && $no_clobber_on_failure) 
{
+          ewarn("preinst for $sourcefile failed; not proceeding");
+          return 0;
+      }
     };
 
     if ( compare($tmpfile,$destfile)) {
@@ -220,13 +224,16 @@
 sub runscript {
 
   my ($scriptname,$sourcefile,$destfile,$class) = @_;
-  return unless -x "$sourcefile/$scriptname";
+  return 0 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 1 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;
+
+  return 0 if $rc;
+  return 1;
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 sub name2num {
@@ -389,6 +396,7 @@
    -C file              Read classes from file.
    -d                   Remove target file if no class applies.
    -D                   Create debug output.
+   -e                   Do not copy file if preinst script fails.
    -F file              Read list of sources from file.
    -h                   Show summary of options.
    -i                   Exit with 0 when no class applies.
@@ -414,10 +422,11 @@
 # main program
 
 $|=1;
-getopts('Ms:t:rm:vidDc:C:hF:lL:P:Bb:I:Un') || usage;
+getopts('Ms:t:rm:vidDc:C:ehF:lL:P:Bb:I:Un') || usage;
 $opt_h && usage;
 $dryrun = $ENV{FCOPY_DRYRUN} || $opt_n || 0; # is true if in dry-run mode
 $dryrun and warn "Dry-run only! Nothing is really executed.\n";
+$no_clobber_on_failure = $opt_e;
 $opt_M and $opt_m = "root,root,0644";  # set default modes
 $opt_m && check_mopt();
 $nobackup = $opt_B || $ENV{FCOPY_NOBACKUP} || 0;

=============== patch


-- System Information:
Debian Release: 5.0.4
  APT prefers proposed-updates
  APT policy: (500, 'proposed-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.30-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages fai-client depends on:
ii  file                     4.26-1          Determines file type using "magic"
ii  iproute                  20080725-2      networking and traffic control too
ii  libapt-pkg-perl          0.1.22+b1       Perl interface to libapt-pkg
pn  liblinux-lvm-perl        <none>          (no description available)
pn  libparse-recdescent-perl <none>          (no description available)
ii  perl                     5.10.0-19lenny2 Larry Wall's Practical Extraction 

Versions of packages fai-client recommends:
pn  cfengine2                     <none>     (no description available)
pn  debconf-utils                 <none>     (no description available)

Versions of packages fai-client suggests:
ii  cryptsetup                   2:1.0.6-7   configures encrypted block devices
ii  dmsetup                      2:1.02.27-4 The Linux Kernel Device Mapper use
pn  ntfsprogs                    <none>      (no description available)


-



-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to