Linux

我怎麼知道更新檔命令是否有效?

  • March 8, 2016

我正在嘗試將 seek-for-android 項目提供的更新檔應用於我從 Cyanogenmod 下載的程式碼。使用make成功編譯的程式碼,所以我知道所有的文件都在那裡。我只是無法了解更新檔正在做什麼,或者它是否正在工作。我嘗試了 -verbose 選項。我不知道patch需要多長時間才能遍歷目錄並查找要更新的文件。我在我的 cpu 中看不到太多活動。這是我正在遵循的說明:在此處輸入連結描述這是我看到的螢幕截圖:

  root@ubuntu:~/android/system# ls
   abi       cm-11-2      docs             Makefile   sdk
   android   cm-11-3      external         ndk        smartcard-api-3_1_0
   art       cts          frameworks       out        smartcard-api-3_1_0.tgz
   bionic    dalvik       hardware         packages   system
   bootable  developers   kernel           pdk        tools
   build     development  libcore          prebuilt   vendor
   cm-11     device       libnativehelper  prebuilts
   root@ubuntu:~/android/system# cd smartcard-api-3_1_0
   root@ubuntu:~/android/system/smartcard-api-3_1_0# cd ..
   root@ubuntu:~/android/system# patch -p1 smartcard-api-3_1_0/smartcard-api.patch   ^C
    root@ubuntu:~/android/system# patch -p1 -R smartcard-api-3_1_0/smartcard- api.patch 
   ^C
   root@ubuntu:~/android/system# patch -p1 -verbose smartcard-   api-3_1_0/smartcard-  
   api.patch 
   patch 2.6.1
   Copyright (C) 1988 Larry Wall
   Copyright (C) 2003, 2009 Free Software Foundation, Inc.

我想在某些情況下,我應該尋找目標文件?下面的輸出似乎說一個更新檔成功了,而另一個文件沒有找到?我想我必須找到目標文件並指定它?由於某種原因,甚至無法辨識完整路徑。

root@ubuntu:~/android/system# patch -p1 < smartcard-api-3_1_0/uicc.patch 
patching file frameworks/base/telephony/java/com/android/internal/telephony  /ITelephony.aidl
Hunk #1 FAILED at 304.
1 out of 1 hunk FAILED -- saving rejects to file frameworks/base/telephony /java/com/android/internal/telephony/ITelephony.aidl.rej
patching file frameworks/base/telephony/java/com/android/internal/telephony  /RILConstants.java
Hunk #1 FAILED at 55.
Hunk #2 FAILED at 262.
2 out of 2 hunks FAILED -- saving rejects to file frameworks/base/telephony/java/com/android/internal/telephony/RILConstants.java.rej
patching file frameworks/opt/telephony/src/java/com/android/internal/telephony /CommandException.java
Hunk #1 FAILED at 42.
Hunk #2 FAILED at 83.
2 out of 2 hunks FAILED -- saving rejects to file frameworks/opt/telephony  /src/java/com/android/internal/telephony/CommandException.java.rej
patching file frameworks/opt/telephony/src/java/com/android/internal/telephony /CommandsInterface.java
Hunk #1 succeeded at 1250 (offset 109 lines).
patching file frameworks/opt/telephony/src/java/com/android/internal/telephony /IccCard.java
Hunk #1 FAILED at 214.
1 out of 1 hunk FAILED -- saving rejects to file frameworks/opt/telephony  /src/java/com/android/internal/telephony/IccCard.java.rej
patching file frameworks/opt/telephony/src/java/com/android/internal/telephony  /RIL.java
Hunk #1 succeeded at 2592 (offset 253 lines).
Hunk #2 succeeded at 4109 (offset 467 lines).
Hunk #3 succeeded at 4619 (offset 543 lines).
patching file frameworks/opt/telephony/src/java/com/android/internal/telephony/sip/SipCommandInterface.java
Hunk #1 FAILED at 536.
1 out of 1 hunk FAILED -- saving rejects to file frameworks/opt/telephony/src/java/com/android/internal/telephony/sip/SipCommandInterface.java.rej
patching file frameworks/opt/telephony/src/java/com/android/internal/telephony  /test/SimulatedCommands.java
Hunk #1 FAILED at 1655.
1 out of 1 hunk FAILED -- saving rejects to file frameworks/opt/telephony /src/java/com/android/internal/telephony/test/SimulatedCommands.java.rej
patching file frameworks/opt/telephony/src/java/com/android/internal/telephony/uicc/IccCardProxy.java
Hunk #1 succeeded at 844 (offset 102 lines).
patching file frameworks/opt/telephony/src/java/com/android/internal/telephony/uicc/UiccCardApplication.java
Hunk #1 FAILED at 44.
Hunk #2 succeeded at 437 (offset 100 lines).
Hunk #3 succeeded at 941 (offset 194 lines).
1 out of 3 hunks FAILED -- saving rejects to file frameworks/opt/telephony  /src/java/com/android/internal/telephony/uicc/UiccCardApplication.java.rej
patching file frameworks/opt/telephony/tests/telephonytests/src/com/android    /internal/telephony/gsm/UsimDataDownloadCommands.java
Hunk #1 succeeded at 651 with fuzz 2 (offset 21 lines).
can't find file to patch at input line 404
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
diff --git a/packages/apps/Phone/src/com/android/phone  /PhoneInterfaceManager.java b/packages/apps/Phone/src/com/android/phone    /PhoneInterfaceManager.java
|index 6600ae5..2ae6739 100644
|--- a/packages/apps/Phone/src/com/android/phone/PhoneInterfaceManager.java
|+++ b/packages/apps/Phone/src/com/android/phone/PhoneInterfaceManager.java
--------------------------
File to patch: 

由於某種原因,必須通過重定向將更新檔文件輸入更新檔程序,即

    patch file

不起作用,但是

   patch < file

作品

一個非常簡單的解決方案是在應用更新檔之前將您的文件置於版本控制之下。目前的版本控制工具是 Git 和 Mercurial。我個人使用並推薦 Mercurial。

此外,如果您想查看更新檔適用於哪些文件,您可以執行

diffstat patchname

Mercurial 的範例輸出:

apt-get source hello
cd hello-2.9
hello-2.9$ hg init
hello-2.9$ hg add
hello-2.9$ hg ci     # brings up an editor - add a commit message
hello-2.9$ patch -p1 < debian/patches/99-config-guess-config-sub 
   patching file build-aux/config.guess
   patching file build-aux/config.sub
hello-2.9$ hg st
   M build-aux/config.guess
   M build-aux/config.sub
hello-2.9$ hg diff   # diff output
hello-2.9$ diffstat debian/patches/99-config-guess-config-sub
   config.guess |  149 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------
   config.sub   |   36 ++++++++++++++++++++----------------
   2 files changed, 106 insertions(+), 79 deletions(-)

引用自:https://unix.stackexchange.com/questions/127808