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'
18 # check version of make
19 my @mkver = split /\s+/, `$mk -v`, 4;
21 $mkver[0] =~ /^GNU/ or $valid_mk = 0;
22 $mkver[1] =~ /^Make/ or $valid_mk = 0;
23 $mkver[2] >= "3.81" or $valid_mk = 0;
24 $valid_mk or die "Unsupported version of make found: $mk\n";
34 open FEEDS
, "feeds.conf" or
35 open FEEDS
, "feeds.conf.default" or
36 die "Unable to open feeds configuration";
41 my @line = split /\s+/, $_, 3;
46 $line[0] =~ /^src-\w+$/ or $valid = 0;
47 $line[1] =~ /^\w+$/ or $valid = 0;
48 @src = split /\s+/, $line[2];
49 $valid or die "Syntax error in feeds.list, line: $line\n";
51 $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
54 push @feeds, [$line[0], $line[1], \
@src];
59 sub update_location
($$)
65 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
67 if( open LOC
, "< ./feeds/$name.tmp/location" )
69 chomp($old_url = readline LOC
);
73 if( !$old_url || $old_url ne $url )
75 if( open LOC
, "> ./feeds/$name.tmp/location" )
80 return $old_url ?
1 : 0;
90 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
91 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
93 system("$mk -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
94 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\"");
95 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
100 my %update_method = (
102 'init' => "svn checkout '%s' '%s'",
103 'update' => "svn update",
104 'controldir' => ".svn"},
106 'init' => "cp -Rf '%s' '%s'",
109 'init' => "ln -s '%s' '%s'",
112 'init' => "git clone --depth 1 '%s' '%s'",
113 'update' => "git pull",
114 'controldir' => ".git"},
116 'init' => "bzr checkout --lightweight '%s' '%s'",
117 'update' => "bzr update",
118 'controldir' => ".bzr"},
120 'init' => "hg clone '%s' '%s'",
121 'update' => "hg pull --update",
122 'controldir' => ".hg"}
125 # src-git: pull broken
126 # src-cpy: broken if `basename $src` != $name
128 sub update_feed_via
($$$$) {
132 my $relocate = shift;
134 my $m = $update_method{$type};
135 my $localpath = "./feeds/$name";
136 my $safepath = $localpath;
137 $safepath =~ s/'/'\\''/;
139 if( $relocate || !$m->{'update'} || !-d
"$localpath/$m->{'controldir'}" ) {
140 system("rm -rf '$safepath'");
141 system(sprintf($m->{'init'}, $src, $safepath)) == 0 or return 1;
143 system("cd '$safepath'; $m->{'update'}") == 0 or return 1;
151 my $file = "./feeds/$feed.index";
156 print "Ignoring feed '$feed' - index missing\n";
159 parse_package_metadata
($file) or return;
163 sub get_installed
() {
164 system("$mk -s prepare-tmpinfo");
166 parse_package_metadata
("./tmp/.packageinfo");
167 %installed = %package;
175 return unless @substr > 0;
177 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
178 my $pkg = $package{$name};
182 next if $pkg->{vdepends
};
183 foreach my $substr (@substr) {
185 foreach my $key (qw(name title description src)) {
186 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
188 $match or undef $pkgmatch;
192 print "Search results in feed '$feed':\n";
195 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
204 getopt
('r:', \
%opts);
205 foreach my $feed (@feeds) {
206 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
214 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
215 my $pkg = $package{$name};
216 next if $pkg->{vdepends
};
218 printf "\%-32s\t\%s\n", $pkg->{name
}, $pkg->{title
};
228 getopts
('r:sh', \
%opts);
234 foreach my $feed (@feeds) {
235 printf "\%-32s\tURL: %s\n", $feed->[1], join(", ", @
{$feed->[2]});
239 foreach my $feed (@feeds) {
240 list_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
245 sub install_generic
() {
248 my $path = $pkg->{makefile
};
251 $path =~ s/\/Makefile$//;
253 -d
"./package/feeds" or mkdir "./package/feeds";
254 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
255 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
257 warn "Package is not valid\n";
264 my %install_method = (
265 'src-svn' => \
&install_generic
,
266 'src-cpy' => \
&install_generic
,
267 'src-link' => \
&install_generic
,
268 'src-git' => \
&install_generic
,
269 'src-bzr' => \
&install_generic
,
270 'src-hg' => \
&install_generic
,
275 sub lookup_package
($$) {
279 foreach my $feed ($feed, @feeds) {
280 next unless $feed->[1];
281 next unless $feed{$feed->[1]};
282 $feed{$feed->[1]}->{$package} and return $feed;
287 sub install_package
{
292 $feed = lookup_package
($feed, $name);
294 $installed{$name} and return 0;
295 # TODO: check if it's already installed within ./package directory
296 $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";
300 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
302 $installed{$name} and return 0;
303 # TODO: check if this is an alias package, maybe it's known by another name
304 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
307 my $src = $pkg->{src
};
308 my $type = $feed->[0];
309 $src or $src = $name;
311 # previously installed packages set the runtime package
312 # newly installed packages set the source package
313 $installed{$src} and return 0;
315 # check previously installed packages
316 $installed{$name} and return 0;
317 $installed{$src} = 1;
318 warn "Installing package '$src'\n";
320 $install_method{$type} or do {
321 warn "Unknown installation method: '$type'\n";
325 &{$install_method{$type}}($feed, $pkg) == 0 or do {
330 # install all dependencies
331 foreach my $vpkg (@
{$srcpackage{$src}}, $pkg) {
332 foreach my $dep (@
{$vpkg->{depends
}}, @
{$vpkg->{builddepends
}}, @
{$vpkg->{"builddepends/host"}}) {
338 install_package
($feed, $dep) == 0 or $ret = 1;
348 # workaround for timestamp check
349 system("rm -f tmp/.packageinfo");
353 system("$mk oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
355 system("$mk defconfig Config.in >/dev/null 2>/dev/null");
365 getopts
('ap:d:h', \
%opts);
374 foreach my $f (@feeds) {
376 $feed{$f->[1]} = get_feed
($f->[1]);
378 # look up the preferred feed
379 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
383 foreach my $f (@feeds) {
384 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
385 printf "Installing all packages from feed %s.\n", $f->[1];
387 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
388 my $p = $package{$name};
389 next if $p->{vdepends
};
391 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
397 while ($name = shift @ARGV) {
398 install_package
($feed, $name) == 0 or $ret = 1;
402 # workaround for timestamp check
405 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
406 refresh_config
($opts{d
});
417 getopts
('ah', \
%opts);
425 system("rm -rvf ./package/feeds");
429 warn "WARNING: no package to uninstall\n";
433 while ($name = shift @ARGV) {
434 my $pkg = $installed{$name};
436 warn "WARNING: $name not installed\n";
439 $pkg->{src
} and $name = $pkg->{src
};
440 warn "Uninstalling package '$name'\n";
441 system("rm -f ./package/feeds/*/$name");
445 $uninstall and refresh_config
();
449 sub update_feed
($$$$)
454 my $perform_update=shift;
455 my $force_relocate=update_location
( $name, "@$src" );
457 if( $force_relocate ) {
458 warn "Source of feed $name has changed, replacing copy\n";
460 $update_method{$type} or do {
461 warn "Unknown type '$type' in feed $name\n";
464 $perform_update and do {
466 foreach my $feedsrc (@
$src) {
467 warn "Updating feed '$name' from '$feedsrc' ...\n";
468 next unless update_feed_via
($type, $name, $feedsrc, $force_relocate) == 0;
477 warn "Create index file './feeds/$name.index' \n";
478 update_index
($name) == 0 or do {
488 my $perform_update=1;
490 $ENV{SCAN_COOKIE
} = $$;
491 $ENV{KBUILD_VERBOSE
} = 99;
493 getopts
('ahi', \
%opts);
501 # don't update from (remote) repository
502 # only re-create index information
507 mkdir "feeds" or die "Unable to create the feeds directory";
510 if ( ($#ARGV == -1) or $opts{a
}) {
511 foreach my $feed (@feeds) {
512 my ($type, $name, $src) = @
$feed;
513 update_feed
($type, $name, $src, $perform_update);
516 while ($feed_name = shift @ARGV) {
517 foreach my $feed (@feeds) {
518 my ($type, $name, $src) = @
$feed;
519 if($feed_name ne $name) {
522 update_feed
($type, $name, $src, $perform_update);
534 Usage: $0 <command> [options]
537 list [options]: List feeds and their content
539 -s : List of feed names and their URL.
540 -r <feedname>: List packages of specified feed.
542 install [options] <package>: Install a package
544 -a : Install all packages from all feeds or from the specified feed using the -p option.
545 -p <feedname>: Prefer this feed when installing packages.
546 -d <y|m|n>: Set default for newly installed packages.
548 search [options] <substring>: Search for a package
550 -r <feedname>: Only search in this feed
552 uninstall -a|<package>: Uninstall a package
554 -a : Uninstalls all packages.
556 update -a|<feedname(s)>: Update packages and lists of feeds in feeds.conf .
558 -a : Update all feeds listed within feeds.conf. Otherwise the spezified feeds will be updated.
559 -i : Recreate the index only. No feed update from repository is performed.
561 clean: Remove downloaded/generated files.
569 'update' => \
&update
,
570 'install' => \
&install
,
571 'search' => \
&search
,
572 'uninstall' => \
&uninstall
,
574 system("rm -rf feeds");
578 my $arg = shift @ARGV;
581 foreach my $cmd (keys %commands) {
582 $arg eq $cmd and do {
583 exit(&{$commands{$cmd}}());
This page took 0.106067 seconds and 5 git commands to generate.