diff options
author | 2009-11-06 07:36:26 -0500 | |
---|---|---|
committer | 2009-11-06 08:04:52 -0500 | |
commit | be456cae9dc34721a5e356400729d78a2c9657ae (patch) | |
tree | 70e472fd5b31d78ae8cb3f4be08787856383e97e | |
parent | rpmunpack: new shortcut for quicker unpacking (diff) | |
download | rpm2targz-be456cae9dc34721a5e356400729d78a2c9657ae.tar.gz rpm2targz-be456cae9dc34721a5e356400729d78a2c9657ae.tar.bz2 rpm2targz-be456cae9dc34721a5e356400729d78a2c9657ae.zip |
rpm2targz: make coding/testing easier
Add some err/warn helper functions, and use the local rpmoffset when
testing the local script.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rwxr-xr-x | rpm2targz | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -22,6 +22,8 @@ # argv0=${0##*/} +warn() { echo "${argv0}: warning: $*" 1>&2; } +err() { echo "${argv0}: warning: $*" 1>&2; exit 1; } usage=false stdout=false @@ -55,13 +57,19 @@ if ! ${files} || ${usage} ; then EOF if [ -n "${msg}" ] ; then - echo "Error: ${msg}" 1>&2 - exit 1 + err "${msg}" else exit 0 fi fi +# allow for local development +if [ "${0#./}" != "${0}" -a -x "./rpmoffset" ] ; then + rpmoffset="./rpmoffset" +else + rpmoffset="rpmoffset" +fi + compress="cat" case ${argv0} in rpmunpack) suffix="";; @@ -103,8 +111,7 @@ if [ -z "${WORKDIR}" ] ; then fi fi if ! ${worked} ; then - echo "${argv0}: ${WORKDIR}: unable to create a temp directory" - exit 1 + err "${WORKDIR}: unable to create a temp directory" fi fi fi @@ -129,9 +136,8 @@ for file; do DEST="${WORKDIR}/${base}" rm -rf "${DEST}" if ! mkdir "${DEST}" ; then - echo "${argv0}: ${file}: ${DEST}: unable to create working directory" - rm -rf "${WORKDIR}" - exit 1 + rm -rf "${WORKDIR}" & + err "${file}: ${DEST}: unable to create working directory" fi # extract the CPIO from the RPM and unpack it |