5 use lib
"$FindBin::Bin";
11 chdir "$FindBin::Bin/..";
12 $ENV{TOPDIR
}=getcwd
();
22 open FEEDS
, "feeds.conf";
27 my @line = split /\s+/, $_, 3;
31 $line[0] =~ /^src-\w+$/ or $valid = 0;
32 $line[1] =~ /^\w+$/ or $valid = 0;
33 $line[2] =~ /\s/ and $valid = 0;
34 $valid or die "Syntax error in feeds.list, line: $line\n";
36 $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
48 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
49 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
51 system("make -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
52 system("make -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\"");
53 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
62 if (-d
"./feeds/$name/.svn" ) {
63 system("(cd \"./feeds/$name\"; svn up)") == 0 or return 1;
65 system("rm -rf \"./feeds/$name\"");
66 system("svn co $src \"./feeds/$name\"") == 0 or return 1;
68 return update_index
($name, $src);
75 system("cp -Rf $src ./feeds/$name");
76 return update_index
($name, $src);
81 my $src = abs_path
(shift);
83 system("ln -sf $src ./feeds/$name");
84 return update_index
($name, $src);
91 if (-d
"./feeds/$name/.git" ) {
92 system("GIT_DIR=./feeds/$name/.git git pull") == 0 or return 1;
94 system("rm -rf \"./feeds/$name\"");
95 system("git-clone --depth 1 $src ./feeds/$name") == 0 or return 1;
97 return update_index
($name, $src);
104 parse_package_metadata
("./feeds/$feed.index") or return;
108 sub get_installed
() {
109 system("make -s prepare-tmpinfo");
111 parse_package_metadata
("./tmp/.packageinfo");
112 %installed = %package;
120 return unless @substr > 0;
122 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
123 my $pkg = $package{$name};
127 foreach my $substr (@substr) {
129 foreach my $key (qw(name title description)) {
130 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
132 $match or undef $pkgmatch;
136 print "Search results in feed '$feed':\n";
139 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
148 getopt
('r:', \
%opts);
149 foreach my $feed (@feeds) {
150 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
158 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
159 my $pkg = $package{$name};
161 printf "\%-32s\t\%s\n", $pkg->{name
}, $pkg->{title
};
171 getopts
('r:sh', \
%opts);
177 foreach my $feed (@feeds) {
178 printf "\%-32s\tURL: %s\n", $feed->[1], $feed->[2];
182 foreach my $feed (@feeds) {
183 list_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
188 sub install_generic
() {
191 my $path = $pkg->{makefile
};
194 $path =~ s/\/Makefile$//;
196 -d
"./package/feeds" or mkdir "./package/feeds";
197 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
198 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
200 warn "Package is not valid\n";
207 my %install_method = (
208 'src-svn' => \
&install_generic
,
209 'src-cpy' => \
&install_generic
,
210 'src-link' => \
&install_generic
,
211 'src-git' => \
&install_generic
,
216 sub lookup_package
($$) {
220 foreach my $feed ($feed, @feeds) {
221 next unless $feed->[1];
222 next unless $feed{$feed->[1]};
223 $feed{$feed->[1]}->{$package} and return $feed;
228 sub install_package
{
233 $feed = lookup_package
($feed, $name);
235 $installed{$name} and return 0;
236 warn "WARNING: No feed for package '$name' found.\n";
240 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
242 $installed{$name} and return 0;
243 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
246 my $src = $pkg->{src
};
247 my $type = $feed->[0];
248 $src or $src = $name;
250 # previously installed packages set the runtime package
251 # newly installed packages set the source package
252 $installed{$src} and return 0;
254 # install all dependencies
255 foreach my $dep (@
{$pkg->{depends
}}) {
258 install_package
($feed, $dep) == 0 or $ret = 1;
261 # check previously installed packages
262 $installed{$name} and return 0;
263 $installed{$src} = 1;
264 warn "Installing package '$src'\n";
266 $install_method{$type} or do {
267 warn "Unknown installation method: '$type'\n";
271 &{$install_method{$type}}($feed, $pkg) == 0 or do {
281 $default or $default = "o";
283 # workaround for timestamp check
284 system("rm -f tmp/.packageinfo");
287 system("make oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
296 getopts
('ap:d:', \
%opts);
299 foreach my $f (@feeds) {
301 $feed{$f->[1]} = get_feed
($f->[1]);
303 # look up the preferred feed
304 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
308 foreach my $f (@feeds) {
309 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
310 printf "Installing all packages from feed %s.\n", $f->[1];
312 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
313 my $p = $package{$name};
315 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
317 warn "WARNING: Package '$name' is not available\n";
323 while ($name = shift @ARGV) {
324 install_package
($feed, $name) == 0 or $ret = 1;
328 # workaround for timestamp check
331 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
332 refresh_config
($opts{d
});
342 if ($ARGV[0] eq '-a') {
343 system("rm -rf ./package/feeds");
347 while ($name = shift @ARGV) {
348 my $pkg = $installed{$name};
350 warn "WARNING: $name not installed\n";
353 $pkg->{src
} and $name = $pkg->{src
};
354 warn "Uninstalling package '$name'\n";
355 system("rm -f ./package/feeds/*/$name");
359 $uninstall and refresh_config
();
365 Usage: $0 <command> [options]
368 list [options]: List feeds and their content
370 -s : List of feed names and their URL.
371 -r <feedname>: List packages of specified feed.
373 install [options] <package>: Install a package
375 -a : Install all packages from all feeds or from the specified feed using the -p option.
376 -p <feedname>: Prefer this feed when installing packages.
377 -d <y|m|n>: Set default for newly installed packages.
379 search [options] <substring>: Search for a package
381 -r <feedname>: Only search in this feed
383 uninstall -a|<package>: Uninstall a package
384 -a : Uninstalls all packages.
386 update: Update packages and lists of feeds in feeds.conf .
388 clean: Remove downloaded/generated files.
394 my %update_method = (
395 'src-svn' => \
&update_svn
,
396 'src-cpy' => \
&update_cpy
,
397 'src-link' => \
&update_link
,
398 'src-git' => \
&update_git
405 mkdir "feeds" or die "Unable to create the feeds directory";
407 $ENV{SCAN_COOKIE
} = $$;
408 $ENV{KBUILD_VERBOSE
} = 99;
409 foreach my $feed (@feeds) {
410 my ($type, $name, $src) = @
$feed;
411 $update_method{$type} or do {
412 warn "Unknown type '$type' in feed $name\n";
415 warn "Updating feed '$name'...\n";
416 &{$update_method{$type}}($name, $src) == 0 or do {
423 'install' => \
&install
,
424 'search' => \
&search
,
425 'uninstall' => \
&uninstall
,
427 system("rm -rf feeds");
431 my $arg = shift @ARGV;
434 foreach my $cmd (keys %commands) {
435 $arg eq $cmd and do {
436 exit(&{$commands{$cmd}}());
This page took 0.078921 seconds and 5 git commands to generate.