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.
This commit is contained in:
Maxim Dounin 2016-03-10 16:50:13 +03:00
parent 2301b095e6
commit 5835963d61
3 changed files with 16 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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