10 echo ERROR: ${1+"$@"} >&2
15 [ $# -eq 1 ] || Error "Cd() takes a single parameter."
16 cd $1 || Error "cannot \"cd $1\" from $PWD"
19 # Call this function and then follow it by any specific import script additions
22 # Parse command line options
26 *=*) eval "$1"; shift;;
28 -a) TARBALL=$2; shift 2;;
29 -n) ECHO=echo; shift;;
31 -r) REVIEWER=$2; shift 2;;
34 echo " "$0 '[-ahnPr] [TARBALL=] [PR=] [REVIEWER=]'
35 echo " "$0 '-a <filename> # (a)rchive'
36 echo " "$0 '-h # print usage'
37 echo " "$0 '-n # do not import, check only.'
38 echo " "$0 '-P <PR Number> # Use PR'
39 echo " "$0 '-r <reviewer(s) list> # (r)eviewed by'
40 echo " "$0 'PR=<PR Number>'
41 echo " "$0 'REVIEWER=<reviewer(s) list>'
46 return $(($_shift - $#))
56 test -s ${TARBALL:-/dev/null} || Error need TARBALL
58 # thing should match what the TARBALL contains
59 thing=`basename $here`
62 bmake) (cd .. && tar zxf $TARBALL);;
63 *) Error "we should be in bmake";;
66 VERSION=`grep '^_MAKE_VERSION' VERSION | sed 's,.*=[[:space:]]*,,'`
71 # new files are handled automatically
72 # but we need to rm if needed
73 # FILES are kept sorted so we can determine what was added and deleted
74 # but we need to take care dealing with re-ordering
75 (${GIT} diff FILES | sed -n '/^[+-][^+-]/p'; \
76 ${GIT} diff mk/FILES | sed -n '/^[+-][^+-]/s,.,&mk/,p' ) > $TF.diffs
77 grep '^+' $TF.diffs | sed 's,^.,,' | sort > $TF.adds
78 grep '^-' $TF.diffs | sed 's,^.,,' | sort > $TF.rms
79 comm -13 $TF.adds $TF.rms > $TF.rm
81 if [ -z "$ECHO" ]; then
82 test -s $TF.rm && xargs rm -f < $TF.rm
84 $GIT diff --staged | tee ../tmp/bmake-import.diff
85 echo "$GIT tag -a vendor/NetBSD/bmake/$VERSION" > ../tmp/bmake-post.sh
86 echo "After you commit, run $here/../tmp/bmake-post.sh"
88 comm -23 $TF.adds $TF.rms > $TF.add
89 test -s $TF.rm && { echo Removing:; cat $TF.rm; }
90 test -s $TF.add && { echo Adding:; cat $TF.add; }