Making and using patch package (.patch file) under Linux [u-boot example]

demand

When porting u-boot, it is necessary to modify the general u-boot source code. In order to avoid repeated modification every time, directly use the form of patch package.


Make a patch package

# 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

Use the patch package

# 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

Usage example: (files modified by the patch will be displayed)

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

Guess you like

Origin blog.csdn.net/p1279030826/article/details/113132774