Linux下补丁包(.patch文件)制作及使用[u-boot示例]

需求

移植 u-boot 时需要修改通用的 u-boot 源码,为了避免每次都去重复修改,直接使用 patch 包的形式。


制作补丁包

# 1、完成功能调试之后,在当前目录下执行 
make distclean

# 2、切换到上一级目录
cd ..

# 3、修改文件夹名称  
mv u-boot u-boot-bak

# 4、解压之前的压缩包,即准备未修改的文件
tar xjf u-boot.tar.bz2 

# 5、对比两个文件夹,并生成补丁
diff -urN u-boot u-boot-ask > u-boot-uart1.patch

使用补丁包

# 1、解压uboot源码
tar xjf u-boot.tar.bz2

# 2、切换到解压好的路径下
cd u-boot/

# 3、打补丁(u-boot-uart1.patch 在u-boot 同级目录)
patch -p1 < ../u-boot-uart1.patch

使用示例:(会显示补丁修改的文件)

pjw@pjw-virtual-machine:/u-boot$ patch -p1 < ../u-boot-uart1.patch 

patching file arch/arm/dts/suniv.dtsi
patching file arch/arm/dts/suniv-f1c100s-licheepi-nano.dts
patching file arch/arm/include/asm/arch-sunxi/gpio.h
patching file arch/arm/mach-sunxi/board.c
patching file include/configs/suniv.h

猜你喜欢

转载自blog.csdn.net/p1279030826/article/details/113132774