Changeset 517 for trunk/plugins


Ignore:
Timestamp:
Jun 26, 2013, 11:25:44 PM (6 years ago)
Author:
amain
Message:

Merge contrib branch 340:516. Main features added:

  • updated plugin architecture
  • improved patch system
  • bitten continous integration support
  • sever build fixed over time to remain in sync with OpenWrt
Location:
trunk
Files:
4 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/plugins

    • Property svn:ignore
      •  

        old new  
        55de-apply-debwrt
        66de-apply-openwrt
         7generate-config
  • trunk/plugins/README

    r273 r517  
    33Layout:
    44
    5   plugins/<plugin-name/        - plugin directory
    6   plugins/<plugin-name/debwrt  - debwrt patches
    7   plugins/<plugin-name/openwrt - openwrt patches
    8   plugins/<plugin-name/README  - information about the plugin
     5  plugins/<plugin-name>/           - plugin directory
     6  plugins/<plugin-name>/README     - information about the plugin
     7  plugins/<plugin-name>/plugin.mk  - included as a Makefile by plugins.mk
     8  plugins/<plugin-name>/debwrt     - debwrt patches
     9  plugins/<plugin-name>/openwrt    - openwrt patches
    910
    1011All plugins are enabled by default and all patches part of the plugin will be
    11 applied to DebWrt and OpenWrt. Use the make <taget> PLUGIN=<plugin-name> to
     12applied to DebWrt and OpenWrt. Use the make <target> PLUGIN=<plugin-name> to
    1213only apply one plugin.
    1314
    14 The DebWrt patches are automatically applied in sort order before
    15 make (menu)config. OpenWrt patches are automatically applied in sort order
    16 after OpenWrt has been checked out.
     15The DebWrt patches are automatically applied in `sort`-ed order before
     16make (menu)config.
     17
     18OpenWrt patches are applied at the same time as DebWrt's patches to OpenWrt.
     19Patches can be target at specific branches or ranges of revision based on
     20filename.  Refer to openwrt/patches/README for imformation on the process.
     21Note patches MUST follow the rules in openwrt/patches/README as otherwise they
     22will not be applied!
     23
     24plugin.mk is included by the plugins.mk Makefile.  See
     25plugins/example/plugin.mk.example for an example.  Note most rules will require
     26$(PLUGIN_ID) to be copied into a pattern-specific variable.
     27
    1728
    1829Make targets to manage plugings. Normally only needed when developing a plugin. Targets:
    1930
    20   make plugins/apply             - Apply debwrt patches and show message openwrt patches are done later
    21   make plugins/apply-debwrt      - Apply debwrt patches
    22   make plugins/apply-openwrt     - Apply openwrt patches
    23   make plugins/de-apply          - De apply debwrt and openwrt patches
    24   make plugins/de-apply-debwrt   - Apply debwrt patches
    25   make plugins/de-apply-openwrt  - Apply openwrt patches
    26   make plugins/clean             - Clean up apply and de-apply states
     31  make plugins/apply   - Apply debwrt patches and show message openwrt patches are done later
     32  make plugins/remove  - Remove debwrt patches
     33  make plugins/clean   - Clean up apply and de-apply states
    2734
  • trunk/plugins/plugins.mk

    r285 r517  
    11# DebWrt - Debian on Embedded devices
    22#
    3 # Copyright (C) 2011 Johan van Zoomeren <amain@debwrt.net>
     3# Copyright (C) 2011-2012 Johan van Zoomeren <amain@debwrt.net>
     4#
     5# Copyright (C) 2012 Elliott Mitchell <ehem+debwrt@m5p.com>
     6#       2012-10-06  merged OpenWRT patching with DebWRT's patching of OpenWRT
     7#       2012-10-06  added ability to include Makefile from plugins
    48#
    59# This program is free software: you can redistribute it and/or modify
     
    1620# along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1721
    18 ifeq ($(PLUGIN),)
    19         PLUGIN_LIST:=$(shell find $(PLUGINS_DIR) -maxdepth 1 -mindepth 1 -type d -name '*' ! -name '.*' -printf '%f\n')
     22PLUGINS_AVAILABLE:=$(shell find $(PLUGINS_DIR) \
     23                                -maxdepth 1 \
     24                                -mindepth 1 \
     25                                -type d ! \
     26                                -name '.*' \
     27                                -printf '%f\n')
     28PLUGIN_CHOICE_BEGIN = \
     29choice\n\
     30   prompt \"Target Plugin\"\n\
     31   default PLUGIN_NONE \n\
     32   help\n\
     33     Select a target plugin\n\
     34\nconfig PLUGIN_NONE\n\
     35  bool\n\
     36  prompt \"None\"\n\
     37
     38PLUGIN_CHOICE_END = \
     39endchoice\n
     40
     41PLUGIN_CONFIG_LINE = \
     42config PLUGIN_$${plugin_up}\n\
     43  bool\n\
     44  prompt \"$${plugin}\"\n\
     45  deselect HAS_SUBTARGETS\n\
     46  deselect DO_CONF_TARGETS\n\
     47
     48
     49# Register target
     50#
     51# $(1): target
     52# $(2): prerequisite(s)
     53define register_target
     54$(1): $(2)
     55endef
     56
     57# Register target for plugin
     58#
     59# $(1): plugin name
     60# $(2): debwrt target
     61#
     62# Check if CONFIG_PLUGIN_<plugin_name>_ENABLE =  y
     63# Check if CONFIG_PLUGIN_<plugin_name>_UUID   == PLUGIN_<plugin_name>_UUID
     64#
     65# Register target
     66#
     67# - make plugin specific target a prerequitite of the DebWrt target
     68# - when DebWrt target is rebuild, first the plugin specic target is rebuild
     69#
     70# target: plugin/<pluging_name>/target
     71#
     72# or on UUID mismatch:
     73#
     74# target: plugin/<plugin_name>/uuid-error
     75define register_plugin_target
     76ifeq ($(CONFIG_PLUGIN_$(call upper,$(1))_ENABLE),y)
     77ifeq ($(call qstrip,$(CONFIG_PLUGIN_$(call upper,$(1))_UUID)),$(PLUGIN_$(call upper,$(1))_UUID))
     78REGISTERED_TARGETS+=plugin/$(1)/$(2)
     79ifeq ($(2),plugins/check)
     80$(call register_target,$(2),plugin/$(call lower,$(1))/uuid-success)
    2081else
    21         PLUGIN_LIST:=$(PLUGIN)
     82$(call register_target,$(2),plugin/$(call lower,$(1))/$(2))
     83endif
     84else
     85$(call register_target,$(2),plugin/$(call lower,$(1))/uuid-error)
     86endif
     87endif
     88endef
     89
     90# Call-back for plugins: register plugin targets and mandatory plugins/check target
     91#
     92# $(1): plugin name
     93# $(2): list of targets
     94#
     95define register
     96$(eval $(foreach target,$(2) plugins/check,$(eval $(call register_plugin_target,$(1),$(target)))))
     97endef
     98
     99# Include a plugin
     100#
     101# $(1): plugin name
     102#
     103# Define plugin specific variables, before including and
     104# evaluating plugins/<plugin_name>/plugin.mk.
     105define include_plugin
     106ifneq ($(1),)
     107PLUGIN_NAME:=$(call upper,$(1))
     108plugin_name:=$(call lower,$(1))
     109target=plugins/$(call lower,$(1))
     110include $(PLUGINS_DIR)/$(call lower,$(1))/plugin.mk
     111endif
     112endef
     113
     114# Inlcude plugin.mk for each plugin
     115$(foreach plugin,$(PLUGINS_AVAILABLE),$(eval $(call include_plugin,$(plugin))))
     116
     117plugin/%/uuid-success:
     118ifeq ($(findstring plugins/check,$(MAKECMDGOALS)),plugins/check)
     119        @echo "Version verified for plugin $(call upper,$*)"
     120        @echo "  Configured UUID: $(PLUGIN_$(call upper,$*)_UUID) (Config.in)"
     121        @echo "  Plugin UUID    : $(CONFIG_PLUGIN_$(call upper,$*)_UUID) (plugin.mk)"
     122else
     123        @true
    22124endif
    23125
    24 plugins/apply: plugins/apply-debwrt
    25         @echo "note: openwrt patches in plugins will be applied after OpenWrt has been checked out."
    26         >$@
     126plugin/%/uuid-error:
     127        @echo "Version mismatch for plugin $(call upper,$*)"
     128        @echo "  Configured UUID: $(PLUGIN_$(call upper,$*)_UUID) (Config.in)"
     129        @echo "  Plugin UUID    : $(CONFIG_PLUGIN_$(call upper,$*)_UUID) (plugin.mk)"
     130ifneq ($(findstring plugins/check,$(MAKECMDGOALS)),plugins/check)
     131        @exit 1
     132endif
    27133
    28 plugins/de-apply: plugins/de-apply-debwrt plugins/de-apply-openwrt
    29         >$@
     134plugins/generate-config:
     135        @mkdir $(TMP_DIR)
     136        @/bin/echo -e "$(PLUGIN_CHOICE_BEGIN)" >$(TMP_DIR)/plugins-generated.in
     137        @for plugin in $(PLUGINS_AVAILABLE); \
     138        do \
     139          plugin_up=$$(echo $${plugin} | tr [a-z] [A-Z]); \
     140          echo "Generating config for plugin: $${plugin_up}"; \
     141          /bin/echo -e "$(PLUGIN_CONFIG_LINE)" >>$(TMP_DIR)/plugins-generated.in; \
     142        done
     143        @/bin/echo -e "$(PLUGIN_CHOICE_END)" >>$(TMP_DIR)/plugins-generated.in
     144        touch $@
    30145
    31 plugins/apply-debwrt:
    32         @for plugin in $(PLUGIN_LIST); do \
    33                 echo "Applying plugin '$$plugin' on DebWrt:"; \
    34                 for patch in `find $(PLUGINS_DIR)/$$plugin/debwrt -maxdepth 2 -mindepth 1 -type f -printf '%f\n' | sort`; do \
    35                         if ( echo "$$patch" | grep -q ".rpatch$$" ); then \
    36                                 echo "Reverse patch: $$patch"; \
    37                                 patch -R -p1 -d $(TOPDIR) <$(PLUGINS_DIR)/$$plugin/debwrt/$$patch; \
    38                         else \
    39                                 echo "Normal patch: $$patch"; \
    40                                 patch -p1 -d $(TOPDIR) <$(PLUGINS_DIR)/$$plugin/debwrt/$$patch; \
    41                         fi \
    42                 done; \
     146plugins/list:
     147        @for plugin in $(PLUGINS_AVAILABLE); \
     148        do \
     149           echo $${plugin}; \
    43150        done
    44         >$@
    45151
    46 plugins/de-apply-debwrt:
    47         @for plugin in $(PLUGIN_LIST); do \
    48                 echo "De-applying plugin '$$plugin' on DebWrt:"; \
    49                 for patch in `find $(PLUGINS_DIR)/$$plugin/debwrt/ -maxdepth 1 -mindepth 1 -type f -printf '%f\n' | sort`; do \
    50                         if ( echo "$$patch" | grep -q ".rpatch$$" ); then \
    51                                 echo "Reverse patch: $$patch"; \
    52                                 patch -p1 -d $(TOPDIR) <$(PLUGINS_DIR)/$$plugin/debwrt/$$patch; \
    53                         else \
    54                                 echo "Normal patch: $$patch"; \
    55                                 patch -R -p1 -d $(TOPDIR) <$(PLUGINS_DIR)/$$plugin/debwrt/$$patch; \
    56                         fi \
    57                 done; \
     152plugins/targets/registered:
     153        @for target in $(REGISTERED_TARGETS); \
     154        do \
     155           echo $${target}; \
    58156        done
    59         >$@
    60157
    61 plugins/apply-openwrt:
    62         @for plugin in $(PLUGIN_LIST); do \
    63                 echo "Applying plugin '$$plugin' on OpenWrt:"; \
    64                 for patch in `find $(PLUGINS_DIR)/$$plugin/openwrt/ -maxdepth 1 -mindepth 1 -type f -printf '%f\n' | sort`; do \
    65                         patch -p1 -d $(OPENWRT_BUILD_DIR) <$(PLUGINS_DIR)/$$plugin/openwrt/$$patch; \
    66                 done; \
     158plugins/enabled/list:
     159        @echo $(PLUGINS_ENABLED)
     160        @for plugin in $(PLUGINS_ENABLED); \
     161        do \
     162           echo $${plugin}; \
    67163        done
    68         >$@
    69 
    70 plugins/de-apply-openwrt:
    71         @for plugin in $(PLUGIN_LIST); do \
    72                 echo "De-applying plugin '$$plugin' on OpenWrt:"; \
    73                 for patch in `find $(PLUGINS_DIR)/$$plugin/openwrt/ -maxdepth 1 -mindepth 1 -type f -printf '%f\n' | sort`; do \
    74                         patch -R -p1 -d $(OPENWRT_BUILD_DIR) <$(PLUGINS_DIR)/$$plugin/openwrt/$$patch || true ; \
    75                 done; \
    76         done
    77         >$@
    78164
    79165plugins/clean:
    80         rm -f plugins/apply
    81         rm -f plugins/apply-debwrt
    82         rm -f plugins/apply-openwrt
    83         rm -f plugins/de-apply
    84         rm -f plugins/de-apply-debwrt
    85         rm -f plugins/de-apply-openwrt
     166
     167plugins/check:
     168
     169test:
     170        @echo "Test Plugins"
     171
     172register:
     173        @echo "Register plugins"
     174
     175
     176.PHONY: plugins/list \
     177        plugins/targets/registered \
     178        plugins/enabled/list \
     179        plugin/%/uuid-error \
     180        plugin/%/uuid-success \
     181        plugins/clean \
     182        plugins/check
     183
Note: See TracChangeset for help on using the changeset viewer.