From 8c36253d8db34451d50bee473f9a3669b3a9f36c Mon Sep 17 00:00:00 2001 From: Kazuhiko Shiozaki <kazuhiko@nexedi.com> Date: Tue, 12 Mar 2013 19:40:49 +0100 Subject: [PATCH] put rpm2cpio in our repository for safety. our specified revision seems to be disappeared maybe by force push. --- component/rpm2cpio/buildout.cfg | 3 +- component/rpm2cpio/rpm2cpio | 55 +++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 component/rpm2cpio/rpm2cpio diff --git a/component/rpm2cpio/buildout.cfg b/component/rpm2cpio/buildout.cfg index d1e094759..11439bd5b 100644 --- a/component/rpm2cpio/buildout.cfg +++ b/component/rpm2cpio/buildout.cfg @@ -3,6 +3,7 @@ parts = rpm2cpio [rpm2cpio] +# https://github.com/ruda/rpm2cpio recipe = slapos.recipe.build:download -url = https://raw.github.com/ruda/rpm2cpio/e196173f1f6b746463b7398e381b94a42edfa345/rpm2cpio.py +url = ${:_profile_base_location_}/${:_buildout_section_name_} md5sum = c5bb6227d99e1ff5df880f997cbed2e3 diff --git a/component/rpm2cpio/rpm2cpio b/component/rpm2cpio/rpm2cpio new file mode 100644 index 000000000..5d838f5d5 --- /dev/null +++ b/component/rpm2cpio/rpm2cpio @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Standalone RPM to CPIO converter +# Copyright (c) 2012 Rudá Moura +# + +'''Extract cpio archive from RPM package. + +rpm2cpio converts the RPM on standard input or first parameter to a CPIO archive on standard output. + +Usage: +rpm2cpio < adjtimex-1.20-2.1.i386.rpm | cpio -it +./sbin/adjtimex +./usr/share/doc/adjtimex-1.20 +./usr/share/doc/adjtimex-1.20/COPYING +./usr/share/doc/adjtimex-1.20/COPYRIGHT +./usr/share/doc/adjtimex-1.20/README +./usr/share/man/man8/adjtimex.8.gz +133 blocks +''' + +import sys +import StringIO +import gzip + +RPM_MAGIC = '\xed\xab\xee\xdb' +GZIP_MAGIC = '\x1f\x8b' + +def rpm2cpio(stream_in=sys.stdin, stream_out=sys.stdout): + lead = stream_in.read(96) + if lead[0:4] != RPM_MAGIC: + raise IOError, 'the input is not a RPM package' + data = stream_in.read() + idx = data.find(GZIP_MAGIC) + if idx == -1: + raise IOError, 'could not find compressed cpio archive' + gzstream = StringIO.StringIO(data[idx:]) + gzipper = gzip.GzipFile(fileobj=gzstream) + data = gzipper.read() + stream_out.write(data) + +if __name__ == '__main__': + if sys.argv[1:]: + try: + fin = open(sys.argv[1]) + rpm2cpio(fin) + fin.close() + except IOError, e: + print 'Error:', sys.argv[1], e + else: + try: + rpm2cpio() + except IOError, e: + print 'Error:', e -- 2.30.9