Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/pax/delta2patch.sh
1808 views
1
########################################################################
2
# #
3
# This software is part of the ast package #
4
# Copyright (c) 1987-2011 AT&T Intellectual Property #
5
# and is licensed under the #
6
# Eclipse Public License, Version 1.0 #
7
# by AT&T Intellectual Property #
8
# #
9
# A copy of the License is available at #
10
# http://www.eclipse.org/org/documents/epl-v10.html #
11
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
12
# #
13
# Information and Software Systems Research #
14
# AT&T Research #
15
# Florham Park NJ #
16
# #
17
# Glenn Fowler <[email protected]> #
18
# #
19
########################################################################
20
command=delta2patch
21
22
USAGE=$'
23
[-?
24
@(#)$Id: delta2patch (AT&T Research) 2007-12-11 $
25
]
26
'$USAGE_LICENSE$'
27
[+NAME?delta2patch - generate patch script from pax delta+base archives]
28
[+DESCRIPTION?\bdelta2patch\b generates a \bpatch\b(1) \adiff -u\a script
29
given a \bpax\b(1) delta and base source archive to convert
30
files extracted from the base archive to be equivalent to files
31
extracted from the delta archive with respect to the base archive.]
32
33
delta base
34
35
[+SEE ALSO?\bpackage\b(1), \bpax\b(1)]
36
'
37
38
function usage
39
{
40
OPTIND=0
41
getopts -a $command "$USAGE" OPT '--??long'
42
exit 2
43
}
44
45
while getopts -a $command "$USAGE" OPT
46
do case $OPT in
47
*) usage ;;
48
esac
49
done
50
51
if (( $# != 2 ))
52
then usage
53
fi
54
delta=$1
55
base=$2
56
changes=$(pax --nosummary -f $delta 2>/dev/null | sed -e '/^\(update\|create\) /!d' -e 's/^[^ ]* //')
57
tmp=/tmp/d2p-$$
58
trap "rm -rf $tmp" 0
59
mkdir $tmp $tmp/old $tmp/new || exit
60
pax --nosummary -rf $base -s ",.*,$tmp/old/&," $changes
61
pax --nosummary -rf $delta -z $base -s ",.*,$tmp/new/&," $changes
62
diff -r -N -u $tmp/old $tmp/new | sed -e "s,$tmp/new/,,g" -e "s,$tmp/old/,,g" -e $'s/^--- \\([^\t]*\\)/&.orig/' -e '/^diff /s/ [^ ]*$/.orig&/'
63
64