From c9b960ea2db17725b8f9ac0270cee2dedf67aec1 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sun, 24 Oct 2004 17:31:30 +0000 Subject: - DWIM, ie autodetection of the argument ( if a spec, build from spec, etc ) --- rpmbuildupdate | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/rpmbuildupdate b/rpmbuildupdate index 1a86dfb..b81bc81 100755 --- a/rpmbuildupdate +++ b/rpmbuildupdate @@ -15,7 +15,6 @@ # TODO # do not hardcode sudo urpmi command ( to use --deps on cluster ) # rework configuration option -# add more dwimess ( ie, autodetect if we give a spec, a src.rpm, or a package name ) use strict; use AppConfig; @@ -548,22 +547,32 @@ sub main { if ($config{rpmmon}) { print($config{srpms}); parse_rpmmon($config{rpmmon}) - } elsif ($config{src} && $ARGV[0]) { - build_from_src($config{src}, $ARGV[0]) - } elsif ($config{spec} && $ARGV[0]) { - build_from_spec($config{spec}, $ARGV[0]) - } elsif ($ARGV[0] && $ARGV[1]) { - check_dir($config{srpms}); - build_from_repository($ARGV[0], $ARGV[1]) - } elsif ($config{src}) { - build_from_src($config{src}) - } elsif ($config{spec}) { - build_from_spec($config{spec}) - } elsif ($ARGV[0]) { - check_dir($config{srpms}); - build_from_repository($ARGV[0]) - } else { - usage + } else { + my ($new_version,$name); + if ($config{src} or $config{spec}) + { + $new_version = $ARGV[0] || undef; + } + elsif ($ARGV[0]) + { + $name= $ARGV[0]; $new_version = $ARGV[1]; + if (-f $name) + { + $name =~ /.spec$/ and $config{spec} = $name; + # FIXME better auto detection with nosrc.rpm ? + $name =~ /.src.rpm$/ and $config{src} = $name; + } + } + if ($config{src}) { + build_from_src($config{src}, $new_version) + } elsif ($config{spec}) { + build_from_spec($config{spec},$new_version) + } elsif ($name) { + check_dir($config{srpms}); + build_from_repository($name,$new_version) + } else { + usage + } } } -- cgit v1.2.1