Changeset 54f72bc in freewrt
- Timestamp:
- Jul 25, 2006, 1:36:46 PM (19 years ago)
- Branches:
- freewrt_1_0, freewrt_2_0
- Children:
- ecb5fbe
- Parents:
- f3b127c
- Files:
-
- 2 edited
-
package/rules.mk (modified) (1 diff)
-
scripts/update-patches (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
package/rules.mk
rf3b127c r54f72bc 102 102 103 103 update-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=: 105 107 @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}' \ 108 109 ${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; \ 111 112 cd patches && $${VISUAL:-$${EDITOR:-/usr/bin/vi}} $$toedit; \ 112 fi 113 fi; \ 114 rm -rf ${WRKDIR}.orig; \ 115 [[ $$toedit != FAIL ]] 113 116 114 117 .PHONY: all source prepare compile install clean update-patches -
scripts/update-patches
rf3b127c r54f72bc 5 5 # Copyright (c) 2006 6 6 # Thorsten Glaser <tg@freewrt.org> 7 # 8 # Derived from the MirPorts Framework "update-patches" script: 9 # 7 10 # Copyright (c) 2003, 2004, 2005 8 11 # Thorsten "mirabile" Glaser <tg@MirBSD.de> … … 29 32 30 33 TRANSFORM='sed s/[.+]/\\\\&/g' 31 tfile=$(echo "$PATCHORIG" | $TRANSFORM)32 DIFF_FLAGS="-adu -I \"^--- @@$(echo "$tfile") \""33 DIFF_FLAGS="${DIFF_FLAGS} -I \"^\+\+\+ @@ \""34 34 35 35 mkdir -p $PATCHDIR 36 36 37 SUBDIST=${WRKDIST##${WRKDIR1}?(/)} 38 if [[ -n $SUBDIST ]]; then 39 mv ${WRKDIR1}.orig/${SUBDIST} ${WRKDIR1}/${SUBDIST}.orig 40 D_BASE=${WRKDIR1} 41 D_SUB=${SUBDIST} 42 D_CMP=$D_SUB 43 else 44 # WRKSRC == WRKDIR 45 D_BASE=$(dirname ${WRKDIR1}) 46 D_SUB=$(basename ${WRKDIR1}) 47 D_CMP= 48 fi 49 ORGDIST=${D_BASE}/${D_SUB}.orig 37 50 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 ) |& 51 DIFF_FLAGS="-adu -I \"^--- $(echo $D_SUB.orig | $TRANSFORM)@@\"" 52 DIFF_FLAGS="$DIFF_FLAGS -I \"^\+\+\+ $(echo $D_SUB | $TRANSFORM)@@\"" 42 53 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 54 for file in $(cd ${WRKDIST}; find . -type f | sed 's#^\./##'); do 55 cmp -s "$ORGDIST/$file" "$WRKDIST/$file" && continue 52 56 echo "Processing ${file}..." >&2 53 57 # look in patchdir for an existing patchfile matching this … … 55 59 for i in $PATCH_LIST; do 56 60 # Ignore non-files, or old backup 57 [[ ! -f $i || $i = *@(${PATCHORIG}|.rej|~) ]] \ 58 && continue 61 [[ ! -f $i || $i = *@(.orig|.rej|~) ]] && continue 59 62 60 63 # 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 62 99 accounted="$accounted $i" 63 100 # found it, copy preamble before comparision 64 101 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" \ 68 105 ) >"$i.new" 69 106 # did it change ? mark it as changed 70 107 tfile="$(echo "$file" | $TRANSFORM)" 71 108 if eval diff "$(echo "${DIFF_FLAGS}" \ 72 ${DIFF_ARGS}| sed "s#@@#${tfile}#g")" \109 | sed "s#@@#${tfile}#g")" \ 73 110 "$i" "$i.new" 1>&2; then 74 111 rm "$i.new" 75 112 else 76 113 echo "Patch $i for $file updated" >&2 77 mv "$i" "$i $PATCHORIG"114 mv "$i" "$i.orig" 78 115 mv "$i.new" "$i" 79 116 edit="$edit $i" … … 87 124 echo "No patch-* found for $file, creating $patchname" >&2 88 125 ( 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" \ 90 127 ) >$patchname 91 128 edit="$edit $patchname" … … 96 133 cd $PATCHDIR 97 134 for i in *; do 98 [[ ! -f $i || $i = *@(${PATCHORIG}|.rej|~) ]] \ 99 && continue 135 [[ ! -f $i || $i = *@(.orig|.rej|~) ]] && continue 100 136 grep '^\\ No newline at end of file' $i >/dev/null \ 101 137 && echo "*** Patch $i needs manual intervention" >&2 … … 105 141 106 142 echo $edit 143 [[ -n $SUBDIST ]] && mv ${WRKDIR1}/${SUBDIST}.orig ${WRKDIR1}.orig/${SUBDIST} 107 144 exit 0
Note:
See TracChangeset
for help on using the changeset viewer.
