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";
31 my @line = split /\s+/, $_, 3;
35 $line[0] =~ /^src-\w+$/ or $valid = 0;
36 $line[1] =~ /^\w+$/ or $valid = 0;
37 $line[2] =~ /\s/ and $valid = 0;
38 $valid or die "Syntax error in feeds.list, line: $line\n";
40 $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
52 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
53 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
55 system("$mk -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
56 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\"");
57 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
66 if (-d
"./feeds/$name/.svn" ) {
67 system("(cd \"./feeds/$name\"; svn up)") == 0 or return 1;
69 system("rm -rf \"./feeds/$name\"");
70 system("svn co $src \"./feeds/$name\"") == 0 or return 1;
80 system("mkdir -p ./feeds/$name");
81 system("cp -Rf $src ./feeds");
88 my $src = abs_path
(shift);
90 system("rm -f ./feeds/$name; ln -s $src ./feeds/$name");
99 if (-d
"./feeds/$name/.git" ) {
100 system("GIT_DIR=./feeds/$name/.git git pull") == 0 or return 1;
102 system("rm -rf \"./feeds/$name\"");
103 system("git-clone --depth 1 $src ./feeds/$name") == 0 or return 1;
111 my $file = "./feeds/$feed.index";
116 print "Ignoring feed '$feed' - index missing\n";
119 parse_package_metadata
($file) or return;
123 sub get_installed
() {
124 system("$mk -s prepare-tmpinfo");
126 parse_package_metadata
("./tmp/.packageinfo");
127 %installed = %package;
135 return unless @substr > 0;
137 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
138 my $pkg = $package{$name};
142 foreach my $substr (@substr) {
144 foreach my $key (qw(name title description)) {
145 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
147 $match or undef $pkgmatch;
151 print "Search results in feed '$feed':\n";
154 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
163 getopt
('r:', \
%opts);
164 foreach my $feed (@feeds) {
165 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
173 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
174 my $pkg = $package{$name};
176 printf "\%-32s\t\%s\n", $pkg->{name
}, $pkg->{title
};
186 getopts
('r:sh', \
%opts);
192 foreach my $feed (@feeds) {
193 printf "\%-32s\tURL: %s\n", $feed->[1], $feed->[2];
197 foreach my $feed (@feeds) {
198 list_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
203 sub install_generic
() {
206 my $path = $pkg->{makefile
};
209 $path =~ s/\/Makefile$//;
211 -d
"./package/feeds" or mkdir "./package/feeds";
212 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
213 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
215 warn "Package is not valid\n";
222 my %install_method = (
223 'src-svn' => \
&install_generic
,
224 'src-cpy' => \
&install_generic
,
225 'src-link' => \
&install_generic
,
226 'src-git' => \
&install_generic
,
231 sub lookup_package
($$) {
235 foreach my $feed ($feed, @feeds) {
236 next unless $feed->[1];
237 next unless $feed{$feed->[1]};
238 $feed{$feed->[1]}->{$package} and return $feed;
243 sub install_package
{
248 $feed = lookup_package
($feed, $name);
250 $installed{$name} and return 0;
251 # TODO: check if it's already installed within ./package directory
252 $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";
256 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
258 $installed{$name} and return 0;
259 # TODO: check if this is an alias package, maybe it's known by another name
260 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
263 my $src = $pkg->{src
};
264 my $type = $feed->[0];
265 $src or $src = $name;
267 # previously installed packages set the runtime package
268 # newly installed packages set the source package
269 $installed{$src} and return 0;
271 # check previously installed packages
272 $installed{$name} and return 0;
273 $installed{$src} = 1;
274 warn "Installing package '$src'\n";
276 $install_method{$type} or do {
277 warn "Unknown installation method: '$type'\n";
281 &{$install_method{$type}}($feed, $pkg) == 0 or do {
286 # install all dependencies
287 foreach my $vpkg (@
{$srcpackage{$src}}) {
288 foreach my $dep (@
{$vpkg->{depends
}}, @
{$vpkg->{builddepends
}}) {
291 install_package
($feed, $dep) == 0 or $ret = 1;
301 # workaround for timestamp check
302 system("rm -f tmp/.packageinfo");
306 system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
308 system("$mk defconfig Config.in >/dev/null 2>/dev/null");
318 getopts
('ap:d:h', \
%opts);
327 foreach my $f (@feeds) {
329 $feed{$f->[1]} = get_feed
($f->[1]);
331 # look up the preferred feed
332 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
336 foreach my $f (@feeds) {
337 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
338 printf "Installing all packages from feed %s.\n", $f->[1];
340 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
341 my $p = $package{$name};
343 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
349 while ($name = shift @ARGV) {
350 install_package
($feed, $name) == 0 or $ret = 1;
354 # workaround for timestamp check
357 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
358 refresh_config
($opts{d
});
369 getopts
('ah', \
%opts);
377 system("rm -rvf ./package/feeds");
381 warn "WARNING: no package to uninstall\n";
385 while ($name = shift @ARGV) {
386 my $pkg = $installed{$name};
388 warn "WARNING: $name not installed\n";
391 $pkg->{src
} and $name = $pkg->{src
};
392 warn "Uninstalling package '$name'\n";
393 system("rm -f ./package/feeds/*/$name");
397 $uninstall and refresh_config
();
401 my %update_method = (
402 'src-svn' => \
&update_svn
,
403 'src-cpy' => \
&update_cpy
,
404 'src-link' => \
&update_link
,
405 'src-git' => \
&update_git
408 sub update_feed
($$$$)
413 my $perform_update=shift;
415 $update_method{$type} or do {
416 warn "Unknown type '$type' in feed $name\n";
419 $perform_update and do {
420 warn "Updating feed '$name' from '$src' ...\n";
421 &{$update_method{$type}}($name, $src) == 0 or do {
426 warn "Create index file './feeds/$name.index' \n";
427 update_index
($name) == 0 or do {
437 my $perform_update=1;
439 $ENV{SCAN_COOKIE
} = $$;
440 $ENV{KBUILD_VERBOSE
} = 99;
442 getopts
('ahi', \
%opts);
450 # don't update from (remote) repository
451 # only re-create index information
456 mkdir "feeds" or die "Unable to create the feeds directory";
459 if ( ($#ARGV == -1) or $opts{a
}) {
460 foreach my $feed (@feeds) {
461 my ($type, $name, $src) = @
$feed;
462 update_feed
($type, $name, $src, $perform_update);
465 while ($feed_name = shift @ARGV) {
466 foreach my $feed (@feeds) {
467 my ($type, $name, $src) = @
$feed;
468 if($feed_name ne $name) {
471 update_feed
($type, $name, $src, $perform_update);
483 Usage: $0 <command> [options]
486 list [options]: List feeds and their content
488 -s : List of feed names and their URL.
489 -r <feedname>: List packages of specified feed.
491 install [options] <package>: Install a package
493 -a : Install all packages from all feeds or from the specified feed using the -p option.
494 -p <feedname>: Prefer this feed when installing packages.
495 -d <y|m|n>: Set default for newly installed packages.
497 search [options] <substring>: Search for a package
499 -r <feedname>: Only search in this feed
501 uninstall -a|<package>: Uninstall a package
503 -a : Uninstalls all packages.
505 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
507 -a : Update all feeds listed within feeds.conf. Otherwise the spezified feeds will be updated.
508 -i : Recreate the index only. No feed update from repository is performed.
510 clean: Remove downloaded/generated files.
518 'update' => \
&update
,
519 'install' => \
&install
,
520 'search' => \
&search
,
521 'uninstall' => \
&uninstall
,
523 system("rm -rf feeds");
527 my $arg = shift @ARGV;
530 foreach my $cmd (keys %commands) {
531 $arg eq $cmd and do {
532 exit(&{$commands{$cmd}}());
This page took 0.09249 seconds and 5 git commands to generate.