[nginx] Dynamic modules: do not overwrite old modules on install.
Maxim Dounin
mdounin at mdounin.ru
Thu Mar 10 13:51:06 UTC 2016
details: http://hg.nginx.org/nginx/rev/05c894a598ea
branches:
changeset: 6425:05c894a598ea
user: Maxim Dounin <mdounin at mdounin.ru>
date: Thu Mar 10 16:50:13 2016 +0300
description:
Dynamic modules: do not overwrite old modules on install.
Just using "cp" is incorrect, as it will overwrite old files
possibly used by OS, leading to unexpected effects. Changed
to "mv + cp", much like used for the main binary.
diffstat:
auto/init | 1 -
auto/install | 18 ++++++++++++++++--
auto/make | 2 --
3 files changed, 16 insertions(+), 5 deletions(-)
diffs (60 lines):
diff --git a/auto/init b/auto/init
--- a/auto/init
+++ b/auto/init
@@ -5,7 +5,6 @@
NGX_MAKEFILE=$NGX_OBJS/Makefile
NGX_MODULES_C=$NGX_OBJS/ngx_modules.c
-NGX_MODULES=
NGX_AUTO_HEADERS_H=$NGX_OBJS/ngx_auto_headers.h
NGX_AUTO_CONFIG_H=$NGX_OBJS/ngx_auto_config.h
diff --git a/auto/install b/auto/install
--- a/auto/install
+++ b/auto/install
@@ -169,17 +169,31 @@ END
fi
-if test -n "$NGX_MODULES"; then
+if test -n "$DYNAMIC_MODULES"; then
cat << END >> $NGX_MAKEFILE
test -d '\$(DESTDIR)$NGX_MODULES_PATH' \
|| mkdir -p '\$(DESTDIR)$NGX_MODULES_PATH'
- cp $NGX_MODULES '\$(DESTDIR)$NGX_MODULES_PATH'
END
fi
+for ngx_module in $DYNAMIC_MODULES
+do
+ ngx_module=$ngx_module$ngx_modext
+
+ cat << END >> $NGX_MAKEFILE
+
+ test ! -f '\$(DESTDIR)$NGX_MODULES_PATH/$ngx_module' \
+ || mv '\$(DESTDIR)$NGX_MODULES_PATH/$ngx_module' \
+ '\$(DESTDIR)$NGX_MODULES_PATH/$ngx_module.old'
+ cp $NGX_OBJS/$ngx_module '\$(DESTDIR)$NGX_MODULES_PATH/$ngx_module'
+END
+
+done
+
+
# create Makefile
cat << END >> Makefile
diff --git a/auto/make b/auto/make
--- a/auto/make
+++ b/auto/make
@@ -609,8 +609,6 @@ END
ngx_obj=$NGX_OBJS$ngx_dirsep$ngx_module$ngx_modext
- NGX_MODULES="$NGX_MODULES $ngx_obj"
-
if [ "$NGX_PLATFORM" = win32 ]; then
ngx_module_libs="$CORE_LIBS $ngx_module_libs"
fi
More information about the nginx-devel
mailing list