From aa0dba94438d061850e3a8a99f588e5b782afeda Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Mon, 8 Jan 2007 11:45:20 +0100 Subject: [PATCH] Add a cpio emulation script based on GNU tar. --- Makefile | 3 ++- cpio.sh | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 cpio.sh diff --git a/Makefile b/Makefile index 9d4944a12d..2aa3bed4e6 100644 --- a/Makefile +++ b/Makefile @@ -177,7 +177,8 @@ SCRIPT_SH = \ git-applymbox.sh git-applypatch.sh git-am.sh \ git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \ git-merge-resolve.sh git-merge-ours.sh \ - git-lost-found.sh git-quiltimport.sh + git-lost-found.sh git-quiltimport.sh \ + cpio.sh SCRIPT_PERL = \ git-add--interactive.perl \ diff --git a/cpio.sh b/cpio.sh new file mode 100644 index 0000000000..a0a5a372f2 --- /dev/null +++ b/cpio.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# +# Emulates some cpio behavior using GNU tar + +die() { + echo >&2 "$@" + exit 1 +} + +tr0=cat + +while test $# -gt 0; do + case "$1" in + -0) tr0="tr '\0' ' '";; + -o) mode=o;; + -iuv) ;; + -pumd|-pumdl) + mode=p + dir="$2" + shift + ;; + *) die "cpio emulation supports only -0, -o, -iuv, -pumdl";; + esac + shift +done + +case $mode in +o) + files=.cpiofiles$$ + $tr0 > $files + tar --create --file=- --files-from=$files --exclude=$files + rc=$? + rm -f $files + exit $rc + ;; +p) + files=.cpiofiles$$ + $tr0 > $files + tar --create --file=- --files-from=$files --exclude=$files | + tar --extract --directory="$dir" --file=- + rm -f $files + ;; +*) + tar xvf - || exit +esac