Changeset daec02d in freewrt for scripts


Ignore:
Timestamp:
Jul 25, 2006, 12:17:04 PM (19 years ago)
Author:
Thorsten Glaser <tg@…>
Branches:
freewrt_1_0, freewrt_2_0
Children:
f3b127c
Parents:
9829980
Message:

freewrtify a little

git-svn-id: svn://www.freewrt.org/trunk/freewrt@402 afb5a338-a214-0410-bd46-81f09a774fd1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/update-patches

    r9829980 rdaec02d  
    1 #!/bin/mksh
     1#!/usr/bin/env bash
    22# $FreeWRT$
    33# $MirOS: ports/infrastructure/scripts/update-patches,v 1.5 2006/06/15 19:18:43 tg Exp $
     
    2626# the possibility of such damage or existence of a nontrivial bug.
    2727
     28shopt -s extglob
    2829
    29 # if OS diff not capable enough, require GNU diff
    30 if [[ $NEED_GDIFF = yes ]]; then
    31         if [[ ! -x $(which gdiff) ]]; then
    32                 exec >&2
    33                 print "Fatal:\tGNU diff (gdiff) required for 'update-patches'"
    34                 print "\tIt may be installed from the textproc/gdiff port."
    35                 exit 1
    36         fi
    37         DIFFPROG=$(which gdiff)
    38         TRANSFORM=cat
    39         DIFF_FLAGS="-adu --ignore-matching-lines="
    40         DIFF_FLAGS="${DIFF_FLAGS}\"^--- @@$PATCHORIG    .*\""
    41         DIFF_FLAGS="${DIFF_FLAGS} --ignore-matching-lines="
    42         DIFF_FLAGS="${DIFF_FLAGS}\"^+++ @@      .*\""
    43 else
    44         DIFFPROG=$(which diff)
    45         TRANSFORM='sed s/[.+]/\\\\&/g'
    46         tfile=$(print -r -- $PATCHORIG | $TRANSFORM)
    47         DIFF_FLAGS="-adu -I \"^--- @@$(print -- $tfile) \""
    48         DIFF_FLAGS="${DIFF_FLAGS} -I \"^\+\+\+ @@       \""
    49 fi
     30TRANSFORM='sed s/[.+]/\\\\&/g'
     31tfile=$(echo "$PATCHORIG" | $TRANSFORM)
     32DIFF_FLAGS="-adu -I \"^--- @@$(echo "$tfile")   \""
     33DIFF_FLAGS="${DIFF_FLAGS} -I \"^\+\+\+ @@       \""
    5034
    5135mkdir -p $PATCHDIR
     
    5943while read -p file; do
    6044        if cmp -s "$WRKDIST/$file" "$WRKDIST/$file$PATCHORIG"; then
    61                 print -r -- "$file and $file$PATCHORIG are identical" >&2
     45                echo "$file and $file$PATCHORIG are identical" >&2
    6246                continue
    6347        fi
    6448        if [[ ! -f $WRKDIST/$file ]]; then
    65                 print -r -- "$file does not exist" >&2
     49                echo "$file does not exist" >&2
    6650                continue
    6751        fi
    68         print -r -- "Processing ${file}..." >&2
     52        echo "Processing ${file}..." >&2
    6953        # look in patchdir for an existing patchfile matching this
    7054        cd $PATCHDIR
     
    7862                        accounted="$accounted $i"
    7963                        # found it, copy preamble before comparision
    80                         esc="$(print -r -- "$file" | sed -e 's#/#\\/#g')"
     64                        esc="$(echo "$file" | sed -e 's#/#\\/#g')"
    8165                        ( sed -e "/^--- $esc$PATCHORIG/,\$d" <$i; \
    82                           cd $WRKDIST && ${DIFFPROG} -adup \
     66                          cd $WRKDIST && diff -adup \
    8367                          ${DIFF_ARGS} "$file$PATCHORIG" "$file" \
    8468                        ) >"$i.new"
    8569                        # did it change ? mark it as changed
    86                         tfile="$(print -r -- "$file" | $TRANSFORM)"
    87                         if eval ${DIFFPROG} "$(print -r -- "${DIFF_FLAGS}" \
     70                        tfile="$(echo "$file" | $TRANSFORM)"
     71                        if eval diff "$(echo "${DIFF_FLAGS}" \
    8872                            ${DIFF_ARGS} | sed "s#@@#${tfile}#g")" \
    8973                            "$i" "$i.new" 1>&2; then
    9074                                rm "$i.new"
    9175                        else
    92                                 print -r -- "Patch $i for $file updated" >&2
     76                                echo "Patch $i for $file updated" >&2
    9377                                mv "$i" "$i$PATCHORIG"
    9478                                mv "$i.new" "$i"
     
    10084
    10185        # Build a sensible name for the new patch file
    102         patchname=patch-$(print -r -- "$file" | sed -e 's#[/. ]#_#g')
    103         print -r -- "No patch-* found for $file, creating $patchname" >&2
    104         ( print -r -- '$Mir''OS$'; \
    105           cd $WRKDIST && ${DIFFPROG} -adup ${DIFF_ARGS} \
    106           "$file$PATCHORIG" "$file" \
     86        patchname=patch-$(echo "$file" | sed -e 's#[/. ]#_#g')
     87        echo "No patch-* found for $file, creating $patchname" >&2
     88        ( echo '$Free''WRT$'; \
     89          cd $WRKDIST && diff -adup ${DIFF_ARGS} "$file$PATCHORIG" "$file" \
    10790        ) >$patchname
    10891        edit="$edit $patchname"
     
    11699            && continue
    117100        grep '^\\ No newline at end of file' $i >/dev/null \
    118             && print -r -- "*** Patch $i needs manual intervention" >&2
     101            && echo "*** Patch $i needs manual intervention" >&2
    119102        [[ $accounted != *@($i)* ]] \
    120             && print -r -- "*** Patch $i not accounted for" >&2
     103            && echo "*** Patch $i not accounted for" >&2
    121104done
    122105
    123 print -r -- $edit
     106echo $edit
    124107exit 0
Note: See TracChangeset for help on using the changeset viewer.