source: trunk/plugins/plugins.mk @ 285

Last change on this file since 285 was 285, checked in by amain, 8 years ago

plugins: add support for reverse patches

File size: 3.0 KB
Line 
1# DebWrt - Debian on Embedded devices
2#
3# Copyright (C) 2011 Johan van Zoomeren <amain@debwrt.net>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18ifeq ($(PLUGIN),)
19        PLUGIN_LIST:=$(shell find $(PLUGINS_DIR) -maxdepth 1 -mindepth 1 -type d -name '*' ! -name '.*' -printf '%f\n')
20else
21        PLUGIN_LIST:=$(PLUGIN)
22endif
23
24plugins/apply: plugins/apply-debwrt
25        @echo "note: openwrt patches in plugins will be applied after OpenWrt has been checked out."
26        >$@
27
28plugins/de-apply: plugins/de-apply-debwrt plugins/de-apply-openwrt
29        >$@
30
31plugins/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; \
43        done
44        >$@
45
46plugins/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; \
58        done
59        >$@
60
61plugins/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; \
67        done
68        >$@
69
70plugins/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        >$@
78
79plugins/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
Note: See TracBrowser for help on using the repository browser.