当前目录下两个rpm包做差分。

*.rpm

两个目录,解压rpm包。

export LANG=c

差分判断是脚本还是Binary Files

脚本添加命令行提示符,awk。

[root@sj_x861 diff_rwz]# cat diff_rpm.sh
#!/bin/bash

export LANG=c
source ~/.bashrc

#############################
#basic command label
#############################
if [ "$(whoami)" = "$(basename $(pwd))" ]; then
     cmd_label="[$(whoami)@$(hostname) ~]# "
else
     cmd_label="[$(whoami)@$(hostname) $(basename $(pwd))]# "
fi

mkdir new_bin/ new_rpm/ old_bin/ old_rpm/
rpms=(`ls *.rpm`)
cp -a ${rpms[0]} old_rpm
cp -a ${rpms[1]} new_rpm

echo -e "${cmd_label}ls"
ls
echo -e "${cmd_label}ls -l */*.rpm"
ls -l */*.rpm
echo -e "${cmd_label}md5sum */*.rpm"
md5sum */*.rpm
echo -e "${cmd_label}cd new_bin/"
cd new_bin/
echo -e "${cmd_label}ls"
ls
echo -e "${cmd_label}rpm2cpio ../new_rpm/*.rpm | cpio -idm"
rpm2cpio ../new_rpm/*.rpm | cpio -idm
echo -e "${cmd_label}cd ../old_bin/"
cd ../old_bin/
echo -e "${cmd_label}ls"
ls
echo -e "${cmd_label}rpm2cpio ../old_rpm/*.rpm | cpio -idm"
rpm2cpio ../old_rpm/*.rpm | cpio -idm
echo -e "${cmd_label}ls"
ls
echo -e "${cmd_label}cd .."
cd ..
echo -e "${cmd_label}ls"
ls
echo -e "${cmd_label}diff -r old_bin/ new_bin/"
diff -r old_bin/ new_bin/

diff -r old_bin/ new_bin/ | grep "Binary files " >/var/tmp/diff_rpm.txt
if [[ -s /var/tmp/diff_rpm.txt ]];then
        echo -e "${cmd_label}diff -r old_bin/ new_bin/ | grep \"Binary files \" | awk '{print \$3; print \$5}' | xargs md5sum"
        diff -r old_bin/ new_bin/ | grep "Binary files " | awk '{print $3; print $5}' | xargs md5sum
fi

diff -r old_bin/ new_bin/ | grep "diff -r "  >/var/tmp/diff_rpm.txt
if [[ -s /var/tmp/diff_rpm.txt ]];then
        echo -e "${cmd_label}diff -r old_bin/ new_bin/ | grep \"diff -r \" | awk '{print \$3; print \$4}' | xargs md5sum"
        diff -r old_bin/ new_bin/ | grep "diff -r " | awk '{print $3; print $4}' | xargs md5sum
fi

rm -rf new_bin/ new_rpm/ old_bin/ old_rpm/
[root@sj_x861 diff_rwz]# cat

 

awk

[root@sj_x861 diff_rms]# cat temp
ls
ll */*.rpm
md5sum */*.rpm
cd new_bin/
ls
rpm2cpio ../new_rpm/*.rpm | cpio -idm
cd ../old_bin/
ls
rpm2cpio ../old_rpm/*.rpm | cpio -idm
ls
cd ..
ls
diff -r old_bin/ new_bin/
diff -r old_bin/ new_bin/ | grep "Binary files " | awk '{print $3; print $5}' | xargs md5sum  =>双引号和美元符号需要转义.
#diff -r old_bin/ new_bin/ | grep "diff -r " | awk '{print $3; print $4}' | xargs md5sum
[root@sj_x861 diff_rms]# cat temp | awk '{ print "echo -e \"${cmd_label}"$0"\""; print $0}'
echo -e "${cmd_label}ls"
ls
echo -e "${cmd_label}ll */*.rpm"
ll */*.rpm
echo -e "${cmd_label}md5sum */*.rpm"
md5sum */*.rpm
echo -e "${cmd_label}cd new_bin/"
cd new_bin/
echo -e "${cmd_label}ls"
ls
echo -e "${cmd_label}rpm2cpio ../new_rpm/*.rpm | cpio -idm"
rpm2cpio ../new_rpm/*.rpm | cpio -idm
echo -e "${cmd_label}cd ../old_bin/"
cd ../old_bin/
echo -e "${cmd_label}ls"
ls
echo -e "${cmd_label}rpm2cpio ../old_rpm/*.rpm | cpio -idm"
rpm2cpio ../old_rpm/*.rpm | cpio -idm

 

 

 

 

end

shell 两个rpm包做差分的更多相关文章

  1. shell如何生成rpm包仓库列表文件的对比结果

    基本步骤: 1.切换至仓库目录RPM_LIST_DIR1和RPM_LIST_DIR2 2.ls列出仓库的rpm包文件并分别重定向至输出文件rpm_list_file1和rpm_list_file2 3 ...

  2. 制作RPM包

    RPM包制作过程 1.1 前期工作 1)创建打包用的目录rpmbuild/{BUILD,SPECS,RPMS, SOURCES,SRPMS} 建议使用普通用户,在用户家目录中创建 2)确定好制作的对象 ...

  3. MySQL5.6.36 linux rpm包安装配置文档

    一.卸载自带mysql,删除MySQL的lib库,服务文件 [root@localhost ~]#rpm -qa|grep mysql qt-mysql-4.6.2-26.el6_4.x86_64 m ...

  4. RPM包的版本号比较

    版本号表示格式为 epoch:version-release,例如 1:2-3 第一条原则是 rpm 属性优先级 epoch > version > release        两个 r ...

  5. 定制化rpm包及本地yum仓库搭建

    为方便本地yum的管理,一般都是在公司局域网内搭建本地yum仓库,实现公司内部快速安装常用软件. 步骤如下: 1.搭建要实现本地yum管理的软件,测试该软件搭建成功与否: 2.定制rpm包及其相关依赖 ...

  6. rpm包制作介绍

    RPM(Rpm Package Management)在ReadHat等发行版下被用作软件包管理程序,其将某个软件相关的文件置入一个.rpm包中,用rpm命令,我们可以方便地完成Linux下软件安装. ...

  7. 其他综合-搭建本地yum仓库及自制rpm包

    搭建本地yum仓库及自制rpm包 实验目的 为方便本地 yum 的管理,建本地 yum 仓库,实现局域网内部快速安装常用软件 实验环境 VMware:12版本 系统版本:CentOS Linux re ...

  8. Ceph 客户端的 RPM 包升级问题

    问题 最近想把一个现有的 Ceph 客户端升级为最新的 M 版: [root@overcloud-ovscompute-0 ~]# rpm -qa | grep ceph puppet-ceph-2. ...

  9. 制作FastDFS的RPM包

    首先获取fastdfs的源码,因为fastdfs还依赖一个libfastcommon的库,所以也要准备好. fastdfs的源码目录结构: libfastcommon的源码目录结构: 接下来将以Cen ...

随机推荐

  1. ORACLE查看锁(lock)情况

      SELECT /*+ RULE */         ls.osuser os_user_name,          ls.username user_name,          DECODE ...

  2. Java金字塔及变形

    Java金字塔 package com.tfj.test; public class JinZiTa { public static void main(String[] args){ int num ...

  3. WordPress Suco Themes ‘themify-ajax.php’任意文件上传漏洞

    漏洞名称: WordPress Suco Themes ‘themify-ajax.php’任意文件上传漏洞 CNNVD编号: CNNVD-201311-403 发布时间: 2013-11-28 更新 ...

  4. ☀【CSS3】box-sizing

    <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8& ...

  5. 在 ASP.NET MVC Web 应用程序中输出 RSS Feeds

    RSS全称Really Simple Syndication.一些更新频率较高的网站可以通过RSS让订阅者快速获取更新信息.RSS文档需遵守XML规范的,其中必需包含标题.链接.描述信息,还可以包含发 ...

  6. 关于 Unity UI 中 GraphicRaycaster.Raycast 数量巨大的问题

    有时候会发现 Unity UI 非常耗时,在 Profiler 中可以轻易的看到 UI 中 的 GraphicRaycaster.Raycast 单帧调用可以成百上千,甚至好几千,帧速率前不忍赌,一关 ...

  7. Asp.Net MVC4新特性指南(2):新特性介绍

       上一章讲解了最基本的MVC4说明.今天就介绍下几种新特性的使用例子:   就当大家有MVC3的基础了.在这个基础上在看下面的介绍就容易多了.1.Web API MVC4包括一个更好的解决方案:A ...

  8. JDK1.5新特性(三)……Varargs

    援引 Varargs - This facility eliminates the need for manually boxing up argument lists into an array w ...

  9. HDOJ-ACM1013(JAVA)

    这道题也很简单~主要是将输入转为字符串(存储大数,操作字符数组) 题意: 24 : 2 + 4 = 6  输出6 39 : 3 + 9 = 12 , 1 + 2 = 3 输出3 999: 9 + 9 ...

  10. CF29D - Ant on the Tree(DFS)

    题目大意 给定一棵树,要求你按给定的叶子节点顺序对整棵树进行遍历,并且恰好经过2*n-1个点,输出任意一条符合要求的路径 题解 每次从叶子节点开始遍历到上一个叶子节点就OK了, 这个就是符合要求的路径 ...