1

安装依赖

```shell

yum install gcc rpm-build rpm-devel rpmlint make python bash coreutils diffutils

yum install rpmdev-newspec

```

准备build文件

  1. 生成目录

```

rpmdev-setuptree

```

2.准备源文件

```

echo "ccc" > /root/test.txt

```

3.编写SPEC文件

```

cd rpmbuild/SPECS

rpmdev-newspec provisioner.

vi provisioner.spec

```

```spec

Name: provisioner

Version: 1.0

Release: 1%{?dist}

Summary: provisioner post script install

License: cccc

URL: https://aaaa.cccc.com

BuildArch: noarch

%description

%install

rm -fr /tmp/provisioner

install -m 755 -d %{buildroot}/tmp/provisioner

cp -a /root/test.txt %{buildroot}/tmp/provisioner

%files

/tmp/provisioner

%post

mkdir -p /root/provisioner

cp -a /tmp/provisioner/. /root/provisioner/

%doc

%changelog

```

  1. 打包

```

rpmbuild -ba provisioner.spec

```

```

Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.giWZzf

+ umask 022

+ cd /root/rpmbuild/BUILD

+ '[' /root/rpmbuild/BUILDROOT/provisioner-1.0-1.el7.x86_64 '!=' / ']'

+ rm -rf /root/rpmbuild/BUILDROOT/provisioner-1.0-1.el7.x86_64

++ dirname /root/rpmbuild/BUILDROOT/provisioner-1.0-1.el7.x86_64

+ mkdir -p /root/rpmbuild/BUILDROOT

+ mkdir /root/rpmbuild/BUILDROOT/provisioner-1.0-1.el7.x86_64

+ rm -fr /tmp/provisioner

+ install -m 755 -d /root/rpmbuild/BUILDROOT/provisioner-1.0-1.el7.x86_64/tmp/provisioner

+ cp -a /root/test.txt /root/rpmbuild/BUILDROOT/provisioner-1.0-1.el7.x86_64/tmp/provisioner

+ '[' noarch = noarch ']'

+ case "${QA_CHECK_RPATHS:-}" in

+ /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

Processing files: provisioner-1.0-1.el7.noarch

Provides: provisioner = 1.0-1.el7

Requires(interp): /bin/sh

Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1

Requires(post): /bin/sh

Checking for unpackaged file(s): /usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/provisioner-1.0-1.el7.x86_64

Wrote: /root/rpmbuild/SRPMS/provisioner-1.0-1.el7.src.rpm

Wrote: /root/rpmbuild/RPMS/noarch/provisioner-1.0-1.el7.noarch.rpm

Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.ku3Neo

+ umask 022

+ cd /root/rpmbuild/BUILD

+ /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/provisioner-1.0-1.el7.x86_64

+ exit 0

```

本地安装测试

```

yum install /root/rpmbuild/RPMS/noarch/provisioner-1.0-1.el7.noarch.rpm

```


mumubin
375 声望185 粉丝

引用和评论

0 条评论