mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2024-12-22 07:00:28 +00:00
Keep original package order on recreate
This commit is contained in:
parent
0a9ca00905
commit
d984d89ced
@ -137,7 +137,7 @@ sub write_apkbuild {
|
||||
provides => ($provides or ''),
|
||||
replaces => ($replaces or ''),
|
||||
);
|
||||
$repl{source} =~ s/$repl{pkgver}/\$pkgver/g;
|
||||
$repl{source} =~ s/-$repl{pkgver}/-\$pkgver/g;
|
||||
$template =~ s/\[% (.*?) %\]/$repl{$1}/g;
|
||||
|
||||
open my $fh, '>', "APKBUILD" or die;
|
||||
@ -166,7 +166,7 @@ sub parse_deps {
|
||||
next if $module eq 'perl';
|
||||
if (Module::CoreList->is_core($module)) {
|
||||
my $perlver = Module::CoreList->first_release($module);
|
||||
say "$module is part of core perl since $perlver.";
|
||||
say " $module is part of core perl since $perlver.";
|
||||
next;
|
||||
}
|
||||
# map module name to package name
|
||||
@ -259,9 +259,46 @@ EOF
|
||||
close $fh;
|
||||
}
|
||||
|
||||
sub do_depends {
|
||||
sub sort_pkgs_by_orig {
|
||||
my $sort_order = shift;
|
||||
my @array_to_sort = split / /, shift;;
|
||||
|
||||
s/[\t\n\r\f]/ /g for $sort_order; # remove embedded new lines from sort order
|
||||
s/\h+/ /g for $sort_order; # remove embedded spaces from sort order
|
||||
|
||||
my @sort_order = split / /, $sort_order;
|
||||
|
||||
#get order of order by string
|
||||
my $count = 0;
|
||||
my %position_of;
|
||||
$position_of{$_} = $count++ for @sort_order;
|
||||
|
||||
my %sorted; # holds the position of array to sort
|
||||
|
||||
foreach (@array_to_sort) {
|
||||
my $pos = $position_of{$_};
|
||||
if (!defined $pos) {
|
||||
# not found in sort order so add to the end
|
||||
$sorted{$_} = $count;
|
||||
$count++;
|
||||
} else {
|
||||
$sorted{$_} = $pos;
|
||||
}
|
||||
}
|
||||
|
||||
my @tmp; # hold array of sorted in position order
|
||||
|
||||
foreach my $name (sort { $sorted{$a} <=> $sorted{$b} } keys %sorted) {
|
||||
push @tmp, $name;
|
||||
}
|
||||
|
||||
return join(" ", @tmp);
|
||||
}
|
||||
|
||||
sub do_depends {
|
||||
my $oldapkbuild = shift;
|
||||
my $apkbuild = read_apkbuild;
|
||||
|
||||
my $metaprefix = '';
|
||||
if ( exists $apkbuild->{'_realname'} ) {
|
||||
$metaprefix = "src/" . $apkbuild->{'_realname'} . "-" . $apkbuild->{'pkgver'} . "/";
|
||||
@ -306,13 +343,21 @@ sub do_depends {
|
||||
|
||||
my $deps = parse_deps $meta->effective_prereqs->requirements_for('runtime', 'requires');
|
||||
|
||||
if (defined $oldapkbuild->{'depends'}){
|
||||
if (defined $oldapkbuild->{'cpandepends'}) {
|
||||
$oldapkbuild->{'depends'} =~ s/\$cpandepends/$oldapkbuild->{'cpandepends'}/g;
|
||||
}
|
||||
$deps = sort_pkgs_by_orig ($oldapkbuild->{'depends'}, $deps);
|
||||
}
|
||||
|
||||
if ($deps eq '') {
|
||||
$deps = "perl";
|
||||
} else {
|
||||
$deps = "perl " . $deps;
|
||||
}
|
||||
say "CPAN deps: $deps";
|
||||
say "Recommend: " . parse_deps $meta->effective_prereqs->requirements_for('runtime', 'recommends');
|
||||
|
||||
say "CPAN runtime Required: $deps";
|
||||
say "CPAN runtime Recommended: " . parse_deps $meta->effective_prereqs->requirements_for('runtime', 'recommends');
|
||||
|
||||
my $makedeps = parse_deps(
|
||||
$meta->effective_prereqs->requirements_for('configure', 'requires'),
|
||||
@ -325,16 +370,32 @@ sub do_depends {
|
||||
$makedeps = "$makedeps perl-module-build";
|
||||
}
|
||||
|
||||
if (defined $oldapkbuild->{'makedepends'}){
|
||||
if (defined $oldapkbuild->{'cpanmakedepends'}) {
|
||||
$oldapkbuild->{'makedepends'} =~ s/\$cpanmakedepends/$oldapkbuild->{'cpanmakedepends'}/g;
|
||||
}
|
||||
$makedeps = sort_pkgs_by_orig ($oldapkbuild->{'makedepends'}, $makedeps);
|
||||
}
|
||||
|
||||
if ($makedeps eq '') {
|
||||
$makedeps = "perl-dev";
|
||||
} else {
|
||||
$makedeps = "perl-dev " . $makedeps;
|
||||
}
|
||||
|
||||
say "CPAN build deps: $makedeps";
|
||||
say "CPAN requires: " . parse_deps($meta->effective_prereqs->requirements_for('configure', 'requires'), $meta->effective_prereqs->requirements_for('build', 'requires'));
|
||||
say "CPAN recommends: " . parse_deps($meta->effective_prereqs->requirements_for('configure', 'recommends'), $meta->effective_prereqs->requirements_for('build', 'recommends'));
|
||||
say " CPAN build requires: " . parse_deps($meta->effective_prereqs->requirements_for('configure', 'requires'), $meta->effective_prereqs->requirements_for('build', 'requires'));
|
||||
say " CPAN build recommends: " . parse_deps($meta->effective_prereqs->requirements_for('configure', 'recommends'), $meta->effective_prereqs->requirements_for('build', 'recommends'));
|
||||
|
||||
my $checkdeps = parse_deps($meta->effective_prereqs->requirements_for('test', 'requires'), $meta->effective_prereqs->requirements_for('test', 'recommends'));
|
||||
|
||||
if (defined $oldapkbuild->{'checkdepends'}){
|
||||
if (defined $oldapkbuild->{'cpancheckdepends'}) {
|
||||
$oldapkbuild->{'checkdepends'} =~ s/\$cpancheckdepends/$oldapkbuild->{'cpancheckdepends'}/g;
|
||||
}
|
||||
$checkdeps = sort_pkgs_by_orig ($oldapkbuild->{'checkdepends'}, $checkdeps);
|
||||
}
|
||||
|
||||
say "CPAN check deps: $checkdeps";
|
||||
|
||||
my $text = read_file "APKBUILD";
|
||||
@ -487,7 +548,7 @@ given ( $ARGV[0] ) {
|
||||
write_apkbuild($distdata, $apkbuild, $moddata);
|
||||
prepare_tree;
|
||||
update_functions;
|
||||
do_depends;
|
||||
do_depends($apkbuild);
|
||||
}
|
||||
when ("upgrade") {
|
||||
my ($apkbuild, $distdata, $moddata) = get_data;
|
||||
|
Loading…
Reference in New Issue
Block a user