Upstream has been using a tiny shell script wrapper around bsdtar for
years now.

sysutils/mdprint extracts just fine as before.

OK?


Index: Makefile
===================================================================
RCS file: /cvs/ports/converters/rpm2cpio/Makefile,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile
--- Makefile    12 Jul 2019 20:43:52 -0000      1.16
+++ Makefile    21 Mar 2020 09:46:15 -0000
@@ -1,27 +1,21 @@
 # $OpenBSD: Makefile,v 1.16 2019/07/12 20:43:52 sthen Exp $
 
-COMMENT=       rpm2cpio converter in Perl
+COMMENT=       Convert .rpm files to cpio format
 
-DISTNAME=      rpm2cpio-1.3
+DISTNAME=      rpm2cpio-1.4
 CATEGORIES=    converters archivers
 
-REVISION=      2
-
-HOMEPAGE=      http://www.freebsd.org/cgi/cvsweb.cgi/ports/archivers/rpm2cpio/
+HOMEPAGE=      https://svnweb.freebsd.org/ports/archivers/rpm2cpio/
 
 # BSD
 PERMIT_PACKAGE=        Yes
 
 DISTFILES=     # empty
 
-RUN_DEPENDS=   archivers/bzip2 \
-               archivers/xz
+RUN_DEPENDS=   archivers/libarchive>2.8
 
-# don't extract, don't build. Install the script directly
-EXTRACT_ONLY=  # empty
 NO_BUILD=      Yes
 NO_TEST=       Yes
-PKG_ARCH=      *
 
 do-install:
        ${INSTALL_SCRIPT} ${FILESDIR}/rpm2cpio ${PREFIX}/bin
Index: files/rpm2cpio
===================================================================
RCS file: /cvs/ports/converters/rpm2cpio/files/rpm2cpio,v
retrieving revision 1.2
diff -u -p -r1.2 rpm2cpio
--- files/rpm2cpio      22 Aug 2010 17:55:38 -0000      1.2
+++ files/rpm2cpio      21 Mar 2020 09:57:56 -0000
@@ -1,98 +1,15 @@
-#!/usr/bin/perl -w
+#!/bin/sh
 
-# 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 
-# 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
+# NB! needs bsdtar/libarchive v2.8+
 
-# (whew, that's done!)
+if [ $# -eq 0 -a ! -t 0 ]; then
+       f=/dev/stdin
+elif [ $# -eq 1 ]; then
+       f=$1
+else
+       echo Usage: rpm2cpio [file.rpm]
+       echo dumps the contents to stdout as a GNU cpio archive
+       exit 0
+fi
 
-# 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.
-
-use strict;
-
-my ($f, $rpm, $filter) = ();
-
-if ($#ARGV == -1) {
-       $f = "STDIN";
-} elsif ($#ARGV == 0) {
-       open($f, "< $ARGV[0]") or die "Can't read file $ARGV[0]\n";
-} else {
-       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;
-}
-
-read $f, $rpm, 96;
-
-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 and $major != 4;
-
-read $f, $rpm, 16 or die "No header\n";
-while(1) {
-       ($magic, undef, my $sections, my $bytes) = unpack("N4", $rpm);
-       my ($smagic, $smagic2) = unpack("nN", $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;
-       }
-       # BZh
-       if ($smagic == 0x425a and ($smagic2 & 0xff000000) == 0x68000000) {
-               $filter = "bzip2 -cd";
-               last;
-       }
-       # 0xFD, '7zXZ', 0x0
-       if ($smagic == 0xfd37 and $smagic2 == 0x7a585a00) {
-               $filter = "xz -cd";
-               last;
-       }
-       # assume lzma if there is no sig
-       if ($magic != 0x8eade801) {
-               $filter = "lzma -cd";
-               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" ;
-       } while(0 == unpack("C", $rpm));
-       read $f, $rpm, 15, 1 or die "No header\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
-}
-
-close ZCAT;
-close $f;
+bsdtar cf - --format=newc @- < ${f}
Index: pkg/DESCR
===================================================================
RCS file: /cvs/ports/converters/rpm2cpio/pkg/DESCR,v
retrieving revision 1.2
diff -u -p -r1.2 DESCR
--- pkg/DESCR   15 Dec 2003 21:42:15 -0000      1.2
+++ pkg/DESCR   21 Mar 2020 09:32:05 -0000
@@ -1,4 +1,7 @@
-Rpm archives are actually cpio archive disguised behind another header.
+Convert .rpm files to cpio format.
 
-Rpm2cpio is a simple perl filter that strips this header, without
-having to install the whole rpm program.
+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.
+
+This version is just a tiny wrapper around bsdtar.

Reply via email to