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 if ( ! -d
"./feeds/$name" ) {
94 system("git clone $src ./feeds/$name") == 0 or return 1;
96 system("GIT_DIR=./feeds/$name/.git git pull") == 0 or return 1;
99 -d
"./feeds/$name.tmp" or mkdir "./feeds/$name.tmp" or return 1;
100 -d
"./feeds/$name.tmp/info" or mkdir "./feeds/$name.tmp/info" or return 1;
102 system("make -s prepare-mk TMP_DIR=\"$ENV{TOPDIR}/feeds/$name.tmp\"");
103 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\"");
104 system("ln -sf $name.tmp/.packageinfo ./feeds/$name.index");
113 parse_package_metadata
("./feeds/$feed.index") or return;
117 sub get_installed
() {
118 system("make -s prepare-tmpinfo");
120 parse_package_metadata
("./tmp/.packageinfo");
121 %installed = %package;
129 return unless @substr > 0;
131 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
132 my $pkg = $package{$name};
136 foreach my $substr (@substr) {
138 foreach my $key (qw(name title description)) {
139 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
141 $match or undef $pkgmatch;
145 print "Search results in feed '$feed':\n";
148 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
158 getopt
('r:', \
%opts);
159 foreach my $feed (@feeds) {
160 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
164 sub install_generic
() {
167 my $path = $pkg->{makefile
};
171 $path =~ s/\/Makefile$//;
173 -d
"./package/feeds" or mkdir "./package/feeds";
174 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
175 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
178 warn "Package is not valid\n";
184 my %install_method = (
185 'src-svn' => \
&install_generic
,
186 'src-cpy' => \
&install_generic
,
187 'src-link' => \
&install_generic
192 sub lookup_package
($$) {
196 foreach my $feed ($feed, @feeds) {
197 next unless $feed->[1];
198 next unless $feed{$feed->[1]};
199 $feed{$feed->[1]}->{$package} and return $feed;
204 sub install_package
{
209 $feed = lookup_package
($feed, $name);
211 $installed{$name} and return 0;
212 warn "WARNING: No feed for package '$name' found.\n";
216 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
218 $installed{$name} and return 0;
219 warn "WARNING: Package '$name' is not available in feed $feed->[1].\n";
222 my $src = $pkg->{src
};
223 my $type = $feed->[0];
224 $src or $src = $name;
226 # previously installed packages set the runtime package
227 # newly installed packages set the source package
228 $installed{$src} and return 0;
230 # install all dependencies
231 foreach my $dep (@
{$pkg->{depends
}}) {
234 install_package
($feed, $dep) == 0 or $ret = 1;
237 # check previously installed packages
238 $installed{$name} and return 0;
239 $installed{$src} = 1;
240 warn "Installing package '$src'\n";
242 $install_method{$type} or do {
243 warn "Unknown installation method: '$type'\n";
247 &{$install_method{$type}}($feed, $pkg) == 0 or do {
257 $default or $default = "o";
259 # workaround for timestamp check
260 system("rm -f tmp/.packageinfo");
263 system("make oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
272 getopts
('ap:d:', \
%opts);
275 foreach my $f (@feeds) {
277 $feed{$f->[1]} = get_feed
($f->[1]);
279 # look up the preferred feed
280 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
284 foreach my $f (@feeds) {
285 if (!defined($opts{p
}) or $opts{p
} eq $f->[1]) {
286 printf "Installing all packages from feed %s.\n", $f->[1];
288 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
289 my $p = $package{$name};
291 install_package
($feed, $p->{name
}) == 0 or $ret = 1;
293 warn "WARNING: Package '$name' is not available\n";
299 while ($name = shift @ARGV) {
300 install_package
($feed, $name) == 0 or $ret = 1;
304 # workaround for timestamp check
307 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
308 refresh_config
($opts{d
});
318 if ($ARGV[0] eq '-a') {
319 system("rm -rf ./package/feeds");
323 while ($name = shift @ARGV) {
324 my $pkg = $installed{$name};
326 warn "WARNING: $name not installed\n";
329 $pkg->{src
} and $name = $pkg->{src
};
330 warn "Uninstalling package '$name'\n";
331 system("rm -f ./package/feeds/*/$name");
335 $uninstall and refresh_config
();
341 Usage: $0 <command> [options]
344 install [options] <package>: Install a package
346 -a installs all packages from all feeds or from the specified feed
347 -p <feedname>: Prefer this feed when installing packages
348 -d <y|m|n>: Set default for newly installed packages
350 search [options] <substring>: Search for a package
352 -r <feedname>: Only search in this feed
354 uninstall -a|<package>: Uninstall a package
355 -a uninstalls all packages
357 update: Update packages and lists of feeds in feeds.list
358 clean: Remove downloaded/generated files
364 my %update_method = (
365 'src-svn' => \
&update_svn
,
366 'src-cpy' => \
&update_cpy
,
367 'src-link' => \
&update_link
,
368 'src-git' => \
&update_git
374 mkdir "feeds" or die "Unable to create the feeds directory";
376 $ENV{SCAN_COOKIE
} = $$;
377 $ENV{KBUILD_VERBOSE
} = 99;
378 foreach my $feed (@feeds) {
379 my ($type, $name, $src) = @
$feed;
380 $update_method{$type} or do {
381 warn "Unknown type '$type' in feed $name\n";
384 warn "Updating feed '$name'...\n";
385 &{$update_method{$type}}($name, $src) == 0 or do {
392 'install' => \
&install
,
393 'search' => \
&search
,
394 'uninstall' => \
&uninstall
,
396 system("rm -rf feeds");
400 my $arg = shift @ARGV;
403 foreach my $cmd (keys %commands) {
404 $arg eq $cmd and do {
405 exit(&{$commands{$cmd}}());
This page took 0.096736 seconds and 5 git commands to generate.