Simple RPM package Creation
Today, in order to test and build your own yum repository and install the upgrade software package, you need an rpm package for testing, so you think of yourself as the simplest rpm, because it is just a test, no file to be compiled is added, but only a shell file is used to output the cute Hello World.
1. First download and install the rpm package preparation Tool
$ Sudo yum install-y rpm-build rpmdevtools
2. Run rpmdev-setuptree to generate the skeleton directory of an rpm package.
$ Rpmdev-setuptreer
By default, the pmdev-setuptree command will create an RPM under the root directory of the current user to build the root directory structure ~ /Rpmbuild/
3. Generate source code package
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
4. In ~ Use rpmdev-newspec in the/rpmbuild/SPECS directory to generate a spec skeleton File
$ Rpmdev-newspec helloworld. spec
Edit the helloworld. spec file with the following content:
Name: helloworld
Version: 1.0.0
Release: 1% {? Dist}
Summary: helloworld
Group: Development/Tools
License: GPL
# URL:
Source0: Too Many name‑‑0000version‑.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
5. Package
Rpmbuild-ba SPECS/helloworld. spec
6. Test
6.1 installation test
Sudo yum install ~ // Rpmbuild/RPMS/x86_64/helloworld-1.0.0-1.el6.x86_64.rpm
6.2 upgrade Test
Modify the helloworld. spec file and change Release
Release: 2% {? Dist}
Then run "rpmbuild-ba SPECS/helloworld. spec" to package
Finally, run the following command to upgrade the rpm package.
Sudo yum update ~ // Rpmbuild/RPMS/x86_64/helloworld-1.0.0-2.el6.x86_64.rpm
Create your own rpm package
Directory structure and configuration after rpm installation in Linux
Brief Introduction and demo of rpm and yum
RedHat Linux --- rpm command details
Use FPM to easily create an RPM package