标签:
本文链接:http://blog.csdn.net/kongxx/article/details/43761295
今天为了测试搭建自己的yum仓库并安装升级软件包,因此需要一个rpm包来做测试,所以就想到了自己来做一个最简单rpm,因为仅仅就是做一个测试所以没有添加需要编译的文件,而是只使用了一个shell文件来输出可爱的Hello World。
$ sudo yum install -y rpm-build rpmdevtools
$ rpmdev-setuptreerpmdev-setuptree命令默认将再当前用户的根目录下创建一个RPM构建根目录结构 ~/rpmbuild/
mkdir -p ~/rpmbuild/SOURCES/helloworld-1.0.0 touch ~/rpmbuild/SOURCES/helloworld-1.0.0/helloworld chmod 755 ~/rpmbuild/SOURCES/helloworld-1.0.0/helloworld echo "#!/bin/sh" >> ~/rpmbuild/SOURCES/helloworld-1.0.0/helloworld echo "echo Hello World!" >> ~/rpmbuild/SOURCES/helloworld-1.0.0/helloworld cd ~/rpmbuild/SOURCES; tar zcvf helloworld-1.0.0.tar.gz helloworld-1.0.0
$ rpmdev-newspec helloworld.spec
Name: helloworld Version: 1.0.0 Release: 1%{?dist} Summary: helloworld Group: Development/Tools License: GPL #URL: Source0: %{name}-%{version}.tar.gz #BuildRequires: #Requires: %description %prep %setup -q %build mkdir -p $RPM_BUILD_ROOT/usr/bin cp $RPM_BUILD_DIR/%{name}-%{version}/helloworld $RPM_BUILD_ROOT/usr/bin/ %install %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc /usr/bin/helloworld %changelog
rpmbuild -ba SPECS/helloworld.spec
sudo yum install ~/rpmbuild/RPMS/x86_64/helloworld-1.0.0-1.el6.x86_64.rpm
Release: 2%{?dist}然后运行 "rpmbuild -ba SPECS/helloworld.spec" 打包
sudo yum update ~/rpmbuild/RPMS/x86_64/helloworld-1.0.0-2.el6.x86_64.rpm
标签:
原文地址:http://blog.csdn.net/kongxx/article/details/43761295