SlideShare a Scribd company logo
Creating RPM package in Linux
This exercise was done on RHEL 6 and same steps are applicable for other variants too. This tutorial provides you with
steps to create your own RPM packages in Linux. Following procedure shows creating a basic RPM package that
includes a shell script. After the RPM is installed, the script is executed on the command prompt to display the output.
Step 1 – Install necessary RPM dependencies
[student@desktop3 ~]$yum install rpm-build–y
Step 2 – Setup your package in a directory
[student@desktop3 ~]$mkdir myrpm-1.0
[student@desktop3 ~]$cd myrpm-1.0
(Create a simple script which executes after installing the rpm)
[student@desktop3 ~]$ vi myrpm.sh
#!/bin/bash
#
echo 'Hello There ! This is my RPM script...'
exit 0
(Make the script executable)
[student@desktop3 ~]$ chmod a+x myrpm.sh
Step 3 – Create a tar file of your package
[student@desktop3 ~]$ mkdir -p ~/rpmbuild/SOURCES
[student@desktop3 ~]$ mkdir -p ~/rpmbuild/SPECS
[student@desktop3 ~]$ tar -zcvf ~/rpmbuild/SOURCES/myrpm-1.0-1.tar.gz myrpm-1.0/
Step 4 – Create and edit SPEC file
[student@desktop3 ~]$ vi ~/rpmbuild/SPECS/myrpm.spec
Name: myrpm
Version: 1.0
Release: 1
Summary: MyRPM
Group: RHCE
License: GPL
URL: http://www.redhat.com
Source0: %{name}-%{version}-%{release}.tar.gz
BuildRoot: /var/tmp/%{name}-buildroot
%description
Installs /root/bin/myrpm.sh
%prep
%setup -q -n %{name}-%{version}
%build
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/root/bin
install -m 755 myrpm.sh $RPM_BUILD_ROOT/root/bin/myrpm.sh
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
/root/bin/myrpm.sh
%changelog
Step 5 – Execute rpmbuild to build the RPM package
[student@desktop3 ~]$rpmbuild -ba rpmbuild/SPECS/myrpm.spec
Step 6 – Install and Run the RPM package
[root@desktop3 ~]# rpm -ivh /home/student/rpmbuild/RPMS/x86_64/myrpm-1.0-1.x86_64.rpm
Preparing... ########################################### [100%]
1:myrpm ########################################### [100%]
[root@desktop3 ~]# ll /root/bin/myrpm.sh
-rwxr-xr-x. 1 root root 131 Jun 29 17:19 /root/bin/myrpm.sh
[root@desktop3 ~]# myrpm.sh
Hello There ! This is my RPM script...
Document Version 1
Date : 29th
June 2012
Author : Manish Chopra

More Related Content

DOCX
PDF
package mangement
PPTX
Presentation Linux Server setup Advance Networking
PDF
tmux20141007
PPTX
Linux Run Level
PDF
Upload files-to-zenterprise-server-via-ftp
PDF
2.1.using the shell
DOCX
Linux syllabus
package mangement
Presentation Linux Server setup Advance Networking
tmux20141007
Linux Run Level
Upload files-to-zenterprise-server-via-ftp
2.1.using the shell
Linux syllabus

Viewers also liked (10)

PDF
dr. Brigita Serafinavičiūtė (VU) Atviras mokslas: nauja mada ar būtinybė?
PDF
The Anatomy of GOOGLE Search Engine
PDF
Tadas Juknevičius (MOSTA) Doktorantūros horizontai Lietuvos mokslo politikoje
PPTX
Lietuvos doktorantūra iššūkiai ir galimybės
PPTX
Congenital vertical talus BY DR.NAVEEN RATHOR
PDF
GSMA 2017 | 200 Plus Slides
PDF
7 Trends & Insights MWC 2017
 
PPT
MAROC EN AFRIQUE ; LES MODES D’ENTRÉE DES ENTREPRISES MAROCAINES SUR LE MARCH...
PPTX
Women day splash answers
PDF
Féminisme et égalité des sexes
dr. Brigita Serafinavičiūtė (VU) Atviras mokslas: nauja mada ar būtinybė?
The Anatomy of GOOGLE Search Engine
Tadas Juknevičius (MOSTA) Doktorantūros horizontai Lietuvos mokslo politikoje
Lietuvos doktorantūra iššūkiai ir galimybės
Congenital vertical talus BY DR.NAVEEN RATHOR
GSMA 2017 | 200 Plus Slides
7 Trends & Insights MWC 2017
 
MAROC EN AFRIQUE ; LES MODES D’ENTRÉE DES ENTREPRISES MAROCAINES SUR LE MARCH...
Women day splash answers
Féminisme et égalité des sexes
Ad

Similar to Steps to create an RPM package in Linux (20)

PPTX
Software management in linux
PPT
Unix Administration 2
PPT
101 2.5 use rpm and yum package management
PDF
OSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
PPT
OpenWRT guide and memo
PPTX
Linux for programmers
PDF
Bundling Packages and Deploying Applications with RPM
PPT
How to run_moses 2
PPTX
Linux Presentation
PPTX
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
PDF
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
DOCX
Adding System Call to Kernel
PDF
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
PDF
Installation of lammps-5Nov14 on Mac OS X Yosemite
PDF
Docker perl build
PDF
InstallingRoRinLinux
PDF
InstallingRoRinLinux
PDF
Oracle11g on fedora14
PDF
Oracle11g On Fedora14
PPT
Linux Troubleshooting
Software management in linux
Unix Administration 2
101 2.5 use rpm and yum package management
OSDC 2013 | Software Packaging with RPM Demystified by Andrew Ford
OpenWRT guide and memo
Linux for programmers
Bundling Packages and Deploying Applications with RPM
How to run_moses 2
Linux Presentation
A to Z of a Multi-platform Docker Swarm: Building, Shipping, and Running Mult...
From Arm to Z: Building, Shipping, and Running a Multi-platform Docker Swarm ...
Adding System Call to Kernel
Dockerizing Symfony Applications - Symfony Live Berlin 2014
 
Installation of lammps-5Nov14 on Mac OS X Yosemite
Docker perl build
InstallingRoRinLinux
InstallingRoRinLinux
Oracle11g on fedora14
Oracle11g On Fedora14
Linux Troubleshooting
Ad

More from Manish Chopra (20)

PDF
Agentic AI Use Cases using GenAI LLM models
PDF
AWS and Slack Integration - Sending CloudWatch Notifications to Slack.pdf
PDF
Getting Started with ChatGPT.pdf
PDF
Grafana and AWS - Implementation and Usage
PDF
Containers Auto Scaling on AWS.pdf
PDF
OpenKM Solution Document
PDF
Alfresco Content Services - Solution Document
PDF
Jenkins Study Guide ToC
PDF
Ansible Study Guide ToC
PDF
Microservices with Dockers and Kubernetes
PDF
Unix and Linux Operating Systems
PDF
Working with Hive Analytics
PDF
Preparing a Dataset for Processing
PDF
Organizations with largest hadoop clusters
PDF
Distributed File Systems
PDF
Difference between hadoop 2 vs hadoop 3
PDF
Oracle solaris 11 installation
PDF
Big Data Analytics Course Guide TOC
PDF
Emergence and Importance of Cloud Computing for the Enterprise
PDF
Setting up a HADOOP 2.2 cluster on CentOS 6
Agentic AI Use Cases using GenAI LLM models
AWS and Slack Integration - Sending CloudWatch Notifications to Slack.pdf
Getting Started with ChatGPT.pdf
Grafana and AWS - Implementation and Usage
Containers Auto Scaling on AWS.pdf
OpenKM Solution Document
Alfresco Content Services - Solution Document
Jenkins Study Guide ToC
Ansible Study Guide ToC
Microservices with Dockers and Kubernetes
Unix and Linux Operating Systems
Working with Hive Analytics
Preparing a Dataset for Processing
Organizations with largest hadoop clusters
Distributed File Systems
Difference between hadoop 2 vs hadoop 3
Oracle solaris 11 installation
Big Data Analytics Course Guide TOC
Emergence and Importance of Cloud Computing for the Enterprise
Setting up a HADOOP 2.2 cluster on CentOS 6

Recently uploaded (20)

PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
System and Network Administraation Chapter 3
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPT
Introduction Database Management System for Course Database
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Nekopoi APK 2025 free lastest update
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Transform Your Business with a Software ERP System
PPTX
L1 - Introduction to python Backend.pptx
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
ai tools demonstartion for schools and inter college
PDF
Design an Analysis of Algorithms I-SECS-1021-03
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PTS Company Brochure 2025 (1).pdf.......
System and Network Administraation Chapter 3
How to Choose the Right IT Partner for Your Business in Malaysia
Upgrade and Innovation Strategies for SAP ERP Customers
Introduction Database Management System for Course Database
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Wondershare Filmora 15 Crack With Activation Key [2025
Operating system designcfffgfgggggggvggggggggg
CHAPTER 2 - PM Management and IT Context
Design an Analysis of Algorithms II-SECS-1021-03
Nekopoi APK 2025 free lastest update
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Transform Your Business with a Software ERP System
L1 - Introduction to python Backend.pptx
Which alternative to Crystal Reports is best for small or large businesses.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Odoo Companies in India – Driving Business Transformation.pdf
ai tools demonstartion for schools and inter college
Design an Analysis of Algorithms I-SECS-1021-03

Steps to create an RPM package in Linux

  • 1. Creating RPM package in Linux This exercise was done on RHEL 6 and same steps are applicable for other variants too. This tutorial provides you with steps to create your own RPM packages in Linux. Following procedure shows creating a basic RPM package that includes a shell script. After the RPM is installed, the script is executed on the command prompt to display the output. Step 1 – Install necessary RPM dependencies [student@desktop3 ~]$yum install rpm-build–y Step 2 – Setup your package in a directory [student@desktop3 ~]$mkdir myrpm-1.0 [student@desktop3 ~]$cd myrpm-1.0 (Create a simple script which executes after installing the rpm) [student@desktop3 ~]$ vi myrpm.sh #!/bin/bash # echo 'Hello There ! This is my RPM script...' exit 0 (Make the script executable) [student@desktop3 ~]$ chmod a+x myrpm.sh Step 3 – Create a tar file of your package [student@desktop3 ~]$ mkdir -p ~/rpmbuild/SOURCES [student@desktop3 ~]$ mkdir -p ~/rpmbuild/SPECS [student@desktop3 ~]$ tar -zcvf ~/rpmbuild/SOURCES/myrpm-1.0-1.tar.gz myrpm-1.0/ Step 4 – Create and edit SPEC file [student@desktop3 ~]$ vi ~/rpmbuild/SPECS/myrpm.spec Name: myrpm Version: 1.0 Release: 1 Summary: MyRPM Group: RHCE License: GPL URL: http://www.redhat.com Source0: %{name}-%{version}-%{release}.tar.gz BuildRoot: /var/tmp/%{name}-buildroot %description Installs /root/bin/myrpm.sh %prep %setup -q -n %{name}-%{version}
  • 2. %build %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/root/bin install -m 755 myrpm.sh $RPM_BUILD_ROOT/root/bin/myrpm.sh %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) /root/bin/myrpm.sh %changelog Step 5 – Execute rpmbuild to build the RPM package [student@desktop3 ~]$rpmbuild -ba rpmbuild/SPECS/myrpm.spec Step 6 – Install and Run the RPM package [root@desktop3 ~]# rpm -ivh /home/student/rpmbuild/RPMS/x86_64/myrpm-1.0-1.x86_64.rpm Preparing... ########################################### [100%] 1:myrpm ########################################### [100%] [root@desktop3 ~]# ll /root/bin/myrpm.sh -rwxr-xr-x. 1 root root 131 Jun 29 17:19 /root/bin/myrpm.sh [root@desktop3 ~]# myrpm.sh Hello There ! This is my RPM script... Document Version 1 Date : 29th June 2012 Author : Manish Chopra