2016-04-28 12:34:13 +00:00
|
|
|
#!/usr/bin/env perl
|
2007-09-23 02:39:01 +00:00
|
|
|
use Getopt::Std;
|
|
|
|
use FindBin;
|
|
|
|
use Cwd;
|
|
|
|
use lib "$FindBin::Bin";
|
|
|
|
use metadata;
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2008-01-25 11:33:20 +00:00
|
|
|
use Cwd 'abs_path';
|
2007-09-23 02:39:01 +00:00
|
|
|
|
|
|
|
chdir "$FindBin::Bin/..";
|
2017-02-16 22:02:50 +00:00
|
|
|
$ENV{TOPDIR} //= getcwd();
|
|
|
|
chdir $ENV{TOPDIR};
|
2012-05-08 13:30:54 +00:00
|
|
|
$ENV{GIT_CONFIG_PARAMETERS}="'core.autocrlf=false'";
|
2014-06-30 06:50:22 +00:00
|
|
|
$ENV{GREP_OPTIONS}="";
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2012-06-25 00:27:03 +00:00
|
|
|
my $mk=`which gmake 2>/dev/null`; # select the right 'make' program
|
2008-08-08 21:30:08 +00:00
|
|
|
chomp($mk); # trim trailing newline
|
|
|
|
$mk or $mk = "make"; # default to 'make'
|
|
|
|
|
2009-03-02 17:34:34 +00:00
|
|
|
# check version of make
|
|
|
|
my @mkver = split /\s+/, `$mk -v`, 4;
|
|
|
|
my $valid_mk = 1;
|
|
|
|
$mkver[0] =~ /^GNU/ or $valid_mk = 0;
|
|
|
|
$mkver[1] =~ /^Make/ or $valid_mk = 0;
|
2016-06-15 14:39:26 +00:00
|
|
|
|
|
|
|
my ($mkv1, $mkv2) = split /\./, $mkver[2];
|
|
|
|
($mkv1 >= 4 || ($mkv1 == 3 && $mkv2 >= 81)) or $valid_mk = 0;
|
|
|
|
|
2009-03-02 17:34:34 +00:00
|
|
|
$valid_mk or die "Unsupported version of make found: $mk\n";
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
my @feeds;
|
|
|
|
my %build_packages;
|
|
|
|
my %installed;
|
2018-01-11 17:38:42 +00:00
|
|
|
my %installed_pkg;
|
2015-03-15 11:07:44 +00:00
|
|
|
my %installed_targets;
|
2010-08-26 15:13:42 +00:00
|
|
|
my %feed_cache;
|
|
|
|
|
|
|
|
my $feed_package = {};
|
|
|
|
my $feed_src = {};
|
2015-03-15 11:07:44 +00:00
|
|
|
my $feed_target = {};
|
2018-01-11 17:38:42 +00:00
|
|
|
my $feed_vpackage = {};
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2019-06-05 12:19:11 +00:00
|
|
|
sub parse_file($$);
|
|
|
|
|
|
|
|
sub parse_file($$) {
|
2019-08-28 13:21:35 +00:00
|
|
|
my ($fname, $existing) = @_;
|
2007-09-23 02:39:01 +00:00
|
|
|
my $line = 0;
|
2019-06-05 12:19:11 +00:00
|
|
|
my $fh;
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2019-06-05 12:19:11 +00:00
|
|
|
open $fh, $fname or return undef;
|
|
|
|
while (<$fh>) {
|
2007-09-23 02:39:01 +00:00
|
|
|
chomp;
|
|
|
|
s/#.+$//;
|
2019-06-05 12:19:11 +00:00
|
|
|
$line++;
|
2007-09-23 02:39:01 +00:00
|
|
|
next unless /\S/;
|
2019-08-28 13:21:35 +00:00
|
|
|
|
|
|
|
my ($type, $flags, $name, $urls) = m!^src-(\w+)((?:\s+--\w+(?:=\S+)?)*)\s+(\w+)(?:\s+(\S.*))?$!;
|
|
|
|
unless ($type && $name) {
|
|
|
|
die "Syntax error in $fname, line $line\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($existing->{$name}++) {
|
|
|
|
die "Duplicate feed name '$name' in '$fname' line: $line\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
my @src = defined($urls) ? split /\s+/, $urls : ();
|
|
|
|
push @src, '' if @src == 0;
|
|
|
|
|
|
|
|
my %flags;
|
|
|
|
if (defined $flags) {
|
|
|
|
while ($flags =~ m!\s+--(\w+)(?:=(\S+))?!g) {
|
|
|
|
$flags{$1} = defined($2) ? $2 : 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($type eq "include") {
|
2019-09-02 11:49:21 +00:00
|
|
|
parse_file($urls, $existing) or
|
2019-08-28 13:21:35 +00:00
|
|
|
die "Unable to open included file '$urls'";
|
2019-06-05 12:19:11 +00:00
|
|
|
next;
|
|
|
|
}
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2019-08-28 13:21:35 +00:00
|
|
|
push @feeds, ["src-$type", $name, \@src, \%flags];
|
2007-09-23 02:39:01 +00:00
|
|
|
}
|
2019-06-05 12:19:11 +00:00
|
|
|
close $fh;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub parse_config() {
|
|
|
|
my %name;
|
|
|
|
parse_file("feeds.conf", \%name) or
|
|
|
|
parse_file("feeds.conf.default", \%name) or
|
|
|
|
die "Unable to open feeds configuration";
|
2007-09-23 02:39:01 +00:00
|
|
|
}
|
|
|
|
|
2008-11-07 14:01:22 +00:00
|
|
|
sub update_location($$)
|
|
|
|
{
|
|
|
|
my $name = shift;
|
|
|
|
my $url = shift;
|
|
|
|
my $old_url;
|
|
|
|
|
|
|
|
-d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
|
|
|
|
|
|
|
|
if( open LOC, "< ./feeds/$name.tmp/location" )
|
|
|
|
{
|
|
|
|
chomp($old_url = readline LOC);
|
|
|
|
close LOC;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !$old_url || $old_url ne $url )
|
|
|
|
{
|
|
|
|
if( open LOC, "> ./feeds/$name.tmp/location" )
|
|
|
|
{
|
|
|
|
print LOC $url, "\n";
|
|
|
|
close LOC;
|
|
|
|
}
|
|
|
|
return $old_url ? 1 : 0;
|
|
|
|
}
|
|
|
|
|
2009-03-02 17:34:34 +00:00
|
|
|
return 0;
|
2008-11-07 14:01:22 +00:00
|
|
|
}
|
|
|
|
|
2008-03-18 15:50:29 +00:00
|
|
|
sub update_index($)
|
2008-01-27 15:09:03 +00:00
|
|
|
{
|
2007-09-23 02:39:01 +00:00
|
|
|
my $name = shift;
|
2008-03-18 15:50:29 +00:00
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
-d "./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
|
|
|
|
-d "./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
|
|
|
|
|
2011-10-21 13:03:37 +00:00
|
|
|
system("$mk -s prepare-mk OPENWRT_BUILD= TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
|
2018-07-02 12:23:19 +00:00
|
|
|
system("$mk -s -f include/scan.mk IS_TTY=1 SCAN_TARGET=\"packageinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"package\" SCAN_DEPTH=5 SCAN_EXTRA=\"\" TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
|
|
|
|
system("$mk -s -f include/scan.mk IS_TTY=1 SCAN_TARGET=\"targetinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"target\" SCAN_DEPTH=5 SCAN_EXTRA=\"\" SCAN_MAKEOPTS=\"TARGET_BUILD=1\" TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
|
2007-09-23 02:39:01 +00:00
|
|
|
system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
|
2015-03-15 11:07:34 +00:00
|
|
|
system("ln -sf $name.tmp/.targetinfo ./feeds/$name.targetindex");
|
2007-09-23 02:39:01 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-31 14:52:10 +00:00
|
|
|
my %update_method = (
|
|
|
|
'src-svn' => {
|
2010-07-08 16:15:57 +00:00
|
|
|
'init' => "svn checkout '%s' '%s'",
|
2008-12-31 14:52:10 +00:00
|
|
|
'update' => "svn update",
|
2012-04-24 12:56:18 +00:00
|
|
|
'controldir' => ".svn",
|
|
|
|
'revision' => "svn info | grep 'Revision' | cut -d ' ' -f 2 | tr -d '\n'"},
|
2008-12-31 14:52:10 +00:00
|
|
|
'src-cpy' => {
|
|
|
|
'init' => "cp -Rf '%s' '%s'",
|
2012-04-24 12:56:18 +00:00
|
|
|
'update' => "",
|
|
|
|
'revision' => "echo -n 'local'"},
|
2008-12-31 14:52:10 +00:00
|
|
|
'src-link' => {
|
|
|
|
'init' => "ln -s '%s' '%s'",
|
2012-04-24 12:56:18 +00:00
|
|
|
'update' => "",
|
|
|
|
'revision' => "echo -n 'local'"},
|
2018-07-09 20:00:27 +00:00
|
|
|
'src-dummy' => {
|
|
|
|
'init' => "true '%s' && mkdir '%s'",
|
|
|
|
'update' => "",
|
|
|
|
'revision' => "echo -n 'dummy'"},
|
2008-12-31 14:52:10 +00:00
|
|
|
'src-git' => {
|
2012-04-24 18:19:16 +00:00
|
|
|
'init' => "git clone --depth 1 '%s' '%s'",
|
|
|
|
'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'",
|
2013-09-25 13:02:55 +00:00
|
|
|
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
|
2013-09-02 18:25:10 +00:00
|
|
|
'update' => "git pull --ff",
|
2017-02-14 17:35:57 +00:00
|
|
|
'update_force' => "git pull --ff || (git reset --hard HEAD; git pull --ff; exit 1)",
|
2018-04-25 09:31:48 +00:00
|
|
|
'post_update' => "git submodule update --init --recursive",
|
2012-04-24 12:56:18 +00:00
|
|
|
'controldir' => ".git",
|
2016-11-02 13:36:19 +00:00
|
|
|
'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
|
2015-05-10 15:51:19 +00:00
|
|
|
'src-git-full' => {
|
|
|
|
'init' => "git clone '%s' '%s'",
|
|
|
|
'init_branch' => "git clone --branch '%s' '%s' '%s'",
|
|
|
|
'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -",
|
|
|
|
'update' => "git pull --ff",
|
2017-02-14 17:35:57 +00:00
|
|
|
'update_force' => "git pull --ff || (git reset --hard HEAD; git pull --ff; exit 1)",
|
2018-04-25 09:31:48 +00:00
|
|
|
'post_update' => "git submodule update --init --recursive",
|
2015-05-10 15:51:19 +00:00
|
|
|
'controldir' => ".git",
|
2016-11-02 13:36:19 +00:00
|
|
|
'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
|
2011-05-24 09:30:24 +00:00
|
|
|
'src-gitsvn' => {
|
2012-04-24 12:56:18 +00:00
|
|
|
'init' => "git svn clone -r HEAD '%s' '%s'",
|
|
|
|
'update' => "git svn rebase",
|
|
|
|
'controldir' => ".git",
|
2016-11-02 13:36:19 +00:00
|
|
|
'revision' => "git rev-parse --short HEAD | tr -d '\n'"},
|
2008-12-31 14:52:10 +00:00
|
|
|
'src-bzr' => {
|
|
|
|
'init' => "bzr checkout --lightweight '%s' '%s'",
|
|
|
|
'update' => "bzr update",
|
|
|
|
'controldir' => ".bzr"},
|
|
|
|
'src-hg' => {
|
|
|
|
'init' => "hg clone '%s' '%s'",
|
|
|
|
'update' => "hg pull --update",
|
2010-10-24 12:36:51 +00:00
|
|
|
'controldir' => ".hg"},
|
|
|
|
'src-darcs' => {
|
|
|
|
'init' => "darcs get '%s' '%s'",
|
|
|
|
'update' => "darcs pull -a",
|
|
|
|
'controldir' => "_darcs"},
|
2008-12-31 14:52:10 +00:00
|
|
|
);
|
2008-03-18 15:50:29 +00:00
|
|
|
|
2008-12-31 14:52:10 +00:00
|
|
|
# src-git: pull broken
|
|
|
|
# src-cpy: broken if `basename $src` != $name
|
2008-01-25 11:33:20 +00:00
|
|
|
|
2017-02-14 17:35:57 +00:00
|
|
|
sub update_feed_via($$$$$) {
|
2008-12-31 14:52:10 +00:00
|
|
|
my $type = shift;
|
2008-01-27 15:08:58 +00:00
|
|
|
my $name = shift;
|
|
|
|
my $src = shift;
|
2008-11-07 14:01:22 +00:00
|
|
|
my $relocate = shift;
|
2017-02-14 17:35:57 +00:00
|
|
|
my $force = shift;
|
2015-03-15 11:06:50 +00:00
|
|
|
|
2008-12-31 14:52:10 +00:00
|
|
|
my $m = $update_method{$type};
|
|
|
|
my $localpath = "./feeds/$name";
|
|
|
|
my $safepath = $localpath;
|
|
|
|
$safepath =~ s/'/'\\''/;
|
2013-09-25 13:02:55 +00:00
|
|
|
my ($base_branch, $branch) = split(/;/, $src, 2);
|
|
|
|
my ($base_commit, $commit) = split(/\^/, $src, 2);
|
2008-12-31 14:52:10 +00:00
|
|
|
|
|
|
|
if( $relocate || !$m->{'update'} || !-d "$localpath/$m->{'controldir'}" ) {
|
|
|
|
system("rm -rf '$safepath'");
|
2010-12-06 16:57:25 +00:00
|
|
|
if ($m->{'init_branch'} and $branch) {
|
2013-09-25 13:02:55 +00:00
|
|
|
system(sprintf($m->{'init_branch'}, $branch, $base_branch, $safepath)) == 0 or return 1;
|
|
|
|
} elsif ($m->{'init_commit'} and $commit) {
|
|
|
|
system(sprintf($m->{'init_commit'}, $base_commit, $safepath, $safepath, $commit, $commit)) == 0 or return 1;
|
2010-12-06 16:57:25 +00:00
|
|
|
} else {
|
|
|
|
system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1;
|
|
|
|
}
|
2013-09-25 13:02:55 +00:00
|
|
|
} elsif ($m->{'init_commit'} and $commit) {
|
|
|
|
# in case git hash has been provided don't update the feed
|
2008-01-27 15:09:03 +00:00
|
|
|
} else {
|
2017-02-14 17:35:57 +00:00
|
|
|
my $update_cmd = $m->{'update'};
|
|
|
|
if ($force && exists $m->{'update_force'}) {
|
|
|
|
$update_cmd = $m->{'update_force'};
|
|
|
|
}
|
|
|
|
system("cd '$safepath'; $update_cmd") == 0 or return 1;
|
2008-01-27 15:09:03 +00:00
|
|
|
}
|
2018-04-25 09:31:48 +00:00
|
|
|
if ($m->{'post_update'}) {
|
|
|
|
my $cmd = $m->{'post_update'};
|
|
|
|
system("cd '$safepath'; $cmd") == 0 or return 1;
|
|
|
|
}
|
2015-03-15 11:06:50 +00:00
|
|
|
|
2008-03-18 15:50:29 +00:00
|
|
|
return 0;
|
2008-01-27 15:08:58 +00:00
|
|
|
}
|
|
|
|
|
2015-03-15 11:07:44 +00:00
|
|
|
sub get_targets($) {
|
|
|
|
my $file = shift;
|
|
|
|
my @target = parse_target_metadata($file);
|
|
|
|
my %target;
|
|
|
|
foreach my $target (@target) {
|
|
|
|
$target{$target->{id}} = $target;
|
|
|
|
}
|
|
|
|
return %target
|
|
|
|
}
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
sub get_feed($) {
|
|
|
|
my $feed = shift;
|
|
|
|
|
2010-08-26 15:13:42 +00:00
|
|
|
if (!defined($feed_cache{$feed})) {
|
|
|
|
my $file = "./feeds/$feed.index";
|
2008-04-05 14:32:08 +00:00
|
|
|
|
2010-08-26 15:13:42 +00:00
|
|
|
clear_packages();
|
|
|
|
-f $file or do {
|
|
|
|
print "Ignoring feed '$feed' - index missing\n";
|
|
|
|
return;
|
|
|
|
};
|
|
|
|
parse_package_metadata($file) or return;
|
2015-03-15 11:07:44 +00:00
|
|
|
my %target = get_targets("./feeds/$feed.targetindex");
|
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
$feed_cache{$feed} = [ { %package }, { %srcpackage }, { %target }, { %vpackage } ];
|
2010-08-26 15:13:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$feed_package = $feed_cache{$feed}->[0];
|
|
|
|
$feed_src = $feed_cache{$feed}->[1];
|
2015-03-15 11:07:44 +00:00
|
|
|
$feed_target = $feed_cache{$feed}->[2];
|
2018-01-11 17:38:42 +00:00
|
|
|
$feed_vpackage = $feed_cache{$feed}->[3];
|
2007-09-23 02:39:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub get_installed() {
|
2011-10-21 13:03:37 +00:00
|
|
|
system("$mk -s prepare-tmpinfo OPENWRT_BUILD=");
|
2007-09-23 02:39:01 +00:00
|
|
|
clear_packages();
|
|
|
|
parse_package_metadata("./tmp/.packageinfo");
|
2018-01-11 17:38:42 +00:00
|
|
|
%installed_pkg = %vpackage;
|
|
|
|
%installed = %srcpackage;
|
2015-03-15 11:07:44 +00:00
|
|
|
%installed_targets = get_targets("./tmp/.targetinfo");
|
2007-09-23 02:39:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub search_feed {
|
|
|
|
my $feed = shift;
|
|
|
|
my @substr = @_;
|
|
|
|
my $display;
|
2008-01-25 11:33:20 +00:00
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
return unless @substr > 0;
|
|
|
|
get_feed($feed);
|
2010-08-26 15:13:42 +00:00
|
|
|
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
|
|
|
|
my $pkg = $feed_package->{$name};
|
2007-09-23 02:39:01 +00:00
|
|
|
my $substr;
|
|
|
|
my $pkgmatch = 1;
|
|
|
|
|
|
|
|
foreach my $substr (@substr) {
|
|
|
|
my $match;
|
2009-02-17 03:44:43 +00:00
|
|
|
foreach my $key (qw(name title description src)) {
|
2007-12-07 10:32:48 +00:00
|
|
|
$pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
|
2007-09-23 02:39:01 +00:00
|
|
|
}
|
|
|
|
$match or undef $pkgmatch;
|
|
|
|
};
|
|
|
|
$pkgmatch and do {
|
|
|
|
$display or do {
|
|
|
|
print "Search results in feed '$feed':\n";
|
|
|
|
$display = 1;
|
|
|
|
};
|
|
|
|
printf "\%-25s\t\%s\n", $pkg->{name}, $pkg->{title};
|
|
|
|
};
|
|
|
|
}
|
2015-03-15 11:07:44 +00:00
|
|
|
|
|
|
|
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_target) {
|
|
|
|
my $target = $feed_target->{$name};
|
|
|
|
my $targetmatch = 1;
|
|
|
|
|
|
|
|
foreach my $substr (@substr) {
|
|
|
|
my $match;
|
|
|
|
foreach my $key (qw(id name description)) {
|
|
|
|
$target->{$key} and $substr and $target->{$key} =~ m/$substr/i and $match = 1;
|
|
|
|
}
|
|
|
|
$match or undef $targetmatch;
|
|
|
|
};
|
|
|
|
$targetmatch and do {
|
|
|
|
$display or do {
|
|
|
|
print "Search results in feed '$feed':\n";
|
|
|
|
$display = 1;
|
|
|
|
};
|
|
|
|
printf "TARGET: \%-17s\t\%s\n", $target->{id}, $target->{name};
|
|
|
|
};
|
|
|
|
}
|
2007-09-23 02:39:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub search {
|
|
|
|
my %opts;
|
|
|
|
|
|
|
|
getopt('r:', \%opts);
|
|
|
|
foreach my $feed (@feeds) {
|
|
|
|
search_feed($feed->[1], @ARGV) if (!defined($opts{r}) or $opts{r} eq $feed->[1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-30 09:22:05 +00:00
|
|
|
sub list_feed {
|
|
|
|
my $feed = shift;
|
|
|
|
|
|
|
|
get_feed($feed);
|
2010-08-26 21:40:16 +00:00
|
|
|
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_package) {
|
2010-08-26 15:13:42 +00:00
|
|
|
my $pkg = $feed_package->{$name};
|
2008-01-30 09:22:05 +00:00
|
|
|
if($pkg->{name}) {
|
|
|
|
printf "\%-32s\t\%s\n", $pkg->{name}, $pkg->{title};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-15 11:07:44 +00:00
|
|
|
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_target) {
|
|
|
|
my $target = $feed_target->{$name};
|
|
|
|
if($target->{name}) {
|
|
|
|
printf "TARGET: \%-24s\t\%s\n", $target->{id}, $target->{name};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-30 09:22:05 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub list {
|
|
|
|
my %opts;
|
|
|
|
|
2015-08-23 09:35:46 +00:00
|
|
|
getopts('r:d:nshf', \%opts);
|
2008-01-30 09:22:05 +00:00
|
|
|
if ($opts{h}) {
|
|
|
|
usage();
|
|
|
|
return 0;
|
|
|
|
}
|
2014-08-05 11:24:24 +00:00
|
|
|
if ($opts{n}) {
|
|
|
|
foreach my $feed (@feeds) {
|
|
|
|
printf "%s\n", $feed->[1];
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-01-30 09:22:05 +00:00
|
|
|
if ($opts{s}) {
|
|
|
|
foreach my $feed (@feeds) {
|
2012-04-24 12:56:18 +00:00
|
|
|
my $localpath = "./feeds/$feed->[1]";
|
|
|
|
my $m = $update_method{$feed->[0]};
|
|
|
|
my $revision;
|
2016-11-02 12:59:29 +00:00
|
|
|
if (!-d "$localpath" || !$m->{'revision'}) {
|
2012-04-24 12:56:18 +00:00
|
|
|
$revision = "X";
|
|
|
|
}
|
|
|
|
elsif( $m->{'controldir'} && -d "$localpath/$m->{'controldir'}" ) {
|
|
|
|
$revision = `cd '$localpath'; $m->{'revision'}`;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$revision = "local";
|
|
|
|
}
|
|
|
|
if ($opts{d}) {
|
|
|
|
printf "%s%s%s%s%s%s%s\n", $feed->[1], $opts{d}, $feed->[0], $opts{d}, $revision, $opts{d}, join(", ", @{$feed->[2]});
|
|
|
|
}
|
2015-08-23 09:35:46 +00:00
|
|
|
elsif ($opts{f}) {
|
|
|
|
my $uri = join(", ", @{$feed->[2]});
|
|
|
|
if ($revision ne "local" && $revision ne "X") {
|
|
|
|
$uri =~ s/[;^].*//;
|
|
|
|
$uri .= "^" . $revision;
|
|
|
|
}
|
|
|
|
printf "%s %s %s\n", $feed->[0], $feed->[1], $uri;
|
|
|
|
}
|
2012-04-24 12:56:18 +00:00
|
|
|
else {
|
2016-11-02 14:02:53 +00:00
|
|
|
printf "\%-10s \%-8s \%-8s \%s\n", $feed->[1], $feed->[0], $revision, join(", ", @{$feed->[2]});
|
2012-04-24 12:56:18 +00:00
|
|
|
}
|
2008-01-30 09:22:05 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
foreach my $feed (@feeds) {
|
|
|
|
list_feed($feed->[1], @ARGV) if (!defined($opts{r}) or $opts{r} eq $feed->[1]);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
sub do_install_src($$) {
|
2007-09-23 02:39:01 +00:00
|
|
|
my $feed = shift;
|
2018-01-11 17:38:42 +00:00
|
|
|
my $src = shift;
|
2008-01-27 15:09:03 +00:00
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
my $path = $src->{makefile};
|
|
|
|
if ($path) {
|
2008-01-25 11:33:20 +00:00
|
|
|
$path =~ s/\/Makefile$//;
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2008-01-25 11:33:20 +00:00
|
|
|
-d "./package/feeds" or mkdir "./package/feeds";
|
|
|
|
-d "./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
|
|
|
|
system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
|
|
|
|
} else {
|
|
|
|
warn "Package is not valid\n";
|
|
|
|
return 1;
|
|
|
|
}
|
2008-01-27 15:09:03 +00:00
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-15 11:08:05 +00:00
|
|
|
sub do_install_target($) {
|
|
|
|
my $target = shift;
|
|
|
|
my $path = $target->{makefile};
|
|
|
|
|
|
|
|
if ($path) {
|
|
|
|
$path =~ s/\/Makefile$//;
|
|
|
|
my $name = $path;
|
|
|
|
$name =~ s/.*\///;
|
|
|
|
my $dest = "./target/linux/$name";
|
|
|
|
|
|
|
|
-e $dest and do {
|
|
|
|
warn "Path $dest already exists";
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
|
|
|
system("ln -sf ../../$path ./target/linux/");
|
|
|
|
} else {
|
2015-05-27 15:20:22 +00:00
|
|
|
warn "Target is not valid\n";
|
2015-03-15 11:08:05 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
sub lookup_src($$) {
|
|
|
|
my $feed = shift;
|
|
|
|
my $src = shift;
|
|
|
|
|
|
|
|
foreach my $feed ($feed, @feeds) {
|
|
|
|
next unless $feed->[1];
|
|
|
|
next unless $feed_cache{$feed->[1]};
|
|
|
|
$feed_cache{$feed->[1]}->[1]->{$src} and return $feed;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
sub lookup_package($$) {
|
|
|
|
my $feed = shift;
|
|
|
|
my $package = shift;
|
|
|
|
|
|
|
|
foreach my $feed ($feed, @feeds) {
|
|
|
|
next unless $feed->[1];
|
2015-03-15 11:07:57 +00:00
|
|
|
next unless $feed_cache{$feed->[1]};
|
2018-01-11 17:38:42 +00:00
|
|
|
$feed_cache{$feed->[1]}->[3]->{$package} and return $feed;
|
2007-09-23 02:39:01 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-15 11:08:05 +00:00
|
|
|
sub lookup_target($$) {
|
|
|
|
my $feed = shift;
|
|
|
|
my $target = shift;
|
|
|
|
|
|
|
|
foreach my $feed ($feed, @feeds) {
|
|
|
|
next unless $feed->[1];
|
|
|
|
next unless $feed_cache{$feed->[1]};
|
|
|
|
$feed_cache{$feed->[1]}->[2]->{$target} and return $feed;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
sub is_core_src($) {
|
|
|
|
my $src = shift;
|
|
|
|
foreach my $file ("tmp/info/.packageinfo-$src", glob("tmp/info/.packageinfo-*_$src")) {
|
2013-05-29 18:17:07 +00:00
|
|
|
next unless index($file, "tmp/info/.packageinfo-feeds_");
|
|
|
|
return 1 if -s $file;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-03-15 11:08:05 +00:00
|
|
|
sub install_target {
|
|
|
|
my $feed = shift;
|
|
|
|
my $name = shift;
|
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
$installed_targets{$name} and return 0;
|
|
|
|
|
2015-03-15 11:08:05 +00:00
|
|
|
$feed = $feed_cache{$feed->[1]}->[2];
|
|
|
|
$feed or return 0;
|
|
|
|
|
|
|
|
my $target = $feed->{$name};
|
|
|
|
$target or return 0;
|
|
|
|
|
|
|
|
warn "Installing target '$name'\n";
|
|
|
|
return do_install_target($target);
|
|
|
|
}
|
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
sub install_src {
|
2007-09-23 02:39:01 +00:00
|
|
|
my $feed = shift;
|
|
|
|
my $name = shift;
|
2015-02-09 12:09:23 +00:00
|
|
|
my $force = shift;
|
2007-09-23 02:39:01 +00:00
|
|
|
my $ret = 0;
|
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
$feed = lookup_src($feed, $name);
|
|
|
|
unless ($feed) {
|
2007-09-23 02:39:01 +00:00
|
|
|
$installed{$name} and return 0;
|
2018-01-11 17:38:42 +00:00
|
|
|
$feed_src->{$name} or warn "WARNING: No feed for source package '$name' found\n";
|
2008-03-20 17:08:24 +00:00
|
|
|
return 0;
|
2018-01-11 17:38:42 +00:00
|
|
|
}
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2010-08-26 15:13:47 +00:00
|
|
|
# switch to the metadata for the selected feed
|
2018-01-11 17:38:42 +00:00
|
|
|
get_feed($feed->[1]);
|
|
|
|
my $src = $feed_src->{$name} or return 1;
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2019-08-28 13:21:35 +00:00
|
|
|
# enable force flag if feed src line was declared with --force
|
|
|
|
if (exists($feed->[3]{force})) {
|
|
|
|
$force = 1;
|
|
|
|
}
|
|
|
|
|
2015-02-09 12:09:23 +00:00
|
|
|
# If it's a core package and we don't want to override, just return
|
2018-01-11 17:38:42 +00:00
|
|
|
my $override = 0;
|
|
|
|
if (is_core_src($name)) {
|
|
|
|
return 0 unless $force;
|
|
|
|
$override = 1;
|
|
|
|
}
|
2015-02-09 12:09:23 +00:00
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
if ($installed{$name}) {
|
|
|
|
# newly installed packages set the source package to 1
|
|
|
|
return 0 if ($installed{$name} == 1);
|
|
|
|
return 0 unless ($override);
|
|
|
|
}
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
$installed{$name} = 1;
|
|
|
|
foreach my $pkg (@{$src->{packages}}) {
|
|
|
|
foreach my $vpkg (@{$pkg->{provides}}) {
|
|
|
|
$installed_pkg{$vpkg} = 1;
|
|
|
|
}
|
|
|
|
}
|
2015-02-09 12:09:23 +00:00
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
if ($override) {
|
|
|
|
warn "Overriding core package '$name' with version from $feed->[1]\n";
|
|
|
|
} else {
|
|
|
|
warn "Installing package '$name' from $feed->[1]\n";
|
|
|
|
}
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
do_install_src($feed, $src) == 0 or do {
|
2007-09-23 02:39:01 +00:00
|
|
|
warn "failed.\n";
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
|
2010-08-26 15:13:47 +00:00
|
|
|
# install all dependencies referenced from the source package
|
2018-01-06 13:49:08 +00:00
|
|
|
foreach my $dep (
|
2018-01-11 17:38:42 +00:00
|
|
|
@{$src->{builddepends}},
|
|
|
|
@{$src->{'builddepends/host'}},
|
2018-01-06 13:49:08 +00:00
|
|
|
) {
|
|
|
|
next if $dep =~ /@/;
|
|
|
|
$dep =~ s/^.+://;
|
|
|
|
$dep =~ s/\/.+$//;
|
|
|
|
next unless $dep;
|
2018-01-11 17:38:42 +00:00
|
|
|
install_src($feed, $dep, 0) == 0 or $ret = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach my $pkg (@{$src->{packages}}) {
|
|
|
|
foreach my $dep (@{$pkg->{depends}}) {
|
|
|
|
next if $dep =~ /@/;
|
|
|
|
$dep =~ s/^\+//;
|
|
|
|
$dep =~ s/^.+://;
|
|
|
|
next unless $dep;
|
|
|
|
install_package($feed, $dep, 0) == 0 or $ret = 1;
|
|
|
|
}
|
2008-04-13 22:36:51 +00:00
|
|
|
}
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
2018-01-11 17:38:42 +00:00
|
|
|
sub install_package {
|
|
|
|
my $feed = shift;
|
|
|
|
my $name = shift;
|
|
|
|
my $force = shift;
|
|
|
|
|
|
|
|
$feed = lookup_package($feed, $name);
|
|
|
|
unless ($feed) {
|
|
|
|
$installed_pkg{$name} and return 0;
|
|
|
|
$feed_vpackage->{$name} or warn "WARNING: No feed for package '$name' found\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
# switch to the metadata for the selected feed
|
|
|
|
get_feed($feed->[1]);
|
|
|
|
my $pkg = $feed_vpackage->{$name} or return 1;
|
|
|
|
return install_src($feed, $pkg->[0]{src}{name}, $force);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub install_target_or_package {
|
|
|
|
my $feed = shift;
|
|
|
|
my $name = shift;
|
|
|
|
my $force = shift;
|
|
|
|
|
|
|
|
my $this_feed_target = lookup_target($feed, $name);
|
|
|
|
$this_feed_target and do {
|
|
|
|
return install_target($this_feed_target, $name);
|
|
|
|
};
|
|
|
|
|
|
|
|
my $this_feed_src = lookup_src($feed, $name);
|
2018-01-14 16:07:28 +00:00
|
|
|
$this_feed_src and do {
|
2018-01-11 17:38:42 +00:00
|
|
|
return install_src($this_feed_src, $name, $force);
|
|
|
|
};
|
|
|
|
|
|
|
|
return install_package($feed, $name, $force);
|
|
|
|
}
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
sub refresh_config {
|
|
|
|
my $default = shift;
|
|
|
|
|
2016-07-04 08:43:02 +00:00
|
|
|
# Don't create .config if it doesn't already exist so that making a
|
|
|
|
# config only occurs when the user intends it do (however we do
|
|
|
|
# want to refresh an existing config).
|
|
|
|
return if not (-e '.config');
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
# workaround for timestamp check
|
|
|
|
system("rm -f tmp/.packageinfo");
|
|
|
|
|
2008-01-25 11:33:20 +00:00
|
|
|
# refresh the config
|
2009-03-02 17:34:34 +00:00
|
|
|
if ($default) {
|
2008-08-08 21:30:08 +00:00
|
|
|
system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
|
2008-03-18 15:50:29 +00:00
|
|
|
} else {
|
2008-08-08 21:30:08 +00:00
|
|
|
system("$mk defconfig Config.in >/dev/null 2>/dev/null");
|
2008-03-18 15:50:29 +00:00
|
|
|
}
|
2007-09-23 02:39:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub install {
|
|
|
|
my $name;
|
|
|
|
my %opts;
|
|
|
|
my $feed;
|
|
|
|
my $ret = 0;
|
2008-01-25 11:33:20 +00:00
|
|
|
|
2015-02-09 12:09:23 +00:00
|
|
|
getopts('ap:d:fh', \%opts);
|
2008-03-18 15:50:29 +00:00
|
|
|
|
|
|
|
if ($opts{h}) {
|
|
|
|
usage();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
get_installed();
|
|
|
|
|
|
|
|
foreach my $f (@feeds) {
|
2015-03-15 11:07:57 +00:00
|
|
|
# fetch all feeds
|
|
|
|
get_feed($f->[1]);
|
2007-09-23 02:39:01 +00:00
|
|
|
|
|
|
|
# look up the preferred feed
|
|
|
|
$opts{p} and $f->[1] eq $opts{p} and $feed = $f;
|
|
|
|
}
|
|
|
|
|
2008-01-25 11:33:20 +00:00
|
|
|
if($opts{a}) {
|
|
|
|
foreach my $f (@feeds) {
|
|
|
|
if (!defined($opts{p}) or $opts{p} eq $f->[1]) {
|
|
|
|
printf "Installing all packages from feed %s.\n", $f->[1];
|
|
|
|
get_feed($f->[1]);
|
2018-01-11 17:38:42 +00:00
|
|
|
foreach my $name (sort { lc($a) cmp lc($b) } keys %$feed_src) {
|
|
|
|
install_src($feed, $name, exists($opts{f})) == 0 or $ret = 1;
|
|
|
|
get_feed($f->[1]);
|
2008-01-25 11:33:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while ($name = shift @ARGV) {
|
2018-01-11 17:38:42 +00:00
|
|
|
install_target_or_package($feed, $name, exists($opts{f})) == 0 or $ret = 1;
|
2008-01-25 11:33:20 +00:00
|
|
|
}
|
2007-09-23 02:39:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# workaround for timestamp check
|
2008-01-25 11:33:20 +00:00
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
# set the defaults
|
|
|
|
if ($opts{d} and $opts{d} =~ /^[ymn]$/) {
|
|
|
|
refresh_config($opts{d});
|
|
|
|
}
|
|
|
|
|
|
|
|
return $ret;
|
|
|
|
}
|
|
|
|
|
2015-03-15 11:08:10 +00:00
|
|
|
sub uninstall_target($) {
|
|
|
|
my $dir = shift;
|
|
|
|
my $name = $dir;
|
|
|
|
$name =~ s/.*\///g;
|
|
|
|
|
|
|
|
my $dest = readlink $dir;
|
|
|
|
return unless $dest =~ /..\/..\/feeds/;
|
|
|
|
warn "Uninstalling target '$name'\n";
|
|
|
|
unlink "$dir";
|
|
|
|
}
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
sub uninstall {
|
2008-03-18 15:50:29 +00:00
|
|
|
my %opts;
|
2007-09-23 02:39:01 +00:00
|
|
|
my $name;
|
|
|
|
my $uninstall;
|
|
|
|
|
2008-03-18 15:50:29 +00:00
|
|
|
getopts('ah', \%opts);
|
|
|
|
|
|
|
|
if ($opts{h}) {
|
|
|
|
usage();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($opts{a}) {
|
|
|
|
system("rm -rvf ./package/feeds");
|
2015-03-15 11:08:10 +00:00
|
|
|
foreach my $dir (glob "target/linux/*") {
|
|
|
|
next unless -l $dir;
|
|
|
|
uninstall_target($dir);
|
|
|
|
}
|
2007-09-23 02:39:01 +00:00
|
|
|
$uninstall = 1;
|
|
|
|
} else {
|
2008-03-18 15:50:29 +00:00
|
|
|
if($#ARGV == -1) {
|
|
|
|
warn "WARNING: no package to uninstall\n";
|
|
|
|
return 0;
|
|
|
|
}
|
2007-09-23 02:39:01 +00:00
|
|
|
get_installed();
|
|
|
|
while ($name = shift @ARGV) {
|
2015-03-15 11:08:10 +00:00
|
|
|
my $target = "target/linux/$name";
|
|
|
|
-l "$target" and do {
|
|
|
|
uninstall_target($target);
|
|
|
|
$uninstall = 1;
|
|
|
|
next;
|
|
|
|
};
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
my $pkg = $installed{$name};
|
|
|
|
$pkg or do {
|
|
|
|
warn "WARNING: $name not installed\n";
|
|
|
|
next;
|
|
|
|
};
|
2018-01-06 17:01:25 +00:00
|
|
|
$pkg->{src} and $name = $pkg->{src}{name};
|
2007-09-23 02:39:01 +00:00
|
|
|
warn "Uninstalling package '$name'\n";
|
|
|
|
system("rm -f ./package/feeds/*/$name");
|
|
|
|
$uninstall = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$uninstall and refresh_config();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-14 17:35:57 +00:00
|
|
|
sub update_feed($$$$$)
|
2008-03-18 15:50:29 +00:00
|
|
|
{
|
|
|
|
my $type=shift;
|
|
|
|
my $name=shift;
|
|
|
|
my $src=shift;
|
|
|
|
my $perform_update=shift;
|
2017-02-14 17:35:57 +00:00
|
|
|
my $force_update=shift;
|
2008-11-07 14:01:22 +00:00
|
|
|
my $force_relocate=update_location( $name, "@$src" );
|
2017-02-14 17:35:57 +00:00
|
|
|
my $rv=0;
|
2008-03-18 15:50:29 +00:00
|
|
|
|
2008-11-07 14:01:22 +00:00
|
|
|
if( $force_relocate ) {
|
|
|
|
warn "Source of feed $name has changed, replacing copy\n";
|
|
|
|
}
|
2008-03-18 15:50:29 +00:00
|
|
|
$update_method{$type} or do {
|
|
|
|
warn "Unknown type '$type' in feed $name\n";
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
$perform_update and do {
|
2008-09-27 22:57:58 +00:00
|
|
|
my $failed = 1;
|
|
|
|
foreach my $feedsrc (@$src) {
|
|
|
|
warn "Updating feed '$name' from '$feedsrc' ...\n";
|
2017-02-14 17:35:57 +00:00
|
|
|
if (update_feed_via($type, $name, $feedsrc, $force_relocate, $force_update) != 0) {
|
|
|
|
if ($force_update) {
|
|
|
|
$rv=1;
|
|
|
|
$failed=0;
|
|
|
|
warn "failed, ignore.\n";
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
last;
|
|
|
|
}
|
2008-09-27 22:57:58 +00:00
|
|
|
$failed = 0;
|
|
|
|
}
|
|
|
|
$failed and do {
|
2008-03-18 15:50:29 +00:00
|
|
|
warn "failed.\n";
|
|
|
|
return 1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
warn "Create index file './feeds/$name.index' \n";
|
|
|
|
update_index($name) == 0 or do {
|
|
|
|
warn "failed.\n";
|
|
|
|
return 1;
|
|
|
|
};
|
2017-02-14 17:35:57 +00:00
|
|
|
return $rv;
|
2008-03-18 15:50:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub update {
|
|
|
|
my %opts;
|
|
|
|
my $feed_name;
|
|
|
|
my $perform_update=1;
|
2015-07-14 22:27:39 +00:00
|
|
|
my $failed=0;
|
2008-03-18 15:50:29 +00:00
|
|
|
|
|
|
|
$ENV{SCAN_COOKIE} = $$;
|
2012-04-26 17:53:56 +00:00
|
|
|
$ENV{OPENWRT_VERBOSE} = 's';
|
2008-03-18 15:50:29 +00:00
|
|
|
|
2017-02-14 17:35:57 +00:00
|
|
|
getopts('ahif', \%opts);
|
2008-03-18 15:50:29 +00:00
|
|
|
|
|
|
|
if ($opts{h}) {
|
|
|
|
usage();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($opts{i}) {
|
|
|
|
# don't update from (remote) repository
|
|
|
|
# only re-create index information
|
|
|
|
$perform_update=0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-d "feeds" or do {
|
|
|
|
mkdir "feeds" or die "Unable to create the feeds directory";
|
|
|
|
};
|
|
|
|
|
|
|
|
if ( ($#ARGV == -1) or $opts{a}) {
|
|
|
|
foreach my $feed (@feeds) {
|
|
|
|
my ($type, $name, $src) = @$feed;
|
2017-02-14 17:35:57 +00:00
|
|
|
update_feed($type, $name, $src, $perform_update, $opts{f}) == 0 or $failed=1;
|
2008-03-18 15:50:29 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
while ($feed_name = shift @ARGV) {
|
|
|
|
foreach my $feed (@feeds) {
|
|
|
|
my ($type, $name, $src) = @$feed;
|
|
|
|
if($feed_name ne $name) {
|
|
|
|
next;
|
|
|
|
}
|
2017-02-14 17:35:57 +00:00
|
|
|
update_feed($type, $name, $src, $perform_update, $opts{f}) == 0 or $failed=1;
|
2008-03-18 15:50:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
refresh_config();
|
|
|
|
|
2015-07-14 22:27:39 +00:00
|
|
|
return $failed;
|
2008-03-18 15:50:29 +00:00
|
|
|
}
|
|
|
|
|
2014-08-05 11:24:24 +00:00
|
|
|
sub feed_config() {
|
|
|
|
foreach my $feed (@feeds) {
|
|
|
|
my $installed = (-f "feeds/$feed->[1].index");
|
|
|
|
|
|
|
|
printf "\tconfig FEED_%s\n", $feed->[1];
|
2018-07-09 22:00:01 +00:00
|
|
|
printf "\t\ttristate \"Enable feed %s\"\n", $feed->[1];
|
2014-08-05 11:24:24 +00:00
|
|
|
printf "\t\tdepends on PER_FEED_REPO\n";
|
|
|
|
printf "\t\tdefault y\n" if $installed;
|
|
|
|
printf "\t\thelp\n";
|
2018-07-09 22:00:01 +00:00
|
|
|
printf "\t\t Enable the \\\"%s\\\" feed in opkg distfeeds.conf.\n", $feed->[1];
|
|
|
|
printf "\t\t Say M to add the feed commented out.\n";
|
2014-08-05 11:24:24 +00:00
|
|
|
printf "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
sub usage() {
|
|
|
|
print <<EOF;
|
|
|
|
Usage: $0 <command> [options]
|
|
|
|
|
|
|
|
Commands:
|
2012-04-24 12:56:18 +00:00
|
|
|
list [options]: List feeds, their content and revisions (if installed)
|
2008-01-30 09:22:05 +00:00
|
|
|
Options:
|
2014-08-05 11:24:24 +00:00
|
|
|
-n : List of feed names.
|
2012-04-24 12:56:18 +00:00
|
|
|
-s : List of feed names and their URL.
|
|
|
|
-r <feedname>: List packages of specified feed.
|
|
|
|
-d <delimiter>: Use specified delimiter to distinguish rows (default: spaces)
|
2015-08-23 09:35:46 +00:00
|
|
|
-f : List feeds in feeds.conf compatible format (when using -s).
|
2008-01-30 09:22:05 +00:00
|
|
|
|
2007-09-23 02:39:01 +00:00
|
|
|
install [options] <package>: Install a package
|
|
|
|
Options:
|
2008-01-30 09:22:05 +00:00
|
|
|
-a : Install all packages from all feeds or from the specified feed using the -p option.
|
|
|
|
-p <feedname>: Prefer this feed when installing packages.
|
|
|
|
-d <y|m|n>: Set default for newly installed packages.
|
2015-02-09 12:09:23 +00:00
|
|
|
-f : Install will be forced even if the package exists in core OpenWrt (override)
|
2007-09-23 02:39:01 +00:00
|
|
|
|
|
|
|
search [options] <substring>: Search for a package
|
|
|
|
Options:
|
|
|
|
-r <feedname>: Only search in this feed
|
|
|
|
|
|
|
|
uninstall -a|<package>: Uninstall a package
|
2008-03-18 15:50:29 +00:00
|
|
|
Options:
|
2008-01-30 09:22:05 +00:00
|
|
|
-a : Uninstalls all packages.
|
|
|
|
|
2008-03-18 15:50:29 +00:00
|
|
|
update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
|
|
|
|
Options:
|
2010-10-18 21:43:50 +00:00
|
|
|
-a : Update all feeds listed within feeds.conf. Otherwise the specified feeds will be updated.
|
2008-03-18 15:50:29 +00:00
|
|
|
-i : Recreate the index only. No feed update from repository is performed.
|
2017-02-14 17:35:57 +00:00
|
|
|
-f : Force updating feeds even if there are changed, uncommitted files.
|
2007-09-23 02:39:01 +00:00
|
|
|
|
2008-01-30 09:22:05 +00:00
|
|
|
clean: Remove downloaded/generated files.
|
2007-09-23 02:39:01 +00:00
|
|
|
|
|
|
|
EOF
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
my %commands = (
|
2008-01-30 09:22:05 +00:00
|
|
|
'list' => \&list,
|
2008-03-18 15:50:29 +00:00
|
|
|
'update' => \&update,
|
2007-09-23 02:39:01 +00:00
|
|
|
'install' => \&install,
|
|
|
|
'search' => \&search,
|
|
|
|
'uninstall' => \&uninstall,
|
2014-08-05 11:24:24 +00:00
|
|
|
'feed_config' => \&feed_config,
|
2007-09-23 02:39:01 +00:00
|
|
|
'clean' => sub {
|
2015-05-23 15:29:06 +00:00
|
|
|
system("rm -rf ./feeds ./package/feeds");
|
2007-09-23 02:39:01 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
my $arg = shift @ARGV;
|
|
|
|
$arg or usage();
|
|
|
|
parse_config;
|
|
|
|
foreach my $cmd (keys %commands) {
|
|
|
|
$arg eq $cmd and do {
|
|
|
|
exit(&{$commands{$cmd}}());
|
|
|
|
};
|
|
|
|
}
|
|
|
|
usage();
|