diff options
author | nanardon <nanardon@971eb68f-4bfb-0310-8326-d2484c010a4c> | 2005-10-04 04:08:46 +0000 |
---|---|---|
committer | nanardon <nanardon@971eb68f-4bfb-0310-8326-d2484c010a4c> | 2005-10-04 04:08:46 +0000 |
commit | 9e2966a33f9148fdc8ef81783bab1fe18e87bd34 (patch) | |
tree | 7497629483bdfca79e64991306f251dfdc9bdafb /RPM4/bin/urpm_interactive | |
parent | 588601a22c421404c9db24e0a47330d2186977f9 (diff) | |
download | perl-RPM4-9e2966a33f9148fdc8ef81783bab1fe18e87bd34.tar perl-RPM4-9e2966a33f9148fdc8ef81783bab1fe18e87bd34.tar.gz perl-RPM4-9e2966a33f9148fdc8ef81783bab1fe18e87bd34.tar.bz2 perl-RPM4-9e2966a33f9148fdc8ef81783bab1fe18e87bd34.tar.xz perl-RPM4-9e2966a33f9148fdc8ef81783bab1fe18e87bd34.zip |
- move to trunk
git-svn-id: svn+ssh://haiku.zarb.org/home/projects/rpm4/svn/trunk@36 971eb68f-4bfb-0310-8326-d2484c010a4c
Diffstat (limited to 'RPM4/bin/urpm_interactive')
-rwxr-xr-x | RPM4/bin/urpm_interactive | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/RPM4/bin/urpm_interactive b/RPM4/bin/urpm_interactive new file mode 100755 index 0000000..7756fea --- /dev/null +++ b/RPM4/bin/urpm_interactive @@ -0,0 +1,149 @@ +#!/usr/bin/perl + +##- Nanar <nanardon@mandrake.org> +##- +##- This program is free software; you can redistribute it and/or modify +##- it under the terms of the GNU General Public License as published by +##- the Free Software Foundation; either version 2, or (at your option) +##- any later version. +##- +##- This program is distributed in the hope that it will be useful, +##- but WITHOUT ANY WARRANTY; without even the implied warranty of +##- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +##- GNU General Public License for more details. +##- +##- You should have received a copy of the GNU General Public License +##- along with this program; if not, write to the Free Software +##- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# $Id$ + +use strict; +use warnings; + +use Hdlist::Media; +use Hdlist::Media::Solve; +use Term::ReadLine; +use Text::ParseWords; +use urpm; +use Getopt::Long; + +#Hdlist::setverbosity('DEBUG'); + +my $dbpath; + +GetOptions( + "dbpath=s" => \$dbpath, +); + + +Hdlist::add_macro("_dbpath $dbpath") if ($dbpath); + +my $s = Hdlist::Media::Solve->new( +); + +{ + my $u = urpm->new(); + $u->read_config; + foreach my $m (@{$u->{media}}) { + $m->{virtual} or next; + my $dir = $m->{url}; + $dir =~ s!file:/+!/!; + $s->addmedia( + Hdlist::Media->new( + hdlist => $m->{with_hdlist}, + rpmsdir => $dir, + ), + ); + } +} + +$s->add_system_dep('REQUIRE', "basesystem"); + +$s->load(); + +my $term = new Term::ReadLine 'Hdlist'; + +my $prompt = "urpm > "; + +while (defined (my $cmdline = $term->readline($prompt))) { + chomp($cmdline); + my $cmd; local @ARGV; + ($cmd, @ARGV) = &parse_line('\s+', 0, $cmdline); + + $cmd or next; + $term->addhistory($cmdline); + + $cmd =~ /^quit$/ and last; + + $cmd =~ /^(q|query)$/ and do { + my $tag; + my $qf; + GetOptions( + "t|tag=s" => \$tag, + "qf|queryformat=s" => \$qf, + ); + $s->traverse(db => 1, medium => undef, callback => sub { + my ($header, $id, $media) = @_; + print "$media: " . $header->queryformat($qf || $s->{short_fmt}) ."\n"; + 1; + }, tag => $tag || ($ARGV[0] ? 'NAME' : ""), tagvalue => $ARGV[0]); + next; + }; + + $cmd =~ /^sysdep$/ and do { + my $tag = 'REQUIRE'; + GetOptions( + 'c' => sub { $tag = 'CONFLICT'; }, + ); + $ARGV[0] or next; + $s->add_system_dep($tag, @ARGV); + next; + }; + + $cmd =~ /^(\+|add)$/ and do { + $s->find_and_add($ARGV[0]); + next; + }; + + $cmd =~ /^(-|remove)$/ and do { + $s->find_and_remove($ARGV[0]); + next; + }; + + $cmd =~ /^a(utoselect)?$/ and do { + $s->autoselect(); + next; + }; + + $cmd =~ /^c(heck)?$/ and do { + $s->check(); + next; + }; + + $cmd =~ /^r(un)?$/ and do { + $s->run(); + next; + }; + + $cmd =~ /^l(ist)?$/ and do { + $s->list_trans(); + next; + }; + + $cmd =~ /^d$/ and do { + $s->add_from_require(@ARGV); + next; + }; + + $cmd =~ /^clean$/ and do { + foreach (@ARGV) { + m/trans/ and $s->clean_trans(); + m/request/ and $s->clean_request(); + } + next; + }; + + print "unknow command '$cmd'\n"; +}; + |