]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
UBUNTU: [Debian] postinst -- handle recreating symlinks when a real file is present
authorAndy Whitcroft <apw@canonical.com>
Mon, 22 Feb 2016 19:18:02 +0000 (19:18 +0000)
committerTim Gardner <tim.gardner@canonical.com>
Mon, 20 Feb 2017 03:57:58 +0000 (20:57 -0700)
BugLink: http://bugs.launchpad.net/bugs/1536810
Signed-off-by: Andy Whitcroft <apw@canonical.com>
debian/control-scripts/postinst

index dc2d1c172d5a291a4c7bd875a801bd0093df1203..808575ce8a80f853473256cef5d54d9eeb799edd 100644 (file)
@@ -730,6 +730,31 @@ sub handle_non_symlinks {
     }
   }
   ##,####
+  # case Five!?!
+  #`####
+  elsif ($do_symlink) {
+    # Ok then. this ought to be a symlink, and hence fair game
+    # don't clobber $kimage.old quite yet
+    my $Old = $realimageloc;
+    my $cwd;
+    chomp($cwd=`pwd`);
+    if (test_relative ('Old Dir' => $Old, 'New Dir' => $cwd,
+                       'Test File' => "$image_name")) {
+      $Old   =~ s|^/*||o;
+    }
+    # Special case is they are in the same dir
+    my $rel_path = spath('Old' => "$Old", 'New' => "$cwd" );
+    $Old ="" if $rel_path =~ m/^\s*$/o;
+
+    warn "symlink " . $Old . "$image_name " . "$kimage" if $DEBUG;
+    if (! symlink($Old . "$image_name", "$kimage")) {
+      warn "mv $kimage.$$ $kimage" if $DEBUG;
+      rename("$kimage.$$", "$kimage");
+      die("Failed to link " . $realimageloc . "$image_name to "
+          . $image_dest . "$kimage");
+    }
+  }
+  ##,####
   # case Four
   #`####
   else {