Changeset 480


Ignore:
Timestamp:
Nov 4, 2012, 12:47:32 AM (7 years ago)
Author:
amain
Message:

openwrt: reverted to original patch/unpatch plan. Clean-up of redundant code. Adding dependency on .config. And add error message if openwrt/unpatch is called while no patches previously where applied.

Location:
branches/contrib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/contrib/openwrt/openwrt.mk

    r479 r480  
    2222
    2323OPENWRT_PATCHES_DIR=$(TOPDIR)/openwrt/patches
    24 
    2524OPENWRT_PATCH_DIRS:= "$(OPENWRT_PATCHES_DIR)/all" \
    2625        "$(OPENWRT_PATCHES_DIR)/$(OPENWRT_BRANCH)"
    2726
     27get_patches = \
     28        if [ ! -d "$(OPENWRT_BUILD_DIR)" ]; then exit 1; fi ; \
     29        rev=$(call get_svn_revision,$(OPENWRT_BUILD_DIR)) ; \
     30        find \
     31          $(OPENWRT_PATCH_DIRS) \
     32          -name .svn -prune -o \! -type d -printf %f/%p\\n | \
     33        gawk -F / '\
     34          BEGIN { OFS=FS } \
     35          match($$1, "^([[:digit:]])+((-$(OPENWRT_BRANCH))|(-all))?(-([[:digit:]]*):([[:digit:]]*))?_([^/]*)", revs) \
     36            { if(revs[6] <= '$${rev}' && (!length(revs[7]) || revs[7] >= '$${rev}')) \
     37              { $$1=revs[1] "_" revs[8]; print } \
     38            }' | \
     39        sort $(1) | sed -e's/^[^/]\+\///'
    2840
     41do_patches = \
     42        if [ ! -d "$(OPENWRT_BUILD_DIR)" ]; then exit 1; fi ; \
     43        $(call get_patches,$(1)) | while read patch ; \
     44        do \
     45                patchi=$$(echo $${patch} | sed -e's!$(TOPDIR)/!!') ; \
     46                if ! patch -b -d "$(OPENWRT_BUILD_DIR)" -p1 $(2) < "$${patch}" ; \
     47                then \
     48                        echo ">> fail: $${patchi}" > /dev/stderr ; \
     49                        [ $(FORCE_PATCH) != "1" ] && exit 1 || true ; \
     50                else \
     51                        echo ">> success: $${patchi}" ; \
     52                fi ; \
     53        done
    2954
    3055openwrt/all: openwrt/build
     
    5378  openwrt/files-copy \
    5479  openwrt/merge-config \
    55   openwrt/download-link \
    56   # end openwrt/prepare:
     80  openwrt/download-link
    5781        touch $@
    5882
     
    86110        touch $@
    87111
     112openwrt/patch/show: openwrt/checkout
     113        @$(call get_patches) | while read patch ;\
     114        do \
     115           echo $${patch}; \
     116        done
     117
    88118openwrt/patch/force:
    89119        rm -f $(TOPDIR)/openwrt/patch ; \
    90120        make -C $(TOPDIR) openwrt/patch FORCE_PATCH=1 ; \
    91         touch $(TOPDIR)/openwrt/patch
    92121
    93122openwrt/patch: openwrt/checkout
    94         rev=$(call get_svn_revision,$(OPENWRT_BUILD_DIR)) ; \
    95         find \
    96           $(OPENWRT_PATCH_DIRS) \
    97           -name .svn -prune -o \! -type d -printf %f/%p\\n | \
    98         gawk -F / '\
    99           BEGIN { OFS=FS } \
    100           match($$1, "^([[:digit:]])+((-$(OPENWRT_BRANCH))|(-all))?(-([[:digit:]]*):([[:digit:]]*))?_([^/]*)", revs) \
    101             { if(revs[6] <= '$${rev}' && (!length(revs[7]) || revs[7] >= '$${rev}')) \
    102               { $$1=revs[1] "_" revs[8]; print } \
    103             }' | \
    104         sort | sed -e's/^[^/]\+\///' | \
    105         while read pat ; \
     123        @$(call do_patches,,-N)
     124        rm -f openwrt/unpatch
     125        touch $@
     126
     127openwrt/unpatch/show: openwrt/checkout
     128        @$(call get_patches,-r) | while read patch ;\
    106129        do \
    107                 echo "$${pat}" >> $@.applied ; \
    108                 pati=$$(echo $${pat} | sed -e's!$(TOPDIR)/!!') ; \
    109                 if ! patch -b -d "$(OPENWRT_BUILD_DIR)" -p1 -N < "$${pat}" ; \
    110                 then \
    111                         echo ">> fail: $${pati}" > /dev/stderr ; \
    112                         $(if $(FORCE_PATCH),retval=1,exit 1) ; \
    113                 else \
    114                         echo ">> success: $${pati}" ; \
    115                 fi ; \
    116         done ; \
    117         rm -f openwrt/unpatch ; \
    118         touch $@ ; \
    119         exit $${retval}
    120 
     130           echo $${patch}; \
     131        done
    121132openwrt/unpatch/force:
    122133        rm -f $(TOPDIR)/openwrt/unpatch ; \
    123134        make -C $(TOPDIR) openwrt/unpatch FORCE_PATCH=1 ; \
    124         touch $(TOPDIR)/openwrt/unpatch
    125135
    126 openwrt/unpatch: openwrt/patch.applied
    127         if [ -f openwrt/patch -o "$(FORCE_PATCH)" ] ; \
    128         then \
    129                 targ="-n+1" ; \
    130         else \
    131                 pat=`tail -1 $<`; \
    132                 pati=$$(echo $${pat} | sed -e's!$(TOPDIR)/!!') ; \
    133                 if ! patch -b -d "$(OPENWRT_BUILD_DIR)" -p1 -R < "$${pat}" ; \
    134                 then \
    135                         echo ">> fail: $${pati} (ignored)" > /dev/stderr ; \
    136                 else \
    137                         echo ">> success: $${pati}" ; \
    138                 fi ; \
    139                 targ="-n+2" ; \
    140         fi ; \
    141         tac $< | tail $${targ} | \
    142         while read pat ; \
    143         do \
    144                 pati=$$(echo $${pat} | sed -e's!$(TOPDIR)/!!') ; \
    145                 if ! patch -d "$(OPENWRT_BUILD_DIR)" -p1 -R < "$${pat}" ; \
    146                 then \
    147                         echo ">> fail: $${pati}" > /dev/stderr ; \
    148                         $(if $(FORCE_PATCH),retval=1\
    149                         ,echo ">> fatal: build dir in unrecoverable state" > /dev/stderr ; \
    150                         rm -f openwrt/checkout "$(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp" ; \
    151                         exit 127) ; \
    152                 else \
    153                         echo ">> success: $${pati}" ; \
    154                 fi ; \
    155         done ; \
    156         rm -f openwrt/patch $< ; \
    157         touch $@ ; \
    158         exit $${retval}
    159 
     136openwrt/unpatch:
     137        @if [ ! -f $(TOPDIR)/openwrt/patch ]; then \
     138           echo "E: can't unpatch if patches have not previously been applied"; \
     139           exit 1; \
     140        fi
     141        @$(call do_patches,-r,-R)
     142        rm -f openwrt/patch
     143        touch $@
    160144
    161145openwrt/files-copy: openwrt/patch
     
    170154endif
    171155
    172 $(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp:
    173 openwrt/checkout: $(OPENWRT_BUILD_DIR)/.debwrt.checkout.stamp
    174         if [ "`svn info $(OPENWRT_BUILD_DIR) 2>/dev/null | grep ^URL:`" = "URL: $(OPENWRT_SUBVERSION)" ] ; \
    175         then \
    176                 mkdir -p $(TMP_DIR) ; \
    177                 svn st --no-ignore $(OPENWRT_BUILD_DIR) > $(TMP_DIR)/svn.openwrt.state && \
    178                 grep -e^\[\?I\] "$(TMP_DIR)/svn.openwrt.state" | cut -c9- | xargs rm -rf && \
    179                 grep -ve^\[\?I\] "$(TMP_DIR)/svn.openwrt.state" | cut -c9- | xargs svn revert && \
    180                 rm -f "$(TMP_DIR)/svn.openwrt.state" && \
    181                 exit 0 ; \
    182         fi ; \
    183         rm -rf $(OPENWRT_BUILD_DIR) && \
    184         svn co -r $(OPENWRT_REVISION) $(OPENWRT_SUBVERSION) $(OPENWRT_BUILD_DIR) && \
    185         touch $@ $<
     156openwrt/checkout: .config
     157        mkdir -p $(OPENWRT_BUILD_DIR)
     158        svn co -r $(OPENWRT_REVISION) $(OPENWRT_SUBVERSION) $(OPENWRT_BUILD_DIR)
     159        touch $@
    186160
    187161openwrt/update: openwrt/checkout
  • branches/contrib/rules/functions.mk

    r345 r480  
    2020
    2121# Get the SVN revision of something (always returns a number, 0 if absent)
    22 get_svn_revision=$(shell svnversion $(1) | sed -e's/^\([0-9]*\).*$$/\1/g' -e's/^$$/0/g')
     22get_svn_revision=$(shell if [ -d $(1) ]; then svnversion $(1) | sed -e's/^\([0-9]*\).*$$/\1/g' -e's/^$$/0/g' ; fi)
    2323
Note: See TracChangeset for help on using the changeset viewer.