|
Today, in order to test and build your own yum repository to install the upgrade package, requiring a rpm package to do the test, so I thought of his own to do a simple rpm, just because a test is to do so there is no need to add the compiled file, only uses a shell file output cute Hello World.
1. first need to download and install the rpm package Maker
$ Sudo yum install -y rpm-build rpmdevtools
2. Run rpmdev-setuptree skeleton directory to generate a rpm package
$ Rpmdev-setuptreer
pmdev-setuptree a further command to create a default RPM build root directory structure under the root directory of the current user's ~ / rpmbuild /
3. Generate the 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. Under ~ / rpmbuild / SPECS directory with rpmdev-newspec to generate a skeleton file spec
$ Rpmdev-newspec helloworld.spec
Edit helloworld.spec file, as follows
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
5. Packing
rpmbuild -ba SPECS / helloworld.spec
6. Test
6.1 installation and testing
sudo yum install ~ / rpmbuild / RPMS / x86_64 / helloworld-1.0.0-1.el6.x86_64.rpm
6.2 upgrade testing
Modify helloworld.spec file, which will be modified to Release
Release: 2% {dist?}
Then run "rpmbuild -ba SPECS / helloworld.spec" 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 |
|
|
|