Patchwork [1/1] UBUNTU: [Config] fix up postinst to ensure we know which error is which

login
register
mail settings
Submitter Andy Whitcroft
Date May 25, 2012, 4:34 p.m.
Message ID <1337963668-28405-2-git-send-email-apw@canonical.com>
Download mbox | patch
Permalink /patch/161384/
State New
Headers show

Comments

Andy Whitcroft - May 25, 2012, 4:34 p.m.
We are seeing cases of errors from the postinst saying "Failed to
symbolic-link", but there are more than one of these in the script.
Convert all of these errors to errors without newline which will trigger
perl to add "at FILE line line NN.".  Also be consistant about format
and spaceing for error string ($!) printing.

BugLink: http://bugs.launchpad.net/bugs/1002388
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
 debian/control-scripts/postinst |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
Tim Gardner - May 25, 2012, 4:44 p.m.

Brad Figg - May 25, 2012, 5:34 p.m.
On 05/25/2012 09:34 AM, Andy Whitcroft wrote:
> We are seeing cases of errors from the postinst saying "Failed to
> symbolic-link", but there are more than one of these in the script.
> Convert all of these errors to errors without newline which will trigger
> perl to add "at FILE line line NN.".  Also be consistant about format
> and spaceing for error string ($!) printing.
> 
> BugLink: http://bugs.launchpad.net/bugs/1002388
> Signed-off-by: Andy Whitcroft <apw@canonical.com>
> ---
>  debian/control-scripts/postinst |   24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/debian/control-scripts/postinst b/debian/control-scripts/postinst
> index ce5ae56..b6ed9f8 100644
> --- a/debian/control-scripts/postinst
> +++ b/debian/control-scripts/postinst
> @@ -332,7 +332,7 @@ sub really_move_image {
>                     " $target");
>    if ($ret) {
>      die("Failed to move " . $src_dir . "$target to "
> -        . $dest_dir . "$target.\n");
> +        . $dest_dir . "$target");
>    }
>    # Ok, now we may clobber the previous .old files
>    if (-e "$target.$$") {
> @@ -367,13 +367,13 @@ sub really_reverse_link {
>    if ($use_hard_links =~ m/YES/i) {
>      link($Old . "$link_name", $src_dir . "$link_name") ||
>        die("Failed to link " . $dest_dir . "$link_name to " . $src_dir . 
> -          "$link_name .\n");
> +          "$link_name:$!");
>      warn "ln " . $Old . "$link_name " . $src_dir . "$link_name"  if $DEBUG;
>    }
>    else {
>      symlink($Old . "$link_name", $src_dir . "$link_name") ||
>        die("Failed to symbolic-link " . $dest_dir . "$link_name to " . $src_dir
> -          . "$link_name : $!\n");
> +          . "$link_name:$!");
>      warn "ln -s " . $Old . "$link_name " . $src_dir . "$link_name" if $DEBUG;
>    }
>  }
> @@ -512,7 +512,7 @@ sub really_move_link {
>      if (! link("${Old}${image_name}", "$kimage")) {
>        rename("$kimage.$$", "$kimage");
>        die("Failed to link ${Old}${image_name} to " .
> -          "${image_dest}${kimage}.\n");
> +          "${image_dest}${kimage}:$!");
>      }
>    } 
>    else {
> @@ -520,7 +520,7 @@ sub really_move_link {
>      if (! symlink("${Old}${image_name}", "$kimage")) {
>        rename("$kimage.$$", "$kimage");
>        die("Failed to symbolic-link ${Old}${image_name} to " .
> -          "${image_dest}${kimage}: $!\n");
> +          "${image_dest}${kimage}:$!");
>      }
>    }
>  
> @@ -555,7 +555,7 @@ sub handle_missing_link {
>                       "$image_name "   . " $kimage");
>      if ($ret) {
>        die("Failed to copy " . $realimageloc . "$image_name to "
> -          . $image_dest . "$kimage .\n");
> +          . $image_dest . "$kimage");
>      }
>    } 
>    elsif ($reverse_symlink) {
> @@ -564,7 +564,7 @@ sub handle_missing_link {
>                       . "$kimage");
>      if ($ret) {
>        die("Failed to move " . $realimageloc . "$image_name to "
> -          . $image_dest . "$kimage .\n");
> +          . $image_dest . "$kimage");
>      }
>    } 
>    else {
> @@ -612,7 +612,7 @@ sub handle_missing_link {
>      $Old ="" if $rel_path =~ m/^\s*$/o;
>  
>      symlink($Old . "$Name", "$Link_Dest") ||
> -      die("Failed to symbolic-link ${Old}$Name to $Link_Dest: $!\n");
> +      die("Failed to symbolic-link ${Old}$Name to $Link_Dest:$!");
>      warn "ln -s ${Old}$Name $Link_Dest" if $DEBUG;
>  
>    }
> @@ -647,7 +647,7 @@ sub handle_non_symlinks {
>          warn "mv $kimage.$$ $kimage" if $DEBUG;
>        }
>        die("Failed to copy " . $realimageloc . "$image_name to "
> -          . $image_dest . "$kimage .\n");
> +          . $image_dest . "$kimage");
>      }
>    }
>    ##,#### 
> @@ -663,7 +663,7 @@ sub handle_non_symlinks {
>          warn "mv $kimage.$$ $kimage" if $DEBUG;
>        }
>        die("Failed to move " . $realimageloc . "$image_name to "
> -          . $image_dest . "$kimage .\n");
> +          . $image_dest . "$kimage");
>      }
>      my $Old = $image_dest;
>      if (test_relative ('Old Dir' => $Old, 'New Dir' => $realimageloc,
> @@ -711,7 +711,7 @@ sub handle_non_symlinks {
>        warn "mv $kimage.$$ $kimage" if $DEBUG;
>        rename("$kimage.$$", "$kimage");
>        die("Failed to link " . $realimageloc . "$image_name to "
> -          . $image_dest . "$kimage .\n");
> +          . $image_dest . "$kimage");
>      }
>    }
>    ##,####
> @@ -728,7 +728,7 @@ sub handle_non_symlinks {
>          rename("$kimage.$$", "$kimage");
>        }
>        die("Failed to copy " . $realimageloc . "$image_name to "
> -          . $image_dest . "$kimage .\n");
> +          . $image_dest . "$kimage");
>      }
>    }
>    # Ok, now we may clobber the previous .old file

