ports/148446: [patch] update archivers/rpm2cpio
Alex Kozlov
spam at rm-rf.kiev.ua
Thu Jul 8 03:30:07 UTC 2010
>Number: 148446
>Category: ports
>Synopsis: [patch] update archivers/rpm2cpio
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Thu Jul 08 03:30:06 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Alex Kozlov
>Release: RELENG_8
>Organization:
private
>Environment:
>Description:
Update rpm2cpio
-general cleanup
-remove invalid email (550 <odar at pobox.com>: Recipient address rejected: User unknown)
-replace PERL by REINPLACE_CMD
-add supports the lzma compressed rpms
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
Index: archivers/rpm2cpio/Makefile
@@ -6,8 +6,7 @@
#
PORTNAME= rpm2cpio
-PORTVERSION= 1.2
-PORTREVISION= 2
+PORTVERSION= 1.3
CATEGORIES= archivers
MASTER_SITES= # none
DISTFILES= # none
@@ -19,6 +18,8 @@
USE_PERL5= yes
NO_BUILD= yes
+REINPLACE_ARGS=
+
PLIST_FILES= bin/rpm2cpio.pl
do-fetch:
@@ -26,7 +27,7 @@
do-extract:
@${MKDIR} ${WRKSRC}
- ${PERL5} -p -e "if (1 .. 1) {s-^#!/usr/bin/perl-#!${PERL}-;}" ${FILESDIR}/${PORTNAME} >${WRKDIR}/${PORTNAME}
+ @${REINPLACE_CMD} -e 's|^#!/usr/bin/perl|#!${PERL}|' ${FILESDIR}/${PORTNAME} >${WRKDIR}/${PORTNAME}
do-install:
${INSTALL_SCRIPT} ${WRKDIR}/${PORTNAME} ${PREFIX}/bin/${PORTNAME}.pl
Index: archivers/rpm2cpio/files/rpm2cpio
@@ -1,7 +1,8 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -w
# Copyright (C) 1997,1998,1999, Roger Espel Llima
# Copyright (C) 2000, Sergey Babkin
+# Copyright (C) 2009, Alex Kozlov
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and any associated documentation files (the "Software"), to
@@ -28,79 +29,68 @@
# 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.
+use strict;
-# 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;
-}
+my ($f, $rpm, $filter) = ();
if ($#ARGV == -1) {
- printhelp if -t STDIN;
- $f = "STDIN";
+ $f = "STDIN";
} elsif ($#ARGV == 0) {
- open(F, "< $ARGV[0]") or die "Can't read file $ARGV[0]\n";
- $f = 'F';
+ open($f, "< $ARGV[0]") or die "Can't read file $ARGV[0]\n";
} else {
- printhelp;
+ print "rpm2cpio v1.3, perl version by orabidoo\n";
+ print "use: rpm2cpio [file.rpm]\n";
+ print "dumps the contents to stdout as a GNU cpio archive\n";
+ exit 0;
}
-printhelp if -t STDOUT;
-
# gobble the file up
undef $/;
$|=1;
-#$rpm = <$f>;
-#close ($f);
-read $f, $rpm, 96 ;
+read $f, $rpm, 96;
-($magic, $major, $minor) = unpack("NCC", $rpm);
+my ($magic, $major, undef) = unpack("NCC", $rpm);
die "Not an RPM\n" if $magic != 0xedabeedb;
die "Not a version 3 or 4 RPM\n" if $major != 3 && $major != 4;
-$filter="";
-
-read $f, $rpm, 16 or die "No header\n" ;
+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";
+ ($magic, undef, my $sections, my $bytes) = unpack("N4", $rpm);
+ my $smagic = unpack("n", $rpm);
+
+ #printf(STDERR "0x%x 0x%x 0x%x 0x%x 0x%x\n",
+ # tell($f)-16, $magic, $sections, $bytes, $smagic);
+
+ if ($smagic == 0x1f8b) {
+ $filter = "gzip -cd";
last;
}
if (substr($rpm, 0, 3) eq "BZh") {
- $filter="bzip2 -cd";
+ $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
+ # assume lzma if there is no sig
+ if ($magic != 0x8eade801) {
+ $filter = "lzma -dc";
+ last;
+ }
+
+ # skip the headers
+ seek $f, 16*$sections+$bytes, 1 or die "File is too small\n";
do {
read $f, $rpm, 1 or die "No header\n" ;
- $c = unpack("C", $rpm);
- } while($c==0);
+ } while(0 == unpack("C", $rpm));
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";
+open(ZCAT, "| $filter") or die "can't pipe to $filter\n";
while($rpm ne '') {
print ZCAT $rpm;
- read $f, $rpm, 10240 ; # read in blocks
+ read $f, $rpm, 10240; # read in blocks
}
close ZCAT;
-
+close $f;
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list