aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2001-01-23 19:18:29 +0000
committerFrancois Pons <fpons@mandriva.com>2001-01-23 19:18:29 +0000
commit96c7624418b7b11ef42c95abb9059086de357c3b (patch)
tree5a689cd052d32660bfc26704f7f14bb33bdf509a
parentc4fa5b0abb878f44e75f575e20d303304d4e6d36 (diff)
downloadrpmtools-96c7624418b7b11ef42c95abb9059086de357c3b.tar
rpmtools-96c7624418b7b11ef42c95abb9059086de357c3b.tar.gz
rpmtools-96c7624418b7b11ef42c95abb9059086de357c3b.tar.bz2
rpmtools-96c7624418b7b11ef42c95abb9059086de357c3b.tar.xz
rpmtools-96c7624418b7b11ef42c95abb9059086de357c3b.zip
added --dir and -d flag for packdrake*.
management of specific directory for building archive.
-rwxr-xr-xpackdrake5
-rw-r--r--packdrake.pm24
-rw-r--r--rpmtools.pm22
-rw-r--r--rpmtools.spec6
4 files changed, 31 insertions, 26 deletions
diff --git a/packdrake b/packdrake
index d7b3b91..31841e2 100755
--- a/packdrake
+++ b/packdrake
@@ -17,6 +17,7 @@ usage:
--build <file> - build archive <file> with filenames given on
standard input.
-[1..9] - select appropriate compression ratio, $default_ratio by default.
+ --dir <srcdir> - set source directory where to search files, \".\" by default.
--size <cmd> - set maximun chunk size, $default_size by default.
--method <cmd> - select standard compression command method, default
is set according to archive filename, example is
@@ -45,6 +46,7 @@ sub main {
/^--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 };
@@ -55,6 +57,7 @@ sub main {
/x/ and do { $mode and die $error_mode; $mode = "extract"; @nextargv = (\$file, \$dir); next };
/l/ and do { $mode and die $error_mode; $mode = "list"; @nextargv = (\$file); next };
/c/ and do { $mode and die $error_mode; $mode = "cat"; @nextargv = (\$file); next };
+ /d/ and do { push @nextargv, \$dir; next };
/s/ and do { push @nextargv, \$size; next };
/m/ and do { push @nextargv, \$method; next };
die "packdrake: unknown option \"-$1\", check usage with --help\n"; } next };
@@ -78,7 +81,7 @@ sub main {
$mode =~ /extract/ && !$dir && !@list and ($mode, @list) = ('list', $file);
for ($mode) {
- /build/ and do { packdrake::build_archive(\*STDIN, $file, $size, $compress, $uncompress); last };
+ /build/ and do { packdrake::build_archive(\*STDIN, $dir, $file, $size, $compress, $uncompress); last };
/extract/ and do { my $packer = new packdrake($file); $packer->extract_archive($dir, @list); last };
/list/ and do { packdrake::list_archive($file, @list); last };
/cat/ and do { packdrake::cat_archive($file, @list); last };
diff --git a/packdrake.pm b/packdrake.pm
index 7bd57f4..5c720a1 100644
--- a/packdrake.pm
+++ b/packdrake.pm
@@ -3,7 +3,7 @@ package packdrake;
use strict;
use vars qw($VERSION);
-$VERSION = "0.02";
+$VERSION = "0.03";
=head1 NAME
@@ -21,7 +21,7 @@ packdrake - Mandrake Simple Archive Extractor/Builder
$packer->extract_archive("/tmp", "file1.o", "file2.o");
my $packer = packdrake::build_archive
- (\*STDIN, "/tmp/modules.cz2",
+ (\*STDIN, "/lib/modules", "/tmp/modules.cz2",
400000, "bzip2", "bzip2 -d");
my $packer = packdrake::build_archive
(\*STDIN, "/export/Mandrake/base/hdlist.cz",
@@ -212,14 +212,15 @@ sub catsksz {
}
sub cat_compress {
- my ($packer, @filenames) = @_;
+ my ($packer, $srcdir, @filenames) = @_;
local *F;
open F, "| $packer->{compress} >$packer->{tmpz}" or die "packdrake: cannot start \"$packer->{compress}\"\n";
foreach (@filenames) {
+ my $srcfile = $srcdir ? "$srcdir/$_" : $_;
my ($buf, $siz, $sz);
local *FILE;
- open FILE, $_ or die "packdrake: cannot open $_: $!\n";
- $siz = -s $_;
+ open FILE, $srcfile or die "packdrake: cannot open $srcfile: $!\n";
+ $siz = -s $srcfile;
while (($sz = sysread(FILE, $buf, $siz > 65536 ? 65536 : $siz))) {
$siz -= $sz;
syswrite(F, $buf);
@@ -407,7 +408,7 @@ sub extract_archive {
}
sub build_archive {
- my ($f, $archivename, $maxsiz, $compress, $uncompress, $tmpz) = @_;
+ my ($f, $srcdir, $archivename, $maxsiz, $compress, $uncompress, $tmpz) = @_;
my ($off1, $siz1, $off2, $siz2) = ('', '', 0, 0, 0, 0);
my @filelist = ();
my $packer = new packdrake;
@@ -424,23 +425,24 @@ sub build_archive {
my $file;
while ($file = <$f>) {
chomp $file;
- -e $file or die "packdrake: unable to find file $file\n";
+ my $srcfile = $srcdir ? "$srcdir/$file" : $file;
+ -e $srcfile or die "packdrake: unable to find file $srcfile\n";
push @{$packer->{files}}, $file;
#- now symbolic link and directory are supported, extension is
#- available with the first field of $data{$file}.
if (-l $file) {
- $packer->{data}{$file} = [ 'l', readlink $file ];
+ $packer->{data}{$file} = [ 'l', readlink $srcfile ];
} elsif (-d $file) {
$packer->{data}{$file} = [ 'd' ];
} else {
- $siz2 = -s $file;
+ $siz2 = -s $srcfile;
push @filelist, $file;
$packer->{data}{$file} = [ 'f', -1, -1, $off2, $siz2 ];
if ($off2 + $siz2 > $maxsiz) { #- need compression.
- $siz1 = cat_compress($packer, @filelist);
+ $siz1 = cat_compress($packer, $srcdir, @filelist);
foreach (@filelist) {
$packer->{data}{$_} = [ 'f', $off1, $siz1, $packer->{data}{$_}[3], $packer->{data}{$_}[4] ];
@@ -455,7 +457,7 @@ sub build_archive {
}
}
if (scalar @filelist) {
- $siz1 = cat_compress($packer, @filelist);
+ $siz1 = cat_compress($packer, $srcdir, @filelist);
foreach (@filelist) {
$packer->{data}{$_} = [ 'f', $off1, $siz1, $packer->{data}{$_}[3], $packer->{data}{$_}[4] ];
diff --git a/rpmtools.pm b/rpmtools.pm
index d401183..738aab5 100644
--- a/rpmtools.pm
+++ b/rpmtools.pm
@@ -74,10 +74,6 @@ sub new {
info => {},
depslist => [],
provides => {},
- options => {
- tmpdir => $ENV{TMPDIR} || "/tmp",
- noclean => 0,
- },
}, $class;
}
@@ -108,22 +104,22 @@ sub read_hdlists {
#- build an hdlist from a list of files.
sub build_hdlist {
- my ($params, $hdlist, @rpms) = @_;
- my ($work_dir, %names) = "$params->{options}{tmpdir}/.build_hdlist";
+ my ($params, $noclean, $dir, $hdlist, @rpms) = @_;
+ my %names;
#- build a working directory which will hold rpm headers.
- -d $work_dir or mkdir $work_dir, 0755 or die "cannot create working directory $work_dir\n";
- my $cwd = `pwd`; chdir $work_dir;
+ $dir ||= '.';
+ -d $dir or mkdir $dir, 0755 or die "cannot create directory $dir\n";
foreach (@rpms) {
my ($key, $name) = /(([^\/]*)-[^-]*-[^-]*\.[^\/\.]*)\.rpm$/ or next;
- system("rpm2header '$_' > $key") unless -e $key;
- $? == 0 or unlink($key), die "bad rpm $_\n";
- -s $key or unlink($key), die "bad rpm $_\n";
+ system("rpm2header '$_' > '$dir/$key'") unless -e "$dir/$key";
+ $? == 0 or unlink("$dir/$key"), die "bad rpm $_\n";
+ -s "$dir/$key" or unlink("$dir/$key"), die "bad rpm $_\n";
push @{$names{$name} ||= []}, $key;
}
- open B, "| packdrake -b9s '$hdlist' 400000";
+ open B, "| packdrake -b9ds '$hdlist' '$dir' 400000";
foreach (@{$params->{depslist}}) {
if (my $keys = delete $names{$_->{name}}) {
print B "$_\n" foreach @$keys;
@@ -134,7 +130,7 @@ sub build_hdlist {
}
close B or die "packdrake failed\n";
- chdir $cwd; system("rm", "-rf", $work_dir) unless $params->{options}{noclean};
+ system("rm", "-rf", $dir) unless $dir eq '.' || $noclean;
}
#- read one or more rpm files.
diff --git a/rpmtools.spec b/rpmtools.spec
index a07610b..27304b3 100644
--- a/rpmtools.spec
+++ b/rpmtools.spec
@@ -1,5 +1,5 @@
%define name rpmtools
-%define release 8mdk
+%define release 9mdk
# do not modify here, see Makefile in the CVS
%define version 2.1
@@ -51,6 +51,10 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/perl5/man/*/*
%changelog
+* Tue Jan 23 2001 François Pons <fpons@ackbar.mandrakesoft.com> 2.1-9mdk
+- packdrake.pm to 0.03, added source directory for building an archive.
+- changed build_archive to use a specific directory.
+
* Wed Jan 17 2001 François Pons <fpons@mandrakesoft.com> 2.1-8mdk
- removed obsoleted genhdlists, genhdlist_cz2, genbasefiles by gendistrib.
- new tools gendistrib which integrate all the obsoleted tools.