xev@GTE.COM (Xev Gittler) (08/17/90)
Are there any tools around for easily building patch files from distributions? This tool would have to create files that didn't exist. Any pointers on how people maintain patches to large distributions would be appreciated. -- Xev Gittler xev@bunny.gte.com
meissner@osf.org (Michael Meissner) (08/27/90)
In article <9605@bunny.GTE.COM> xev@GTE.COM (Xev Gittler) writes: | Path: paperboy!think.com!sdd.hp.com!samsung!umich!mailrus!husc6!bunny!xev | From: xev@GTE.COM (Xev Gittler) | Newsgroups: comp.sources.wanted,comp.unix.questions | Keywords: patch diff | Date: 17 Aug 90 12:39:41 GMT | Followup-To: comp.sources.wanted | Organization: GTE Laboratories, Inc., Waltham, MA | Lines: 7 | Xref: paperboy comp.sources.wanted:7052 comp.unix.questions:14048 | | Are there any tools around for easily building patch files from | distributions? This tool would have to create files that didn't exist. | Any pointers on how people maintain patches to large distributions | would be appreciated. I use GNU diff with the -c option (the old file is the first file argument, and the new file is the second). For large distributions, I use the following shell script. It handles the case of new files (patch automatically creates the file if it doesn't exist), and tells you about files that should be deleted (patch can't deal with this case). #! /bin/sh # Make a patch file for files in two different directories # GNU diff must be in the current PATH # arg1: old directory # arg2: new directory # arg3: optional output file for patches or - for stdout # arg4: optional egrep options to match files to be excluded. if [ $# -lt 2 -o $# -gt 4 ]; then echo "Calling Sequence:" echo " `basename $0` <old-dir> <new-dir> [ <out-file> [ <egrep-exclusions> ]]" exit 1 fi # Open output file on file descriptor 4, and trace file on 5 if [ "$3" != "" -a "$3" != "-" ]; then exec 4>$3 5>&1 else exec 4>&1 5>&2 fi curdir=`pwd` tmpdir="${TMPDIR=/tmp}/patch$$" mkdir ${tmpdir} trap "rm -rf ${tmpdir}" 0 1 2 3 if [ "$4" != "" ]; then find $1 -type f -print | egrep -v "$4" | sed -e "s;^$1/;;" | sort > ${tmpdir}/old-files find $2 -type f -print | egrep -v "$4" | sed -e "s;^$2/;;" | sort > ${tmpdir}/new-files else find $1 -type f -print | sed -e "s;^$1/;;" | sort > ${tmpdir}/old-files find $2 -type f -print | sed -e "s;^$2/;;" | sort > ${tmpdir}/new-files fi comm -23 ${tmpdir}/old-files ${tmpdir}/new-files > ${tmpdir}/old-only if [ -s "${tmpdir}/old-only" ]; then echo >&5 echo >&5 "The following files only appear in $1" echo >&5 sed >&5 < ${tmpdir}/old-only -e 's/^/ /' fi comm -13 ${tmpdir}/old-files ${tmpdir}/new-files > ${tmpdir}/new-only if [ -s "${tmpdir}/new-only" ]; then echo >&5 echo >&5 "The following files only appear in $2" echo >&5 sed >&5 < ${tmpdir}/new-only -e 's/^/ /' fi comm -12 ${tmpdir}/old-files ${tmpdir}/new-files > ${tmpdir}/same-only sort ${tmpdir}/same-only ${tmpdir}/new-only > ${tmpdir}/same-or-new-only if [ ! -s "${tmpdir}/same-or-new-only" ]; then echo >&5 echo >&5 "No files are available to produce patch files on" exit 1 fi echo >&5 echo >&5 "The following files are different" echo >&5 (while read file; do if [ -f "$1/${file}" ]; then if cmp -s "$1/${file}" "$2/${file}" ; then different=no else different=yes fi else different=yes fi if [ "${different}" = "yes" ]; then echo "${file}" >> ${tmpdir}/different echo >&5 " ${file}" dir= slash= base="${file}" looping=yes while [ "${looping}" = "yes" ]; do case "${base}" in */*) nextdir=`echo "${base}" | sed -e 's;/.*$;;'` dir="${dir}${slash}${nextdir}" slash="/" base=`echo "${base}" | sed -e 's;^[^/]*/;;'` if [ ! -d "${tmpdir}${slash}${dir}" ]; then mkdir "${tmpdir}${slash}${dir}" fi;; *) looping=no;; esac done if [ -f "$1/${file}" ]; then cp "$1/$file" "${tmpdir}${slash}${dir}/${base}~" cp "$2/$file" "${tmpdir}${slash}${dir}/${base}" cd "${tmpdir}" diff -c ${dir}${slash}${base}~ ${dir}${slash}${base} >&4 else cp "$2/$file" "${tmpdir}${slash}${dir}/${base}" cd "${tmpdir}" diff -c /dev/null ${dir}${slash}${base} >&4 fi cd "${curdir}" fi done) < ${tmpdir}/same-or-new-only if [ ! -s "${tmpdir}/different" ]; then echo >&5 echo >&5 "No files are different" echo >&5 fi -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142 Do apple growers tell their kids money doesn't grow on bushes?