6fda84e00e63493688a93c765fef04356f0543ad
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 system("svn co $src ./feeds/$name") == 0 or return 1;
49 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
50 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
52 system("make -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
53 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\"");
54 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
63 system("cp -Rf $src ./feeds/$name");
64 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
65 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
67 system("make -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
68 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\"");
69 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
76 my $src = abs_path
(shift);
78 system("ln -sf $src ./feeds/$name");
79 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
80 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
82 system("make -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
83 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\"");
84 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
93 parse_package_metadata
("./feeds/$feed.index") or return;
98 system("make -s prepare-tmpinfo");
100 parse_package_metadata
("./tmp/.packageinfo");
101 %installed = %package;
109 return unless @substr > 0;
111 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
112 my $pkg = $package{$name};
116 foreach my $substr (@substr) {
118 foreach my $key (qw(name title description)) {
119 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
121 $match or undef $pkgmatch;
125 print "Search results in feed '$feed':\n";
128 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
138 getopt
('r:', \
%opts);
139 foreach my $feed (@feeds) {
140 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
144 sub install_generic
() {
147 my $path = $pkg->{makefile
};
151 $path =~ s/\/Makefile$//;
153 -d
"./package/feeds" or mkdir "./package/feeds";
154 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
155 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
158 warn "Package is not valid\n";
164 my %install_method = (
165 'src-svn' => \
&install_generic
,
166 'src-cpy' => \
&install_generic
,
167 'src-link' => \
&install_generic
172 sub lookup_package
($$) {
176 foreach my $feed ($feed, @feeds) {
177 next unless $feed->[1];
178 next unless $feed{$feed->[1]};
179 $feed{$feed->[1]}->{$package} and return $feed;
184 sub install_package
{
189 $feed = lookup_package
($feed, $name);
191 $installed{$name} and return 0;
192 warn "WARNING: No feed for package '$name' found.\n";
196 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
198 $installed{$name} and return 0;
199 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
202 my $src = $pkg->{src
};
203 my $type = $feed->[0];
204 $src or $src = $name;
206 # previously installed packages set the runtime package
207 # newly installed packages set the source package
208 $installed{$src} and return 0;
210 # install all dependencies
211 foreach my $dep (@
{$pkg->{depends
}}) {
214 install_package
($feed, $dep) == 0 or $ret = 1;
217 # check previously installed packages
218 $installed{$name} and return 0;
219 $installed{$src} = 1;
220 warn "Installing package '$src'\n";
222 $install_method{$type} or do {
223 warn "Unknown installation method: '$type'\n";
227 &{$install_method{$type}}($feed, $pkg) == 0 or do {
237 $default or $default = "o";
239 # workaround for timestamp check
240 system("rm -f tmp/.packageinfo");
243 system("make oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
252 getopts
('ap:d:', \
%opts);
255 foreach my $f (@feeds) {
257 $feed{$f->[1]} = get_feed
($f->[1]);
259 # look up the preferred feed
260 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
264 foreach my $f (@feeds) {
265 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
266 printf "Installing all packages from feed %s.\n", $f->[1];
268 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
269 my $p = $package{$name};
271 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
273 warn "WARNING: Package '$name' is not available\n";
279 while ($name = shift @ARGV) {
280 install_package
($feed, $name) == 0 or $ret = 1;
284 # workaround for timestamp check
287 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
288 refresh_config
($opts{d
});
298 if ($ARGV[0] eq '-a') {
299 system("rm -rf ./package/feeds");
303 while ($name = shift @ARGV) {
304 my $pkg = $installed{$name};
306 warn "WARNING: $name not installed\n";
309 $pkg->{src
} and $name = $pkg->{src
};
310 warn "Uninstalling package '$name'\n";
311 system("rm -f ./package/feeds/*/$name");
315 $uninstall and refresh_config
();
321 Usage: $0 <command> [options]
324 install [options] <package>: Install a package
326 -a installs all packages from all feeds or from the specified feed
327 -p <feedname>: Prefer this feed when installing packages
328 -d <y|m|n>: Set default for newly installed packages
330 search [options] <substring>: Search for a package
332 -r <feedname>: Only search in this feed
334 uninstall -a|<package>: Uninstall a package
335 -a uninstalls all packages
337 update: Update packages and lists of feeds in feeds.list
338 clean: Remove downloaded/generated files
344 my %update_method = (
345 'src-svn' => \
&update_svn
,
346 'src-cpy' => \
&update_cpy
,
347 'src-link' => \
&update_link
353 mkdir "feeds" or die "Unable to create the feeds directory";
355 $ENV{SCAN_COOKIE
} = $$;
356 $ENV{KBUILD_VERBOSE
} = 99;
357 foreach my $feed (@feeds) {
358 my ($type, $name, $src) = @
$feed;
359 $update_method{$type} or do {
360 warn "Unknown type '$type' in feed $name\n";
363 warn "Updating feed '$name'...\n";
364 &{$update_method{$type}}($name, $src) == 0 or do {
371 'install' => \
&install
,
372 'search' => \
&search
,
373 'uninstall' => \
&uninstall
,
375 system("rm -rf feeds");
379 my $arg = shift @ARGV;
382 foreach my $cmd (keys %commands) {
383 $arg eq $cmd and do {
384 exit(&{$commands{$cmd}}());
This page took 0.075794 seconds and 3 git commands to generate.