Created
May 25, 2018 06:43
-
-
Save koitsu/94c3e48f1debf4ea4b8c124db9518f7b to your computer and use it in GitHub Desktop.
fix-patch-methodology.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/release/src-rt-6.x.4708/router/Makefile b/release/src-rt-6.x.4708/router/Makefile | |
index e97164e7f..b76ef17cf 100644 | |
--- a/release/src-rt-6.x.4708/router/Makefile | |
+++ b/release/src-rt-6.x.4708/router/Makefile | |
@@ -18,23 +18,6 @@ include common.mak | |
export PARALLEL_BUILD := -j`grep -c '^processor' /proc/cpuinfo` | |
-define patch_files | |
- find patches/$(1) -maxdepth 1 -type f -name '*.patch' | sort -t '\0' -n | while read FILE; do \ | |
- ( if ! patch -p0 -Rf --dry-run --silent < $$FILE 2>/dev/null; then \ | |
- patch -p0 < $$FILE; \ | |
- fi ) \ | |
- done | |
-endef | |
- | |
-define unpatch_files | |
- find patches/$(1) -maxdepth 1 -type f -name '*.patch' | sort -t '\0' -n | while read FILE; do \ | |
- ( if patch -p0 -Rf --dry-run --silent < $$FILE 2>/dev/null; then \ | |
- patch -p0 -Rf < $$FILE; \ | |
- fi ) \ | |
- done | |
-endef | |
- | |
- | |
# | |
# | |
# | |
@@ -833,7 +816,7 @@ OPENSSL_CIPHERS:= | |
endif | |
openssl/stamp-h1: | |
- $(call patch_files,openssl) | |
+ @$(TOP)/patches/apply openssl | |
cd openssl && \ | |
./Configure $(HOSTCONFIG) --openssldir=/etc --cross-compile-prefix=' ' \ | |
-ffunction-sections -fdata-sections -Wl,--gc-sections \ | |
@@ -854,7 +837,7 @@ openssl: openssl/stamp-h1 | |
openssl-clean: | |
-@$(MAKE) -C openssl clean | |
@rm -f openssl/stamp-h1 | |
- $(call unpatch_files,openssl) | |
+ @$(TOP)/patches/unapply openssl | |
openssl-install: | |
install -D openssl/libcrypto.so.1.0.0 $(INSTALLDIR)/openssl/usr/lib/libcrypto.so.1.0.0 | |
@@ -901,7 +884,7 @@ bridge-install: | |
dnsmasq: $(if $(TCONFIG_DNSSEC),nettle,) | |
@$(SEP) | |
- $(call patch_files,dnsmasq) | |
+ @$(TOP)/patches/apply dnsmasq | |
@$(MAKE) -C dnsmasq $(PARALLEL_BUILD) \ | |
COPTS="$(if $(TCONFIG_DNSSEC),-I$(TOP)/nettle/include -I$(TOP)/gmp -DHAVE_DNSSEC -DHAVE_DNSSEC_STATIC,) \ | |
$(if $(TCONFIG_IPV6),-DUSE_IPV6,-DNO_IPV6) \ | |
@@ -915,7 +898,7 @@ dnsmasq-install: | |
$(STRIP) $(INSTALLDIR)/dnsmasq/usr/sbin/dnsmasq | |
dnsmasq-clean: | |
- $(call unpatch_files,dnsmasq) | |
+ @$(TOP)/patches/unapply dnsmasq | |
nettle/stamp-h1: gmp | |
@cd nettle && CC=$(CC) AR=$(AR) RANLIB=$(RANLIB) LD=$(LD) \ | |
@@ -1098,13 +1081,13 @@ miniupnpd-config: | |
miniupnpd: $(IPTABLES_TARGET) miniupnpd-config | |
@$(SEP) | |
- $(call patch_files,miniupnpd) | |
+ @$(TOP)/patches/apply miniupnpd | |
$(MAKE) -C miniupnpd -f Makefile.linux | |
miniupnpd-clean: | |
-@$(MAKE) -C miniupnpd -f Makefile.linux clean | |
@rm -f miniupnpd/config.h | |
- $(call unpatch_files,miniupnpd) | |
+ @$(TOP)/patches/unapply miniupnpd | |
miniupnpd-install: | |
install -D miniupnpd/miniupnpd $(INSTALLDIR)/miniupnpd/usr/sbin/miniupnpd | |
@@ -1302,7 +1285,7 @@ ifeq ($(TCONFIG_L2TP),y) | |
endif | |
xl2tpd: pppd | |
- $(call patch_files,xl2tpd) | |
+ @$(TOP)/patches/apply xl2tpd | |
CFLAGS="-g $(EXTRACFLAGS)" $(MAKE) -C $@ PREFIX=/usr xl2tpd $(PARALLEL_BUILD) | |
xl2tpd-install: | |
@@ -1310,7 +1293,7 @@ xl2tpd-install: | |
$(STRIP) $(INSTALLDIR)/xl2tpd/usr/sbin/xl2tpd | |
xl2tpd-clean: | |
- $(call unpatch_files,xl2tpd) | |
+ @$(TOP)/patches/unapply xl2tpd | |
bpalogin-install: | |
install -D bpalogin/bpalogin $(INSTALLDIR)/bpalogin/usr/sbin/bpalogin | |
@@ -1374,10 +1357,10 @@ dropbear-install: | |
dropbear-clean: | |
-@$(MAKE) -C dropbear clean | |
@rm -f dropbear/config.h | |
- $(call unpatch_files,dropbear) | |
+ @$(TOP)/patches/unapply dropbear | |
dropbear/config.h: | |
- $(call patch_files,dropbear) | |
+ @$(TOP)/patches/apply dropbear | |
cd dropbear && \ | |
CFLAGS="-Os -Wall $(EXTRACFLAGS) -DARGTYPE=3 -ffunction-sections -fdata-sections" \ | |
LDFLAGS="-ffunction-sections -fdata-sections -Wl,--gc-sections" \ | |
@@ -1603,7 +1586,7 @@ ifeq ($(TCONFIG_SNMP),y) | |
endif | |
libid3tag/stamp-h1: zlib | |
- $(call patch_files,libid3tag) | |
+ @$(TOP)/patches/apply libid3tag | |
cd libid3tag && \ | |
CFLAGS="-Os -Wall $(EXTRACFLAGS) -ffunction-sections -fdata-sections" CPPFLAGS="-I$(TOP)/zlib" \ | |
LDFLAGS="-L$(TOP)/zlib -fPIC -ffunction-sections -fdata-sections -Wl,--gc-sections" \ | |
@@ -1617,7 +1600,7 @@ libid3tag: libid3tag/stamp-h1 zlib | |
libid3tag-clean: | |
-@$(MAKE) -C libid3tag clean | |
@rm -f libid3tag/stamp-h1 | |
- $(call unpatch_files,libid3tag) | |
+ @$(TOP)/patches/unapply libid3tag | |
libid3tag-install: | |
@$(SEP) | |
@@ -1652,13 +1635,13 @@ endif | |
minidlna: zlib sqlite ffmpeg libogg flac jpeg libexif libid3tag libvorbis | |
@$(SEP) | |
- $(call patch_files,minidlna) | |
+ @$(TOP)/patches/apply minidlna | |
@$(MAKE) -C minidlna CC=$(CC) $(if $(MEDIA_SERVER_STATIC),STATIC=1,) minidlna $(PARALLEL_BUILD) | |
minidlna-clean: | |
-@$(MAKE) -C minidlna clean | |
@rm -f minidlna/stamp-h1 | |
- $(call unpatch_files,minidlna) | |
+ @$(TOP)/patches/unapply minidlna | |
minidlna-install: | |
@$(SEP) | |
@@ -1910,7 +1893,7 @@ libpng-clean: | |
php/stamp-h1: pcre zlib libiconv sqlite libxml2 libpng jpeg libcurl | |
@$(SEP) | |
- $(call patch_files,php) | |
+ @$(TOP)/patches/apply php | |
cd php && CC=$(CC) CXX=$(ARCH)-g++ AR=$(AR) RANLIB=$(RANLIB) LD=$(LD) \ | |
CFLAGS="-Os -Wall -I$(TOP)/zlib -I$(TOP)/libxml2/include/libxml -I$(TOP)/libxml2/include -I$(TOP)/pcre -I$(TOP)/libiconv/include \ | |
-I$(TOP)/libpng/staged/usr/include -I$(TOP)/libcurl/staged/include" \ | |
@@ -1989,7 +1972,7 @@ php: php/stamp-h1 | |
php-clean: | |
-@$(MAKE) -C php clean | |
-@rm php/stamp-h1 | |
- $(call unpatch_files,php) | |
+ @$(TOP)/patches/unapply php | |
php-install: | |
@$(SEP) | |
@@ -2002,7 +1985,7 @@ php-install: | |
nginx/stamp-h1: openssl zlib pcre | |
@$(SEP) | |
- $(call patch_files,nginx) | |
+ @$(TOP)/patches/apply nginx | |
cd $(TOP)/nginx && ./configure --crossbuild=Linux::$(ARCH) \ | |
--prefix=/usr \ | |
--sbin-path=/usr/sbin \ | |
@@ -2031,7 +2014,7 @@ nginx: nginx/stamp-h1 | |
nginx-clean: | |
-@$(MAKE) -C nginx clean | |
-@rm -f nginx/stamp-h1 | |
- $(call unpatch_files,nginx) | |
+ @$(TOP)/patches/unapply nginx | |
nginx-install: | |
install -d $(INSTALLDIR)/nginx/usr/sbin | |
@@ -2084,7 +2067,7 @@ libncurses-install: | |
mysql/stamp-h1: openssl zlib libncurses | |
@$(SEP) | |
@cp -f $(TOP)/patches/mysql/.host.tgz $(TOP)/mysql/ || true | |
- $(call patch_files,mysql) | |
+ @$(TOP)/patches/apply mysql | |
cd mysql && \ | |
CFLAGS="-O2 -Wall -fno-delete-null-pointer-checks -funit-at-a-time --param large-function-growth=800 \ | |
--param max-inline-insns-single=3000 -ffunction-sections -fdata-sections -I$(TOP)/zlib \ | |
@@ -2123,7 +2106,7 @@ mysql-clean: | |
-@rm -f mysql/stamp-h1 | |
-@rm -rf mysql/staged mysql/host | |
-@rm -f mysql/.host.tgz | |
- $(call unpatch_files,mysql) | |
+ @$(TOP)/patches/unapply mysql | |
mysql-install: | |
install -d $(INSTALLDIR)/mysql/usr/bin | |
@@ -2216,7 +2199,7 @@ openvpn_plugin_auth_nvram: nvram$(BCMEX) | |
#shibby | |
nano/stamp-h1: libncurses | |
- $(call patch_files,nano) | |
+ @$(TOP)/patches/apply nano | |
cd nano && CC=$(CC) STRIP=$(STRIP) \ | |
autoreconf && \ | |
CFLAGS="-Os -Wall $(EXTRACFLAGS) -I$(TOP)/libncurses/staged/usr/include -ffunction-sections -fdata-sections" \ | |
@@ -2233,7 +2216,7 @@ nano: nano/stamp-h1 | |
nano-clean: | |
-@$(MAKE) -C nano clean | |
@rm -f nano/stamp-h1 nano/Makefile nano/src/Makefile | |
- $(call unpatch_files,nano) | |
+ @$(TOP)/patches/unapply nano | |
nano-install: | |
install -d $(INSTALLDIR)/nano/usr/sbin | |
@@ -2701,7 +2684,7 @@ libmnl-clean: | |
-@rm -rf libmnl/staged | |
ipset/stamp-h1: libmnl | |
- $(call patch_files,ipset) | |
+ @$(TOP)/patches/apply ipset | |
cd $(TOP)/ipset && CC=$(CC) STRIP=$(STRIP) \ | |
autoreconf -fsi && \ | |
CFLAGS="-Os -Wall $(EXTRACFLAGS) -ffunction-sections -fdata-sections" \ | |
@@ -2727,7 +2710,7 @@ ipset-install: | |
ipset-clean: | |
-@$(MAKE) -C ipset clean | |
-@rm -rf ipset/Makefile ipset/stamp-h1 | |
- $(call unpatch_files,ipset) | |
+ @$(TOP)/patches/unapply ipset | |
libjson-c/stamp-h1: | |
cd $(TOP)/libjson-c && CC=$(CC) STRIP=$(CROSS_COMPILE)strip \ | |
diff --git a/release/src-rt-6.x.4708/router/patches/apply b/release/src-rt-6.x.4708/router/patches/apply | |
new file mode 100755 | |
index 000000000..0540bbc5a | |
--- /dev/null | |
+++ b/release/src-rt-6.x.4708/router/patches/apply | |
@@ -0,0 +1,24 @@ | |
+#!/bin/sh | |
+ | |
+dir=$1 | |
+ | |
+if [ -z "$dir" ]; then | |
+ echo "ERROR: $0 -- missing directory argument" | |
+ exit 1 | |
+fi | |
+ | |
+if [ ! -d "patches/$dir" ]; then | |
+ echo "ERROR: $0 -- patches/$dir doesn't exist" | |
+ exit 1 | |
+fi | |
+ | |
+patches=$(find patches/$dir -maxdepth 1 -type f -name '*.patch' | sort -t '\0' -n) | |
+ | |
+if [ -n "$patches" ]; then | |
+ for FILE in $patches; do | |
+ if ! patch -p0 -Rf --dry-run 1>/dev/null < $FILE; then | |
+ patch -p0 < $FILE || exit $? | |
+ fi | |
+ done | |
+fi | |
+ | |
diff --git a/release/src-rt-6.x.4708/router/patches/unapply b/release/src-rt-6.x.4708/router/patches/unapply | |
new file mode 100755 | |
index 000000000..10eb2987f | |
--- /dev/null | |
+++ b/release/src-rt-6.x.4708/router/patches/unapply | |
@@ -0,0 +1,24 @@ | |
+#!/bin/sh | |
+ | |
+dir=$1 | |
+ | |
+if [ -z "$dir" ]; then | |
+ echo "ERROR: $0 -- missing directory argument" | |
+ exit 1 | |
+fi | |
+ | |
+if [ ! -d "patches/$dir" ]; then | |
+ echo "ERROR: $0 -- patches/$dir doesn't exist" | |
+ exit 1 | |
+fi | |
+ | |
+patches=$(find patches/$dir -maxdepth 1 -type f -name '*.patch' | sort -t '\0' -n) | |
+ | |
+if [ -n "$patches" ]; then | |
+ for FILE in $patches; do | |
+ if patch -p0 -Rf --dry-run 1>/dev/null < $FILE; then | |
+ patch -p0 -Rf < $FILE || exit $? | |
+ fi | |
+ done | |
+fi | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment