Changeset 404

Show
Ignore:
Timestamp:
07/25/06 13:36:46 (2 years ago)
Author:
tg
Message:

(cd package/foo; TOPDIR=../.. gmake update-patches) # should now work

IMPORTANT: gmake TOPDIR=../.. foo *does not work* (since it overrides
the correct value which otherwise gets pulled from prereq.mk after it
has been found from the environment-TOPDIR value and gets preference)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freewrt/package/rules.mk

    r393 r404  
    102102 
    103103update-patches: 
    104         @echo >&2 not ready;exit 1 
     104        @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig 
     105        @test ! -d ${WRKDIR}.orig 
     106        @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PATCH=: 
    105107        @toedit=$$(WRKDIST='${WRKSRC}' PATCHDIR=$$(pwd)/patches \ 
    106             PATCH_LIST='${PATCH_LIST}' DIFF_ARGS= \ 
    107             DISTORIG=.bak.orig PATCHORIG=.orig \ 
     108            PATCH_LIST='patch-* *.patch' WRKDIR1='${WRKDIR}' \ 
    108109            ${BASH} ${TOPDIR}/scripts/update-patches); \ 
    109             if [[ -n $$toedit ]]; then \ 
    110                 read i?'edit patches: '; \ 
     110            if [[ -n $$toedit && $$toedit != FAIL ]]; then \ 
     111                echo -n 'edit patches: '; read i; \ 
    111112                cd patches && $${VISUAL:-$${EDITOR:-/usr/bin/vi}} $$toedit; \ 
    112         fi 
     113            fi; \ 
     114            rm -rf ${WRKDIR}.orig; \ 
     115            [[ $$toedit != FAIL ]] 
    113116 
    114117.PHONY: all source prepare compile install clean update-patches 
  • trunk/freewrt/scripts/update-patches

    r402 r404  
    55# Copyright (c) 2006 
    66#       Thorsten Glaser <tg@freewrt.org> 
     7# 
     8# Derived from the MirPorts Framework "update-patches" script: 
     9# 
    710# Copyright (c) 2003, 2004, 2005 
    811#       Thorsten "mirabile" Glaser <tg@MirBSD.de> 
     
    2932 
    3033TRANSFORM='sed s/[.+]/\\\\&/g' 
    31 tfile=$(echo "$PATCHORIG" | $TRANSFORM) 
    32 DIFF_FLAGS="-adu -I \"^--- @@$(echo "$tfile")   \"" 
    33 DIFF_FLAGS="${DIFF_FLAGS} -I \"^\+\+\+ @@       \"" 
    3434 
    3535mkdir -p $PATCHDIR 
    3636 
     37SUBDIST=${WRKDIST##${WRKDIR1}?(/)} 
     38if [[ -n $SUBDIST ]]; then 
     39        mv ${WRKDIR1}.orig/${SUBDIST} ${WRKDIR1}/${SUBDIST}.orig 
     40        D_BASE=${WRKDIR1} 
     41        D_SUB=${SUBDIST} 
     42        D_CMP=$D_SUB 
     43else 
     44        # WRKSRC == WRKDIR 
     45        D_BASE=$(dirname ${WRKDIR1}) 
     46        D_SUB=$(basename ${WRKDIR1}) 
     47        D_CMP= 
     48fi 
     49ORGDIST=${D_BASE}/${D_SUB}.orig 
    3750 
    38 # Find out all $PATCHORIG files and strip the name to what diff will use 
    39 ( cd $WRKDIST && find . -type f -name "*${PATCHORIG}" \ 
    40     | fgrep -v $DISTORIG | sed -e "s#^./\(.*\)\.${PATCHORIG#.*}\$#\1#" \ 
    41 ) |& 
     51DIFF_FLAGS="-adu -I \"^--- $(echo $D_SUB.orig | $TRANSFORM)@@\"" 
     52DIFF_FLAGS="$DIFF_FLAGS -I \"^\+\+\+ $(echo $D_SUB | $TRANSFORM)@@\"" 
    4253 
    43 while read -p file; do 
    44         if cmp -s "$WRKDIST/$file" "$WRKDIST/$file$PATCHORIG"; then 
    45                 echo "$file and $file$PATCHORIG are identical" >&2 
    46                 continue 
    47         fi 
    48         if [[ ! -f $WRKDIST/$file ]]; then 
    49                 echo "$file does not exist" >&2 
    50                 continue 
    51         fi 
     54for file in $(cd ${WRKDIST}; find . -type f | sed 's#^\./##'); do 
     55        cmp -s "$ORGDIST/$file" "$WRKDIST/$file" && continue 
    5256        echo "Processing ${file}..." >&2 
    5357        # look in patchdir for an existing patchfile matching this 
     
    5559        for i in $PATCH_LIST; do 
    5660                # Ignore non-files, or old backup 
    57                 [[ ! -f $i || $i = *@(${PATCHORIG}|.rej|~) ]] \ 
    58                     && continue 
     61                [[ ! -f $i || $i = *@(.orig|.rej|~) ]] && continue 
    5962 
    6063                # Patch found. Is this the one? 
    61                 if grep "^--- $file$PATCHORIG" "$i" >/dev/null; then 
     64                if grep "^[+-][+-][+-] $D_CMP[^/]*/$file" "$i" >/dev/null; then 
     65                        # Multiple files in the diff? 
     66                        if [ $(grep -c "^--- $D_CMP" "$i") -gt 1 -o \ 
     67                            $(grep -c "^\+\+\+ $D_CMP" "$i") -gt 1 ]; then 
     68                                echo "Cannot process, $i contains patches" >&2 
     69                                echo "to multiple files! Aborting." >&2 
     70                                echo FAIL 
     71                                [[ -n $SUBDIST ]] && mv \ 
     72                                    ${WRKDIR1}/${SUBDIST}.orig \ 
     73                                    ${WRKDIR1}.orig/${SUBDIST} 
     74                                exit 0 
     75                        fi 
     76                        # Multiple diffs with this file? 
     77                        let n=0 
     78                        esc= 
     79                        for j in $PATCH_LIST; do 
     80                                [[ ! -f $j || $j = *@(.orig|.rej|~) ]] && \ 
     81                                    continue 
     82                                grep "^[+-][+-][+-] $D_CMP[^/]*/$file" \ 
     83                                    "$j" >/dev/null || continue 
     84                                let n++ 
     85                                esc="$esc '$j'" 
     86                        done 
     87                        if (( n != 1 )); then 
     88                                echo "Cannot process, file $file" >&2 
     89                                echo "is contained in multiple patches:" >&2 
     90                                echo "$esc" >&2 
     91                                echo FAIL 
     92                                [[ -n $SUBDIST ]] && mv \ 
     93                                    ${WRKDIR1}/${SUBDIST}.orig \ 
     94                                    ${WRKDIR1}.orig/${SUBDIST} 
     95                                exit 0 
     96                        fi 
     97                        # No, process this patch 
     98 
    6299                        accounted="$accounted $i" 
    63100                        # found it, copy preamble before comparision 
    64101                        esc="$(echo "$file" | sed -e 's#/#\\/#g')" 
    65                         ( sed -e "/^--- $esc$PATCHORIG/,\$d" <$i; \ 
    66                           cd $WRKDIST && diff -adup \ 
    67                           ${DIFF_ARGS} "$file$PATCHORIG" "$file" \ 
     102                        ( sed -e "/^--- /,\$d" <$i; \ 
     103                          cd $D_BASE && diff -adup \ 
     104                            "$D_SUB.orig/$file" "$D_SUB/$file" \ 
    68105                        ) >"$i.new" 
    69106                        # did it change ? mark it as changed 
    70107                        tfile="$(echo "$file" | $TRANSFORM)" 
    71108                        if eval diff "$(echo "${DIFF_FLAGS}" \ 
    72                             ${DIFF_ARGS} | sed "s#@@#${tfile}#g")" \ 
     109                            | sed "s#@@#${tfile}#g")" \ 
    73110                            "$i" "$i.new" 1>&2; then 
    74111                                rm "$i.new" 
    75112                        else 
    76113                                echo "Patch $i for $file updated" >&2 
    77                                 mv "$i" "$i$PATCHORIG
     114                                mv "$i" "$i.orig
    78115                                mv "$i.new" "$i" 
    79116                                edit="$edit $i" 
     
    87124        echo "No patch-* found for $file, creating $patchname" >&2 
    88125        ( echo '$Free''WRT$'; \ 
    89           cd $WRKDIST && diff -adup ${DIFF_ARGS} "$file$PATCHORIG" "$file" \ 
     126          cd $D_BASE && diff -adup "$D_SUB.orig/$file" "$D_SUB/$file" \ 
    90127        ) >$patchname 
    91128        edit="$edit $patchname" 
     
    96133cd $PATCHDIR 
    97134for i in *; do 
    98         [[ ! -f $i || $i = *@(${PATCHORIG}|.rej|~) ]] \ 
    99             && continue 
     135        [[ ! -f $i || $i = *@(.orig|.rej|~) ]] && continue 
    100136        grep '^\\ No newline at end of file' $i >/dev/null \ 
    101137            && echo "*** Patch $i needs manual intervention" >&2 
     
    105141 
    106142echo $edit 
     143[[ -n $SUBDIST ]] && mv ${WRKDIR1}/${SUBDIST}.orig ${WRKDIR1}.orig/${SUBDIST} 
    107144exit 0