summaryrefslogtreecommitdiff
path: root/mk/scripts
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2006-01-21 16:40:19 +0000
committerjlam <jlam@pkgsrc.org>2006-01-21 16:40:19 +0000
commit42c1f7217db1ad69d8b2d651b73da449db431d5f (patch)
tree7282a9b5010428797ae967b1b94271a08c05f46c /mk/scripts
parent77f9120ba9fb1a48f35b07d78558ecc4a56ea53b (diff)
downloadpkgsrc-42c1f7217db1ad69d8b2d651b73da449db431d5f.tar.gz
Teach the extract script a "-d dir" option to extract into a specific
directory.
Diffstat (limited to 'mk/scripts')
-rwxr-xr-xmk/scripts/extract15
1 files changed, 13 insertions, 2 deletions
diff --git a/mk/scripts/extract b/mk/scripts/extract
index 9cddbaadd4f..4390cc06189 100755
--- a/mk/scripts/extract
+++ b/mk/scripts/extract
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: extract,v 1.9 2006/01/21 15:33:05 jlam Exp $
+# $NetBSD: extract,v 1.10 2006/01/21 16:40:19 jlam Exp $
#
# Copyright (c) 2006 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -54,6 +54,11 @@
# distfile is simply copied into the current working directory.
#
# OPTIONS
+# -d dir Extract the files into the specified dir instead
+# of the current working directory. If the directory
+# doesn't exist, then it is created along with any
+# intermediate directories using the current umask.
+#
# -f format Force interpretation of the distfile's archive
# format to be the specified format.
#
@@ -91,6 +96,7 @@
: ${ECHO:=echo}
: ${GZCAT:=gzcat}
: ${LHA:=lha}
+: ${MKDIR:=mkdir}
: ${PAX:=pax}
: ${SH:=sh}
: ${TAR:=tar}
@@ -102,19 +108,21 @@
self="${0##*/}"
usage() {
- ${ECHO} 1>&2 "usage: $self [-f format] [-t tarprog] [-X excludefile | -x] distfile [file ...]"
+ ${ECHO} 1>&2 "usage: $self [-d dir] [-f format] [-t tarprog] [-X excludefile | -x] distfile [file ...]"
}
decompress_cat="${CAT}"
exclude=no
exclude_file=
exclude_flag=
+extract_dir=.
extract_using=tar
format=
# Process optional arguments
while ${TEST} $# -gt 0; do
case "$1" in
+ -d) extract_dir="$2"; shift 2 ;;
-f) format="$2"; shift 2 ;;
-t) extract_using="$2"; shift 2 ;;
-X) exclude_file="$2"; shift 2 ;;
@@ -166,6 +174,9 @@ case "$distfile" in
esac
${TEST} -n "$format" || format="$_format"
+${TEST} -d "$extract_dir" || ${MKDIR} -p "$extract_dir"
+cd "$extract_dir"
+
# Use the correct tool and extraction procedure to perform the extraction
# based on the archive format.
#