aboutsummaryrefslogtreecommitdiffstats
path: root/packdrake
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-10-03 12:49:04 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2005-10-03 12:49:04 +0000
commit7f10b37e17863c3b2248c9e797a9edf0deea898a (patch)
treed5a71f2a14e744afeb47dc3275aa0bc25c8274f3 /packdrake
parent377a9c91ef276d7ff34b32426d4ea17717a6f2f5 (diff)
downloadrpmtools-7f10b37e17863c3b2248c9e797a9edf0deea898a.tar
rpmtools-7f10b37e17863c3b2248c9e797a9edf0deea898a.tar.gz
rpmtools-7f10b37e17863c3b2248c9e797a9edf0deea898a.tar.bz2
rpmtools-7f10b37e17863c3b2248c9e797a9edf0deea898a.tar.xz
rpmtools-7f10b37e17863c3b2248c9e797a9edf0deea898a.zip
Begin cleanup.
Diffstat (limited to 'packdrake')
-rwxr-xr-xpackdrake99
1 files changed, 48 insertions, 51 deletions
diff --git a/packdrake b/packdrake
index 22a5469..7bf266f 100755
--- a/packdrake
+++ b/packdrake
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use strict;
-require packdrake;
+use packdrake;
#- general information.
my $default_size = 400000;
@@ -34,26 +34,25 @@ usage:
);
}
-sub main {
- my ($file, $mode, $dir, $size, $method, $compress, $uncompress, $ratio, $quiet);
- my @nextargv = (\$file);
- my @list;
+my ($file, $mode, $dir, $size, $method, $compress, $uncompress, $ratio, $quiet);
+my @nextargv = (\$file);
+my @list;
- #- some quite useful error message.
- my $error_mode = "packdrake: choose only --build, --extract, --list or --cat\n";
- foreach (@_) {
- /^--help$/ and do { usage; next };
- /^--build$/ and do { $mode and die $error_mode; $mode = "build"; @nextargv = (\$file); next };
- /^--extract$/ and do { $mode and die $error_mode; $mode = "extract"; @nextargv = (\$file, \$dir); next };
- /^--list$/ and do { $mode and die $error_mode; $mode = "list"; @nextargv = (\$file); next };
- /^--cat$/ and do { $mode and die $error_mode; $mode = "cat"; @nextargv = (\$file); next };
- /^--dir$/ and do { push @nextargv, \$dir; next };
- /^--size$/ and do { push @nextargv, \$size; next };
- /^--method$/ and do { push @nextargv, \$method; next };
- /^--compress$/ and do { push @nextargv, \$compress; next };
- /^--uncompress$/ and do { push @nextargv, \$uncompress; next };
- /^--quiet$/ and $quiet = 1, next;
- /^-(.*)$/ and do { foreach (split //, $1) {
+#- some quite useful error message.
+my $error_mode = "packdrake: choose only --build, --extract, --list or --cat\n";
+foreach (@ARGV) {
+ /^--help$/ and do { usage; next };
+ /^--build$/ and do { $mode and die $error_mode; $mode = "build"; @nextargv = (\$file); next };
+ /^--extract$/ and do { $mode and die $error_mode; $mode = "extract"; @nextargv = (\$file, \$dir); next };
+ /^--list$/ and do { $mode and die $error_mode; $mode = "list"; @nextargv = (\$file); next };
+ /^--cat$/ and do { $mode and die $error_mode; $mode = "cat"; @nextargv = (\$file); next };
+ /^--dir$/ and do { push @nextargv, \$dir; next };
+ /^--size$/ and do { push @nextargv, \$size; next };
+ /^--method$/ and do { push @nextargv, \$method; next };
+ /^--compress$/ and do { push @nextargv, \$compress; next };
+ /^--uncompress$/ and do { push @nextargv, \$uncompress; next };
+ /^--quiet$/ and $quiet = 1, next;
+ /^-(.*)$/ and do { foreach (split //, $1) {
/[1-9]/ and do { $ratio = $_; next };
/b/ and do { $mode and die $error_mode; $mode = "build"; @nextargv = (\$file); next };
/x/ and do { $mode and die $error_mode; $mode = "extract"; @nextargv = (\$file, \$dir); next };
@@ -63,40 +62,38 @@ sub main {
/s/ and do { push @nextargv, \$size; next };
/m/ and do { push @nextargv, \$method; next };
die qq(packdrake: unknown option "-$1", check usage with --help\n) } next };
- $mode =~ /extract|list|cat/
- or @nextargv
- or die qq(packdrake: unknown option "$_", check usage with --help\n);
- my $ref = shift @nextargv;
- $ref ? ($$ref = $_) : push @list, $_;
- $mode ||= "list";
- }
+ $mode =~ /extract|list|cat/
+ or @nextargv
+ or die qq(packdrake: unknown option "$_", check usage with --help\n);
+ my $ref = shift @nextargv;
+ $ref ? ($$ref = $_) : push @list, $_;
+ $mode ||= "list";
+}
- #- examine and lauch.
- $file or die "packdrake: no archive filename given, check usage with --help\n";
- $size ||= 400000;
- $ratio ||= 6;
+#- examine and lauch.
+$file or die "packdrake: no archive filename given, check usage with --help\n";
+$size ||= $default_size;
+$ratio ||= $default_ratio;
- unless ($method) {
- $file =~ /\.cz$/ and $method = "gzip";
- $file =~ /\.cz2$/ and $method = "bzip2";
- }
+unless ($method) {
+ $file =~ /\.cz$/ and $method = "gzip";
+ $file =~ /\.cz2$/ and $method = "bzip2";
+}
- $compress ||= "$method -$ratio";
- $uncompress ||= "$method -d";
+$compress ||= "$method -$ratio";
+$uncompress ||= "$method -d";
- $mode =~ /extract/ && !$dir && !@list and ($mode, @list) = ('list', $file);
- for ($mode) {
- /build/ and do { packdrake::build_archive(\*STDIN, $dir, $file, $size, $compress, $uncompress); last };
- /extract/ and do {
- my $packer = new packdrake($file, quiet => $quiet);
- $packer->extract_archive($dir, @list);
- last;
- };
- /list/ and do { packdrake::list_archive($file, @list); last };
- /cat/ and do { packdrake::cat_archive($file, @list); last };
- die "packdrake: internal error, unable to select right mode?\n";
- }
+$mode =~ /extract/ && !$dir && !@list and ($mode, @list) = ('list', $file);
+for ($mode) {
+ /build/ and do { packdrake::build_archive(\*STDIN, $dir, $file, $size, $compress, $uncompress); last };
+ /extract/ and do {
+ my $packer = new packdrake($file, quiet => $quiet);
+ $packer->extract_archive($dir, @list);
+ last;
+ };
+ /list/ and do { packdrake::list_archive($file, @list); last };
+ /cat/ and do { packdrake::cat_archive($file, @list); last };
+ die "packdrake: internal error, unable to select right mode?\n";
}
-#- start the stuff.
-main(@ARGV);
+__END__