【转】Linux下patch打补丁命令
【转】Linux下patch打补丁命令
转自:http://www.cnblogs.com/noaming1900/archive/2010/10/28/1863282.html
此命令用于为特定软件包打补丁,他使用diff命令对源文件进行操作。
基本命令语法:
patch [-R] {-p(n)} [--dry-run] < patch_file_name
p:为path的缩写。
n:指将patch文件中的path第n条’/’及其左边部分取消。
-R:卸载patch包。
--dry-run:尝试patch软件,并不真正修改软件。
使用实例:
/home/sense/patch-2.6.19.1
============================================================= diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c index d12fb97..c8f96cf 100644 --- a/arch/i386/kernel/acpi/boot.c +++ b/arch/i386/kernel/acpi/boot.c @@ -333,7 +333,7 @@ acpi_parse_ioapic(acpi_table_entry_heade /* * Parse Interrupt Source Override for the ACPI SCI */ -static void acpi_sci_ioapic_setup(u32 bus_irq, u32 gsi, u16 polarity, u16 trigger) +static void acpi_sci_ioapic_setup(u32 gsi, u16 polarity, u16 trigger) =============================================================
此patch文件的path=a/arch/i386/kernel/acpi
[sense@ssn src]$ pwd /usr/src [sense@ssn src]$ tree . `-- a `-- arch `-- i386 `-- kernel `-- acpi
和a/同目录时:
[sense@ssn src]$ pwd /usr/src [sense@ssn src]$ patch -p0 < /home/sense/patch-2.6.19.1 安装补丁 [sense@ssn src]$ patch -p0 -R < /home/sense/patch-2.6.19.1 卸载补丁 和a/arch/同目录时: [sense@ssn src]$ pwd /usr/src/a/ [sense@ssn src]$ patch -p1 < /home/sense/patch-2.6.19.1 安装补丁 [sense@ssn src]$ patch -p1 -R < /home/sense/patch-2.6.19.1 卸载补丁 和a/arch/i386/同目录时: [sense@ssn src]$ pwd /usr/src/a/arch/ [sense@ssn src]$ patch -p2 < /home/sense/patch-2.6.19.1 安装补丁 [sense@ssn src]$ patch -p2 -R < /home/sense/patch-2.6.19.1 卸载补丁