rpm 简单 package 创建demo

安装的工具

yum install -y  rpmdevtools

准备环境

主要是初始化,会自动创建rpm 包构建需要的目录

rpmdev-setuptree

编写简单的spec

cd ~/rpmbuild/SPECS/dalong.spec

Name: dalong-demo
Version: 1
Release: 1
Summary: this is a demo
License: fixme
%description

this is a demo app

%prep

# nothing

%build

cat > dalong.sh <<EOF
#!/bin/sh
echo "dalong demo"
EOF

%install

mkdir -p %{buildroot}/usr/bin/
install -m 755 dalong.sh %{buildroot}/usr/bin/dalong.sh

%files

/usr/bin/dalong.sh

%changelog

# nothing

构建

rpmbuild -ba dalong.spec

效果

执行(%prep): /bin/sh -e /var/tmp/rpm-tmp.FiOyqX
+ umask 022
+ cd /root/rpmbuild/BUILD
+ exit 0
执行(%build): /bin/sh -e /var/tmp/rpm-tmp.jyWbrS
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cat
+ exit 0
执行(%install): /bin/sh -e /var/tmp/rpm-tmp.pogwtN
+ umask 022
+ cd /root/rpmbuild/BUILD
+ '[' /root/rpmbuild/BUILDROOT/dalong-demo-1-1.x86_64 '!=' / ']'
+ rm -rf /root/rpmbuild/BUILDROOT/dalong-demo-1-1.x86_64
++ dirname /root/rpmbuild/BUILDROOT/dalong-demo-1-1.x86_64
+ mkdir -p /root/rpmbuild/BUILDROOT
+ mkdir /root/rpmbuild/BUILDROOT/dalong-demo-1-1.x86_64
+ mkdir -p /root/rpmbuild/BUILDROOT/dalong-demo-1-1.x86_64/usr/bin/
+ install -m 755 dalong.sh /root/rpmbuild/BUILDROOT/dalong-demo-1-1.x86_64/usr/bin/dalong.sh
+ '[' '%{buildarch}' = noarch ']'
+ QA_CHECK_RPATHS=1
+ case "${QA_CHECK_RPATHS:-}" in
+ /usr/lib/rpm/check-rpaths
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
处理文件:dalong-demo-1-1.x86_64
Provides: dalong-demo = 1-1 dalong-demo(x86-64) = 1-1
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: /bin/sh
检查未打包文件:/usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/dalong-demo-1-1.x86_64
写道:/root/rpmbuild/SRPMS/dalong-demo-1-1.src.rpm
写道:/root/rpmbuild/RPMS/x86_64/dalong-demo-1-1.x86_64.rpm
执行(%clean): /bin/sh -e /var/tmp/rpm-tmp.dvCayz
+ umask 022
+ cd /root/rpmbuild/BUILD
+ /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/dalong-demo-1-1.x86_64
+ exit 0

安装

yum install -y  ~/rpmbuild/RPMS/x86_64/dalong-demo-1-1.x86_64.rpm

效果

 已加载插件:fastestmirror
正在检查 dalong-demo-1-1.x86_64.rpm: dalong-demo-1-1.x86_64
dalong-demo-1-1.x86_64.rpm 将被安装
正在解决依赖关系
--> 正在检查事务
---> 软件包 dalong-demo.x86_64.0.1-1 将被 安装
--> 解决依赖关系完成

依赖关系解决

===============================================================================================================
 Package 架构 版本 源 大小
===============================================================================================================
正在安装:
 dalong-demo x86_64 1-1 /dalong-demo-1-1.x86_64 29  

事务概要
===============================================================================================================
安装 1 软件包

总计:29  
安装大小:29  
Is this ok [y/d/N]: 
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装 : dalong-demo-1-1.x86_64 1/1 
  验证中 : dalong-demo-1-1.x86_64 1/1 

已安装:
  dalong-demo.x86_64 0:1-1                                                                                     

完毕

使用

  • 命令
dalong.sh 
dalong demo

参考资料

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/rpm_packaging_guide/index

posted on 2019-05-22 15:29  荣锋亮  阅读(619)  评论(0编辑  收藏  举报

导航