scripts/feeds: generate index after all feeds are updated
This separates index update from feed update. The result is that all requested feeds are first updated and only then indexed. The reason for this change is to prevent errors being reported and potentially invalid index being generated thanks to cross feeds dependency. The feeds script pulls in default all feeds as they come and on install prefers packages from first feeds (unless special feed is requested). Thus order of feeds in some way specifies preferences. This is handy for downstream distributions as they can simply override any package from upstream feeds by placing their feed before them. This removes need to patch or fork upstream feeds. The problem is that such feed most likely depends in some way also on subsequent feeds. The most likely feeds are 'packages' or 'luci'. The example would be Python package that needs 'python.mk' from 'packages' feed. Ordering custom feed after dependent feeds is sometimes just not possible because of preference requirement described before. The solution is to just first pull all feeds and generate indexes only after that. In the end this ensures that index is generated correctly at first try without any error. In terms of code this removes 'perform_update' argument from 'update_feed' as with index update removal the update is the only action performed in that subroutine. Thus this moves condition to 'update' subroutine. Signed-off-by: Karel Kočí <karel.koci@nic.cz>
This commit is contained in:
parent
902d7e497c
commit
1aa80ce393
@ -756,12 +756,11 @@ sub uninstall {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub update_feed($$$$$)
|
sub update_feed($$$$)
|
||||||
{
|
{
|
||||||
my $type=shift;
|
my $type=shift;
|
||||||
my $name=shift;
|
my $name=shift;
|
||||||
my $src=shift;
|
my $src=shift;
|
||||||
my $perform_update=shift;
|
|
||||||
my $force_update=shift;
|
my $force_update=shift;
|
||||||
my $force_relocate=update_location( $name, "@$src" );
|
my $force_relocate=update_location( $name, "@$src" );
|
||||||
my $rv=0;
|
my $rv=0;
|
||||||
@ -773,28 +772,22 @@ sub update_feed($$$$$)
|
|||||||
warn "Unknown type '$type' in feed $name\n";
|
warn "Unknown type '$type' in feed $name\n";
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
$perform_update and do {
|
|
||||||
my $failed = 1;
|
my $failed = 1;
|
||||||
foreach my $feedsrc (@$src) {
|
foreach my $feedsrc (@$src) {
|
||||||
warn "Updating feed '$name' from '$feedsrc' ...\n";
|
warn "Updating feed '$name' from '$feedsrc' ...\n";
|
||||||
if (update_feed_via($type, $name, $feedsrc, $force_relocate, $force_update) != 0) {
|
if (update_feed_via($type, $name, $feedsrc, $force_relocate, $force_update) != 0) {
|
||||||
if ($force_update) {
|
if ($force_update) {
|
||||||
$rv=1;
|
$rv=1;
|
||||||
$failed=0;
|
$failed=0;
|
||||||
warn "failed, ignore.\n";
|
warn "failed, ignore.\n";
|
||||||
next;
|
next;
|
||||||
}
|
|
||||||
last;
|
|
||||||
}
|
}
|
||||||
$failed = 0;
|
last;
|
||||||
}
|
}
|
||||||
$failed and do {
|
$failed = 0;
|
||||||
warn "failed.\n";
|
}
|
||||||
return 1;
|
$failed and do {
|
||||||
};
|
|
||||||
};
|
|
||||||
warn "Create index file './feeds/$name.index' \n";
|
|
||||||
update_index($name) == 0 or do {
|
|
||||||
warn "failed.\n";
|
warn "failed.\n";
|
||||||
return 1;
|
return 1;
|
||||||
};
|
};
|
||||||
@ -803,45 +796,39 @@ sub update_feed($$$$$)
|
|||||||
|
|
||||||
sub update {
|
sub update {
|
||||||
my %opts;
|
my %opts;
|
||||||
my $feed_name;
|
my %argv_feeds;
|
||||||
my $perform_update=1;
|
|
||||||
my $failed=0;
|
my $failed=0;
|
||||||
|
|
||||||
$ENV{SCAN_COOKIE} = $$;
|
$ENV{SCAN_COOKIE} = $$;
|
||||||
$ENV{OPENWRT_VERBOSE} = 's';
|
$ENV{OPENWRT_VERBOSE} = 's';
|
||||||
|
|
||||||
getopts('ahif', \%opts);
|
getopts('ahif', \%opts);
|
||||||
|
%argv_feeds = map { $_ => 1 } @ARGV;
|
||||||
|
|
||||||
if ($opts{h}) {
|
if ($opts{h}) {
|
||||||
usage();
|
usage();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($opts{i}) {
|
|
||||||
# don't update from (remote) repository
|
|
||||||
# only re-create index information
|
|
||||||
$perform_update=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
-d "feeds" or do {
|
-d "feeds" or do {
|
||||||
mkdir "feeds" or die "Unable to create the feeds directory";
|
mkdir "feeds" or die "Unable to create the feeds directory";
|
||||||
};
|
};
|
||||||
|
|
||||||
if ( ($#ARGV == -1) or $opts{a}) {
|
my @index_feeds;
|
||||||
foreach my $feed (@feeds) {
|
foreach my $feed (@feeds) {
|
||||||
my ($type, $name, $src) = @$feed;
|
my ($type, $name, $src) = @$feed;
|
||||||
update_feed($type, $name, $src, $perform_update, $opts{f}) == 0 or $failed=1;
|
next unless $#ARGV == -1 or $opts{a} or $argv_feeds{$name};
|
||||||
}
|
if (not $opts{i}) {
|
||||||
} else {
|
update_feed($type, $name, $src, $opts{f}) == 0 or $failed=1;
|
||||||
while ($feed_name = shift @ARGV) {
|
|
||||||
foreach my $feed (@feeds) {
|
|
||||||
my ($type, $name, $src) = @$feed;
|
|
||||||
if($feed_name ne $name) {
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
update_feed($type, $name, $src, $perform_update, $opts{f}) == 0 or $failed=1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
push @index_feeds, $name;
|
||||||
|
}
|
||||||
|
foreach my $name (@index_feeds) {
|
||||||
|
warn "Create index file './feeds/$name.index' \n";
|
||||||
|
update_index($name) == 0 or do {
|
||||||
|
warn "failed.\n";
|
||||||
|
$failed=1;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh_config();
|
refresh_config();
|
||||||
|
Loading…
Reference in New Issue
Block a user