prt-auf: cleaned up the handling of build logs

This commit is contained in:
John McQuah 2022-06-15 17:40:52 -04:00
parent d8bd1bc39f
commit 59ebcc963c

View File

@ -641,9 +641,8 @@ sub deporder {
return @outfile, "MISSING", @missing if ($#missing >= 0);
}
sub up_inst { # returns scalar references to five arrays;
my $type=shift; my @requested=@_; my %EXEMPT; my %WANTED;
my $logfile; my $logdir; my %pdirs;
sub up_inst { # returns scalar references to five arrays
my $type=shift; my @requested=@_; my %EXEMPT; my %WANTED; my %pdirs;
my $PKGMK=$opkg{makecommand}; my $PKGADD=$opkg{addcommand};
my $SUDO="/usr/bin/doas"; my $FAKEROOT="/usr/bin/fakeroot";
@ -659,17 +658,17 @@ sub up_inst { # returns scalar references to five arrays;
@targets = grep { ($V_REPO{$_}) } @targets if ($type eq "grpinst");
# exempt any locked ports from an sysup operation
%EXEMPT = map { $_ => 1 } @LOCKED;
%EXEMPT = map { $_ => 0 } @LOCKED;
%WANTED = map { $_ => 1 } @requested;
if ($action eq "sysup") { @targets = grep {! defined $EXEMPT{$_}} @targets;
if ($action eq "sysup") { @targets = grep {! $EXEMPT{$_}} @targets;
} else {
@targets = grep {(! defined $EXEMPT{$_}) or ($WANTED{$_})} @targets;
@targets = grep {(! $EXEMPT{$_}) or ($WANTED{$_})} @targets;
}
# first determine the directories from which pkgmk must be called,
# the package that will appear after a successful build,
# and where to save the build log.
my %builtpkg; my %mkcmd; my %addcmd; my %status; my %logfile; my %logfh; my %pvars;
my %builtpkg; my %mkcmd; my %addcmd; my %status; my %logfile; my %pvars;
my ($COMPRESSION, $PKG_DIR) = parse_pkgmk_conf();
foreach my $t (@targets) {
$opkg{$t} = $opkg{margs}; $pvars{'%n'}=$t;
@ -684,7 +683,8 @@ sub up_inst { # returns scalar references to five arrays;
if ($olog{write} eq "enabled") {
$logfile{$t} = ($olog{file}) ? $olog{file} : "/var/log/pkgmk/%n.log";
$logfile{$t} =~ s/(%n|%v|%r|%p)/$pvars{$1}/g;
$mkcmd{$t} .= ($olog{mode} eq "append") ? " >>$logfile{$t} 2>&1" : " >$logfile{$t} 2>&1";
$mkcmd{$t} .= ($olog{mode} eq "append") ? " 2>&1 |/usr/bin/tee -a $logfile{$t}"
: " 2>&1 |/usr/bin/tee $logfile{$t}";
}
}
@ -705,14 +705,8 @@ sub up_inst { # returns scalar references to five arrays;
$status{$t} .= ( $?>>8 == 0 ) ? "pre-install ok. " : "pre-install failed. ";
}
($opkg{test} eq "no") ? chdir $pdirs{$t} : print "cd $pdirs{$t}\n";
print "target $t ... waiting for the log to be written\n" if (($opkg{test} eq "no") and ($logfile{$t}));
($opkg{test} eq "no") ? system("$mkcmd{$t}") : print "$mkcmd{$t}\n";
$status{$t} .= ( $?>>8 == 0 ) ? "build ok. " : "build failed. ";
if (($logfile{$t}) and (-r $logfile{$t}) and (-M $logfile{$t} < 0)) {
open (my $tailf, "$logfile{$t}");
while (<$tailf>) { print $_; }
close ($tailf); print "\n";
}
$status{$t} = ( $mkcmd{$t} =~ /skipped/ ) ? "build skipped. " : $status{$t};
if ($status{$t} =~ /build ok/) {
$addcmd{$t} =~ s/ -u / / if (port_diff("utd",$t)<0);
@ -843,6 +837,7 @@ COMMON OPTIONS
-v show version in listing
-vv show version and decription in listing
--path print path to port if appropriate (search, list, depends)
--regex treat search term as a Perl-compatible regular expression
--cache use a cache file
--test do not actually run pkgmk/pkgadd, just print the commands on STDOUT
EOF