From 82c5a404af30116b7f898adcc9df4efb99268e84 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 19 Aug 2008 18:50:17 -0400 Subject: Add a -S/--strip-path option Often times it's nice to create a "raw" tarball which does not include the package name in its paths. Compare old method: $ rpm2targz pkg-ver.rpm $ tar tf pkg-ver.tar.gz ./pkg-ver/ With new method: $ rpm2targz -S pkg-ver.rpm $ tar tf pkg-ver.tar.gz ./ Signed-off-by: Mike Frysinger --- rpm2targz | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'rpm2targz') diff --git a/rpm2targz b/rpm2targz index dcfdc27..9a0087c 100755 --- a/rpm2targz +++ b/rpm2targz @@ -26,16 +26,18 @@ argv0=${0##*/} usage=false stdout=false verbose=false +strip=false files=false msg="" for opt; do case ${opt} in - -h|--help) usage=true;; - -O|--stdout) stdout=true;; - -v|--verbose) verbose=true;; - --) break;; - -*) usage=true msg="unknown option '${opt}'";; - *) files=true;; + -h|--help) usage=true;; + -O|--stdout) stdout=true;; + -v|--verbose) verbose=true;; + -S|--strip-path) strip=true;; + --) break;; + -*) usage=true msg="unknown option '${opt}'";; + *) files=true;; esac done @@ -48,6 +50,7 @@ if ! ${files} || ${usage} ; then Options: -h, --help This help screen (imagine that) -O, --stdout Write tarball to stdout + -S, --strip-path Strip package name from tarball -v, --verbose Verbose output EOF @@ -109,6 +112,7 @@ for file; do case ${file} in -v|--verbose) continue;; -O|--stdout) continue;; + -S|--strip-path) continue;; --) dashdash=true; continue;; esac fi @@ -117,7 +121,7 @@ for file; do outfile=${file##*/} outfile=${outfile%.rpm} - base=${outfile%.src} + ${strip} && base="" || base=${outfile%.src} DEST="${WORKDIR}/${base}" rm -rf "${DEST}" if ! mkdir "${DEST}" ; then -- cgit v1.2.3-65-gdbad