summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam@pkgsrc.org>2006-01-21 19:26:09 +0000
committerjlam <jlam@pkgsrc.org>2006-01-21 19:26:09 +0000
commitfd7b3b4b479a5193e94e7ede05055e26d5dafa53 (patch)
treef6bd31f14bc12e82f31a1674c4e733458942b58f /mk
parent758d912e338f2060213377f59a7f58ced9eeab24 (diff)
downloadpkgsrc-fd7b3b4b479a5193e94e7ede05055e26d5dafa53.tar.gz
Allow using standard input for the archive contents for tar and shar
extraction.
Diffstat (limited to 'mk')
-rwxr-xr-xmk/scripts/extract19
1 files changed, 16 insertions, 3 deletions
diff --git a/mk/scripts/extract b/mk/scripts/extract
index 578cc268f51..ddfb161ca79 100755
--- a/mk/scripts/extract
+++ b/mk/scripts/extract
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: extract,v 1.13 2006/01/21 18:21:08 jlam Exp $
+# $NetBSD: extract,v 1.14 2006/01/21 19:26:09 jlam Exp $
#
# Copyright (c) 2006 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -51,7 +51,10 @@
# only they will be extracted from the distfile, provided that the
# underlying tool supports this ability. If the distfile's file
# extension doesn't match any known archive format's, then the
-# distfile is simply copied into the current working directory.
+# distfile is simply copied into the current working directory. If
+# "-" is given as the distfile, then standard input is used as the
+# contents of the archive, provided that the underlying tool supports
+# this ability.
#
# OPTIONS
# -d dir Extract the files into the specified dir instead
@@ -131,7 +134,7 @@ while ${TEST} $# -gt 0; do
-X) exclude_file="$2"; shift 2 ;;
-x) exclude=yes; shift ;;
--) shift; break ;;
- -*) ${ECHO} 1>&2 "$self: unknown option -- ${1#-}"
+ -?*) ${ECHO} 1>&2 "$self: unknown option -- ${1#-}"
usage
exit 1
;;
@@ -159,6 +162,7 @@ case "$distfile" in
*.gz|*.tgz|*.z) decompress_cat="${GZCAT}" ;;
*.bz2|*.tbz|*.tbz2) decompress_cat="${BZCAT}" ;;
*.Z) decompress_cat="${GZCAT}" ;;
+-) decompress_cat="${CAT}" ;;
esac
# Derive the format of the archive based on the file extension.
@@ -178,6 +182,15 @@ case "$distfile" in
esac
${TEST} -n "$format" || format="$_format"
+case "$format" in
+tar|shar) ;;
+*) if ${TEST} "$distfile" = "-"; then
+ ${ECHO} 1>&2 "$self: archive format cannot be given on standard input -- $format"
+ exit 1
+ fi
+ ;;
+esac
+
${TEST} -d "$extract_dir" || ${MKDIR} -p "$extract_dir"
cd "$extract_dir"