replace horrible shortcuts with half-decent code (specifically: no longer
hardcode destdir in the first cwd, but instead add it systematically where required) fixes stsp@ issue with got thx aja@ for a bulk check "just in case"
This commit is contained in:
parent
6a6c145dc6
commit
2ba447246c
|
@ -1,5 +1,5 @@
|
|||
#! /usr/bin/perl
|
||||
# $OpenBSD: build-debug-info,v 1.43 2022/04/22 15:51:48 espie Exp $
|
||||
# $OpenBSD: build-debug-info,v 1.44 2022/09/11 08:00:37 espie Exp $
|
||||
# Copyright (c) 2019 Marc Espie <espie@openbsd.org>
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software for any
|
||||
|
@ -65,8 +65,8 @@ sub handle_options
|
|||
{
|
||||
my $s = shift;
|
||||
$s->SUPER::handle_options;
|
||||
$s->{prefix} = "$s->{base}$s->{prefix}";
|
||||
}
|
||||
|
||||
# Most of the heavy lifting is done by visitor methods, as always
|
||||
|
||||
package OpenBSD::PackingElement;
|
||||
|
@ -77,7 +77,7 @@ sub write_debug_info
|
|||
package OpenBSD::PackingElement::PkgPath;
|
||||
sub write_debug_info
|
||||
{
|
||||
my ($self, $fh, $o) = @_;
|
||||
my ($self, $base, $fh, $o) = @_;
|
||||
print $fh "\@", $self->keyword, " debug/", $self->name, "\n";
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ package OpenBSD::PackingElement::Cwd;
|
|||
# is cheap)
|
||||
sub write_debug_info
|
||||
{
|
||||
my ($self, $fh, $o) = @_;
|
||||
my ($self, $base, $fh, $o) = @_;
|
||||
if ($o->{first_cwd}) {
|
||||
$o->{first_cwd} = 0;
|
||||
} else {
|
||||
|
@ -101,13 +101,14 @@ package OpenBSD::PackingElement::FileWithDebugInfo;
|
|||
use File::Basename;
|
||||
sub write_debug_info
|
||||
{
|
||||
my ($self, $fh, $o) = @_;
|
||||
my ($self, $base, $fh, $o) = @_;
|
||||
return if $self->{nodebug};
|
||||
my $s = $self->name;
|
||||
my $dbg = $self->mogrify($s);
|
||||
my $dir = $dbg;
|
||||
$dir =~ s/(\/\.debug\/)[^\/]+/$1/;
|
||||
my $path = $self->fullname;
|
||||
my $path = $base.$self->fullname;
|
||||
my $dbgpath = $base.$self->mogrify($self->fullname);
|
||||
if (-l $path) {
|
||||
# turns out we don't need to do anything, egdb follows symlinks
|
||||
return;
|
||||
|
@ -118,7 +119,7 @@ sub write_debug_info
|
|||
if (!defined $l) {
|
||||
$o->{linkstash}{$k} = $dbg;
|
||||
$self->write_rule($o, $fh, $s, $dbg, $dir,
|
||||
"OBJCOPY_RULE");
|
||||
$path, $dbgpath, "OBJCOPY_RULE");
|
||||
return;
|
||||
}
|
||||
my $ldir = dirname($l)."/";
|
||||
|
@ -134,7 +135,8 @@ sub write_debug_info
|
|||
# TODO missing checks to be certain there's no ambiguity, just
|
||||
# need to write an actual example and verify I can detect it.
|
||||
return if exists $o->{ostash}{$n};
|
||||
$self->write_rule($o, $fh, $l, $n, $dir, "LINK_RULE");
|
||||
$self->write_rule($o, $fh, $l, $n, $dir,
|
||||
$path, $dbgpath, "LINK_RULE");
|
||||
} else {
|
||||
$o->{state}->fatal("Error: #1 does not exist", $path);
|
||||
}
|
||||
|
@ -142,15 +144,15 @@ sub write_debug_info
|
|||
|
||||
sub write_rule
|
||||
{
|
||||
my ($self, $o, $fh, $s, $dbg, $dir, $what) = @_;
|
||||
my ($self, $o, $fh, $s, $dbg, $dir, $p1, $p2, $what) = @_;
|
||||
if (!exists $o->{dirstash}{$dir}) {
|
||||
print $fh $dir, "\n";
|
||||
$o->{dirstash}{$dir} = 1;
|
||||
}
|
||||
print $fh $dbg, "\n";
|
||||
my $mk = $o->{mk};
|
||||
print $mk "all: $o->{prefix}/$dbg\n";
|
||||
print $mk "$o->{prefix}/$dbg: $o->{prefix}/$s\n";
|
||||
print $mk "all: $p2\n";
|
||||
print $mk "$p2: $p1\n";
|
||||
print $mk "\t\@\$\{$what\}\n\n";
|
||||
$o->{ostash}{$dbg} = 1;
|
||||
delete $o->{empty};
|
||||
|
@ -172,21 +174,21 @@ sub write_debug_info
|
|||
package OpenBSD::PackingElement::NoDefaultConflict;
|
||||
sub write_debug_info
|
||||
{
|
||||
my ($self, $fh, $o) = @_;
|
||||
my ($self, $base, $fh, $o) = @_;
|
||||
$self->write($fh);
|
||||
}
|
||||
|
||||
package OpenBSD::PackingElement::IsBranch;
|
||||
sub write_debug_info
|
||||
{
|
||||
my ($self, $fh, $o) = @_;
|
||||
my ($self, $base, $fh, $o) = @_;
|
||||
$self->write($fh);
|
||||
}
|
||||
|
||||
package OpenBSD::PackingElement::Conflict;
|
||||
sub write_debug_info
|
||||
{
|
||||
my ($self, $fh, $o) = @_;
|
||||
my ($self, $base, $fh, $o) = @_;
|
||||
my $m = join('|', map {"debug-$_"} split(/\|/, $self->name));
|
||||
print $fh "\@", $self->keyword, " $m\n";
|
||||
}
|
||||
|
@ -236,7 +238,7 @@ PlistReader->parse_args($self);
|
|||
use File::Basename;
|
||||
$self->{mk} = $state->openfile($state->{pkgdir}."/Makefile.new");
|
||||
print {$self->{mk}} << 'EOPREAMBLE';
|
||||
# Makefile generated by build-debug-info $OpenBSD: build-debug-info,v 1.43 2022/04/22 15:51:48 espie Exp $
|
||||
# Makefile generated by build-debug-info $OpenBSD: build-debug-info,v 1.44 2022/09/11 08:00:37 espie Exp $
|
||||
# No serviceable parts
|
||||
# Intended to run under the stage area after cd ${WRKINST}
|
||||
|
||||
|
@ -267,15 +269,17 @@ EOPREAMBLE
|
|||
# but they will contain the right information
|
||||
$self->{linkstash} = {};
|
||||
$self->{ostash} = {};
|
||||
# XXX we assume all subpackage are under the same destdir (-B option)
|
||||
my $base = $self->{lists}[0]->{state}{base};
|
||||
for my $l (@{$self->{lists}}) {
|
||||
$self->{empty} = 1;
|
||||
$self->{dirstash} = {};
|
||||
$self->{prefix} = $l->{state}{prefix};
|
||||
$self->{prefix} = $base."/".$l->{state}{prefix};
|
||||
my $name = pop @{$l->{base_plists}};
|
||||
$name = $state->{pkgdir}."/".(basename $name);
|
||||
my $fh = $state->openfile($name);
|
||||
$self->{first_cwd} = 1;
|
||||
$l->olist->write_debug_info($fh, $self);
|
||||
$l->olist->write_debug_info($base, $fh, $self);
|
||||
close($fh) or $state->fatal("Can't write plist: #1", $!);
|
||||
$self->warn_if_empty($state, $l);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user