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=5 SCAN_EXTRA=\"\" TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
87 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
94 'init' => "svn checkout '%s' '%s'",
95 'update' => "svn update",
96 'controldir' => ".svn"},
98 'init' => "cp -Rf '%s' '%s'",
101 'init' => "ln -s '%s' '%s'",
104 'init' => "git clone --depth 1 '%s' '%s'",
105 'update' => "git pull",
106 'controldir' => ".git"},
108 'init' => "bzr checkout --lightweight '%s' '%s'",
109 'update' => "bzr update",
110 'controldir' => ".bzr"},
112 'init' => "hg clone '%s' '%s'",
113 'update' => "hg pull --update",
114 'controldir' => ".hg"}
117 # src-git: pull broken
118 # src-cpy: broken if `basename $src` != $name
120 sub update_feed_via
($$$$) {
124 my $relocate = shift;
126 my $m = $update_method{$type};
127 my $localpath = "./feeds/$name";
128 my $safepath = $localpath;
129 $safepath =~ s/'/'\\''/;
131 if( $relocate || !$m->{'update'} || !-d
"$localpath/$m->{'controldir'}" ) {
132 system("rm -rf '$safepath'");
133 system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1;
135 system("cd '$safepath'; $m->{'update'}") == 0 or return 1;
143 my $file = "./feeds/$feed.index";
148 print "Ignoring feed '$feed' - index missing\n";
151 parse_package_metadata
($file) or return;
155 sub get_installed
() {
156 system("$mk -s prepare-tmpinfo");
158 parse_package_metadata
("./tmp/.packageinfo");
159 %installed = %package;
167 return unless @substr > 0;
169 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
170 my $pkg = $package{$name};
174 foreach my $substr (@substr) {
176 foreach my $key (qw(name title description)) {
177 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
179 $match or undef $pkgmatch;
183 print "Search results in feed '$feed':\n";
186 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
195 getopt
('r:', \
%opts);
196 foreach my $feed (@feeds) {
197 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
205 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
206 my $pkg = $package{$name};
208 printf "\%-32s\t\%s\n", $pkg->{name
}, $pkg->{title
};
218 getopts
('r:sh', \
%opts);
224 foreach my $feed (@feeds) {
225 printf "\%-32s\tURL: %s\n", $feed->[1], join(", ", @
{$feed->[2]});
229 foreach my $feed (@feeds) {
230 list_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
235 sub install_generic
() {
238 my $path = $pkg->{makefile
};
241 $path =~ s/\/Makefile$//;
243 -d
"./package/feeds" or mkdir "./package/feeds";
244 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
245 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
247 warn "Package is not valid\n";
254 my %install_method = (
255 'src-svn' => \
&install_generic
,
256 'src-cpy' => \
&install_generic
,
257 'src-link' => \
&install_generic
,
258 'src-git' => \
&install_generic
,
259 'src-bzr' => \
&install_generic
,
260 'src-hg' => \
&install_generic
,
265 sub lookup_package
($$) {
269 foreach my $feed ($feed, @feeds) {
270 next unless $feed->[1];
271 next unless $feed{$feed->[1]};
272 $feed{$feed->[1]}->{$package} and return $feed;
277 sub install_package
{
282 $feed = lookup_package
($feed, $name);
284 $installed{$name} and return 0;
285 # TODO: check if it's already installed within ./package directory
286 $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";
290 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
292 $installed{$name} and return 0;
293 # TODO: check if this is an alias package, maybe it's known by another name
294 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
297 my $src = $pkg->{src
};
298 my $type = $feed->[0];
299 $src or $src = $name;
301 # previously installed packages set the runtime package
302 # newly installed packages set the source package
303 $installed{$src} and return 0;
305 # check previously installed packages
306 $installed{$name} and return 0;
307 $installed{$src} = 1;
308 warn "Installing package '$src'\n";
310 $install_method{$type} or do {
311 warn "Unknown installation method: '$type'\n";
315 &{$install_method{$type}}($feed, $pkg) == 0 or do {
320 # install all dependencies
321 foreach my $vpkg (@
{$srcpackage{$src}}, $pkg) {
322 foreach my $dep (@
{$vpkg->{depends
}}, @
{$vpkg->{builddepends
}}) {
327 install_package
($feed, $dep) == 0 or $ret = 1;
337 # workaround for timestamp check
338 system("rm -f tmp/.packageinfo");
342 system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
344 system("$mk defconfig Config.in >/dev/null 2>/dev/null");
354 getopts
('ap:d:h', \
%opts);
363 foreach my $f (@feeds) {
365 $feed{$f->[1]} = get_feed
($f->[1]);
367 # look up the preferred feed
368 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
372 foreach my $f (@feeds) {
373 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
374 printf "Installing all packages from feed %s.\n", $f->[1];
376 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
377 my $p = $package{$name};
379 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
385 while ($name = shift @ARGV) {
386 install_package
($feed, $name) == 0 or $ret = 1;
390 # workaround for timestamp check
393 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
394 refresh_config
($opts{d
});
405 getopts
('ah', \
%opts);
413 system("rm -rvf ./package/feeds");
417 warn "WARNING: no package to uninstall\n";
421 while ($name = shift @ARGV) {
422 my $pkg = $installed{$name};
424 warn "WARNING: $name not installed\n";
427 $pkg->{src
} and $name = $pkg->{src
};
428 warn "Uninstalling package '$name'\n";
429 system("rm -f ./package/feeds/*/$name");
433 $uninstall and refresh_config
();
437 sub update_feed
($$$$)
442 my $perform_update=shift;
443 my $force_relocate=update_location
( $name, "@$src" );
445 if( $force_relocate ) {
446 warn "Source of feed $name has changed, replacing copy\n";
448 $update_method{$type} or do {
449 warn "Unknown type '$type' in feed $name\n";
452 $perform_update and do {
454 foreach my $feedsrc (@
$src) {
455 warn "Updating feed '$name' from '$feedsrc' ...\n";
456 next unless update_feed_via
($type, $name, $feedsrc, $force_relocate) == 0;
465 warn "Create index file './feeds/$name.index' \n";
466 update_index
($name) == 0 or do {
476 my $perform_update=1;
478 $ENV{SCAN_COOKIE
} = $$;
479 $ENV{KBUILD_VERBOSE
} = 99;
481 getopts
('ahi', \
%opts);
489 # don't update from (remote) repository
490 # only re-create index information
495 mkdir "feeds" or die "Unable to create the feeds directory";
498 if ( ($#ARGV == -1) or $opts{a
}) {
499 foreach my $feed (@feeds) {
500 my ($type, $name, $src) = @
$feed;
501 update_feed
($type, $name, $src, $perform_update);
504 while ($feed_name = shift @ARGV) {
505 foreach my $feed (@feeds) {
506 my ($type, $name, $src) = @
$feed;
507 if($feed_name ne $name) {
510 update_feed
($type, $name, $src, $perform_update);
522 Usage: $0 <command> [options]
525 list [options]: List feeds and their content
527 -s : List of feed names and their URL.
528 -r <feedname>: List packages of specified feed.
530 install [options] <package>: Install a package
532 -a : Install all packages from all feeds or from the specified feed using the -p option.
533 -p <feedname>: Prefer this feed when installing packages.
534 -d <y|m|n>: Set default for newly installed packages.
536 search [options] <substring>: Search for a package
538 -r <feedname>: Only search in this feed
540 uninstall -a|<package>: Uninstall a package
542 -a : Uninstalls all packages.
544 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
546 -a : Update all feeds listed within feeds.conf. Otherwise the spezified feeds will be updated.
547 -i : Recreate the index only. No feed update from repository is performed.
549 clean: Remove downloaded/generated files.
557 'update' => \
&update
,
558 'install' => \
&install
,
559 'search' => \
&search
,
560 'uninstall' => \
&uninstall
,
562 system("rm -rf feeds");
566 my $arg = shift @ARGV;
569 foreach my $cmd (keys %commands) {
570 $arg eq $cmd and do {
571 exit(&{$commands{$cmd}}());
This page took 0.088502 seconds and 5 git commands to generate.