diff options
30 files changed, 265 insertions, 97 deletions
diff --git a/Makefile.PL b/Makefile.PL index 422d5d8..64fcbec 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/docker/sysupdate.sh b/docker/sysupdate.sh index 273adb6..5a8cdc9 100644 --- a/docker/sysupdate.sh +++ b/docker/sysupdate.sh @@ -1,6 +1,6 @@ #!/bin/sh # Update a base Slackware installation so it can be used for building packages -# Copyright (C) 2019 Sergey Poznyakoff +# Copyright (C) 2019-2021 Sergey Poznyakoff # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -17,8 +17,21 @@ set -e +. /etc/os-release + +if [ "$VERSION_CODENAME" = "current" ] || [ "$VERSION" = 15.0 ]; then + echo "Installing coreutils 8.25 to work around a docker bug" + cd /tmp + wget http://pirx.gnu.org.ua/slackware/slackware64-14.2/slackware64/a/coreutils-8.25-x86_64-2.txz + installpkg ./coreutils-8.25-x86_64-2.txz + removepkg $(find /var/log/packages/ -name 'coreutils*' -not -name coreutils-8.25-x86_64-2) + cd /usr/bin + ln -sf mktemp-gnu mktemp + cd / +fi + # Update a list of available packages in /var/lib/slackpkg/pkglist -slackpkg update +yes | slackpkg update # Create a list of installed packages. Each line in the output consists of # three fields: @@ -36,6 +49,7 @@ find /var/log/packages -type f -maxdepth 1 -printf '%f\n' | \ # d - development # e - emacs # l - libraries +# n - network # t - TeX # tcl - Tcl/Tk and related # x - X Window System @@ -43,7 +57,7 @@ find /var/log/packages -type f -maxdepth 1 -printf '%f\n' | \ # above. The fourth contains base name of the package without the archive # suffix (.t[gx]z). awk '/^slackware64/ { - if (match($7, /\/[adeltx]$/) || match($7, /\/ap/) || match($7, /\/tcl/)) + if (match($7, /\/[adelntx]$/) || match($7, /\/ap/) || match($7, /\/tcl/)) print $2,$3,$5,$6}' \ /var/lib/slackpkg/pkglist | \ sort -k1 -k2V > /tmp/available diff --git a/lib/LWP/Protocol/sbo.pm b/lib/LWP/Protocol/sbo.pm index e01b3ea..ffc5ebd 100644 --- a/lib/LWP/Protocol/sbo.pm +++ b/lib/LWP/Protocol/sbo.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/Net/SBo.pm b/lib/Net/SBo.pm index e62df81..6d3d31a 100644 --- a/lib/Net/SBo.pm +++ b/lib/Net/SBo.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -272,7 +272,7 @@ sub get { if ($extract) { $dest .= '/' unless $dest =~ m{/$}; - foreach my $file (tar->get_files) { + foreach my $file ($tar->get_files) { my $name = $file->full_path; if ($name =~ s{^\Q$path\E}{$dest}) { if ($file->extract($name)) { diff --git a/lib/SlackBuild/Archive.pm b/lib/SlackBuild/Archive.pm index e9639b8..a9e92b3 100644 --- a/lib/SlackBuild/Archive.pm +++ b/lib/SlackBuild/Archive.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -32,7 +32,7 @@ sub DESTROY { } sub new { my ($class, $pname) = (shift, shift); - my $self = bless $class->SUPER::new(@_), $class; + my $self = $class->SUPER::new(@_); $self->{_package_name} = $pname; return $self; } diff --git a/lib/SlackBuild/Archive/Extractor.pm b/lib/SlackBuild/Archive/Extractor.pm index 38fb488..9590d08 100644 --- a/lib/SlackBuild/Archive/Extractor.pm +++ b/lib/SlackBuild/Archive/Extractor.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Archive/Extractor/HTTP.pm b/lib/SlackBuild/Archive/Extractor/HTTP.pm index dadcdfc..7f16168 100644 --- a/lib/SlackBuild/Archive/Extractor/HTTP.pm +++ b/lib/SlackBuild/Archive/Extractor/HTTP.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Archive/Extractor/Tar.pm b/lib/SlackBuild/Archive/Extractor/Tar.pm index ae539d7..896bb1f 100644 --- a/lib/SlackBuild/Archive/Extractor/Tar.pm +++ b/lib/SlackBuild/Archive/Extractor/Tar.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Archive/Tar.pm b/lib/SlackBuild/Archive/Tar.pm index 2c01deb..d69c0c5 100644 --- a/lib/SlackBuild/Archive/Tar.pm +++ b/lib/SlackBuild/Archive/Tar.pm @@ -15,20 +15,28 @@ SlackBuild::Archive::Tar - domain-specific API for accessing tar archives =head1 DESCRIPTION -This module provides API for accessing (reading and eventually modifying) +This module provides API for accessing (reading or appending to) slackware package tar archives. It uses GNU tar as the underlying agent. =head1 CONSTRUCTOR $tar = new SlackBuild::Archive::Tar($file); -Creates an object for manipulating tar archive B<$file>. +Creates an object for read-only access to tar archive B<$file>. +The returned object can be used to get the listing of the archive, +and extract files from it (see the B<extract> and B<strip> methods), +but cannot be used to alter the archive content. + + $tar = new SlackBuild::Archive::Tar($file, append => 1); + +Creates an object for reading and appending to tar archive B<$file>. +The returned object cannot be used for extraction. =cut sub new { - my ($class, $filename) = @_; - bless { _filename => $filename }, $class; + my ($class, $filename, %opt) = @_; + bless { _filename => $filename, _append => $opt{append} }, $class; } =head1 METHODS @@ -41,19 +49,44 @@ Returns the archive filename. sub filename { shift->{_filename} } +=head2 is_mode_append + +Returns true if the archive was created for appending. + +=cut + +sub is_mode_append { shift->{_append} } + +my %compressor = ( + gz => 'gzip', + tbz => 'bzip2', + bz2 => 'bzip2', + tlz => 'lzma', + lzma => 'lzma', + txz => 'xz', + xz => 'xz' +); + +sub uncompress { + my ($self) = @_; + unless ($self->{_plaintar}) { + my ($name,undef,$suffix) = + fileparse($self->filename, keys(%compressor)); + my $plaintar = File::Spec->catfile($self->workdir, $name); + my $rc = SlackBuild::Runcap->new( + argv => [ $compressor{$suffix}, '-d', '-c', $self->filename ], + stdout => $plaintar); + if ($rc->success) { + $self->{_plaintar} = $plaintar; + } + } + return $self->{_plaintar}; +} + sub tarcmd { my ($self, @argv) = @_; local $ENV{TAR_OPTIONS}; unshift @argv, '-f', $self->filename; - my %compressor = ( - gz => 'gzip', - tbz => 'bzip2', - bz2 => 'bzip2', - tlz => 'lzma', - lzma => 'lzma', - txz => 'xz', - xz => 'xz' - ); my (undef,undef,$suffix) = fileparse($self->filename, keys(%compressor)); if ($suffix) { unshift @argv, '-I', $compressor{$suffix}; @@ -131,10 +164,11 @@ B<strip> methods. If called with an argument sets the working directory and creates it if it does not exist. Such invocation can happen only once, before any -of the following methods were called: B<workdir>, B<extract>, B<strip>. -If the directory has not been set, a call to B<workdir> (without arguments), -B<extract>, or B<strip> will create a temporary directory which will be -removed when the object is destroyed. +of the following methods were called: B<workdir>, B<extract>, B<strip>, +B<add_file>, B<add_file_content>. +If the directory has not been set, a call to any of these functions +will create a temporary directory which will be removed when the object +is destroyed. =cut @@ -171,6 +205,8 @@ been extracted, any subsequent call to B<extract> is a no-op. sub extract { my $self = shift; + croak "can't extract from ".$self->filename.": archive open for appending" + if $self->is_mode_append; if ($self->extracted) { return $self->workdir; } @@ -244,49 +280,63 @@ sub logger { shift->{_logger} //= Log::Log4perl::get_logger(__PACKAGE__) } =head2 add_file - $tar->add_file($filename); + $tar->add_file($filename, $membername); -Adds file B<$filename> to the archive. This implies extracting the archive. -On success, returns the file descriptor. The caller is supposed to write -the actual content of the file to that descriptor and close it. +Reads the file B<$filename> and adds its content to the archive as the +member <$membername>. The B<$tar> object must have been created with +the B<append =E<gt> 1> option. -On failure, returns false and logs the reason using B<Log::Log4perl>. +The appended member will be owner by root and will have the mode of +0644. + +On success, returns true. On failure, returns false and logs the +reason using B<Log::Log4perl>. =cut sub add_file { - my ($self, $filename) = @_; - $self->extract or return; - my $fullname = File::Spec->catfile($self->workdir, $filename); - open(my $fh, '>', $fullname) - or do { - $self->logger->error("can't create $fullname: $!"); - return; - }; - unless ($self->has_file($filename)) { - push @{$self->{_list}}, $filename; + my ($self, $filename, $membername) = @_; + croak "can't append to ".$self->filename.": archive open for extraction" + unless $self->is_mode_append; + my $tarfile = $self->uncompress or return; + (my $s_name = $filename) =~ s{^/}{}; + $s_name =~ s{([\\/|()\[\]{}^\$\*+?.])}{\\$1}g; + (my $d_name = $membername) =~ s{/}{\\/}g; + my $rc = SlackBuild::Runcap->new( + argv => [ 'tar', '-r', '-f', $tarfile, + '--owner=root:0', '--group=root:0', + "--transform=s/$s_name/$d_name/", + '--mode=644', + $filename ]); + if ($rc->success) { + push @{$self->{_list}}, $membername; + $self->{_sort} = 1; + $self->{_changed} = 1; } - $self->{_changed} = $self->{_sort} = 1; - return $fh; + return $rc->success; } =head2 add_file_content - $tar->add_file($filename, $content); + $tar->add_file($membername, $content); -Adds file B<$filename> with the given B<$content> to the archive. -Returns true on success. +Adds B<$content> to the archive under the name B<$membername>. + +The appended member will be owner by root and will have the mode of +0644. On failure, returns false and logs the reason using B<Log::Log4perl>. =cut sub add_file_content { - my ($self, $filename, $text) = @_; - if (my $fh = $self->add_file($filename)) { - print $fh $text; - close $fh; - } + my ($self, $membername, $text) = @_; + croak "can't append to ".$self->filename.": archive open for extraction" + unless $self->is_mode_append; + my ($fh, $filename) = tempfile(DIR => $self->workdir); + print $fh $text; + close $fh; + return $self->add_file($filename, $membername); } =head2 save @@ -307,12 +357,16 @@ sub save { unless (-w $self->filename) { unlink $self->filename; } - if (my $ret = $self->tarcmd('-c', '-C', $self->workdir, - '--no-recursion', - $self->list)) { + + my ($name,undef,$suffix) = + fileparse($self->filename, keys(%compressor)); + my $rc = SlackBuild::Runcap->new( + argv => [ $compressor{$suffix}, '-c', $self->uncompress ], + stdout => $self->filename); + if ($rc->success) { $self->{_changed} = 0; - return $ret; } + return $rc->success; } sub DESTROY { shift->save } diff --git a/lib/SlackBuild/Base.pm b/lib/SlackBuild/Base.pm index aab2620..e4ec8ec 100644 --- a/lib/SlackBuild/Base.pm +++ b/lib/SlackBuild/Base.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Config.pm b/lib/SlackBuild/Config.pm index 60abb9f..a0fb49e 100644 --- a/lib/SlackBuild/Config.pm +++ b/lib/SlackBuild/Config.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -100,6 +100,8 @@ __DATA__ log = STRING :mandatory log pkg = STRING :mandatory pkg spool = STRING :mandatory spool +[docker] + unconfined = BOOL [lookup] order = STRING [lookup file] diff --git a/lib/SlackBuild/Counter.pm b/lib/SlackBuild/Counter.pm index a827acb..e0ed6b3 100644 --- a/lib/SlackBuild/Counter.pm +++ b/lib/SlackBuild/Counter.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Download.pm b/lib/SlackBuild/Download.pm index 24b1abd..9e09b2e 100644 --- a/lib/SlackBuild/Download.pm +++ b/lib/SlackBuild/Download.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Info.pm b/lib/SlackBuild/Info.pm index 21487bc..2e56a18 100644 --- a/lib/SlackBuild/Info.pm +++ b/lib/SlackBuild/Info.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Pattern.pm b/lib/SlackBuild/Pattern.pm index 21145f4..7164730 100644 --- a/lib/SlackBuild/Pattern.pm +++ b/lib/SlackBuild/Pattern.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Rc.pm b/lib/SlackBuild/Rc.pm index 7a04b8b..868e4f5 100644 --- a/lib/SlackBuild/Rc.pm +++ b/lib/SlackBuild/Rc.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ sub resolve { my ($self, $reg) = @_; my @packages; my @unresolved; - foreach my $pkg (@{$self->builder->prereq}) { + foreach my $pkg (@{$self->builder->prereq_full}) { my %q; if (ref($pkg) eq 'HASH') { %q = %$pkg; diff --git a/lib/SlackBuild/Registry.pm b/lib/SlackBuild/Registry.pm index 9c2f678..42f39cd 100644 --- a/lib/SlackBuild/Registry.pm +++ b/lib/SlackBuild/Registry.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Registry/Backend/FS.pm b/lib/SlackBuild/Registry/Backend/FS.pm index 2fd3346..64d72d4 100644 --- a/lib/SlackBuild/Registry/Backend/FS.pm +++ b/lib/SlackBuild/Registry/Backend/FS.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,6 +21,7 @@ use Carp; use File::Basename; use File::stat; use File::Spec; +use File::Path qw(make_path); use Fcntl ':mode'; use SlackBuild::Registry::Record; @@ -53,6 +54,10 @@ sub new { croak "required parameter dir not present"; } croak "too many arguments" if keys %_; + if (! -d $self->{dir}) { + make_path($self->{dir}, {error => \my $err}); + croak @$err if (@$err); + } $self->scan; return $self; } @@ -62,7 +67,7 @@ my @suffixes = qw(.tgz .txz); sub scan { my $self = shift; my $pat = "*-*-*-*"; - + $self->{ls} = [sort { my $d; if ($d = ($a->package || '') cmp ($b->package || '')) { @@ -90,6 +95,8 @@ sub scan { $rec } (glob File::Spec->catfile($self->{dir}, $pat))]; + return unless @{$self->{ls}}; + $self->{index}{$self->{ls}[0]->package}[0] = 0; my $i; for ($i = 1; $i < @{$self->{ls}}; $i++) { diff --git a/lib/SlackBuild/Registry/Pattern.pm b/lib/SlackBuild/Registry/Pattern.pm index 57646f6..8e9b858 100644 --- a/lib/SlackBuild/Registry/Pattern.pm +++ b/lib/SlackBuild/Registry/Pattern.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Registry/Record.pm b/lib/SlackBuild/Registry/Record.pm index 8803661..1529565 100644 --- a/lib/SlackBuild/Registry/Record.pm +++ b/lib/SlackBuild/Registry/Record.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -55,7 +55,7 @@ my @architectures = qw(i386 x86_64 arm noarch); my $rx = '^(?<pkg>.+)-' . '(?<vpref>[rvV]?)' - . '(?<version>\d+(?:\.\d+)*.*?)' + . '(?<version>(?:hg)?\d+(?:\.\d+)*.*?)' . '-(?<arch>' . regexp_opt(@architectures) . ')' . '-(?<build>\d+)' . '(?:_(?<tag>.+?))?$'; @@ -66,7 +66,7 @@ my $rx = '^(?<pkg>.+)-' =cut -my @suffixes = qw(.tgz .txz); +my @suffixes = qw(.tgz .txz .tbz .tlz); sub split { my ($class, $pkgfilename, %opt) = @_; diff --git a/lib/SlackBuild/Registry/Version.pm b/lib/SlackBuild/Registry/Version.pm index 1801d66..9f6fd7d 100644 --- a/lib/SlackBuild/Registry/Version.pm +++ b/lib/SlackBuild/Registry/Version.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Request.pm b/lib/SlackBuild/Request.pm index ff06513..581d739 100644 --- a/lib/SlackBuild/Request.pm +++ b/lib/SlackBuild/Request.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -143,6 +143,9 @@ my %attributes = ( type => 'ARRAY', strategy => 'merge' }, + build_prereq => { + type => 'ARRAY', + }, rc => { type => 'ARRAY', }, @@ -154,7 +157,13 @@ my %attributes = ( }, strategy => { type => 'HASH' - } + }, + tty => { + type => 'BOOL' + }, + unconfined => { + type => 'BOOL' + }, ); # Values for STRATEGY: @@ -178,6 +187,24 @@ my %generics = ( } } }, + 'BOOL' => { + get => sub { + my ($self, $attr) = @_; + return $self->{$attr}; + }, + set => sub { + my ($self, $attr, $value, $strat) = @_; + unless ($value =~ m/^(false|no?|o(ff|n)|true|y(es)?|[01])$/) { + croak "$attr=$value: not a valid boolean value"; + } + if (defined($self->{$attr}) && defined($strat) + && $strat ne 'overwrite') { + ; # Nothing + } else { + $self->{$attr} = ($value =~ m/^(on|true|y(es)?|1)$/i); + } + } + }, 'HASH' => { get => sub { my ($self, $attr) = @_; diff --git a/lib/SlackBuild/Request/Loader/dir.pm b/lib/SlackBuild/Request/Loader/dir.pm index 6b5dbb4..d4b008a 100644 --- a/lib/SlackBuild/Request/Loader/dir.pm +++ b/lib/SlackBuild/Request/Loader/dir.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -36,7 +36,15 @@ sub Configure { sub Load { my ($class, $reqname) = @_; - foreach my $dir (@PATH) { + my @path; + if (($reqname =~ m{^\.\.?/} || File::Spec->file_name_is_absolute($reqname)) + && -d $reqname) { + push @path, dirname($reqname); + $reqname = basename($reqname); + } else { + @path = @PATH; + } + foreach my $dir (@path) { if (my $file = (glob File::Spec->catfile($dir, $reqname, '*.SlackBuild'))[0]) { my ($package,$path) = fileparse($file, '.SlackBuild'); diff --git a/lib/SlackBuild/Request/Loader/file.pm b/lib/SlackBuild/Request/Loader/file.pm index 21acb05..6db35a0 100644 --- a/lib/SlackBuild/Request/Loader/file.pm +++ b/lib/SlackBuild/Request/Loader/file.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Request/Loader/sbo.pm b/lib/SlackBuild/Request/Loader/sbo.pm index c3f1c78..96c8cc4 100644 --- a/lib/SlackBuild/Request/Loader/sbo.pm +++ b/lib/SlackBuild/Request/Loader/sbo.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/Request/Loader/url.pm b/lib/SlackBuild/Request/Loader/url.pm index d1bd386..39c3952 100644 --- a/lib/SlackBuild/Request/Loader/url.pm +++ b/lib/SlackBuild/Request/Loader/url.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuild/URI.pm b/lib/SlackBuild/URI.pm index 217bedf..7cff193 100644 --- a/lib/SlackBuild/URI.pm +++ b/lib/SlackBuild/URI.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/lib/SlackBuilder.pm b/lib/SlackBuilder.pm index b1fdcdf..31b9571 100644 --- a/lib/SlackBuilder.pm +++ b/lib/SlackBuilder.pm @@ -1,5 +1,5 @@ # This file is part of slackbuilder -# Copyright (C) 2017-2019 Sergey Poznyakoff +# Copyright (C) 2017-2021 Sergey Poznyakoff # # Slackbuilder is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -166,6 +166,46 @@ sub source_uri { shift->request->source_uri } sub prereq { shift->request->prereq || []} sub registry { shift->{_registry} } +sub prereq_full { + my $self = shift; + + my %h; + # Build initial prerequisite hash. + foreach my $r (@{$self->request->prereq || []}) { + if (ref($r) eq 'HASH') { + $h{$r->{package}} = $r; + } else { + $h{$r} = $r; + } + } + + # Apply build prerequisites, if any. + # FIXME: Take into account $br->{arch} as well. + # FIXME: Shouldn't the loop below be part of 'merge' policy in Request.pm? + foreach my $br (@{$self->request->build_prereq || []}) { + if (ref($br) eq 'HASH') { + if (exists($h{$br->{package}})) { + if ($br->{version}) { + my $r = $h{$br->{package}}; + if (ref($r) eq 'HASH') { + if (SlackBuild::Registry::Version->new($r->{version}) < SlackBuild::Registry::Version->new($br->{version})) { + $h{$br->{package}}{version} = $br->{version} + } + } else { + $h{$br->{package}}{version} = { package => $br->{package}, + version => $br->{version} } + } + } + } else { + $h{$br->{package}} = $br; + } + } else { + $h{$br} = $br; + } + } + return [ map { $h{$_} } sort keys %h ] +} + sub environ { my $self = shift; my $env = {%{$self->request->environ // {}}, @@ -206,14 +246,15 @@ sub file { if (-e $dst) { unlink $dst; } |