檢視原始碼 修補 OTP 應用程式
簡介
本文檔描述使用較新版本的 Erlang/OTP 應用程式修補現有 OTP 安裝的過程。工具 otp_patch_apply
可用於此特定目的。它位於 Erlang/OTP 原始碼樹的頂層目錄中。
otp_patch_apply
工具使用應用程式資源檔案中的 runtime_dependencies 標籤。此資訊用於判斷是否可以在給定的 Erlang/OTP 安裝目錄中安裝修補程式。
請閱讀更多關於 Erlang/OTP 版本 17 中引入的版本處理,其中也描述如何判斷安裝是否包含一個或多個已修補的應用程式。
如果要套用位於不同 OTP 版本中的多個 OTP 應用程式的修補程式,則必須分多個步驟套用這些修補程式。一次只能套用來自同一 OTP 版本的多個 OTP 應用程式。
先決條件
假設讀者熟悉建置和安裝 Erlang/OTP。為了能夠修補應用程式,必須存在以下條件:
Erlang/OTP 安裝。
包含要修補到現有 Erlang/OTP 安裝中的更新應用程式的 Erlang/OTP 原始碼樹。
使用 otp_patch_apply
警告
修補應用程式是一個單向過程。在繼續之前,請建立 OTP 安裝目錄的備份。
首先,在 $ERL_TOP
處建置包含更新應用程式的 OTP 原始碼樹。
注意
在套用修補程式之前,您需要在原始碼目錄中進行 OTP 的完整建置。
設定並建置 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 應用程式的建置結果。
例如,如果使用者想要將在 /home/me/git/otp
中建置的 mnesia
和 ssl
的修補版本安裝到位於 /opt/erlang/my_otp
中的 OTP 安裝,請輸入
$ otp_patch_apply -s /home/me/git/otp -i /opt/erlang/my_otp \
mnesia ssl
注意
如果應用程式清單包含核心應用程式,例如
erts
、kernel
、stdlib
或sasl
,則必須重新執行已修補 Erlang/OTP 安裝中的Install
腳本。
已修補的應用程式會附加到已安裝應用程式的清單中。請查看 <InstallDir>/releases/OTP-REL/installed_application_versions
。
健全性檢查
可以使用 Erlang Shell 檢查應用程式相依性。otp_patch_apply
會驗證已安裝應用程式之間的應用程式相依性,但這些相依性不一定是實際載入的相依性。透過呼叫 system_information:sanity_check()
,可以驗證實際載入的應用程式之間的相依性。
1> system_information:sanity_check().
ok
請查看 sanity_check() 的參考資料以取得更多資訊。