将脚本打包成rpm包

1.下载所需要的软件

yum install rpm-build rpmdevtools -y

2.生成所需要的工作目录

rpmdev-setuptree

3.拷贝所需文件至文件夹

cp people_update.spec /root/rpmbuild/SPECS/
cp people_update.sh  /root/rpmbuild/SOURCES/

4.创建目录

mkdir -p /root/rpmbuild/BUILDROOT/people_update.sh-1.0.1-1.ky10.aarch64/opt/
cp /root/people_update.sh /root/rpmbuild/BUILDROOT/people_update.sh-1.0.1-1.ky10.aarch64/opt/

5.执行打包命令,打包命令

cd /root/rpmbuild/SPECS
rpmbuild -bb people_update.spec

6. spec文件示例

# rpmrebuild autogenerated specfile

%define defaultbuildroot /
AutoProv: no
%undefine __find_provides
AutoReq: no
%undefine __find_requires
# Do not try autogenerate prereq/conflicts/obsoletes and check files
%undefine __check_files
%undefine __find_prereq
%undefine __find_conflicts
%undefine __find_obsoletes
# Be sure buildpolicy set to do nothing
%define __spec_install_post %{nil}
# Something that need for rpm-4.1
%define _missing_doc_files_terminate_build 0
#dummy
#dummy
#BUILDHOST:    host-172-16-1-125
#BUILDTIME:    Fri Jul 23 17:43:15 2021
#SOURCERPM:    el_pd.service-1.0.1-1.ky10.src.rpm

#RPMVERSION:   4.15.1

#INSTALLTIME:  Fri Jul 23 17:44:04 2021
#INSTPREFIXES: /
#OS:           linux
#SIZE:           826
#ARCHIVESIZE:           1228
#ARCH:         aarch64
BuildArch:     aarch64
Name:          people_update.sh
Version:       1.0.1
Release:       1.ky10
License:       unknown 
Group:         default
Summary:       no description given


URL:           http://example.com/no-uri-given
Vendor:        root@host-172-16-1-125
Packager:      <root@host-172-16-1-125>





Prefix:        /
Provides:      people_update.sh = 1.0.1-1.ky10
Provides:      people_update.sh(aarch-64) = 1.0.1-1.ky10
Requires:      /bin/sh  
#Requires:      rpmlib(CompressedFileNames) <= 3.0.4-1
#Requires:      rpmlib(PayloadFilesHavePrefix) <= 4.0-1
#suggest
#enhance
%description
no description given
%files
%attr(0700, root, root) "/opt/people_update.sh"
%post -p /bin/sh
#!/bin/bash
chmod +x /opt/people_update.sh
%changelog

 

posted @ 2023-06-07 16:00  caibutou  阅读(211)  评论(0编辑  收藏  举报