5.修补OTP应用程序 | 5. Patching OTP Applications

5补丁OTP应用程序

5.1介绍

本文档描述了使用比已安装版本更新的一个或多个Erlang / OTP应用程序对现有OTP安装进行修补的过程。该工具otp_patch_apply可用于此特定目的。它位于Erlang / OTP源代码树的顶层目录中。

otp_patch_apply工具利用中的runtime_dependencies标签application resource file。该信息用于确定修补程序是否可以安装在给定的Erlang / OTP安装目录中。

阅读version handlingErlang / OTP版本17中介绍的更多信息,其中还介绍了如何确定安装是否包含一个或多个已修补的应用程序。

如果要应用驻留在不同OTP版本中的多个OTP应用程序的修补程序,则必须分多步应用这些修补程序。一次只能使用同一个OTP版本的多个OTP应用程序。

5.2先决条件

假定读者熟悉building and installing Erlang/OTP。为了能够修补应用程序,必须存在以下内容:

  • Erlang/OTP安装。

  • 一个Erlang/OTP源代码树,包含要修补到现有Erlang/OTP安装中的更新应用程序。

5.3使用otp_patch_apply

警告

修补应用程序是一个单向过程。在继续之前创建您的OTP安装目录的备份。

首先,在$ERL_TOP包含更新的应用程序。

在应用修补程序之前,您需要在源目录中完整构建OTP。

如果您正在构建git您首先需要生成configure脚本:

$ ./otp_build autoconf

在OTP中配置和构建所有应用程序:

$ configure $ make

$ ./otp_build configure $ ./otp_build boot -a

如果您已经在OTP安装中安装了文档,还可以构建文档:

$ make docs

成功构建后,即可进行修补。源树目录,安装目录和要修补的应用程序以参数形式给出otp_patch_apply。每个应用程序的依赖关系都会根据安装中的应用程序和作为参数给出的其他应用程序进行验证。如果检测到依赖性错误,脚本将被中止。

otp_patch_apply语法:

$ otp_patch_apply -s <Dir> -i <Dir> [-l <Dir>] [-c] [-f] [-h] \ [-n] [-v] <App1> [... <AppN>] -s <Dir> -- OTP source directory that contains build results. -i <Dir> -- OTP installation directory to patch. -l <Dir> -- Alternative OTP source library directory path(s) containing build results of OTP applications. Multiple paths should be colon separated. -c -- Cleanup (remove) old versions of applications patched in the installation. -f -- Force patch of application(s) even though dependencies are not fulfilled (should only be considered in a test environment). -h -- Print help then exit. -n -- Do not install documentation. -v -- Print version then exit. <AppX> -- Application to patch. Environment Variable: ERL_LIBS -- Alternative OTP source library directory path(s) containing build results of OTP applications. Multiple paths should be colon separated.

运行时需要完整的构建环境otp_patch_apply

所有的源目录鉴定-s-l应包含的OTP应用程序生成的结果。

例如,如果用户想要将补丁版本mnesiassl内置/home/me/git/otp安装到位于/opt/erlang/my_otp类型中的OTP安装中

$ otp_patch_apply -s /home/me/git/otp -i /opt/erlang/my_otp \ mnesia ssl

如果应用程序列表中包含核心应用,即ertskernelstdlib或者sasl,将Install在修补二郎山/ OTP安装脚本必须重新运行。

修补后的应用程序将附加到已安装应用程序的列表中。看看<InstallDir>/releases/OTP-REL/installed_application_versions。

5.4完整性检查

应用程序依赖关系可以使用Erlang shell进行检查。应用程序依赖性通过已安装的应用程序进行验证otp_patch_apply,但这些不一定是实际加载的。通过调用system_information:sanity_check()可以验证实际加载的应用程序之间的依赖关系。

1> system_information:sanity_check(). ok

请参阅参考资料以sanity_check()获取更多信息。