5 use lib
"$FindBin::Bin";
10 chdir "$FindBin::Bin/..";
11 $ENV{TOPDIR
}=getcwd
();
21 open FEEDS
, "feeds.conf";
26 my @line = split /\s+/, $_, 3;
30 $line[0] =~ /^src-\w+$/ or $valid = 0;
31 $line[1] =~ /^\w+$/ or $valid = 0;
32 $line[2] =~ /\s/ and $valid = 0;
33 $valid or die "Syntax error in feeds.list, line: $line\n";
35 $name{$line[1]} and die "Duplicate feed name '$line[1]', line: $line\n";
47 system("svn co $src ./feeds/$name") == 0 or return 1;
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 parse_package_metadata
("./feeds/$feed.index") or return;
67 system("make -s prepare-tmpinfo");
69 parse_package_metadata
("./tmp/.packageinfo");
70 %installed = %package;
78 return unless @substr > 0;
80 foreach my $name (sort { lc($a) cmp lc($b) } keys %package) {
81 my $pkg = $package{$name};
85 foreach my $substr (@substr) {
87 foreach my $key (qw(name title description)) {
88 $pkg->{$key} and $substr and $pkg->{$key} =~ m/$substr/i and $match = 1;
90 $match or undef $pkgmatch;
94 print "Search results in feed '$feed':\n";
97 printf "\%-25s\t\%s\n", $pkg->{name
}, $pkg->{title
};
107 getopt
('r:', \
%opts);
108 foreach my $feed (@feeds) {
109 search_feed
($feed->[1], @ARGV) if (!defined($opts{r
}) or $opts{r
} eq $feed->[1]);
116 my $path = $pkg->{makefile
};
117 $path =~ s/\/Makefile$//;
119 -d
"./package/feeds" or mkdir "./package/feeds";
120 -d
"./package/feeds/$feed->[1]" or mkdir "./package/feeds/$feed->[1]";
121 system("ln -sf ../../../$path ./package/feeds/$feed->[1]/");
126 my %install_method = (
127 'src-svn' => \
&install_svn
132 sub lookup_package
($$) {
136 foreach my $feed ($feed, @feeds) {
137 next unless $feed->[1];
138 next unless $feed{$feed->[1]};
139 $feed{$feed->[1]}->{$package} and return $feed;
144 sub install_package
{
149 $feed = lookup_package
($feed, $name);
151 $installed{$name} and return 0;
152 warn "WARNING: Package '$name' is not available.\n";
156 my $pkg = $feed{$feed->[1]}->{$name} or return 1;
157 my $src = $pkg->{src
};
158 my $type = $feed->[0];
159 $src or $src = $name;
161 # previously installed packages set the runtime package
162 # newly installed packages set the source package
163 $installed{$src} and return 0;
165 # install all dependencies
166 foreach my $dep (@
{$pkg->{depends
}}) {
169 install_package
($feed, $dep) == 0 or $ret = 1;
172 # check previously installed packages
173 $installed{$name} and return 0;
174 $installed{$src} = 1;
175 warn "Installing package '$src'\n";
177 $install_method{$type} or do {
178 warn "Unknown installation method: '$type'\n";
182 &{$install_method{$type}}($feed, $pkg) == 0 or do {
192 $default or $default = "o";
194 # workaround for timestamp check
195 system("rm -f tmp/.packageinfo");
198 system("make oldconfig CONFDEFAULT=\"$default\" Config.in >/dev/null 2>/dev/null");
207 getopt
('p:d:', \
%opts);
210 foreach my $f (@feeds) {
212 $feed{$f->[1]} = get_feed
($f->[1]);
214 # look up the preferred feed
215 $opts{p
} and $f->[1] eq $opts{p
} and $feed = $f;
218 while ($name = shift @ARGV) {
219 install_package
($feed, $name) == 0 or $ret = 1;
222 # workaround for timestamp check
225 if ($opts{d
} and $opts{d
} =~ /^[ymn]$/) {
226 refresh_config
($opts{d
});
236 if ($ARGV[0] eq '-a') {
237 system("rm -rf ./package/feeds");
241 while ($name = shift @ARGV) {
242 my $pkg = $installed{$name};
244 warn "WARNING: $name not installed\n";
247 $pkg->{src
} and $name = $pkg->{src
};
248 warn "Uninstalling package '$name'\n";
249 system("rm -f ./package/feeds/*/$name");
253 $uninstall and refresh_config
();
259 Usage: $0 <command> [options]
262 install [options] <package>: Install a package
264 -p <feedname>: Prefer this feed when installing packages
265 -d <y|m|n>: Set default for newly installed packages
267 search [options] <substring>: Search for a package
269 -r <feedname>: Only search in this feed
271 uninstall -a|<package>: Uninstall a package
272 -a uninstalls all packages
274 update: Update packages and lists of feeds in feeds.list
275 clean: Remove downloaded/generated files
281 my %update_method = (
282 'src-svn' => \
&update_svn
288 mkdir "feeds" or die "Unable to create the feeds directory";
290 $ENV{SCAN_COOKIE
} = $$;
291 $ENV{KBUILD_VERBOSE
} = 99;
292 foreach my $feed (@feeds) {
293 my ($type, $name, $src) = @
$feed;
294 $update_method{$type} or do {
295 warn "Unknown type '$type' in feed $name\n";
298 warn "Updating feed '$name'...\n";
299 &{$update_method{$type}}($name, $src) == 0 or do {
306 'install' => \
&install
,
307 'search' => \
&search
,
308 'uninstall' => \
&uninstall
,
310 system("rm -rf feeds");
314 my $arg = shift @ARGV;
317 foreach my $cmd (keys %commands) {
318 $arg eq $cmd and do {
319 exit(&{$commands{$cmd}}());
This page took 0.069969 seconds and 5 git commands to generate.