5 use lib
"$FindBin::Bin";
11 chdir "$FindBin::Bin/..";
12 $ENV{TOPDIR
}=getcwd
();
22 open FEEDS
, "feeds.conf";
27 my @line = split /\s+/, $_, 3;
31 $line[0] =~ /^src-\w+$/ or $valid = 0;
32 $line[1] =~ /^\w+$/ or $valid = 0;
33 $line[2] =~ /\s/ and $valid = 0;
34 $valid or die "Syntax error in feeds.list, line: $line\n";
36 $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
48 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
49 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
51 system("make -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
52 system("make -s -f include/scan.mk IS_TTY=1 SCAN_TARGET=\"packageinfo\" SCAN_DIR=\"feeds/$name\" SCAN_NAME=\"package\" SCAN_DEPS=\"$ENV{TOPDIR}/include/package*.mk\" SCAN_DEPTH=4 SCAN_EXTRA=\"\" TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
53 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
62 if (-d
"./feeds/$name/.svn" ) {
63 system("(cd \"./feeds/$name\"; svn up)") == 0 or return 1;
65 system("rm -rf \"./feeds/$name\"");
66 system("svn co $src \"./feeds/$name\"") == 0 or return 1;
76 system("mkdir -p ./feeds/$name");
77 system("cp -Rf $src ./feeds");
84 my $src = abs_path
(shift);
86 system("ln -sf $src ./feeds/$name");
95 if (-d
"./feeds/$name/.git" ) {
96 system("GIT_DIR=./feeds/$name/.git git pull") == 0 or return 1;
98 system("rm -rf \"./feeds/$name\"");
99 system("git-clone --depth 1 $src ./feeds/$name") == 0 or return 1;
109 parse_package_metadata
("./feeds/$feed.index") or return;
113 sub get_installed
() {
114 system("make -s prepare-tmpinfo");
116 parse_package_metadata
("./tmp/.packageinfo");
117 %installed = %package;
125 return unless @substr > 0;
127 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
128 my $pkg = $package{$name};
132 foreach my $substr (@substr) {
134 foreach my $key (qw(name title description)) {
135 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
137 $match or undef $pkgmatch;
141 print "Search results in feed '$feed':\n";
144 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
153 getopt
('r:', \
%opts);
154 foreach my $feed (@feeds) {
155 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
163 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
164 my $pkg = $package{$name};
166 printf "\%-32s\t\%s\n", $pkg->{name
}, $pkg->{title
};
176 getopts
('r:sh', \
%opts);
182 foreach my $feed (@feeds) {
183 printf "\%-32s\tURL: %s\n", $feed->[1], $feed->[2];
187 foreach my $feed (@feeds) {
188 list_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
193 sub install_generic
() {
196 my $path = $pkg->{makefile
};
199 $path =~ s/\/Makefile$//;
201 -d
"./package/feeds" or mkdir "./package/feeds";
202 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
203 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
205 warn "Package is not valid\n";
212 my %install_method = (
213 'src-svn' => \
&install_generic
,
214 'src-cpy' => \
&install_generic
,
215 'src-link' => \
&install_generic
,
216 'src-git' => \
&install_generic
,
221 sub lookup_package
($$) {
225 foreach my $feed ($feed, @feeds) {
226 next unless $feed->[1];
227 next unless $feed{$feed->[1]};
228 $feed{$feed->[1]}->{$package} and return $feed;
233 sub install_package
{
238 $feed = lookup_package
($feed, $name);
240 $installed{$name} and return 0;
241 warn "WARNING: No feed for package '$name' found.\n";
245 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
247 $installed{$name} and return 0;
248 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
251 my $src = $pkg->{src
};
252 my $type = $feed->[0];
253 $src or $src = $name;
255 # previously installed packages set the runtime package
256 # newly installed packages set the source package
257 $installed{$src} and return 0;
259 # install all dependencies
260 foreach my $dep (@
{$pkg->{depends
}}) {
263 install_package
($feed, $dep) == 0 or $ret = 1;
266 # check previously installed packages
267 $installed{$name} and return 0;
268 $installed{$src} = 1;
269 warn "Installing package '$src'\n";
271 $install_method{$type} or do {
272 warn "Unknown installation method: '$type'\n";
276 &{$install_method{$type}}($feed, $pkg) == 0 or do {
287 # workaround for timestamp check
288 system("rm -f tmp/.packageinfo");
292 system("make oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
294 system("make defconfig Config.in >/dev/null 2>/dev/null");
304 getopts
('ap:d:h', \
%opts);
313 foreach my $f (@feeds) {
315 $feed{$f->[1]} = get_feed
($f->[1]);
317 # look up the preferred feed
318 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
322 foreach my $f (@feeds) {
323 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
324 printf "Installing all packages from feed %s.\n", $f->[1];
326 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
327 my $p = $package{$name};
329 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
331 warn "WARNING: Package '$name' is not available\n";
337 while ($name = shift @ARGV) {
338 install_package
($feed, $name) == 0 or $ret = 1;
342 # workaround for timestamp check
345 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
346 refresh_config
($opts{d
});
357 getopts
('ah', \
%opts);
365 system("rm -rvf ./package/feeds");
369 warn "WARNING: no package to uninstall\n";
373 while ($name = shift @ARGV) {
374 my $pkg = $installed{$name};
376 warn "WARNING: $name not installed\n";
379 $pkg->{src
} and $name = $pkg->{src
};
380 warn "Uninstalling package '$name'\n";
381 system("rm -f ./package/feeds/*/$name");
385 $uninstall and refresh_config
();
389 my %update_method = (
390 'src-svn' => \
&update_svn
,
391 'src-cpy' => \
&update_cpy
,
392 'src-link' => \
&update_link
,
393 'src-git' => \
&update_git
396 sub update_feed
($$$$)
401 my $perform_update=shift;
403 $update_method{$type} or do {
404 warn "Unknown type '$type' in feed $name\n";
407 $perform_update and do {
408 warn "Updating feed '$name' from '$src' ...\n";
409 &{$update_method{$type}}($name, $src) == 0 or do {
414 warn "Create index file './feeds/$name.index' \n";
415 update_index
($name) == 0 or do {
425 my $perform_update=1;
427 $ENV{SCAN_COOKIE
} = $$;
428 $ENV{KBUILD_VERBOSE
} = 99;
430 getopts
('ahi', \
%opts);
438 # don't update from (remote) repository
439 # only re-create index information
444 mkdir "feeds" or die "Unable to create the feeds directory";
447 if ( ($#ARGV == -1) or $opts{a
}) {
448 foreach my $feed (@feeds) {
449 my ($type, $name, $src) = @
$feed;
450 update_feed
($type, $name, $src, $perform_update);
453 while ($feed_name = shift @ARGV) {
454 foreach my $feed (@feeds) {
455 my ($type, $name, $src) = @
$feed;
456 if($feed_name ne $name) {
459 update_feed
($type, $name, $src, $perform_update);
471 Usage: $0 <command> [options]
474 list [options]: List feeds and their content
476 -s : List of feed names and their URL.
477 -r <feedname>: List packages of specified feed.
479 install [options] <package>: Install a package
481 -a : Install all packages from all feeds or from the specified feed using the -p option.
482 -p <feedname>: Prefer this feed when installing packages.
483 -d <y|m|n>: Set default for newly installed packages.
485 search [options] <substring>: Search for a package
487 -r <feedname>: Only search in this feed
489 uninstall -a|<package>: Uninstall a package
491 -a : Uninstalls all packages.
493 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
495 -a : Update all feeds listed within feeds.conf. Otherwise the spezified feeds will be updated.
496 -i : Recreate the index only. No feed update from repository is performed.
498 clean: Remove downloaded/generated files.
506 'update' => \
&update
,
507 'install' => \
&install
,
508 'search' => \
&search
,
509 'uninstall' => \
&uninstall
,
511 system("rm -rf feeds");
515 my $arg = shift @ARGV;
518 foreach my $cmd (keys %commands) {
519 $arg eq $cmd and do {
520 exit(&{$commands{$cmd}}());
This page took 0.097968 seconds and 5 git commands to generate.