summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authormanu <manu@pkgsrc.org>2001-03-20 20:18:07 +0000
committermanu <manu@pkgsrc.org>2001-03-20 20:18:07 +0000
commit94368917127127c872a39c70908351f80f174dd6 (patch)
treecd4efcba252b494559490aa7bfaff082bcdc667f /pkgtools
parentf2a9f370f559ce5a22c6a672222c056ab518ee4b (diff)
downloadpkgsrc-94368917127127c872a39c70908351f80f174dd6.tar.gz
Added a -s flag to strip leading directories in file paths. Requested by
the Netscape package for PowerPC, and probably others.
Diffstat (limited to 'pkgtools')
-rw-r--r--pkgtools/rpm2pkg/Makefile4
-rw-r--r--pkgtools/rpm2pkg/files/rpm2pkg.823
-rw-r--r--pkgtools/rpm2pkg/files/rpm2pkg.c39
3 files changed, 59 insertions, 7 deletions
diff --git a/pkgtools/rpm2pkg/Makefile b/pkgtools/rpm2pkg/Makefile
index 00d465d824c..21e8a6bd4ab 100644
--- a/pkgtools/rpm2pkg/Makefile
+++ b/pkgtools/rpm2pkg/Makefile
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.4 2001/02/17 17:51:33 wiz Exp $
+# $NetBSD: Makefile,v 1.5 2001/03/20 20:18:07 manu Exp $
-DISTNAME= rpm2pkg-1.1
+DISTNAME= rpm2pkg-1.2
CATEGORIES= pkgtools
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/rpm2pkg/files/rpm2pkg.8 b/pkgtools/rpm2pkg/files/rpm2pkg.8
index 5e81d9e5a40..d5d2277e758 100644
--- a/pkgtools/rpm2pkg/files/rpm2pkg.8
+++ b/pkgtools/rpm2pkg/files/rpm2pkg.8
@@ -1,4 +1,4 @@
-.\" $NetBSD: rpm2pkg.8,v 1.3 2001/02/06 17:38:52 wiz Exp $
+.\" $NetBSD: rpm2pkg.8,v 1.4 2001/03/20 20:18:07 manu Exp $
.\"
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -46,6 +46,7 @@
.Op Fl f Ar package_list
.Op Fl i Ar ignored_dir
.Op Fl p Ar prefix
+.Op Fl s Ar strip_path_count
.Ar rpm_file ...
.Sh DESCRIPTION
.Nm
@@ -83,6 +84,10 @@ directory of the RPM file's archives.
Use
.Ar prefix
when extracting files.
+.It Fl s Ar strip_path_count
+Strip
+.Ar strip_path_count
+leading directories in file names.
.El
.Sh EXAMPLES
.Nm
@@ -118,6 +123,22 @@ will not extract files contained in the
or
.Pa usr/tmp
directories of the RPM file's archives.
+.Pp
+.Nm
+.Fl s Ar 1
+.Fl d Ar /usr/pkg
+.Ar /usr/pkgsrc/distfiles/pack/bar.rpm
+.Pp
+This will extract the
+.Ar bar.rpm
+file in
+.Pa /usr/pkg
+while striping the leading directory of files path in
+.Ar bar.rpm .
+This is useful for dealing with RPM archives that contains files like
+.Pa usr/bin/foo ,
+which you would like to go in
+.Pa /usr/pkg/bin .
.Sh COMPATIBILITY
.Nm
should work with any regular RPM file.
diff --git a/pkgtools/rpm2pkg/files/rpm2pkg.c b/pkgtools/rpm2pkg/files/rpm2pkg.c
index dbad089b0f4..427312169b0 100644
--- a/pkgtools/rpm2pkg/files/rpm2pkg.c
+++ b/pkgtools/rpm2pkg/files/rpm2pkg.c
@@ -1,6 +1,6 @@
/*
- $NetBSD: rpm2pkg.c,v 1.1.1.1 2001/01/25 08:57:53 tron Exp $
+ $NetBSD: rpm2pkg.c,v 1.2 2001/03/20 20:18:07 manu Exp $
*/
@@ -176,7 +176,7 @@ void Usage(void)
{
(void)fprintf(stderr,
"Usage: %s [-d directory] [-f packlist] [[-i ignorepath] ...]\n"
- " [-p prefix] rpmfile [...]\n",
+ " [-p prefix] [-s strippath] rpmfile [...]\n",
__progname);
exit(EXIT_FAILURE);
}
@@ -434,7 +434,7 @@ int main(int argc,char **argv)
{
FILE *PList;
char **Ignore,*Prefix;
- int Opt,Index,FD,IsSource;
+ int Opt,Index,FD,IsSource,PathIndex,StripPath;
PListEntry *Files,*Links,*Dirs;
Header Hdr;
gzFile In;
@@ -442,9 +442,16 @@ int main(int argc,char **argv)
PList=NULL;
Ignore=NULL;
Prefix=NULL;
- while ((Opt=getopt(argc,argv,"d:f:i:p:"))!=-1)
+ StripPath = 0;
+ while ((Opt=getopt(argc,argv,"s:d:f:i:p:"))!=-1)
switch (Opt)
{
+ case 's':
+ StripPath=atoi(optarg);
+ if (StripPath == 0) {
+ fprintf(stderr,"Warning: -s argument to %s should be a positive integer, ignoring supplied argument\n",argv[Index]);
+ }
+ break;
case 'f':
if (PList!=NULL) (void)fclose(PList);
if ((PList=fopen(optarg,"a"))==NULL)
@@ -525,6 +532,8 @@ int main(int argc,char **argv)
{
long Fields[CPIO_NUM_HEADERS];
char *Name;
+ char *NewName;
+ char *TmpName;
mode_t Mode;
long Length;
@@ -557,6 +566,28 @@ int main(int argc,char **argv)
if (*Ptr!=NULL) Fields[CPIO_HDR_MODE]=0;
}
+ for (PathIndex=1; PathIndex<=StripPath; PathIndex++) {
+ NewName=Name;
+ do {
+ NewName++;
+ if (NewName[0]=='\0') {
+ fprintf(stderr,"%s: Leading path to strip too big (-s %d)\n",
+ argv[Index], StripPath);
+ return EXIT_FAILURE;
+ }
+ } while (NewName[0]!='/');
+ NewName++; /* We ended up with a leading /, and this must disapear */
+ TmpName=malloc(strlen(NewName));
+ if (TmpName==NULL)
+ {
+ perror(__progname);
+ exit(EXIT_FAILURE);
+ }
+ strcpy(TmpName, NewName);
+ free(Name);
+ Name=TmpName;
+ }
+
if (Prefix!=NULL)
{
char *Fullname;