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];
51 sub update_location
($$)
57 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
59 if( open LOC
, "< ./feeds/$name.tmp/location" )
61 chomp($old_url = readline LOC
);
65 if( !$old_url || $old_url ne $url )
67 if( open LOC
, "> ./feeds/$name.tmp/location" )
72 return $old_url ?
1 : 0;
82 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
83 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
85 system("$mk -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
86 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\"");
87 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
97 if ( !$relocate && -d
"./feeds/$name/.svn" ) {
98 system("(cd \"./feeds/$name\"; svn up)") == 0 or return 1;
100 system("rm -rf \"./feeds/$name\"");
101 system("svn co $src \"./feeds/$name\"") == 0 or return 1;
107 sub update_cpy
($$$) {
110 my $relocate = shift;
112 $relocate && system("rm -rf \"./feeds/$name\"");
113 system("mkdir -p ./feeds/$name");
114 system("cp -Rf $src ./feeds");
119 sub update_link
($$$) {
121 my $src = abs_path
(shift);
122 my $relocate = shift; # no-op
124 system("rm -f ./feeds/$name; ln -s $src ./feeds/$name");
129 sub update_git
($$$) {
132 my $relocate = shift;
134 if ( !$relocate && -d
"./feeds/$name/.git" ) {
135 system("GIT_DIR=./feeds/$name/.git git pull") == 0 or return 1;
137 system("rm -rf \"./feeds/$name\"");
138 system("git clone --depth 1 $src ./feeds/$name") == 0 or return 1;
146 my $file = "./feeds/$feed.index";
151 print "Ignoring feed '$feed' - index missing\n";
154 parse_package_metadata
($file) or return;
158 sub get_installed
() {
159 system("$mk -s prepare-tmpinfo");
161 parse_package_metadata
("./tmp/.packageinfo");
162 %installed = %package;
170 return unless @substr > 0;
172 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
173 my $pkg = $package{$name};
177 foreach my $substr (@substr) {
179 foreach my $key (qw(name title description)) {
180 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
182 $match or undef $pkgmatch;
186 print "Search results in feed '$feed':\n";
189 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
198 getopt
('r:', \
%opts);
199 foreach my $feed (@feeds) {
200 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
208 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
209 my $pkg = $package{$name};
211 printf "\%-32s\t\%s\n", $pkg->{name
}, $pkg->{title
};
221 getopts
('r:sh', \
%opts);
227 foreach my $feed (@feeds) {
228 printf "\%-32s\tURL: %s\n", $feed->[1], join(", ", @
{$feed->[2]});
232 foreach my $feed (@feeds) {
233 list_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
238 sub install_generic
() {
241 my $path = $pkg->{makefile
};
244 $path =~ s/\/Makefile$//;
246 -d
"./package/feeds" or mkdir "./package/feeds";
247 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
248 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
250 warn "Package is not valid\n";
257 my %install_method = (
258 'src-svn' => \
&install_generic
,
259 'src-cpy' => \
&install_generic
,
260 'src-link' => \
&install_generic
,
261 'src-git' => \
&install_generic
,
266 sub lookup_package
($$) {
270 foreach my $feed ($feed, @feeds) {
271 next unless $feed->[1];
272 next unless $feed{$feed->[1]};
273 $feed{$feed->[1]}->{$package} and return $feed;
278 sub install_package
{
283 $feed = lookup_package
($feed, $name);
285 $installed{$name} and return 0;
286 # TODO: check if it's already installed within ./package directory
287 $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";
291 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
293 $installed{$name} and return 0;
294 # TODO: check if this is an alias package, maybe it's known by another name
295 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
298 my $src = $pkg->{src
};
299 my $type = $feed->[0];
300 $src or $src = $name;
302 # previously installed packages set the runtime package
303 # newly installed packages set the source package
304 $installed{$src} and return 0;
306 # check previously installed packages
307 $installed{$name} and return 0;
308 $installed{$src} = 1;
309 warn "Installing package '$src'\n";
311 $install_method{$type} or do {
312 warn "Unknown installation method: '$type'\n";
316 &{$install_method{$type}}($feed, $pkg) == 0 or do {
321 # install all dependencies
322 foreach my $vpkg (@
{$srcpackage{$src}}, $pkg) {
323 foreach my $dep (@
{$vpkg->{depends
}}, @
{$vpkg->{builddepends
}}) {
328 install_package
($feed, $dep) == 0 or $ret = 1;
338 # workaround for timestamp check
339 system("rm -f tmp/.packageinfo");
343 system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
345 system("$mk defconfig Config.in >/dev/null 2>/dev/null");
355 getopts
('ap:d:h', \
%opts);
364 foreach my $f (@feeds) {
366 $feed{$f->[1]} = get_feed
($f->[1]);
368 # look up the preferred feed
369 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
373 foreach my $f (@feeds) {
374 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
375 printf "Installing all packages from feed %s.\n", $f->[1];
377 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
378 my $p = $package{$name};
380 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
386 while ($name = shift @ARGV) {
387 install_package
($feed, $name) == 0 or $ret = 1;
391 # workaround for timestamp check
394 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
395 refresh_config
($opts{d
});
406 getopts
('ah', \
%opts);
414 system("rm -rvf ./package/feeds");
418 warn "WARNING: no package to uninstall\n";
422 while ($name = shift @ARGV) {
423 my $pkg = $installed{$name};
425 warn "WARNING: $name not installed\n";
428 $pkg->{src
} and $name = $pkg->{src
};
429 warn "Uninstalling package '$name'\n";
430 system("rm -f ./package/feeds/*/$name");
434 $uninstall and refresh_config
();
438 my %update_method = (
439 'src-svn' => \
&update_svn
,
440 'src-cpy' => \
&update_cpy
,
441 'src-link' => \
&update_link
,
442 'src-git' => \
&update_git
445 sub update_feed
($$$$)
450 my $perform_update=shift;
451 my $force_relocate=update_location
( $name, "@$src" );
453 if( $force_relocate ) {
454 warn "Source of feed $name has changed, replacing copy\n";
456 $update_method{$type} or do {
457 warn "Unknown type '$type' in feed $name\n";
460 $perform_update and do {
462 foreach my $feedsrc (@
$src) {
463 warn "Updating feed '$name' from '$feedsrc' ...\n";
464 next unless &{$update_method{$type}}($name, $feedsrc, $force_relocate) == 0;
473 warn "Create index file './feeds/$name.index' \n";
474 update_index
($name) == 0 or do {
484 my $perform_update=1;
486 $ENV{SCAN_COOKIE
} = $$;
487 $ENV{KBUILD_VERBOSE
} = 99;
489 getopts
('ahi', \
%opts);
497 # don't update from (remote) repository
498 # only re-create index information
503 mkdir "feeds" or die "Unable to create the feeds directory";
506 if ( ($#ARGV == -1) or $opts{a
}) {
507 foreach my $feed (@feeds) {
508 my ($type, $name, $src) = @
$feed;
509 update_feed
($type, $name, $src, $perform_update);
512 while ($feed_name = shift @ARGV) {
513 foreach my $feed (@feeds) {
514 my ($type, $name, $src) = @
$feed;
515 if($feed_name ne $name) {
518 update_feed
($type, $name, $src, $perform_update);
530 Usage: $0 <command> [options]
533 list [options]: List feeds and their content
535 -s : List of feed names and their URL.
536 -r <feedname>: List packages of specified feed.
538 install [options] <package>: Install a package
540 -a : Install all packages from all feeds or from the specified feed using the -p option.
541 -p <feedname>: Prefer this feed when installing packages.
542 -d <y|m|n>: Set default for newly installed packages.
544 search [options] <substring>: Search for a package
546 -r <feedname>: Only search in this feed
548 uninstall -a|<package>: Uninstall a package
550 -a : Uninstalls all packages.
552 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
554 -a : Update all feeds listed within feeds.conf. Otherwise the spezified feeds will be updated.
555 -i : Recreate the index only. No feed update from repository is performed.
557 clean: Remove downloaded/generated files.
565 'update' => \
&update
,
566 'install' => \
&install
,
567 'search' => \
&search
,
568 'uninstall' => \
&uninstall
,
570 system("rm -rf feeds");
574 my $arg = shift @ARGV;
577 foreach my $cmd (keys %commands) {
578 $arg eq $cmd and do {
579 exit(&{$commands{$cmd}}());
This page took 0.110479 seconds and 5 git commands to generate.