summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2012-10-25 17:42:47 +0200
committerJean Delvare <jdelvare@suse.de>2012-10-25 17:42:47 +0200
commitf163a60ea78987724414d542b1978d1ccf6ef3ca (patch)
tree3cd7408e3639731f8d8a3a96d7e4a1c986d242c8
parent4137fa7e488cd00c0889f0c6a3cadb36431de4f4 (diff)
downloadquilt-f163a60ea78987724414d542b1978d1ccf6ef3ca.tar.gz
inspect: Refactor code to pwd_to_dir
Move the code deriving the directory from $PWD to a separate function to avoid code duplication.
-rw-r--r--quilt.changes1
-rw-r--r--quilt/scripts/inspect.in41
2 files changed, 20 insertions, 22 deletions
diff --git a/quilt.changes b/quilt.changes
index af93d89..ff8a8c6 100644
--- a/quilt.changes
+++ b/quilt.changes
@@ -7,6 +7,7 @@ Thu Oct 25 15:05:42 CEST 2012 - jdelvare@suse.de
- setup/inspect: Handle zip archives.
- setup: Fix white space handling by check_for_existing_files.
- setup: Check for existing directories before unpacking.
+- inspect: Refactor code to pwd_to_dir.
-------------------------------------------------------------------
Thu Oct 25 15:05:10 CEST 2012 - jdelvare@suse.de
diff --git a/quilt/scripts/inspect.in b/quilt/scripts/inspect.in
index 172e418..e8eff26 100644
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -274,6 +274,22 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
esac
}
+ pwd_to_dir() {
+ local subdir=$1 dir
+
+ if [ -n "$subdir" ]
+ then
+ dir=$(cd "$subdir" && echo $PWD)
+ else
+ dir=$PWD
+ fi
+ dir=${dir/$RPM_BUILD_DIR}
+ dir=${dir##/}
+ dir=${dir// /\\ }
+
+ echo "$dir"
+ }
+
tmpdir=${RPM_BUILD_DIR%/*}
rm -f $tmpdir/data
case "${0##*/}" in
@@ -301,38 +317,19 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
patch)
echo -n p >&4
subdir=$(patch_opt_d "$@")
- if [ -n "$subdir" ]
- then
- dir=$(cd "$subdir" && echo $PWD)
- else
- dir=$PWD
- fi
- dir=${dir/$RPM_BUILD_DIR}
- dir=${dir##/}
- dir=${dir// /\\ }
+ dir=$(pwd_to_dir $subdir)
echo "${0##*/} ${dir:-.} $unpackfile" \
$(strip_option "$@") $(reverse_option "$@") >&3
;;
tar)
echo -n t >&4
subdir=$(tar_opt_C "$@")
- if [ -n "$subdir" ]
- then
- dir=$(cd "$subdir" && echo $PWD)
- else
- dir=$PWD
- fi
- dir=${dir/$RPM_BUILD_DIR}
- dir=${dir##/}
- dir=${dir// /\\ }
+ dir=$(pwd_to_dir $subdir)
echo "${0##*/} ${dir:-.} $unpackfile" >&3
;;
unzip)
echo -n Z >&4
- dir=$PWD
- dir=${dir/$RPM_BUILD_DIR}
- dir=${dir##/}
- dir=${dir// /\\ }
+ dir=$(pwd_to_dir)
echo "${0##*/} ${dir:-.} $unpackfile" >&3
;;
esac