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;
37 $line[0] =~ /^src-\w+$/ or $valid = 0;
38 $line[1] =~ /^\w+$/ or $valid = 0;
39 $line[2] =~ /\s/ and $valid = 0;
40 $valid or die "Syntax error in feeds.list, line: $line\n";
42 $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
54 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
55 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
57 system("$mk -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
58 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\"");
59 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
68 if (-d
"./feeds/$name/.svn" ) {
69 system("(cd \"./feeds/$name\"; svn up)") == 0 or return 1;
71 system("rm -rf \"./feeds/$name\"");
72 system("svn co $src \"./feeds/$name\"") == 0 or return 1;
82 system("mkdir -p ./feeds/$name");
83 system("cp -Rf $src ./feeds");
90 my $src = abs_path
(shift);
92 system("rm -f ./feeds/$name; ln -s $src ./feeds/$name");
101 if (-d
"./feeds/$name/.git" ) {
102 system("GIT_DIR=./feeds/$name/.git git pull") == 0 or return 1;
104 system("rm -rf \"./feeds/$name\"");
105 system("git clone --depth 1 $src ./feeds/$name") == 0 or return 1;
113 my $file = "./feeds/$feed.index";
118 print "Ignoring feed '$feed' - index missing\n";
121 parse_package_metadata
($file) or return;
125 sub get_installed
() {
126 system("$mk -s prepare-tmpinfo");
128 parse_package_metadata
("./tmp/.packageinfo");
129 %installed = %package;
137 return unless @substr > 0;
139 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
140 my $pkg = $package{$name};
144 foreach my $substr (@substr) {
146 foreach my $key (qw(name title description)) {
147 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
149 $match or undef $pkgmatch;
153 print "Search results in feed '$feed':\n";
156 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
165 getopt
('r:', \
%opts);
166 foreach my $feed (@feeds) {
167 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
175 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
176 my $pkg = $package{$name};
178 printf "\%-32s\t\%s\n", $pkg->{name
}, $pkg->{title
};
188 getopts
('r:sh', \
%opts);
194 foreach my $feed (@feeds) {
195 printf "\%-32s\tURL: %s\n", $feed->[1], $feed->[2];
199 foreach my $feed (@feeds) {
200 list_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
205 sub install_generic
() {
208 my $path = $pkg->{makefile
};
211 $path =~ s/\/Makefile$//;
213 -d
"./package/feeds" or mkdir "./package/feeds";
214 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
215 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
217 warn "Package is not valid\n";
224 my %install_method = (
225 'src-svn' => \
&install_generic
,
226 'src-cpy' => \
&install_generic
,
227 'src-link' => \
&install_generic
,
228 'src-git' => \
&install_generic
,
233 sub lookup_package
($$) {
237 foreach my $feed ($feed, @feeds) {
238 next unless $feed->[1];
239 next unless $feed{$feed->[1]};
240 $feed{$feed->[1]}->{$package} and return $feed;
245 sub install_package
{
250 $feed = lookup_package
($feed, $name);
252 $installed{$name} and return 0;
253 # TODO: check if it's already installed within ./package directory
254 $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";
258 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
260 $installed{$name} and return 0;
261 # TODO: check if this is an alias package, maybe it's known by another name
262 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
265 my $src = $pkg->{src
};
266 my $type = $feed->[0];
267 $src or $src = $name;
269 # previously installed packages set the runtime package
270 # newly installed packages set the source package
271 $installed{$src} and return 0;
273 # check previously installed packages
274 $installed{$name} and return 0;
275 $installed{$src} = 1;
276 warn "Installing package '$src'\n";
278 $install_method{$type} or do {
279 warn "Unknown installation method: '$type'\n";
283 &{$install_method{$type}}($feed, $pkg) == 0 or do {
288 # install all dependencies
289 foreach my $vpkg (@
{$srcpackage{$src}}, $pkg) {
290 foreach my $dep (@
{$vpkg->{depends
}}, @
{$vpkg->{builddepends
}}) {
293 install_package
($feed, $dep) == 0 or $ret = 1;
303 # workaround for timestamp check
304 system("rm -f tmp/.packageinfo");
308 system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
310 system("$mk defconfig Config.in >/dev/null 2>/dev/null");
320 getopts
('ap:d:h', \
%opts);
329 foreach my $f (@feeds) {
331 $feed{$f->[1]} = get_feed
($f->[1]);
333 # look up the preferred feed
334 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
338 foreach my $f (@feeds) {
339 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
340 printf "Installing all packages from feed %s.\n", $f->[1];
342 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
343 my $p = $package{$name};
345 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
351 while ($name = shift @ARGV) {
352 install_package
($feed, $name) == 0 or $ret = 1;
356 # workaround for timestamp check
359 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
360 refresh_config
($opts{d
});
371 getopts
('ah', \
%opts);
379 system("rm -rvf ./package/feeds");
383 warn "WARNING: no package to uninstall\n";
387 while ($name = shift @ARGV) {
388 my $pkg = $installed{$name};
390 warn "WARNING: $name not installed\n";
393 $pkg->{src
} and $name = $pkg->{src
};
394 warn "Uninstalling package '$name'\n";
395 system("rm -f ./package/feeds/*/$name");
399 $uninstall and refresh_config
();
403 my %update_method = (
404 'src-svn' => \
&update_svn
,
405 'src-cpy' => \
&update_cpy
,
406 'src-link' => \
&update_link
,
407 'src-git' => \
&update_git
410 sub update_feed
($$$$)
415 my $perform_update=shift;
417 $update_method{$type} or do {
418 warn "Unknown type '$type' in feed $name\n";
421 $perform_update and do {
422 warn "Updating feed '$name' from '$src' ...\n";
423 &{$update_method{$type}}($name, $src) == 0 or do {
428 warn "Create index file './feeds/$name.index' \n";
429 update_index
($name) == 0 or do {
439 my $perform_update=1;
441 $ENV{SCAN_COOKIE
} = $$;
442 $ENV{KBUILD_VERBOSE
} = 99;
444 getopts
('ahi', \
%opts);
452 # don't update from (remote) repository
453 # only re-create index information
458 mkdir "feeds" or die "Unable to create the feeds directory";
461 if ( ($#ARGV == -1) or $opts{a
}) {
462 foreach my $feed (@feeds) {
463 my ($type, $name, $src) = @
$feed;
464 update_feed
($type, $name, $src, $perform_update);
467 while ($feed_name = shift @ARGV) {
468 foreach my $feed (@feeds) {
469 my ($type, $name, $src) = @
$feed;
470 if($feed_name ne $name) {
473 update_feed
($type, $name, $src, $perform_update);
485 Usage: $0 <command> [options]
488 list [options]: List feeds and their content
490 -s : List of feed names and their URL.
491 -r <feedname>: List packages of specified feed.
493 install [options] <package>: Install a package
495 -a : Install all packages from all feeds or from the specified feed using the -p option.
496 -p <feedname>: Prefer this feed when installing packages.
497 -d <y|m|n>: Set default for newly installed packages.
499 search [options] <substring>: Search for a package
501 -r <feedname>: Only search in this feed
503 uninstall -a|<package>: Uninstall a package
505 -a : Uninstalls all packages.
507 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
509 -a : Update all feeds listed within feeds.conf. Otherwise the spezified feeds will be updated.
510 -i : Recreate the index only. No feed update from repository is performed.
512 clean: Remove downloaded/generated files.
520 'update' => \
&update
,
521 'install' => \
&install
,
522 'search' => \
&search
,
523 'uninstall' => \
&uninstall
,
525 system("rm -rf feeds");
529 my $arg = shift @ARGV;
532 foreach my $cmd (keys %commands) {
533 $arg eq $cmd and do {
534 exit(&{$commands{$cmd}}());
This page took 0.089291 seconds and 5 git commands to generate.