Commit 62549c4a authored by Manoj Srivastava's avatar Manoj Srivastava

Bug fixes

* kernel/pkg/image/postinst (CanonicalizePath): Use readlink -q -m from
  coreutils instead of using our own; the performance hit is not
  significant. Also, remove all kinds of duplicate invocations of spath
  without checking the return; spath may return an empty value.

* Problems (VFS): Added a record of problems caused by exporting
  GREP_OPTIONS which causes grep invocations in kernel-package to break. 

git-archimport-id: srivasta@debian.org--etch/kernel-package--devel--9.0--patch-196
parent 8a13f171
......@@ -217,3 +217,28 @@ index 82e4993..65dcb40 100644
printf '%s' -dirty
fi
fi
s)
There is a problem when GREP_OPTIONS are exported, since it
may impact the results comoing out of grep in scripts that
are tun in shubshells -- and, of course, make-kpkg is one of
them.
$ echo $GREP_OPTIONS --colour=always
So the Perl regex does not match in:
UTS_RELEASE_VERSION=$(call doit,if [ -f $(UTS_RELEASE_HEADER) ]; then \
grep 'define UTS_RELEASE' $(UTS_RELEASE_HEADER) | \
perl -nle 'm/^\s*\#define\s+UTS_RELEASE\s+("?)(\S+)\1/g && print $$2;';\
else echo "" ; \
fi)
This shows up as an error message like:
,----
| The UTS Release version in include/linux/utsrelease.h
| ""
| does not match current version:
| "2.6.18"
| Please correct this.
| make: *** [install/linux-image-2.6.18] Erreur 2
`----
......@@ -350,37 +350,37 @@ sub test_relative {
############
######################################################################
######################################################################
sub CanonicalizePath {
my $path = join '/', @_;
my @work = split '/', $path;
my @out;
my $is_absolute;
if (@work && $work[0] eq "") {
$is_absolute = 1; shift @work;
}
while (@work) {
my $seg = shift @work;
if ($seg eq "." || $seg eq "") {
}
elsif ($seg eq "..") {
if (@out && $out[-1] ne "..") {
pop @out;
}
else {
# Leading "..", or "../..", etc.
push @out, $seg;
}
}
else {
push @out, $seg;
}
}
unshift @out, "" if $is_absolute;
return join('/', @out);
}
# sub CanonicalizePath {
# my $path = join '/', @_;
# my @work = split '/', $path;
# my @out;
# my $is_absolute;
# if (@work && $work[0] eq "") {
# $is_absolute = 1; shift @work;
# }
# while (@work) {
# my $seg = shift @work;
# if ($seg eq "." || $seg eq "") {
# }
# elsif ($seg eq "..") {
# if (@out && $out[-1] ne "..") {
# pop @out;
# }
# else {
# # Leading "..", or "../..", etc.
# push @out, $seg;
# }
# }
# else {
# push @out, $seg;
# }
# }
# unshift @out, "" if $is_absolute;
# return join('/', @out);
# }
######################################################################
######################################################################
############
......@@ -393,8 +393,8 @@ sub spath {
die "Missing Required paramater 'Old'" unless $params{'Old'};
die "Missing Required paramater 'New'" unless $params{'New'};
my @olddir = split '/', CanonicalizePath $params{'Old'};
my @newdir = split '/', CanonicalizePath $params{'New'};
my @olddir = split '/', `readlink -q -m $params{'Old'}`;
my @newdir = split '/', `readlink -q -m $params{'New'}`;
my @outdir = @olddir;
my $out = '';
......@@ -468,9 +468,6 @@ sub really_reverse_link {
if (test_relative ('Old Dir' => $Old, 'New Dir' => $src_dir,
'Test File' => "$link_name")) {
$Old =~ s|^/*||o;
} elsif ($relative_links) {
$Old = spath('Old' => "$Old", 'New' => "$src_dir" );
}
# Special case is they are in the same dir
my $rel_path = spath('Old' => "$Old", 'New' => "$src_dir" );
......@@ -518,7 +515,7 @@ sub move_p {
if $DEBUG;
my $vmlinuz_target = readlink "$kimage";
my $real_target = '';
my $target = CanonicalizePath("$realimageloc" . "$kimage-$version");
my $target = `readlink -q -m "${realimageloc}${kimage-$version}"`;
$real_target = abs_path($vmlinuz_target) if defined($vmlinuz_target);
if (!defined($vmlinuz_target) || ! -f "$real_target") {
......@@ -538,7 +535,7 @@ sub move_p {
$vmlinuz_target = $cwd . "/" . $vmlinuz_target;
$vmlinuz_target =~ s|/+|/|o;
}
$vmlinuz_target = CanonicalizePath($vmlinuz_target);
$vmlinuz_target = `readlink -q -m $vmlinuz_target`;
if ("$vmlinuz_target" ne "$target") {
warn "DEBUG: We need to handle this.\n" if $DEBUG;
......@@ -555,7 +552,7 @@ sub move_p {
$old_target = $cwd . "/" . $old_target;
$old_target =~ s|/+|/|o;
}
$old_target = CanonicalizePath($old_target);
$old_target = `readlink -q -m $old_target`;
if ("$old_target" ne "$target") {
$force_move = 1;
warn "DEBUG: Old link ($old_target) does not point to us ($target)\n"
......@@ -615,27 +612,24 @@ sub really_move_link {
'Test File' => "$image_name")) {
$Old =~ s|^/*||o;
}
elsif ($relative_links) {
$Old = spath('Old' => "$Old", 'New' => $cwd);
}
# Special case is they are in the same dir
my $rel_path = spath('Old' => "$Old", 'New' => "$cwd" );
$Old ="" if $rel_path =~ m/^\s*$/o;
if ($use_hard_links =~ m/YES/i) {
warn "ln " . $Old . "$image_name " . "$kimage" if $DEBUG;
if (! link($Old . "$image_name", "$kimage")) {
warn "ln ${Old}${image_name} $kimage" if $DEBUG;
if (! link("${Old}${image_name}", "$kimage")) {
rename("$kimage.$$", "$kimage");
die("Failed to link " . $realimageloc .
"$image_name to " . $image_dest . "$kimage .\n");
die("Failed to link ${Old}${image_name} to " .
"${image_dest}${kimage}.\n");
}
}
else {
warn "ln -s " . $Old . "$image_name " . "$kimage" if $DEBUG;
if (! symlink($Old . "$image_name", "$kimage")) {
warn "ln -s ${Old}${image_name} $kimage" if $DEBUG;
if (! symlink("${Old}${image_name}", "$kimage")) {
rename("$kimage.$$", "$kimage");
die("Failed to symbolic-link " . $realimageloc .
"$image_name to " . $image_dest . "$kimage .\n");
die("Failed to symbolic-link ${Old}${image_name} to " .
"${image_dest}${kimage}.\n");
}
}
......@@ -714,42 +708,30 @@ sub handle_missing_link {
}
if (! $no_symlink && $do_symlink =~ /Yes/i) {
if ($reverse_symlink) {
my $Old = $image_dest;
if (test_relative ('Old Dir' => $Old,
'New Dir' => $realimageloc,
'Test File' => "$kimage")) {
$Old =~ s|^/*||o;
} elsif ($relative_links) {
$Old = spath('Old' => "$Old", 'New' => $realimageloc);
}
# Special case is they are in the same dir
my $rel_path = spath('Old' => "$Old", 'New' => "$realimageloc" );
$Old ="" if $rel_path =~ m/^\s*$/o;
my $Old = $realimageloc;
my $New = $image_dest;
my $Name = "$image_name";
my $Link_Dest = "$kimage";
symlink($Old . "$kimage", $realimageloc . "$image_name")
|| die("Failed to symbolic-link " . $realimageloc
. "$image_name to " . $image_dest . "$kimage .\n");
warn "ln -s " . $Old . "$kimage " . $realimageloc . "$image_name" if $DEBUG;
if ($reverse_symlink) {
$Old = $image_dest;
$New = $realimageloc;
$Name = "$kimage";
$Link_Dest = $realimageloc . "$image_name";
}
else {
my $Old = $realimageloc;
if (test_relative ('Old Dir' => $Old,
'New Dir' => $image_dest,
'Test File' => "$image_name")) {
$Old =~ s|^/*||o;
} elsif ($relative_links) {
$Old = spath('Old' => "$Old", 'New' => $image_dest);
}
# Special case is they are in the same dir
my $rel_path = spath('Old' => "$Old", 'New' => "$image_dest" );
$Old ="" if $rel_path =~ m/^\s*$/o;
symlink($Old . "$image_name", "$kimage") ||
die("Failed to symbolic-link " . $realimageloc
. "$image_name to " . $image_dest . "$kimage .\n");
warn "ln -s " . $Old . "$image_name " . "$kimage" if $DEBUG;
if (test_relative ('Old Dir' => $Old,
'New Dir' => $New,
'Test File' => $Name)) {
$Old =~ s|^/*||o;
}
# Special case is they are in the same dir
my $rel_path = spath('Old' => "$Old", 'New' => "$New" );
$Old ="" if $rel_path =~ m/^\s*$/o;
symlink($Old . "$Name", "$Link_Dest") ||
die("Failed to symbolic-link ${Old}$Name to $Link_Dest.\n");
warn "ln -s ${Old}$Name $Link_Dest" if $DEBUG;
}
}
......@@ -804,8 +786,6 @@ sub handle_non_symlinks {
if (test_relative ('Old Dir' => $Old, 'New Dir' => $realimageloc,
'Test File' => "$kimage")) {
$Old =~ s|^/*||o;
} elsif ($relative_links) {
$Old = spath('Old' => "$Old", 'New' => $realimageloc);
}
# Special case is they are in the same dir
my $rel_path = spath('Old' => "$Old", 'New' => "$realimageloc" );
......@@ -838,8 +818,6 @@ sub handle_non_symlinks {
if (test_relative ('Old Dir' => $Old, 'New Dir' => $cwd,
'Test File' => "$image_name")) {
$Old =~ s|^/*||o;
} elsif ($relative_links) {
$Old = spath('Old' => "$Old", 'New' => $cwd);
}
# Special case is they are in the same dir
my $rel_path = spath('Old' => "$Old", 'New' => "$cwd" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment