Simple RPM package Creation

Source: Internet
Author: User
Tags rpmbuild

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.