RPM打包

$ vi hello.spec
Name:    Hello    
Version:    1    
Release:    1%{?dist}
Summary:    Hello

Group:        System
License:    MIT
URL:        www.baidu.com
Source0:    hello.tar.gz
%define         userpath /home/aztzjx/hellorpm
#BuildRequires:     
#Requires:    

%description
hello world rpm build

%prep
#%setup -q
%setup -c   
#同时创建目录
echo "prep"


%build
cat > hello.sh <<EOF
#!/usr/bin/bash
echo Hello World build
EOF
echo "build"

%install
#make install DESTDIR=%{buildroot}
#RPM_BUILD_ROOT 打包目录
install -d $RPM_BUILD_ROOT%{userpath} #仅复制目录(带属性),不复制目录内容
cp -a * * $RPM_BUILD_ROOT%{userpath} #带属性复制内容到指定目录
mkdir -p %{buildroot}/hellopath  #创建父目录
install -m 755 hello.sh %{buildroot}/hellopath/hello.sh #创建目录同时设置属性
echo "install"
echo "${RPM_BUILD_ROOT}"
echo %{buildroot}

%files
%defattr(-,root,root)
%{userpath}
#%{buildroot}/hellopath/hello.sh
/hellopath/hello.sh
#%doc

%changelog

$ rpmbuild -bb SPECS/hello.spec 
错误:dlopen 失败 /usr/lib64/rpm-plugins/selinux.so /usr/lib64/rpm-plugins/selinux.so: 错误 ELF 类: ELFCLASS64
执行(%prep): /bin/sh -e /var/tmp/rpm-tmp.PhCnlR
+ umask 022
+ cd /home/aztzjx/rpmbuild/BUILD
+ cd /home/aztzjx/rpmbuild/BUILD
+ rm -rf Hello-1
+ /usr/bin/mkdir -p Hello-1
+ cd Hello-1
+ /usr/bin/gzip -dc /home/aztzjx/rpmbuild/SOURCES/hello.tar.gz
+ /usr/bin/tar -xvvf -
-rwxrwxr-x aztzjx/aztzjx  8551 2019-06-28 17:21 hello
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ echo prep
prep
+ exit 0
执行(%build): /bin/sh -e /var/tmp/rpm-tmp.1t41pC
+ umask 022
+ cd /home/aztzjx/rpmbuild/BUILD
+ cd Hello-1
+ cat
+ echo build
build
+ exit 0
执行(%install): /bin/sh -e /var/tmp/rpm-tmp.gMuTvn
+ umask 022
+ cd /home/aztzjx/rpmbuild/BUILD
+ '[' /home/aztzjx/rpmbuild/BUILDROOT/Hello-1-1.nd7.x86_64 '!=' / ']'
+ rm -rf /home/aztzjx/rpmbuild/BUILDROOT/Hello-1-1.nd7.x86_64
++ dirname /home/aztzjx/rpmbuild/BUILDROOT/Hello-1-1.nd7.x86_64
+ mkdir -p /home/aztzjx/rpmbuild/BUILDROOT
+ mkdir /home/aztzjx/rpmbuild/BUILDROOT/Hello-1-1.nd7.x86_64
+ cd Hello-1
+ install -d /h

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在 Linux 中,RPM(Red Hat Package Manager)是一种常见的软件包管理工具,可以方便地安装、升级、卸载软件包。下面是使用 RPM 打包的基本步骤: 1. 准备打包文件 将需要打包的文件放在同一个目录下,并确保目录结构正确。 2. 创建 spec 文件 spec 文件是 RPM 打包的核心文件,它包含了软件包的相关信息,如软件名称、版本号、依赖关系等。可以使用文本编辑器创建 spec 文件,命名为 software.spec,其中 software 为软件包名称。 3. 编写 spec 文件 spec 文件格式比较复杂,需要按照规范编写。以下是一个简单的示例: ``` Name: software Version: 1.0 Release: 1 Summary: A brief summary of the software License: GPL Group: Applications/Tools Source0: software.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-root %description A detailed description of the software. %prep %setup -q %build ./configure make %install make install DESTDIR=%{buildroot} %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) /usr/local/bin/software %doc README %changelog ``` 其中,Name、Version、Release、Summary、License、Group、Source0 等字段需要根据实际情况填写,%description、%files、%doc、%changelog 等字段可以根据需求添加或删除。 4. 执行 rpmbuild 命令 执行以下命令进行打包: ``` $ rpmbuild -bb software.spec ``` 其中,-bb 表示打包并构建二进制 RPM 包。如果一切顺利,RPM 包将生成在 /usr/src/redhat/RPMS 目录下。 以上是 RPM 打包的基本步骤,更多细节请参考 RPM 手册。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值