ports/59980: update archivers/rpm2cpio

Juergen Lock nox at jelal.kn-bremen.de
Fri Dec 5 17:50:12 UTC 2003


>Number:         59980
>Category:       ports
>Synopsis:       update archivers/rpm2cpio
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 05 09:50:06 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     Juergen Lock
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
me?  organized??
>Environment:


	
>Description:
	Sergey Babkin sent me an updated version that doesn't slurp
	the entire file into memory and supports the newer bzip2
	compressed rpms.  He doesnt have a homepage for it so i
	just put it into files/ (its a small perl script...)
	Also, call it rpm2cpio.pl so that it doesn't conflict with
	the binary version from archivers/rpm.

>How-To-Repeat:
	
>Fix:

remove distinfo, add files/rpm2cpio

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/archivers/rpm2cpio/Makefile,v
retrieving revision 1.11
diff -u -r1.11 Makefile
--- Makefile	26 Oct 2003 22:37:40 -0000	1.11
+++ Makefile	5 Dec 2003 17:19:53 -0000
@@ -6,26 +6,27 @@
 #
 
 PORTNAME=	rpm2cpio
-PORTVERSION=	1.1.20020306
+PORTVERSION=	1.2
 CATEGORIES=	archivers
-MASTER_SITES=	http://www.iagora.com/~espel/
-DISTNAME=	${PORTNAME}
-EXTRACT_SUFX=
+MASTER_SITES=	# none
+DISTFILES=	# none
 
 MAINTAINER=	nox at jelal.kn-bremen.de
 COMMENT=	Convert .rpm files for extraction with /usr/bin/cpio, needs just perl
 
 NO_WRKSUBDIR=	yes
-EXTRACT_CMD=	${CP}
-EXTRACT_BEFORE_ARGS=
-EXTRACT_AFTER_ARGS=	.
 
 USE_PERL5=	yes
+NO_BUILD=	yes
 
-do-build:
-	${PERL5} -i.bak -p -e "if (1 .. 1) {s-^#!/usr/bin/perl-#!${PERL}-;}" ${WRKDIR}/rpm2cpio
+do-fetch:
+	@${DO_NADA}
+
+do-extract:
+	@${MKDIR} ${WRKSRC}
+	${PERL5} -p -e "if (1 .. 1) {s-^#!/usr/bin/perl-#!${PERL}-;}" ${FILESDIR}/${PORTNAME} >${WRKDIR}/${PORTNAME}
 
 do-install:
-	${INSTALL_SCRIPT} ${WRKDIR}/rpm2cpio ${PREFIX}/bin
+	${INSTALL_SCRIPT} ${WRKDIR}/${PORTNAME} ${PREFIX}/bin/${PORTNAME}.pl
 
 .include <bsd.port.mk>
Index: pkg-descr
===================================================================
RCS file: /home/ncvs/ports/archivers/rpm2cpio/pkg-descr,v
retrieving revision 1.2
diff -u -r1.2 pkg-descr
--- pkg-descr	29 Apr 2000 23:57:19 -0000	1.2
+++ pkg-descr	5 Dec 2003 17:28:02 -0000
@@ -9,4 +9,12 @@
 
 (this one needs just perl)
 
-WWW: http://www.iagora.com/~espel/
+Updated version by Sergey Babkin that doesn't slurp the entire file
+into memory and supports the newer bzip2 compressed rpms.
+
+BUGS: if the rpm contains more than one cpio file this version
+extracts only the first one. (I don't know how widespread these
+types of rpms are, i haven't yet seen one.  If you do, try the
+binary rpm2cpio that comes with the archivers/rpm port.)
+
+Now called rpm2cpio.pl so that it doesn't conflict with the binary one.
Index: pkg-plist
===================================================================
RCS file: /home/ncvs/ports/archivers/rpm2cpio/pkg-plist,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 pkg-plist
--- pkg-plist	1 Aug 1999 04:26:17 -0000	1.1.1.1
+++ pkg-plist	5 Dec 2003 17:19:58 -0000
@@ -1 +1 @@
-bin/rpm2cpio
+bin/rpm2cpio.pl
Index: files/rpm2cpio
@@ -0,0 +1,106 @@
+#!/usr/bin/perl
+
+# Copyright (C) 1997,1998,1999, Roger Espel Llima
+# Copyright (C) 2000, Sergey Babkin
+# 
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and any associated documentation files (the "Software"), to 
+# deal in the Software without restriction, including without limitation the 
+# rights to use, copy, modify, merge, publish, distribute, sublicense, 
+# and/or sell copies of the Software, and to permit persons to whom the 
+# Software is furnished to do so, subject to the following conditions:
+# 
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+# 
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# SOFTWARE'S COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE
+
+# (whew, that's done!)
+
+# why does the world need another rpm2cpio?  because the existing one
+# won't build unless you have half a ton of things that aren't really
+# required for it, since it uses the same library used to extract RPM's.
+# in particular, it won't build on the HPsUX box i'm on.
+
+
+# add a path if desired
+$gzip = "gzip";
+
+sub printhelp {
+  print "rpm2cpio, perl version by orabidoo <odar\@pobox.com>\n";
+  print "use: rpm2cpio [file.rpm]\n";
+  print "dumps the contents to stdout as a GNU cpio archive\n";
+  exit 0;
+}
+
+if ($#ARGV == -1) {
+  printhelp if -t STDIN;
+  $f = "STDIN";
+} elsif ($#ARGV == 0) {
+  open(F, "< $ARGV[0]") or die "Can't read file $ARGV[0]\n";
+  $f = 'F';
+} else {
+  printhelp;
+}
+
+printhelp if -t STDOUT;
+
+# gobble the file up
+undef $/;
+$|=1;
+#$rpm = <$f>;
+#close ($f);
+
+read $f, $rpm, 96 ;
+
+($magic, $major, $minor) = unpack("NCC", $rpm);
+
+die "Not an RPM\n" if $magic != 0xedabeedb;
+die "Not a version 3 RPM\n" if $major != 3;
+
+$filter="";
+
+read $f, $rpm, 16 or die "No header\n" ;
+while(1) {
+	($magic, $crap, $sections, $bytes) = unpack("N4", $rpm);
+	$smagic = unpack("n", $rpm);
+	$format="unknown";
+	if ($smagic eq 0x1f8b) {
+		$filter="gzip -cd";
+		last;
+	}
+	if (substr($rpm, 0, 3) eq "BZh") {
+		$filter="bzip2 -cd";
+		last;
+	}
+	#printf(STDERR "0x%x 0x%x 0x%x 0x%x\n", $magic, $sections, $bytes, $smagic);
+	die "Error: header not recognized\n" if $magic != 0x8eade801;
+	seek $f, 16*$sections+$bytes, 1 or die "FIle is too small\n"; # skip the headers
+	do {
+		read $f, $rpm, 1 or die "No header\n" ;
+		$c = unpack("C", $rpm);
+	} while($c==0);
+	read $f, $rpm, 15, 1 or die "No header\n" ;
+}
+
+#read $f, $rpm, 20 or die "No gzip header\n"; # the gzip header
+#$smagic = unpack("n", $rpm);
+#printf(STDERR "0x%x\n", $smagic);
+die "Error: bogus RPM\n" if $filter eq "";
+
+open(ZCAT, "| $filter") || die "can't pipe to $filter\n";
+#print STDERR "CPIO archive found!\n";
+
+while($rpm ne '') {
+	print ZCAT $rpm;
+	read $f, $rpm, 10240 ; # read in blocks
+}
+
+close ZCAT;
+
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list