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 $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";
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 $vpkg (@
{$srcpackage{$src}}) {
284 foreach my $dep (@
{$vpkg->{depends
}}, @
{$vpkg->{builddepends
}}) {
287 install_package
($feed, $dep) == 0 or $ret = 1;
297 # workaround for timestamp check
298 system("rm -f tmp/.packageinfo");
302 system("make oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
304 system("make defconfig Config.in >/dev/null 2>/dev/null");
314 getopts
('ap:d:h', \
%opts);
323 foreach my $f (@feeds) {
325 $feed{$f->[1]} = get_feed
($f->[1]);
327 # look up the preferred feed
328 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
332 foreach my $f (@feeds) {
333 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
334 printf "Installing all packages from feed %s.\n", $f->[1];
336 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
337 my $p = $package{$name};
339 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
345 while ($name = shift @ARGV) {
346 install_package
($feed, $name) == 0 or $ret = 1;
350 # workaround for timestamp check
353 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
354 refresh_config
($opts{d
});
365 getopts
('ah', \
%opts);
373 system("rm -rvf ./package/feeds");
377 warn "WARNING: no package to uninstall\n";
381 while ($name = shift @ARGV) {
382 my $pkg = $installed{$name};
384 warn "WARNING: $name not installed\n";
387 $pkg->{src
} and $name = $pkg->{src
};
388 warn "Uninstalling package '$name'\n";
389 system("rm -f ./package/feeds/*/$name");
393 $uninstall and refresh_config
();
397 my %update_method = (
398 'src-svn' => \
&update_svn
,
399 'src-cpy' => \
&update_cpy
,
400 'src-link' => \
&update_link
,
401 'src-git' => \
&update_git
404 sub update_feed
($$$$)
409 my $perform_update=shift;
411 $update_method{$type} or do {
412 warn "Unknown type '$type' in feed $name\n";
415 $perform_update and do {
416 warn "Updating feed '$name' from '$src' ...\n";
417 &{$update_method{$type}}($name, $src) == 0 or do {
422 warn "Create index file './feeds/$name.index' \n";
423 update_index
($name) == 0 or do {
433 my $perform_update=1;
435 $ENV{SCAN_COOKIE
} = $$;
436 $ENV{KBUILD_VERBOSE
} = 99;
438 getopts
('ahi', \
%opts);
446 # don't update from (remote) repository
447 # only re-create index information
452 mkdir "feeds" or die "Unable to create the feeds directory";
455 if ( ($#ARGV == -1) or $opts{a
}) {
456 foreach my $feed (@feeds) {
457 my ($type, $name, $src) = @
$feed;
458 update_feed
($type, $name, $src, $perform_update);
461 while ($feed_name = shift @ARGV) {
462 foreach my $feed (@feeds) {
463 my ($type, $name, $src) = @
$feed;
464 if($feed_name ne $name) {
467 update_feed
($type, $name, $src, $perform_update);
479 Usage: $0 <command> [options]
482 list [options]: List feeds and their content
484 -s : List of feed names and their URL.
485 -r <feedname>: List packages of specified feed.
487 install [options] <package>: Install a package
489 -a : Install all packages from all feeds or from the specified feed using the -p option.
490 -p <feedname>: Prefer this feed when installing packages.
491 -d <y|m|n>: Set default for newly installed packages.
493 search [options] <substring>: Search for a package
495 -r <feedname>: Only search in this feed
497 uninstall -a|<package>: Uninstall a package
499 -a : Uninstalls all packages.
501 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
503 -a : Update all feeds listed within feeds.conf. Otherwise the spezified feeds will be updated.
504 -i : Recreate the index only. No feed update from repository is performed.
506 clean: Remove downloaded/generated files.
514 'update' => \
&update
,
515 'install' => \
&install
,
516 'search' => \
&search
,
517 'uninstall' => \
&uninstall
,
519 system("rm -rf feeds");
523 my $arg = shift @ARGV;
526 foreach my $cmd (keys %commands) {
527 $arg eq $cmd and do {
528 exit(&{$commands{$cmd}}());
This page took 0.090305 seconds and 5 git commands to generate.