diff options
author | Tilman Sauerbeck <tilman@crux.nu> | 2009-06-13 22:37:21 +0200 |
---|---|---|
committer | Tilman Sauerbeck <tilman@crux.nu> | 2009-06-13 22:37:21 +0200 |
commit | 3f395cd352e0ebbc5066924fb9747b716d4cdc3f (patch) | |
tree | 3efa3bbb4479df1fcc50a5f4e918006a187c8845 /rpm2targz | |
parent | bc41893dd361495d09d13a77c871f123899bbefe (diff) | |
download | opt-3f395cd352e0ebbc5066924fb9747b716d4cdc3f.tar.gz opt-3f395cd352e0ebbc5066924fb9747b716d4cdc3f.tar.xz |
rpm2targz: moved from core
Diffstat (limited to 'rpm2targz')
-rw-r--r-- | rpm2targz/.footprint | 6 | ||||
-rw-r--r-- | rpm2targz/.md5sum | 2 | ||||
-rw-r--r-- | rpm2targz/Pkgfile | 14 | ||||
-rw-r--r-- | rpm2targz/README | 6 | ||||
-rwxr-xr-x | rpm2targz/rpm2targz | 66 | ||||
-rw-r--r-- | rpm2targz/rpmoffset.c | 24 |
6 files changed, 118 insertions, 0 deletions
diff --git a/rpm2targz/.footprint b/rpm2targz/.footprint new file mode 100644 index 000000000..645e7b10a --- /dev/null +++ b/rpm2targz/.footprint @@ -0,0 +1,6 @@ +drwxr-xr-x root/root usr/ +drwxr-xr-x root/root usr/bin/ +-rwxr-xr-x root/root usr/bin/rpm2targz +drwxr-xr-x root/root usr/lib/ +drwxr-xr-x root/root usr/lib/rpm2targz/ +-rwxr-xr-x root/root usr/lib/rpm2targz/rpmoffset diff --git a/rpm2targz/.md5sum b/rpm2targz/.md5sum new file mode 100644 index 000000000..3b656c07c --- /dev/null +++ b/rpm2targz/.md5sum @@ -0,0 +1,2 @@ +8341044e13ddead93295d57f5853ab00 rpm2targz +4501e004279155038f16000c7b45acb4 rpmoffset.c diff --git a/rpm2targz/Pkgfile b/rpm2targz/Pkgfile new file mode 100644 index 000000000..033e5d506 --- /dev/null +++ b/rpm2targz/Pkgfile @@ -0,0 +1,14 @@ +# Description: A tool to convert RPM files to TAR.GZ files +# URL: http://www.crux.nu +# Maintainer: Tilman Sauerbeck, tilman at crux dot nu + +name=rpm2targz +version=1.0.4 +release=1 +source=(rpm2targz rpmoffset.c) + +build() { + gcc $CFLAGS rpmoffset.c -o rpmoffset + install -D -m 0755 rpm2targz $PKG/usr/bin/rpm2targz + install -D -m 0755 rpmoffset $PKG/usr/lib/rpm2targz/rpmoffset +} diff --git a/rpm2targz/README b/rpm2targz/README new file mode 100644 index 000000000..8380b22a9 --- /dev/null +++ b/rpm2targz/README @@ -0,0 +1,6 @@ +POST-INSTALL + + To enable less(1) to view RPM files, add the following line to + the case statement in /usr/lib/less/filter: + + *.rpm) dd ibs=`/usr/lib/rpm2targz/rpmoffset < "$1"` skip=1 if="$1" | gzip -dc | cpio -tv ;; diff --git a/rpm2targz/rpm2targz b/rpm2targz/rpm2targz new file mode 100755 index 000000000..eee5c2b3f --- /dev/null +++ b/rpm2targz/rpm2targz @@ -0,0 +1,66 @@ +#!/bin/sh +# +# Modified by Per Liden <per@fukt.bth.se>, 2000, 2004. +# Han Boetes <han@mijncomputer.nl>, 2004. +# +# Copyright 1997, 1998 Patrick Volkerding, Moorhead, Minnesota USA +# All rights reserved. +# +# Redistribution and use of this script, with or without modification, is +# permitted provided that the following conditions are met: +# +# 1. Redistributions of this script must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# + +if [ "$#" = "0" ]; then + echo "usage: ${0##*/} <file.rpm> ..." + exit 1 +fi + +# If $TMPDIR is not set, then use $TMP. +# If $TMP is not set either, then mktemp(1) will use /tmp. +${TMPDIR:=$TMP} + +for file_rpm in $*; do + if [ ! -f $file_rpm ]; then + echo "$file_rpm: file not found" + continue + fi + + dir_tar_gz=`mktemp -d` || exit 1 + file_cpio=`mktemp` || exit 1 + file_cpio_z=`mktemp` || exit 1 + file_tar_gz=${file_rpm%.rpm}.tar.gz + + echo "$file_rpm => $file_tar_gz" + + dd ibs=`/usr/lib/rpm2targz/rpmoffset < $file_rpm` skip=1 if=$file_rpm of=$file_cpio_z 2> /dev/null + + if file $file_cpio_z | grep "bzip2 compressed data"; then + bzip2 -dc < $file_cpio_z > $file_cpio + else + gzip -dc < $file_cpio_z > $file_cpio + fi + + ( cd $dir_tar_gz + cpio --quiet -i -m -d < $file_cpio + find . -type d -perm 700 -exec chmod 755 {} \; + tar cf - . + ) | gzip > $file_tar_gz + + rm -rf $file_cpio $file_cpio_z $dir_tar_gz +done + +# End of file. diff --git a/rpm2targz/rpmoffset.c b/rpm2targz/rpmoffset.c new file mode 100644 index 000000000..a0d220023 --- /dev/null +++ b/rpm2targz/rpmoffset.c @@ -0,0 +1,24 @@ +/* Find how deeply inside an .RPM the real data is */ +/* kept, and report the offset in bytes */ + +/* Wouldn't it be a lot more sane if we could just untar these things? */ + +#include <stdlib.h> + +/* These offsets keep getting bigger, so we're going to just bite a 2MB */ +/* chunk of RAM right away so that we have enough. Yeah, horrible */ +/* quick and dirty implementation, but hey -- it gets the job done. */ + +#define RPMBUFSIZ 2097152 +const char magic[][3]={"\x1F\x8B\x08"/*gzip*/,"BZh"/*bzip2*/}; + +main() +{ + char *buff = malloc(RPMBUFSIZ),*eb,*p; + for (p = buff, eb = buff + read(0,buff,RPMBUFSIZ); p < eb; p++) + if ((*p == magic[0][0] && p[1] == magic[0][1] && p[2] == magic[0][2]) || + (*p == magic[1][0] && p[1] == magic[1][1] && p[2] == magic[1][2])) + printf("%d\n",p - buff), + exit(0); + exit(1); +} |