Linux系统怎么生成补丁和打补丁
发表于:2024-10-24 作者:千家信息网编辑
千家信息网最后更新 2024年10月24日,Linux系统怎么生成补丁和打补丁,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。生成补丁:制作 hello.c 和 hello_ne
千家信息网最后更新 2024年10月24日Linux系统怎么生成补丁和打补丁
Linux系统怎么生成补丁和打补丁,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
生成补丁:
制作 hello.c 和 hello_new.c 两个文件如如下所示。
➜ diff ls hello.c hello_new.c hello_test.c hi.patch ➜ diff cat hello.c #include "stdio.h" int main(int argc ,char **argv) { printf("Hello World"); } ➜ diff cat hello_new.c #include "stdio.h" int main(int argc ,char **argv) { printf("Hello World\n"); return 0; }
使用 diff -uN 命令 进行生成patch
➜ diff diff -uN hello_new.c hello.c > hi.patch ➜ diff cat hi.patch --- hello_new.c 2018-07-17 16:58:23.679704122 +0800 +++ hello.c 2018-07-17 16:57:59.190677641 +0800 @@ -1,6 +1,5 @@ #include "stdio.h" int main(int argc ,char **argv) { - printf("Hello World\n"); - return 0; + printf("Hello World"); }
至此,patch 已经创建完毕。
之后,我们进行使用 patch 命令 对 hello.c 文件进行打补丁。
➜ diff patch -p0可见,补丁已经成功应用,并且生成了 .orig 源文件。 –backup-if-mismatch 选项,可以不进行生成orig 文件。 ➜ diff patch -p0 --no-backup-if-mismatchdiff 和 patch 命令介绍:1、diff--------------------NAME diff – find differences between two filesSYNOPSIS diff [options] from-file to-file--------------------简单的说,diff的功能就是用来比较两个文件的不同,然后记录下来,也就是所谓的diff补丁。语法格式:diff 【选项】 源文件(夹) 目的文件(夹),就是要给源文件(夹)打个补丁,使之变成目的文件(夹),术语也就是"升级"。下面介绍三个最为常用选项:-r 是一个递归选项,设置了这个选项,diff会将两个不同版本源代码目录中的所有对应文件全部都进行一次比较,包括子目录文件。-N 选项确保补丁文件将正确地处理已经创建或删除文件的情况。-u 选项以统一格式创建补丁文件,这种格式比缺省格式更紧凑些。2、patch------------------NAME patch – apply a diff file to an originalSYNOPSIS patch [options] [originalfile [patchfile]] but usually just patch -pnum ------------------简单的说,patch就是利用diff制作的补丁来实现源文件(夹)和目的文件(夹)的转换。这样说就意味着你可以有源文件(夹)――>目的文件(夹),也可以目的文件(夹)――>源文件(夹)。下面介绍几个最常用选项:-pnum or –strip=num Strip the smallest prefix containing num leading slashes from each file name found in the patch file. A sequence of one or more adjacent slashes is counted as a single slash. This controls how file names found in the patch file are treated, in case you keep your files in a different directory than the person who sent out the patch. For example, supposing the file name in the patch file was/u/howard/src/blurfl/blurfl.csetting -p0 gives the entire file name unmodified, -p1 givesu/howard/src/blurfl/blurfl.cwithout the leading slash, -p4 givesblurfl/blurfl.cand not specifying -p at all just gives you blurfl.c. Whatever you end up with is looked for either in the current directory, or the directory specified by the -d option.具体的使用说明,可以使用 man diff 和 man patch 命令来进行查看。至此关于Linux系统中生成补丁和打补丁的方法分享完毕,欢迎大家在评论区留言。以上就是良许教程网为各位朋友分享的Linux系统相关内容。想要了解更多Linux相关知识记得关注公众号"良许Linux",或扫描下方二维码进行关注,更多干货等着你!
Linux有哪些版本
Linux的版本有:Deepin、UbuntuKylin、Manjaro、LinuxMint、Ubuntu等版本。其中Deepin是国内发展最好的Linux发行版之一;UbuntuKylin是基于Ubuntu的衍生发行版;Manjaro是基于Arch的Linux发行版;LinuxMint默认的Cinnamon桌面类似Windows XP简单易用;Ubuntu则是以桌面应用为主的Linux操作系统。
关于Linux系统怎么生成补丁和打补丁问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注行业资讯频道了解更多相关知识。
文件
补丁
生成
系统
源文件
目的
命令
就是
更多
格式
版本
两个
问题
发行
不同
也就是
内容
常用
方法
桌面
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
机器学习需要数据库吗
网络安全学习的软件有哪些
康舒fsa011服务器电源介绍
南京信息系统网络安全公司
华为手机怎么学习网络技术
国家数据库资料能随便提取么
画饭圈乱象绘网络安全手抄报
wind数据库股票价格
微信商城 租服务器
建立的数据库vb怎么用
租用服务器流程
电子政务网络安全技术大会
如何获取反向代理服务器ip
数据库对账系统
网易小型超算服务器
痴鸡小队吃鸡服务器
无锡打造智慧小区软件开发
h2 数据库官网
广元网络技术要多少钱
数据库如何给表设置主键并命名
数据库结构的维护
查询社保数据库重复
江西准金互联网科技有限公司简介
单位网络安全应急预案格式
建立的数据库vb怎么用
运城市网络安全宣传周活动
梦幻西游有哪几个限时服务器
文件服务器 nas
内蒙古智慧养老软件开发电话
服务器连接显卡识别不了