5 use lib
"$FindBin::Bin";
11 chdir "$FindBin::Bin/..";
12 $ENV{TOPDIR
}=getcwd
();
14 my $mk=`which gmake`; # select the right 'make' program
15 chomp($mk); # trim trailing newline
16 $mk or $mk = "make"; # default to 'make'
26 open FEEDS
, "feeds.conf" or
27 open FEEDS
, "feeds.conf.default" or
28 die "Unable to open feeds configuration";
33 my @line = split /\s+/, $_, 3;
38 $line[0] =~ /^src-\w+$/ or $valid = 0;
39 $line[1] =~ /^\w+$/ or $valid = 0;
40 @src = split /\s+/, $line[2];
41 $valid or die "Syntax error in feeds.list, line: $line\n";
43 $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
46 push @feeds, [$line[0], $line[1], \
@src];
55 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
56 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
58 system("$mk -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
59 system("$mk -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\"");
60 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
69 if (-d
"./feeds/$name/.svn" ) {
70 system("(cd \"./feeds/$name\"; svn up)") == 0 or return 1;
72 system("rm -rf \"./feeds/$name\"");
73 system("svn co $src \"./feeds/$name\"") == 0 or return 1;
83 system("mkdir -p ./feeds/$name");
84 system("cp -Rf $src ./feeds");
91 my $src = abs_path
(shift);
93 system("rm -f ./feeds/$name; ln -s $src ./feeds/$name");
102 if (-d
"./feeds/$name/.git" ) {
103 system("GIT_DIR=./feeds/$name/.git git pull") == 0 or return 1;
105 system("rm -rf \"./feeds/$name\"");
106 system("git clone --depth 1 $src ./feeds/$name") == 0 or return 1;
114 my $file = "./feeds/$feed.index";
119 print "Ignoring feed '$feed' - index missing\n";
122 parse_package_metadata
($file) or return;
126 sub get_installed
() {
127 system("$mk -s prepare-tmpinfo");
129 parse_package_metadata
("./tmp/.packageinfo");
130 %installed = %package;
138 return unless @substr > 0;
140 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
141 my $pkg = $package{$name};
145 foreach my $substr (@substr) {
147 foreach my $key (qw(name title description)) {
148 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
150 $match or undef $pkgmatch;
154 print "Search results in feed '$feed':\n";
157 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
166 getopt
('r:', \
%opts);
167 foreach my $feed (@feeds) {
168 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
176 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
177 my $pkg = $package{$name};
179 printf "\%-32s\t\%s\n", $pkg->{name
}, $pkg->{title
};
189 getopts
('r:sh', \
%opts);
195 foreach my $feed (@feeds) {
196 printf "\%-32s\tURL: %s\n", $feed->[1], join(", ", @
{$feed->[2]});
200 foreach my $feed (@feeds) {
201 list_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
206 sub install_generic
() {
209 my $path = $pkg->{makefile
};
212 $path =~ s/\/Makefile$//;
214 -d
"./package/feeds" or mkdir "./package/feeds";
215 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
216 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
218 warn "Package is not valid\n";
225 my %install_method = (
226 'src-svn' => \
&install_generic
,
227 'src-cpy' => \
&install_generic
,
228 'src-link' => \
&install_generic
,
229 'src-git' => \
&install_generic
,
234 sub lookup_package
($$) {
238 foreach my $feed ($feed, @feeds) {
239 next unless $feed->[1];
240 next unless $feed{$feed->[1]};
241 $feed{$feed->[1]}->{$package} and return $feed;
246 sub install_package
{
251 $feed = lookup_package
($feed, $name);
253 $installed{$name} and return 0;
254 # TODO: check if it's already installed within ./package directory
255 $srcpackage{$name} or -d
"./package/$name" or warn "WARNING: No feed for package '$name' found, maybe it's already part of the standard packages?\n";
259 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
261 $installed{$name} and return 0;
262 # TODO: check if this is an alias package, maybe it's known by another name
263 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
266 my $src = $pkg->{src
};
267 my $type = $feed->[0];
268 $src or $src = $name;
270 # previously installed packages set the runtime package
271 # newly installed packages set the source package
272 $installed{$src} and return 0;
274 # check previously installed packages
275 $installed{$name} and return 0;
276 $installed{$src} = 1;
277 warn "Installing package '$src'\n";
279 $install_method{$type} or do {
280 warn "Unknown installation method: '$type'\n";
284 &{$install_method{$type}}($feed, $pkg) == 0 or do {
289 # install all dependencies
290 foreach my $vpkg (@
{$srcpackage{$src}}, $pkg) {
291 foreach my $dep (@
{$vpkg->{depends
}}, @
{$vpkg->{builddepends
}}) {
296 install_package
($feed, $dep) == 0 or $ret = 1;
306 # workaround for timestamp check
307 system("rm -f tmp/.packageinfo");
311 system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
313 system("$mk defconfig Config.in >/dev/null 2>/dev/null");
323 getopts
('ap:d:h', \
%opts);
332 foreach my $f (@feeds) {
334 $feed{$f->[1]} = get_feed
($f->[1]);
336 # look up the preferred feed
337 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
341 foreach my $f (@feeds) {
342 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
343 printf "Installing all packages from feed %s.\n", $f->[1];
345 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
346 my $p = $package{$name};
348 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
354 while ($name = shift @ARGV) {
355 install_package
($feed, $name) == 0 or $ret = 1;
359 # workaround for timestamp check
362 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
363 refresh_config
($opts{d
});
374 getopts
('ah', \
%opts);
382 system("rm -rvf ./package/feeds");
386 warn "WARNING: no package to uninstall\n";
390 while ($name = shift @ARGV) {
391 my $pkg = $installed{$name};
393 warn "WARNING: $name not installed\n";
396 $pkg->{src
} and $name = $pkg->{src
};
397 warn "Uninstalling package '$name'\n";
398 system("rm -f ./package/feeds/*/$name");
402 $uninstall and refresh_config
();
406 my %update_method = (
407 'src-svn' => \
&update_svn
,
408 'src-cpy' => \
&update_cpy
,
409 'src-link' => \
&update_link
,
410 'src-git' => \
&update_git
413 sub update_feed
($$$$)
418 my $perform_update=shift;
420 $update_method{$type} or do {
421 warn "Unknown type '$type' in feed $name\n";
424 $perform_update and do {
426 foreach my $feedsrc (@
$src) {
427 warn "Updating feed '$name' from '$feedsrc' ...\n";
428 next unless &{$update_method{$type}}($name, $feedsrc) == 0;
437 warn "Create index file './feeds/$name.index' \n";
438 update_index
($name) == 0 or do {
448 my $perform_update=1;
450 $ENV{SCAN_COOKIE
} = $$;
451 $ENV{KBUILD_VERBOSE
} = 99;
453 getopts
('ahi', \
%opts);
461 # don't update from (remote) repository
462 # only re-create index information
467 mkdir "feeds" or die "Unable to create the feeds directory";
470 if ( ($#ARGV == -1) or $opts{a
}) {
471 foreach my $feed (@feeds) {
472 my ($type, $name, $src) = @
$feed;
473 update_feed
($type, $name, $src, $perform_update);
476 while ($feed_name = shift @ARGV) {
477 foreach my $feed (@feeds) {
478 my ($type, $name, $src) = @
$feed;
479 if($feed_name ne $name) {
482 update_feed
($type, $name, $src, $perform_update);
494 Usage: $0 <command> [options]
497 list [options]: List feeds and their content
499 -s : List of feed names and their URL.
500 -r <feedname>: List packages of specified feed.
502 install [options] <package>: Install a package
504 -a : Install all packages from all feeds or from the specified feed using the -p option.
505 -p <feedname>: Prefer this feed when installing packages.
506 -d <y|m|n>: Set default for newly installed packages.
508 search [options] <substring>: Search for a package
510 -r <feedname>: Only search in this feed
512 uninstall -a|<package>: Uninstall a package
514 -a : Uninstalls all packages.
516 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
518 -a : Update all feeds listed within feeds.conf. Otherwise the spezified feeds will be updated.
519 -i : Recreate the index only. No feed update from repository is performed.
521 clean: Remove downloaded/generated files.
529 'update' => \
&update
,
530 'install' => \
&install
,
531 'search' => \
&search
,
532 'uninstall' => \
&uninstall
,
534 system("rm -rf feeds");
538 my $arg = shift @ARGV;
541 foreach my $cmd (keys %commands) {
542 $arg eq $cmd and do {
543 exit(&{$commands{$cmd}}());
This page took 0.092976 seconds and 5 git commands to generate.