Patch

diff --git a/debian/control-scripts/postinst b/debian/control-scripts/postinst
index ce5ae56..b6ed9f8 100644
--- a/debian/control-scripts/postinst
+++ b/debian/control-scripts/postinst
@@ -332,7 +332,7 @@  sub really_move_image {
                    " $target");
   if ($ret) {
     die("Failed to move " . $src_dir . "$target to "
-        . $dest_dir . "$target.\n");
+        . $dest_dir . "$target");
   }
   # Ok, now we may clobber the previous .old files
   if (-e "$target.$$") {
@@ -367,13 +367,13 @@  sub really_reverse_link {
   if ($use_hard_links =~ m/YES/i) {
     link($Old . "$link_name", $src_dir . "$link_name") ||
       die("Failed to link " . $dest_dir . "$link_name to " . $src_dir . 
-          "$link_name .\n");
+          "$link_name:$!");
     warn "ln " . $Old . "$link_name " . $src_dir . "$link_name"  if $DEBUG;
   }
   else {
     symlink($Old . "$link_name", $src_dir . "$link_name") ||
       die("Failed to symbolic-link " . $dest_dir . "$link_name to " . $src_dir
-          . "$link_name : $!\n");
+          . "$link_name:$!");
     warn "ln -s " . $Old . "$link_name " . $src_dir . "$link_name" if $DEBUG;
   }
 }
@@ -512,7 +512,7 @@  sub really_move_link {
     if (! link("${Old}${image_name}", "$kimage")) {
       rename("$kimage.$$", "$kimage");
       die("Failed to link ${Old}${image_name} to " .
-          "${image_dest}${kimage}.\n");
+          "${image_dest}${kimage}:$!");
     }
   } 
   else {
@@ -520,7 +520,7 @@  sub really_move_link {
     if (! symlink("${Old}${image_name}", "$kimage")) {
       rename("$kimage.$$", "$kimage");
       die("Failed to symbolic-link ${Old}${image_name} to " .
-          "${image_dest}${kimage}: $!\n");
+          "${image_dest}${kimage}:$!");
     }
   }
 
@@ -555,7 +555,7 @@  sub handle_missing_link {
                      "$image_name "   . " $kimage");
     if ($ret) {
       die("Failed to copy " . $realimageloc . "$image_name to "
-          . $image_dest . "$kimage .\n");
+          . $image_dest . "$kimage");
     }
   } 
   elsif ($reverse_symlink) {
@@ -564,7 +564,7 @@  sub handle_missing_link {
                      . "$kimage");
     if ($ret) {
       die("Failed to move " . $realimageloc . "$image_name to "
-          . $image_dest . "$kimage .\n");
+          . $image_dest . "$kimage");
     }
   } 
   else {
@@ -612,7 +612,7 @@  sub handle_missing_link {
     $Old ="" if $rel_path =~ m/^\s*$/o;
 
     symlink($Old . "$Name", "$Link_Dest") ||
-      die("Failed to symbolic-link ${Old}$Name to $Link_Dest: $!\n");
+      die("Failed to symbolic-link ${Old}$Name to $Link_Dest:$!");
     warn "ln -s ${Old}$Name $Link_Dest" if $DEBUG;
 
   }
@@ -647,7 +647,7 @@  sub handle_non_symlinks {
         warn "mv $kimage.$$ $kimage" if $DEBUG;
       }
       die("Failed to copy " . $realimageloc . "$image_name to "
-          . $image_dest . "$kimage .\n");
+          . $image_dest . "$kimage");
     }
   }
   ##,#### 
@@ -663,7 +663,7 @@  sub handle_non_symlinks {
         warn "mv $kimage.$$ $kimage" if $DEBUG;
       }
       die("Failed to move " . $realimageloc . "$image_name to "
-          . $image_dest . "$kimage .\n");
+          . $image_dest . "$kimage");
     }
     my $Old = $image_dest;
     if (test_relative ('Old Dir' => $Old, 'New Dir' => $realimageloc,
@@ -711,7 +711,7 @@  sub handle_non_symlinks {
       warn "mv $kimage.$$ $kimage" if $DEBUG;
       rename("$kimage.$$", "$kimage");
       die("Failed to link " . $realimageloc . "$image_name to "
-          . $image_dest . "$kimage .\n");
+          . $image_dest . "$kimage");
     }
   }
   ##,####
@@ -728,7 +728,7 @@  sub handle_non_symlinks {
         rename("$kimage.$$", "$kimage");
       }
       die("Failed to copy " . $realimageloc . "$image_name to "
-          . $image_dest . "$kimage .\n");
+          . $image_dest . "$kimage");
     }
   }
   # Ok, now we may clobber the previous .old file