X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Ffeeds;h=4b98d3e7e4942c194d419d2729cdd805bec85194;hb=2eb8739b42c0a37ddddf999667cd60918741cbfe;hp=1b7aab79ccc1d3e9d309a2c16b48f07386ad6c72;hpb=1f489e40842a7afe21b01a4bb4533edb00f31071;p=openwrt%2Fopenwrt.git diff --git a/scripts/feeds b/scripts/feeds index 1b7aab79cc..4b98d3e7e4 100755 --- a/scripts/feeds +++ b/scripts/feeds @@ -10,8 +10,10 @@ use Cwd 'abs_path'; chdir "$FindBin::Bin/.."; $ENV{TOPDIR}=getcwd(); +$ENV{GIT_CONFIG_PARAMETERS}="'core.autocrlf=false'"; +$ENV{GREP_OPTIONS}=""; -my $mk=`which gmake`; # select the right 'make' program +my $mk=`which gmake 2>/dev/null`; # select the right 'make' program chomp($mk); # trim trailing newline $mk or $mk = "make"; # default to 'make' @@ -118,7 +120,8 @@ my %update_method = ( 'src-git' => { 'init' => "git clone --depth 1 '%s' '%s'", 'init_branch' => "git clone --depth 1 --branch '%s' '%s' '%s'", - 'update' => "git pull", + 'init_commit' => "git clone '%s' '%s' && cd '%s' && git checkout -b '%s' '%s' && cd -", + 'update' => "git pull --ff", 'controldir' => ".git", 'revision' => "git show --abbrev-commit HEAD | head -n 1 | cut -d ' ' -f 2 | tr -d '\n'"}, 'src-gitsvn' => { @@ -153,15 +156,20 @@ sub update_feed_via($$$$) { my $localpath = "./feeds/$name"; my $safepath = $localpath; $safepath =~ s/'/'\\''/; - my ($base, $branch) = split(/;/, $src, 2); + my ($base_branch, $branch) = split(/;/, $src, 2); + my ($base_commit, $commit) = split(/\^/, $src, 2); if( $relocate || !$m->{'update'} || !-d "$localpath/$m->{'controldir'}" ) { system("rm -rf '$safepath'"); if ($m->{'init_branch'} and $branch) { - system(sprintf($m->{'init_branch'}, $branch, $base, $safepath)) == 0 or return 1; + 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; } else { system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1; } + } elsif ($m->{'init_commit'} and $commit) { + # in case git hash has been provided don't update the feed } else { system("cd '$safepath'; $m->{'update'}") == 0 or return 1; } @@ -254,11 +262,17 @@ sub list_feed { sub list { my %opts; - getopts('r:d:sh', \%opts); + getopts('r:d:nsh', \%opts); if ($opts{h}) { usage(); return 0; } + if ($opts{n}) { + foreach my $feed (@feeds) { + printf "%s\n", $feed->[1]; + } + return 0; + } if ($opts{s}) { foreach my $feed (@feeds) { my $localpath = "./feeds/$feed->[1]"; @@ -332,16 +346,26 @@ sub lookup_package($$) { return; } +sub is_core_package($) { + my $package = shift; + foreach my $file ("tmp/info/.packageinfo-$package", glob("tmp/info/.packageinfo-*_$package")) { + next unless index($file, "tmp/info/.packageinfo-feeds_"); + return 1 if -s $file; + } + return 0; +} + sub install_package { my $feed = shift; my $name = shift; + my $force = shift; my $ret = 0; $feed = lookup_package($feed, $name); $feed or do { $installed{$name} and return 0; # TODO: check if it's already installed within ./package directory - $feed_src->{$name} or -d "./package/$name" or warn "WARNING: No feed for package '$name' found, maybe it's already part of the standard packages?\n"; + $feed_src->{$name} or is_core_package($name) or warn "WARNING: No feed for package '$name' found, maybe it's already part of the standard packages?\n"; return 0; }; @@ -359,14 +383,26 @@ sub install_package { my $type = $feed->[0]; $src or $src = $name; + # If it's a core package and we don't want to override, just return + !$force and is_core_package($src) and return 0; + # previously installed packages set the runtime package - # newly installed packages set the source package - $installed{$src} and return 0; + # newly installed packages set the source package to 1 + $installed{$src} and $installed{$src} == 1 and return 0; + + # we'll trigger the override only with the 3 conditions below: + # - override is allowed by command line (-f) + # - a package with the same src exists in the core packages list + # - the package previously installed is not from a feed + my $override = 1 if ($force and is_core_package($src) and !$installed{$name}->{feed}); # check previously installed packages - $installed{$name} and return 0; + $installed{$name} and !$override and return 0; $installed{$src} = 1; - warn "Installing package '$src'\n"; + + defined($override) and $override == 1 + and warn "Overriding package '$src'\n" + or warn "Installing package '$src'\n"; $install_method{$type} or do { warn "Unknown installation method: '$type'\n"; @@ -386,7 +422,7 @@ sub install_package { $dep =~ s/^.+://; $dep =~ s/\/.+$//; next unless $dep; - install_package($feed, $dep) == 0 or $ret = 1; + install_package($feed, $dep, 0) == 0 or $ret = 1; } } @@ -413,7 +449,7 @@ sub install { my $feed; my $ret = 0; - getopts('ap:d:h', \%opts); + getopts('ap:d:fh', \%opts); if ($opts{h}) { usage(); @@ -439,7 +475,7 @@ sub install { my $p = $feed_package->{$name}; next if $p->{vdepends}; if( $p->{name} ) { - install_package($feed, $p->{name}) == 0 or $ret = 1; + install_package($feed, $p->{name}, exists($opts{f})) == 0 or $ret = 1; get_feed($f->[1]); } } @@ -447,7 +483,7 @@ sub install { } } else { while ($name = shift @ARGV) { - install_package($feed, $name) == 0 or $ret = 1; + install_package($feed, $name, exists($opts{f})) == 0 or $ret = 1; } } @@ -540,7 +576,7 @@ sub update { my $perform_update=1; $ENV{SCAN_COOKIE} = $$; - $ENV{KBUILD_VERBOSE} = 99; + $ENV{OPENWRT_VERBOSE} = 's'; getopts('ahi', \%opts); @@ -562,7 +598,8 @@ sub update { if ( ($#ARGV == -1) or $opts{a}) { foreach my $feed (@feeds) { my ($type, $name, $src) = @$feed; - update_feed($type, $name, $src, $perform_update); + next unless update_feed($type, $name, $src, $perform_update) == 1; + last; } } else { while ($feed_name = shift @ARGV) { @@ -581,6 +618,22 @@ sub update { return 0; } +sub feed_config() { + foreach my $feed (@feeds) { + my $installed = (-f "feeds/$feed->[1].index"); + + printf "\tconfig FEED_%s\n", $feed->[1]; + printf "\t\tbool \"Enable feed %s\"\n", $feed->[1]; + printf "\t\tdepends on PER_FEED_REPO\n"; + printf "\t\tdefault y\n" if $installed; + printf "\t\thelp\n"; + printf "\t\t Enable the \\\"%s\\\" feed at %s.\n", $feed->[1], $feed->[2][0]; + printf "\n"; + } + + return 0; +} + sub usage() { print < [options] @@ -588,6 +641,7 @@ Usage: $0 [options] Commands: list [options]: List feeds, their content and revisions (if installed) Options: + -n : List of feed names. -s : List of feed names and their URL. -r : List packages of specified feed. -d : Use specified delimiter to distinguish rows (default: spaces) @@ -597,6 +651,7 @@ Commands: -a : Install all packages from all feeds or from the specified feed using the -p option. -p : Prefer this feed when installing packages. -d : Set default for newly installed packages. + -f : Install will be forced even if the package exists in core OpenWrt (override) search [options] : Search for a package Options: @@ -623,6 +678,7 @@ my %commands = ( 'install' => \&install, 'search' => \&search, 'uninstall' => \&uninstall, + 'feed_config' => \&feed_config, 'clean' => sub { system("rm -rf feeds"); }