Matthew Burgess wrote:
DJ Lucas wrote:

Hi guys and gals.  Anyone got an idea for a quick script to split up a
regular LFS style (-Naur) diff file?  Ideally, just dump each to it's
own numbered file...trying to save time on OOo-1.1.5.


Hmm, for some reason 'quilt' (http://savannah.nongnu.org/projects/quilt) comes to mind, though I think that's more of a multiple patch management tool. You might be able to get away with a shell script that grep's for the first 'diff -Naur' line, grep's for the second 'diff -Naur' line, then 'split's the file on those line numbers. Repeat until done!

Or even easier:

======================== 8< =======================
#!/bin/sh

ORIGINAL="$1"
BASE="$2"

NUM=0
SEEN_PATCH=1

exec >"$BASE.header"

IFS=""
while read -r LINE
do
        case "$LINE" in
        diff*|\+\+\+*|---*)
                if [ "$SEEN_PATCH" -eq 1 ]
                then
                        SEEN_PATCH=0
                        NUM=$(($NUM + 1))
                        exec >"$BASE.$NUM.patch"
                fi
                echo "$LINE"
                ;;
        *)
                SEEN_PATCH=1
                echo "$LINE"
                ;;
        esac
done <"$ORIGINAL"
======================== >8 =======================

Usage:

./split-patch original-big.patch basename-for-pieces

E.g.,

./split-patch ../coreutils-5.2.1-i18n_fixes-1.patch i18n_fixes

This would produce:

i18n_fixes.header
i18n_fixes.1.patch
i18n_fixes.2.patch
...
i18n_fixes.20.patch

--
Alexander E. Patrakov
--
http://linuxfromscratch.org/mailman/listinfo/lfs-chat
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to