在openwrt 17.01上编译最新nginx 1.14.2的笔记

openwrt 17.01源码对应的nginx版本是1.10.2,有些新功能没有,所以需要升级到nginx 1.14.2最新的稳定版

https://github.com/macports/macports-ports/blob/09603eacd0424538f0321e2ce04f5295f987571a/www/nginx/files/patch-src-ngx_http_lua_headers.c.diff

https://github.com/openwrt/packages/tree/master/net/nginx/patches

有几个地方需要修改:

1、修改feeds/packages/net/nginx/patches目录里的几个文件:

增加一个文件:201-ignore-invalid-options.patch

 --- a/auto/options
+++ b/auto/options
@@ -391,7 +391,6 @@ $0: warning: the \"--with-sha1-asm\" option is deprecated"
         --test-build-solaris-sendfilev)  NGX_TEST_BUILD_SOLARIS_SENDFILEV=YES ;;

         *)
-            echo "$0: error: invalid option \"$option\""
-            exit 1
+            echo "$0: error: ignoring invalid option \"$option\""
         ;;
     esac

修改:

102-sizeof_test_fix.patch

--- a/auto/types/sizeof
+++ b/auto/types/sizeof
@@ -25,8 +25,14 @@ $NGX_INCLUDE_UNISTD_H
 $NGX_INCLUDE_INTTYPES_H
 $NGX_INCLUDE_AUTO_CONFIG_H

+char object_code_block[] = {
+       '\n', 'e', '4', 'V', 'A',
+       '0', 'x', ('0' + sizeof($ngx_type)),
+       'Y', '3', 'p', 'M', '\n'
+};
+
 int main(void) {
-    printf("%d", (int) sizeof($ngx_type));
+    printf("dummy use of object_code_block to avoid gc-section: %c", object_code_block[0]);
     return 0;
 }

@@ -40,7 +46,7 @@ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&


 if [ -x $NGX_AUTOTEST ]; then
-    ngx_size=`$NGX_AUTOTEST`
+    ngx_size=`sed -ne 's/^e4VA0x\(.\)Y3pM$/\1/p' < $NGX_AUTOTEST`
     echo " $ngx_size bytes"
 fi

2、修改feeds/packages/net/nginx/patches-lua-nginx目录里的几个文件:

增加:101-patch-src-ngx_http_lua_headers.c.patch

--- a/lua-nginx/src/ngx_http_lua_headers.c
+++ b/lua-nignx/src/ngx_http_lua_headers.c
@@ -77,6 +77,9 @@
     size_t                       size;
     ngx_buf_t                   *b, *first = NULL;
     ngx_int_t                    i, j;
+#if defined(nginx_version) && nginx_version >= 1011011
+    ngx_chain_t                 *cl;
+#endif
     ngx_connection_t            *c;
     ngx_http_request_t          *r, *mr;
     ngx_http_connection_t       *hc;
@@ -141,8 +141,15 @@

     if (hc->nbusy) {
         b = NULL;
+
+#if defined(nginx_version) && nginx_version >= 1011011
+        for (cl = hc->busy; cl; /* void */) {
+            b = cl->buf;
+            cl = cl->next;
+#else
         for (i = 0; i < hc->nbusy; i++) {
             b = hc->busy[i];
+#endif

             dd("busy buf: %d: [%.*s]", (int) i, (int) (b->pos - b->start),
                b->start);
@@ -216,8 +217,15 @@
     }

     if (hc->nbusy) {
+
+#if defined(nginx_version) && nginx_version >= 1011011
+        for (cl = hc->busy; cl; /* void */) {
+            b = cl->buf;
+            cl = cl->next;
+#else
         for (i = 0; i < hc->nbusy; i++) {
             b = hc->busy[i];
+#endif

             if (!found) {
                 if (b != first) {

3、修改feeds/packages/net/nginx/Makefile文件:

PKG_VERSION:=1.14.2

猜你喜欢

转载自blog.csdn.net/d9394952/article/details/88863572
今日推荐