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("rm -f ./feeds/$name; ln -s $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;
107 my $file = "./feeds/$feed.index";
112 print "Ignoring feed '$feed' - index missing\n";
115 parse_package_metadata
($file) or return;
119 sub get_installed
() {
120 system("make -s prepare-tmpinfo");
122 parse_package_metadata
("./tmp/.packageinfo");
123 %installed = %package;
131 return unless @substr > 0;
133 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
134 my $pkg = $package{$name};
138 foreach my $substr (@substr) {
140 foreach my $key (qw(name title description)) {
141 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
143 $match or undef $pkgmatch;
147 print "Search results in feed '$feed':\n";
150 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
159 getopt
('r:', \
%opts);
160 foreach my $feed (@feeds) {
161 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
169 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
170 my $pkg = $package{$name};
172 printf "\%-32s\t\%s\n", $pkg->{name
}, $pkg->{title
};
182 getopts
('r:sh', \
%opts);
188 foreach my $feed (@feeds) {
189 printf "\%-32s\tURL: %s\n", $feed->[1], $feed->[2];
193 foreach my $feed (@feeds) {
194 list_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
199 sub install_generic
() {
202 my $path = $pkg->{makefile
};
205 $path =~ s/\/Makefile$//;
207 -d
"./package/feeds" or mkdir "./package/feeds";
208 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
209 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
211 warn "Package is not valid\n";
218 my %install_method = (
219 'src-svn' => \
&install_generic
,
220 'src-cpy' => \
&install_generic
,
221 'src-link' => \
&install_generic
,
222 'src-git' => \
&install_generic
,
227 sub lookup_package
($$) {
231 foreach my $feed ($feed, @feeds) {
232 next unless $feed->[1];
233 next unless $feed{$feed->[1]};
234 $feed{$feed->[1]}->{$package} and return $feed;
239 sub install_package
{
244 $feed = lookup_package
($feed, $name);
246 $installed{$name} and return 0;
247 # TODO: check if it's already installed within ./package directory
248 warn "WARNING: No feed for package '$name' found, maybe it's already part of the standard packages?\n";
252 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
254 $installed{$name} and return 0;
255 # TODO: check if this is an alias package, maybe it's known by another name
256 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
259 my $src = $pkg->{src
};
260 my $type = $feed->[0];
261 $src or $src = $name;
263 # previously installed packages set the runtime package
264 # newly installed packages set the source package
265 $installed{$src} and return 0;
267 # check previously installed packages
268 $installed{$name} and return 0;
269 $installed{$src} = 1;
270 warn "Installing package '$src'\n";
272 $install_method{$type} or do {
273 warn "Unknown installation method: '$type'\n";
277 &{$install_method{$type}}($feed, $pkg) == 0 or do {
282 # install all dependencies
283 foreach my $dep (@
{$pkg->{depends
}}, @
{$pkg->{builddepends
}}) {
286 install_package
($feed, $dep) == 0 or $ret = 1;
295 # workaround for timestamp check
296 system("rm -f tmp/.packageinfo");
300 system("make oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
302 system("make defconfig Config.in >/dev/null 2>/dev/null");
312 getopts
('ap:d:h', \
%opts);
321 foreach my $f (@feeds) {
323 $feed{$f->[1]} = get_feed
($f->[1]);
325 # look up the preferred feed
326 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
330 foreach my $f (@feeds) {
331 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
332 printf "Installing all packages from feed %s.\n", $f->[1];
334 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
335 my $p = $package{$name};
337 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
343 while ($name = shift @ARGV) {
344 install_package
($feed, $name) == 0 or $ret = 1;
348 # workaround for timestamp check
351 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
352 refresh_config
($opts{d
});
363 getopts
('ah', \
%opts);
371 system("rm -rvf ./package/feeds");
375 warn "WARNING: no package to uninstall\n";
379 while ($name = shift @ARGV) {
380 my $pkg = $installed{$name};
382 warn "WARNING: $name not installed\n";
385 $pkg->{src
} and $name = $pkg->{src
};
386 warn "Uninstalling package '$name'\n";
387 system("rm -f ./package/feeds/*/$name");
391 $uninstall and refresh_config
();
395 my %update_method = (
396 'src-svn' => \
&update_svn
,
397 'src-cpy' => \
&update_cpy
,
398 'src-link' => \
&update_link
,
399 'src-git' => \
&update_git
402 sub update_feed
($$$$)
407 my $perform_update=shift;
409 $update_method{$type} or do {
410 warn "Unknown type '$type' in feed $name\n";
413 $perform_update and do {
414 warn "Updating feed '$name' from '$src' ...\n";
415 &{$update_method{$type}}($name, $src) == 0 or do {
420 warn "Create index file './feeds/$name.index' \n";
421 update_index
($name) == 0 or do {
431 my $perform_update=1;
433 $ENV{SCAN_COOKIE
} = $$;
434 $ENV{KBUILD_VERBOSE
} = 99;
436 getopts
('ahi', \
%opts);
444 # don't update from (remote) repository
445 # only re-create index information
450 mkdir "feeds" or die "Unable to create the feeds directory";
453 if ( ($#ARGV == -1) or $opts{a
}) {
454 foreach my $feed (@feeds) {
455 my ($type, $name, $src) = @
$feed;
456 update_feed
($type, $name, $src, $perform_update);
459 while ($feed_name = shift @ARGV) {
460 foreach my $feed (@feeds) {
461 my ($type, $name, $src) = @
$feed;
462 if($feed_name ne $name) {
465 update_feed
($type, $name, $src, $perform_update);
477 Usage: $0 <command> [options]
480 list [options]: List feeds and their content
482 -s : List of feed names and their URL.
483 -r <feedname>: List packages of specified feed.
485 install [options] <package>: Install a package
487 -a : Install all packages from all feeds or from the specified feed using the -p option.
488 -p <feedname>: Prefer this feed when installing packages.
489 -d <y|m|n>: Set default for newly installed packages.
491 search [options] <substring>: Search for a package
493 -r <feedname>: Only search in this feed
495 uninstall -a|<package>: Uninstall a package
497 -a : Uninstalls all packages.
499 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
501 -a : Update all feeds listed within feeds.conf. Otherwise the spezified feeds will be updated.
502 -i : Recreate the index only. No feed update from repository is performed.
504 clean: Remove downloaded/generated files.
512 'update' => \
&update
,
513 'install' => \
&install
,
514 'search' => \
&search
,
515 'uninstall' => \
&uninstall
,
517 system("rm -rf feeds");
521 my $arg = shift @ARGV;
524 foreach my $cmd (keys %commands) {
525 $arg eq $cmd and do {
526 exit(&{$commands{$cmd}}());
This page took 0.163321 seconds and 5 git commands to generate.