aboutsummaryrefslogtreecommitdiff
path: root/archivers/rpm2cpio
diff options
context:
space:
mode:
authorAlex Kozlov <ak@FreeBSD.org>2015-12-17 23:19:36 +0000
committerAlex Kozlov <ak@FreeBSD.org>2015-12-17 23:19:36 +0000
commite751b136545efdb7bc961b1c0de792599ea6499f (patch)
tree5fee2daf78bf6a772775d70047ec9608211a291e /archivers/rpm2cpio
parent56e11c5daf7d716a230927c17bcc660a8d2abdff (diff)
downloadports-e751b136545efdb7bc961b1c0de792599ea6499f.tar.gz
ports-e751b136545efdb7bc961b1c0de792599ea6499f.zip
- Convert rpm2cpio to shell script around bsdtar
Notes
Notes: svn path=/head/; revision=403941
Diffstat (limited to 'archivers/rpm2cpio')
-rw-r--r--archivers/rpm2cpio/Makefile8
-rw-r--r--archivers/rpm2cpio/files/rpm2cpio107
-rw-r--r--archivers/rpm2cpio/pkg-descr19
3 files changed, 19 insertions, 115 deletions
diff --git a/archivers/rpm2cpio/Makefile b/archivers/rpm2cpio/Makefile
index bd6752dc604d..82767a451d78 100644
--- a/archivers/rpm2cpio/Makefile
+++ b/archivers/rpm2cpio/Makefile
@@ -2,19 +2,16 @@
# $FreeBSD$
PORTNAME= rpm2cpio
-PORTVERSION= 1.3
-PORTREVISION= 3
+PORTVERSION= 1.4
CATEGORIES= archivers
MASTER_SITES= # none
DISTFILES= # none
MAINTAINER= ak@FreeBSD.org
-COMMENT= Convert .rpm files for extraction with /usr/bin/cpio, needs just perl
+COMMENT= Convert .rpm files to cpio format
NO_WRKSUBDIR= yes
-USES= perl5 shebangfix
-SHEBANG_FILES= ${PORTNAME}
NO_BUILD= yes
NO_ARCH= yes
@@ -25,6 +22,7 @@ do-extract:
@${CP} ${FILESDIR}/${PORTNAME} ${WRKSRC}/${PORTNAME}
do-install:
+# Installed as rpm2cpio.pl to not break existing scripts
${INSTALL_SCRIPT} ${WRKSRC}/${PORTNAME} ${STAGEDIR}${PREFIX}/bin/${PORTNAME}.pl
.include <bsd.port.mk>
diff --git a/archivers/rpm2cpio/files/rpm2cpio b/archivers/rpm2cpio/files/rpm2cpio
index 7f52d1a062f2..047544585420 100644
--- a/archivers/rpm2cpio/files/rpm2cpio
+++ b/archivers/rpm2cpio/files/rpm2cpio
@@ -1,98 +1,17 @@
-#!/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!)
+PATH=/bin:/usr/bin
-# 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.
+if [ $# -eq 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
-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;
-}
-
-die "No header\n" unless (96 == 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;
-
-die "No header\n" unless (16 == read $f, $rpm, 16);
-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));
- die "No header\n" unless (15 == read $f, $rpm, 15, 1);
-}
-
-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;
+tar cf - --format=newc @- < ${f}
diff --git a/archivers/rpm2cpio/pkg-descr b/archivers/rpm2cpio/pkg-descr
index 63226c87940f..0bd1cb8b9d21 100644
--- a/archivers/rpm2cpio/pkg-descr
+++ b/archivers/rpm2cpio/pkg-descr
@@ -1,20 +1,7 @@
-Convert .rpm files for extraction with /usr/bin/cpio
+Convert .rpm files to cpio format
-Quoting the author:
-
-why does the world need another rpm2cpio? because the existing one
+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.
-
-(this one needs just perl)
-
-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.
+This version just a tiny wrapper around bsdtar.