######################################################################## # # # This software is part of the ast package # # Copyright (c) 1987-2011 AT&T Intellectual Property # # and is licensed under the # # Eclipse Public License, Version 1.0 # # by AT&T Intellectual Property # # # # A copy of the License is available at # # http://www.eclipse.org/org/documents/epl-v10.html # # (with md5 checksum b35adb5213ca9657e911e9befb180842) # # # # Information and Software Systems Research # # AT&T Research # # Florham Park NJ # # # # Glenn Fowler # # # ######################################################################## global command := 'delta2patch' global USAGE := "$' [-? @(#)$Id: delta2patch (AT&T Research) 2007-12-11 $ ] '$USAGE_LICENSE$' [+NAME?delta2patch - generate patch script from pax delta+base archives] [+DESCRIPTION?\bdelta2patch\b generates a \bpatch\b(1) \adiff -u\a script given a \bpax\b(1) delta and base source archive to convert files extracted from the base archive to be equivalent to files extracted from the delta archive with respect to the base archive.] delta base [+SEE ALSO?\bpackage\b(1), \bpax\b(1)] "' proc usage { global OPTIND := '0' getopts -a $command $USAGE OPT '--??long' exit 2 } while getopts -a $command "$USAGE" OPT { matchstr $OPT { * { usage } } } if (( $# != 2 )) { usage } global delta := $1 global base := $2 global changes := $[pax --nosummary -f $delta !2 >/dev/null | sed -e '/^\(update\|create\) /!d' -e 's/^[^ ]* //] global tmp := "/tmp/d2p-$Pid" trap "rm -rf $tmp" 0 mkdir $tmp $tmp/old $tmp/new || exit pax --nosummary -rf $base -s ",.*,$tmp/old/&," $changes pax --nosummary -rf $delta -z $base -s ",.*,$tmp/new/&," $changes 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&/' (CommandList children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:command) op:Equal rhs:{(delta2patch)} spids:[57])] spids: [57] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:USAGE) op: Equal rhs: {(SQ <"\n"> <"[-?\n"> <"@(#)$Id: delta2patch (AT&T Research) 2007-12-11 $\n"> <"]\n">) ($ VSub_Name "$USAGE_LICENSE") (SQ <"\n"> <"[+NAME?delta2patch - generate patch script from pax delta+base archives]\n"> <"[+DESCRIPTION?"> <" generates a "> <"(1) "> <"diff -u"> <" script\n"> <"\tgiven a "> <"(1) delta and base source archive to convert\n"> <"\tfiles extracted from the base archive to be equivalent to files\n"> <"\textracted from the delta archive with respect to the base archive.]\n"> <"\n"> <"delta base\n"> <"\n"> <"[+SEE ALSO?"> <"(1), "> <"(1)]\n"> ) } spids: [61] ) ] spids: [61] ) (FuncDef name: usage body: (BraceGroup children: [ (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:OPTIND) op:Equal rhs:{(0)} spids:[114])] spids: [114] ) (C {(getopts)} {(-a)} {($ VSub_Name "$command")} {(DQ ($ VSub_Name "$USAGE"))} {(OPT)} {(SQ <"--??long">)} ) (C {(exit)} {(2)}) ] spids: [111] ) spids: [107 110] ) (While cond: [(C {(getopts)} {(-a)} {($ VSub_Name "$command")} {(DQ ($ VSub_Name "$USAGE"))} {(OPT)})] body: (DoGroup children: [ (Case to_match: {($ VSub_Name "$OPT")} arms: [ (case_arm pat_list: [{(Lit_Other "*")}] action: [(C {(usage)})] spids: [165 166 170 -1] ) ] spids: [158 162 173] ) ] spids: [156 175] ) ) (If arms: [ (if_arm cond: [ (DParen child: (ArithBinary op_id: Arith_NEqual left: (ArithWord w:{($ VSub_Pound "$#")}) right: (ArithWord w:{(Lit_Digits 2)}) ) ) ] action: [(C {(usage)})] spids: [-1 191] ) ] spids: [-1 195] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:delta) op:Equal rhs:{($ VSub_Number "$1")} spids:[197])] spids: [197] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:base) op:Equal rhs:{($ VSub_Number "$2")} spids:[200])] spids: [200] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:changes) op: Equal rhs: { (CommandSubPart command_list: (CommandList children: [ (Pipeline children: [ (SimpleCommand words: [{(pax)} {(--nosummary)} {(-f)} {($ VSub_Name "$delta")}] redirects: [ (Redir op_id: Redir_Great fd: 2 arg_word: {(/dev/null)} spids: [213] ) ] ) (C {(sed)} {(-e)} {(SQ <"/^\\(update\\|create\\) /!d">)} {(-e)} {(SQ <"s/^[^ ]* //">)} ) ] negated: False ) ] ) left_token: spids: [204 231] ) } spids: [203] ) ] spids: [203] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:tmp) op: Equal rhs: {(/tmp/d2p-) ($ VSub_Dollar "$$")} spids: [233] ) ] spids: [233] ) (C {(trap)} {(DQ ("rm -rf ") ($ VSub_Name "$tmp"))} {(0)}) (AndOr children: [ (C {(mkdir)} {($ VSub_Name "$tmp")} {($ VSub_Name "$tmp") (/old)} {($ VSub_Name "$tmp") (/new)}) (C {(exit)}) ] op_id: Op_DPipe ) (C {(pax)} {(--nosummary)} {(-rf)} {($ VSub_Name "$base")} {(-s)} {(DQ (",.*,") ($ VSub_Name "$tmp") ("/old/&,"))} {($ VSub_Name "$changes")} ) (C {(pax)} {(--nosummary)} {(-rf)} {($ VSub_Name "$delta")} {(-z)} {($ VSub_Name "$base")} {(-s)} {(DQ (",.*,") ($ VSub_Name "$tmp") ("/new/&,"))} {($ VSub_Name "$changes")} ) (Pipeline children: [ (C {(diff)} {(-r)} {(-N)} {(-u)} {($ VSub_Name "$tmp") (/old)} {($ VSub_Name "$tmp") (/new)}) (C {(sed)} {(-e)} {(DQ ("s,") ($ VSub_Name "$tmp") ("/new/,,g"))} {(-e)} {(DQ ("s,") ($ VSub_Name "$tmp") ("/old/,,g"))} {(-e)} { (SQ <"s/^--- "> <"([^"> <"]*"> <")/&.orig/"> ) } {(-e)} {(SQ <"/^diff /s/ [^ ]*$/.orig&/">)} ) ] negated: False ) ] )