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
};
149 getopt
('r:', \
%opts);
150 foreach my $feed (@feeds) {
151 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
155 sub install_generic
() {
158 my $path = $pkg->{makefile
};
161 $path =~ s/\/Makefile$//;
163 -d
"./package/feeds" or mkdir "./package/feeds";
164 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
165 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
167 warn "Package is not valid\n";
174 my %install_method = (
175 'src-svn' => \
&install_generic
,
176 'src-cpy' => \
&install_generic
,
177 'src-link' => \
&install_generic
,
178 'src-git' => \
&install_generic
,
183 sub lookup_package
($$) {
187 foreach my $feed ($feed, @feeds) {
188 next unless $feed->[1];
189 next unless $feed{$feed->[1]};
190 $feed{$feed->[1]}->{$package} and return $feed;
195 sub install_package
{
200 $feed = lookup_package
($feed, $name);
202 $installed{$name} and return 0;
203 warn "WARNING: No feed for package '$name' found.\n";
207 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
209 $installed{$name} and return 0;
210 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
213 my $src = $pkg->{src
};
214 my $type = $feed->[0];
215 $src or $src = $name;
217 # previously installed packages set the runtime package
218 # newly installed packages set the source package
219 $installed{$src} and return 0;
221 # install all dependencies
222 foreach my $dep (@
{$pkg->{depends
}}) {
225 install_package
($feed, $dep) == 0 or $ret = 1;
228 # check previously installed packages
229 $installed{$name} and return 0;
230 $installed{$src} = 1;
231 warn "Installing package '$src'\n";
233 $install_method{$type} or do {
234 warn "Unknown installation method: '$type'\n";
238 &{$install_method{$type}}($feed, $pkg) == 0 or do {
248 $default or $default = "o";
250 # workaround for timestamp check
251 system("rm -f tmp/.packageinfo");
254 system("make oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
263 getopts
('ap:d:', \
%opts);
266 foreach my $f (@feeds) {
268 $feed{$f->[1]} = get_feed
($f->[1]);
270 # look up the preferred feed
271 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
275 foreach my $f (@feeds) {
276 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
277 printf "Installing all packages from feed %s.\n", $f->[1];
279 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
280 my $p = $package{$name};
282 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
284 warn "WARNING: Package '$name' is not available\n";
290 while ($name = shift @ARGV) {
291 install_package
($feed, $name) == 0 or $ret = 1;
295 # workaround for timestamp check
298 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
299 refresh_config
($opts{d
});
309 if ($ARGV[0] eq '-a') {
310 system("rm -rf ./package/feeds");
314 while ($name = shift @ARGV) {
315 my $pkg = $installed{$name};
317 warn "WARNING: $name not installed\n";
320 $pkg->{src
} and $name = $pkg->{src
};
321 warn "Uninstalling package '$name'\n";
322 system("rm -f ./package/feeds/*/$name");
326 $uninstall and refresh_config
();
332 Usage: $0 <command> [options]
335 install [options] <package>: Install a package
337 -a installs all packages from all feeds or from the specified feed
338 -p <feedname>: Prefer this feed when installing packages
339 -d <y|m|n>: Set default for newly installed packages
341 search [options] <substring>: Search for a package
343 -r <feedname>: Only search in this feed
345 uninstall -a|<package>: Uninstall a package
346 -a uninstalls all packages
348 update: Update packages and lists of feeds in feeds.list
349 clean: Remove downloaded/generated files
355 my %update_method = (
356 'src-svn' => \
&update_svn
,
357 'src-cpy' => \
&update_cpy
,
358 'src-link' => \
&update_link
,
359 'src-git' => \
&update_git
365 mkdir "feeds" or die "Unable to create the feeds directory";
367 $ENV{SCAN_COOKIE
} = $$;
368 $ENV{KBUILD_VERBOSE
} = 99;
369 foreach my $feed (@feeds) {
370 my ($type, $name, $src) = @
$feed;
371 $update_method{$type} or do {
372 warn "Unknown type '$type' in feed $name\n";
375 warn "Updating feed '$name'...\n";
376 &{$update_method{$type}}($name, $src) == 0 or do {
383 'install' => \
&install
,
384 'search' => \
&search
,
385 'uninstall' => \
&uninstall
,
387 system("rm -rf feeds");
391 my $arg = shift @ARGV;
394 foreach my $cmd (keys %commands) {
395 $arg eq $cmd and do {
396 exit(&{$commands{$cmd}}());
This page took 0.077582 seconds and 5 git commands to generate.