Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions Build.pm
Original file line number Diff line number Diff line change
Expand Up @@ -336,10 +336,9 @@ sub find_config_file {

sub slurp_config_file {
my ($file, $seen) = @_;
local *CONF;
die("$file: $!\n") unless open(CONF, '<', $file);
my @config = <CONF>;
close CONF;
die("$file: $!\n") unless open(my $conffd, '<', $file);
my @config = <$conffd>;
close $conffd;
chomp @config;
if (@config && $config[0] =~ /^#!PrependConfigFile:\s*([^\.\/][^\/]*?)\s*$/) {
my $otherfile = $1;
Expand Down Expand Up @@ -379,10 +378,9 @@ sub read_config {
if (ref($cfile)) {
@config = @$cfile;
} elsif (defined($cfile)) {
local *CONF;
return undef unless open(CONF, '<', $cfile);
@config = <CONF>;
close CONF;
return undef unless open(my $conffd, '<', $cfile);
@config = <$conffd>;
close $conffd;
chomp @config;
}
# create verbatim macro blobs
Expand Down
38 changes: 17 additions & 21 deletions Build/Arch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ sub get_assets {
sub parse {
my ($config, $pkgbuild) = @_;
my $ret;
local *PKG;
if (!open(PKG, '<', $pkgbuild)) {
my $pkgfd;
if (!open($pkgfd, '<', $pkgbuild)) {
$ret->{'error'} = "$pkgbuild: $!";
return $ret;
}
my %vars;
my @ifs;
while (<PKG>) {
while (<$pkgfd>) {
chomp;
next if /^\s*$/;
next if /^\s*#/;
Expand Down Expand Up @@ -127,7 +127,7 @@ sub parse {
my $val = $4;
if ($3) {
while ($val !~ s/\)\s*(?:#.*)?$//s) {
my $nextline = <PKG>;
my $nextline = <$pkgfd>;
last unless defined $nextline;
chomp $nextline;
$val .= ' ' . $nextline;
Expand All @@ -139,7 +139,7 @@ sub parse {
$vars{$var} = [ unquotesplit($val, \%vars) ];
}
}
close PKG;
close $pkgfd;
$ret->{'name'} = $vars{'pkgname'}->[0] if $vars{'pkgname'};
$ret->{'version'} = $vars{'pkgver'}->[0] if $vars{'pkgver'};
$ret->{'deps'} = [];
Expand Down Expand Up @@ -170,21 +170,19 @@ sub parse {

sub islzma {
my ($fn) = @_;
local *F;
return 0 unless open(F, '<', $fn);
return 0 unless open(my $fd, '<', $fn);
my $h;
return 0 unless read(F, $h, 5) == 5;
close F;
return 0 unless read($fd, $h, 5) == 5;
close $fd;
return $h eq "\3757zXZ";
}

sub iszstd {
my ($fn) = @_;
local *F;
return 0 unless open(F, '<', $fn);
return 0 unless open(my $fd, '<', $fn);
my $h;
return 0 unless read(F, $h, 4) == 4;
close F;
return 0 unless read($fd, $h, 4) == 4;
close $fd;
return $h eq "(\265\057\375";
}

Expand Down Expand Up @@ -367,17 +365,15 @@ sub queryinstalled {
my ($root, %opts) = @_;

$root = '' if !defined($root) || $root eq '/';
local *D;
local *F;
opendir(D, "$root/var/lib/pacman/local") || return [];
my @pn = sort(grep {!/^\./} readdir(D));
closedir(D);
opendir(my $dirfd, "$root/var/lib/pacman/local") || return [];
my @pn = sort(grep {!/^\./} readdir($dirfd));
closedir($dirfd);
my @pkgs;
for my $pn (@pn) {
next unless open(F, '<', "$root/var/lib/pacman/local/$pn/desc");
next unless open(my $fd, '<', "$root/var/lib/pacman/local/$pn/desc");
my $data = '';
1 while sysread(F, $data, 8192, length($data));
close F;
1 while sysread($fd, $data, 8192, length($data));
close $fd;
my $d = parserepodata(undef, $data);
next unless defined $d->{'name'};
my $q = {};
Expand Down
8 changes: 4 additions & 4 deletions Build/Collax.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ sub parse {
} elsif (ref($fn) ne "") {
die "Unhandled ref type in collax";
} else {
local *FH;
if (!open(FH, "<", $fn)) {
my $fd;
if (!open($fd, "<", $fn)) {
return {"error" => "$fn: $!"};
}
@bscript = <FH>;
@bscript = <$fd>;
chomp(@bscript);
close(FH);
close($fd);
}

my $ret = {"deps" => []};
Expand Down
7 changes: 3 additions & 4 deletions Build/Deb.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ sub parse {
if (ref($fn) eq 'ARRAY') {
@control = @$fn;
} else {
local *F;
return { 'error' => "$fn: $!" } unless open(F, '<', $fn);
@control = <F>;
close F;
return { 'error' => "$fn: $!" } unless open(my $fd, '<', $fn);
@control = <$fd>;
close $fd;
chomp @control;
}
splice(@control, 0, 3) if @control > 3 && $control[0] =~ /^-----BEGIN/;
Expand Down
7 changes: 3 additions & 4 deletions Build/Docker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ sub gettargetarch {

sub slurp {
my ($fn) = @_;
local *F;
return undef unless open(F, '<', $fn);
return undef unless open(my $fd, '<', $fn);
local $/ = undef; # Perl slurp mode
my $content = <F>;
close F;
my $content = <$fd>;
close $fd;
return $content;
}

Expand Down
18 changes: 8 additions & 10 deletions PBuild/BuildResult.pm
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@ sub read_bininfo {
my ($dir, $withid) = @_;
my $bininfo;
my @bininfo_s;
local *BI;
if (open(BI, '<', "$dir/.bininfo")) {
@bininfo_s = stat(BI);
$bininfo = PBuild::Util::retrieve(\*BI, 1) if @bininfo_s && $bininfo_s[7];
close BI;
if (open(my $bifd, '<', "$dir/.bininfo")) {
@bininfo_s = stat($bifd);
$bininfo = PBuild::Util::retrieve($bifd, 1) if @bininfo_s && $bininfo_s[7];
close $bifd;
if ($bininfo) {
$bininfo->{'.bininfo'} = {'id' => "$bininfo_s[9]/$bininfo_s[7]/$bininfo_s[1]"} if $withid;
return $bininfo;
Expand All @@ -65,13 +64,12 @@ sub read_bininfo {
my $r = {%$d, 'filename' => $file, 'id' => "$s[9]/$s[7]/$s[1]"};
$bininfo->{$file} = $r;
} elsif ($file =~ /[-.]appdata\.xml$/) {
local *F;
open(F, '<', "$dir/$file") || next;
my @s = stat(F);
open(my $fd, '<', "$dir/$file") || next;
my @s = stat($fd);
next unless @s;
my $ctx = Digest::MD5->new;
$ctx->addfile(*F);
close F;
$ctx->addfile($fd);
close $fd;
$bininfo->{$file} = {'md5sum' => $ctx->hexdigest(), 'filename' => $file, 'id' => "$s[9]/$s[7]/$s[1]"};
}
next;
Expand Down
14 changes: 7 additions & 7 deletions PBuild/Checker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -598,10 +598,10 @@ sub check {
my $mylastcheck = $lastcheck->{$packid};
my @meta;
if (!@meta_s || !$mylastcheck || substr($mylastcheck, 96) ne "$meta_s[9]/$meta_s[7]/$meta_s[1]") {
if (open(F, '<', "$dst/_meta")) {
@meta_s = stat F;
@meta = <F>;
close F;
if (open(my $fd, '<', "$dst/_meta")) {
@meta_s = stat $fd;
@meta = <$fd>;
close $fd;
chomp @meta;
$mylastcheck = substr($meta[0], 0, 32);
if (@meta == 2 && $meta[1] =~ /^fake/) {
Expand Down Expand Up @@ -661,9 +661,9 @@ sub check {
goto relsynccheck;
}
# something changed, read in old meta (if not already done)
if (!@meta && open(F, '<', "$dst/_meta")) {
@meta = <F>;
close F;
if (!@meta && open(my $fd, '<', "$dst/_meta")) {
@meta = <$fd>;
close $fd;
chomp @meta;
}
if ($incycle == 1) {
Expand Down
7 changes: 3 additions & 4 deletions PBuild/Container.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,16 @@ sub containerinfo2obsbinlnk {
}
eval { PBuild::Verify::verify_nevraquery($lnk); PBuild::Verify::verify_filename($d->{'file'}) };
return undef if $@;
local *F;
if ($d->{'tar_md5sum'}) {
# this is a normalized container
$lnk->{'hdrmd5'} = $d->{'tar_md5sum'};
$lnk->{'lnk'} = $d->{'file'};
return $lnk;
}
return undef unless open(F, '<', "$dir/$d->{'file'}");
return undef unless open(my $fd, '<', "$dir/$d->{'file'}");
my $ctx = Digest::MD5->new;
$ctx->addfile(*F);
close F;
$ctx->addfile($fd);
close $fd;
$lnk->{'hdrmd5'} = $ctx->hexdigest();
$lnk->{'lnk'} = $d->{'file'};
return $lnk;
Expand Down
12 changes: 6 additions & 6 deletions createdirdeps
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ sub queryfromfilename {
my ($opts, @args) = Build::Options::parse_options($options, @ARGV);

my %old;
if (defined($opts->{'oldfile'}) && open(F, '<', $opts->{'oldfile'})) {
while (<F>) {
if (defined($opts->{'oldfile'}) && open(my $fd, '<', $opts->{'oldfile'})) {
while (<$fd>) {
chomp;
$old{$1} = $_ if /^([PRrCOI]:[^ ]+): /;
}
close F;
close $fd;
}

my %seen;

for my $dir (@args) {
my $cmd = "find $dir -follow -type f \\( -name \"*.rpm\" -o -name \"*.deb\" -o -name \"*.pkg.tar.gz\" -o -name \"*.pkg.tar.xz\" \\) -a ! -name \"*src.rpm\" -printf '\%T@/\%s/\%i \%p\\n'";
open(F, '-|', $cmd) or next;
while (<F>) {
open(my $fd, '-|', $cmd) or next;
while (<$fd>) {
chomp;
next unless /^([\d\.]+\/\d+\/\d+) (.*)$/;
my $id = $1;
Expand Down Expand Up @@ -94,6 +94,6 @@ for my $dir (@args) {
$q->{'location'} = $path;
Build::writedeps(\*STDOUT, $q);
}
close F;
close $fd;
}

12 changes: 6 additions & 6 deletions killchroot
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ my %pids;
my $pid;
my $path;

opendir(D, "/proc") || die("/proc: $!\n");
for $pid (readdir(D)) {
opendir(my $dirfd, "/proc") || die("/proc: $!\n");
for $pid (readdir($dirfd)) {
next unless $pid =~ /^\d+$/;
$path = readlink("/proc/$pid/root");
next unless defined $path;
Expand All @@ -78,7 +78,7 @@ for $pid (readdir(D)) {
$pids{$pid} = 1;
}
}
closedir(D);
closedir($dirfd);

my @pids = sort keys %pids;
exit 0 unless @pids;
Expand All @@ -88,10 +88,10 @@ print "$msg\n" if $msg ne '';
if ($verbose) {
my @pidsv = ();
for $pid (@pids) {
open(F, "</proc/$pid/cmdline");
open(my $fd, "</proc/$pid/cmdline");
my $cmd = '';
sysread(F, $cmd, 128);
close F;
sysread($fd, $cmd, 128);
close $fd;
$cmd =~ s/\0.*//;
#$cmd =~ s/ .*//;
push @pidsv, "$pid($cmd)";
Expand Down
7 changes: 3 additions & 4 deletions order
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ if ($manifest) {
if ($manifest eq '-') {
@p = <STDIN>;
} else {
local *F;
open(F, '<', $manifest) || die("$manifest: $!\n");
@p = <F>;
close F;
open(my $fd, '<', $manifest) || die("$manifest: $!\n");
@p = <$fd>;
close $fd;
}
chomp @p;
}
Expand Down
Loading