BUILDING RPM
1. Create a directory with any name. for example myprojectrpm.
2. Now create BUILD RPMS SOURCES SPECS and SRPMS directory in myproject directory.
3. Go to SOURCES directory and create a directory with the name of your project and then copy your html and cgi-bin folder into that directory. example SOURCES/myproject/html/* and SOURCES/myproject/cgi-bin/*
4. Create SPECS/myproject.spec file. This file is the main file which has the specification for the rpm that is going to be created.
So the directory structure till now:
myprojectrpm-
|
|-- BUILD
|-- RPMS
|-- SOURCES -
| |-- myproject -
| |-- html -
| | |<all the html files css directory etc>
| |-- cgi-bin -
| |<all the cgi files etc>
|-- SPECS -
| |-- myproject.spec
|--SRPMS
The myproject.spec file
*************************************************************************************************
# %define is used to define a variable
%define _topdir /home/test/myprojectrpm # _topdir has the complete path to myprojectrpm dir.
%define name myproject # name of the project
%define release 1 # release of the project. Its 1 because it is the 1st release
%define version 1
%define buildroot %{_topdir}/%{name}-%{version}-root # It is the mock location where the project will be copied duriing the rpmbuild process where the project files will be packed into rpm.
# The specifications of the project
#
BuildRoot: %{buildroot} # value of buildroot is assigned to BuildRoot
Summary: This is my project
License: MY personal
Name: %{name}
Version: %{version}
Release: %{release}
Source: %{name}
Prefix: /var # the parent directory where the rpm will install the files
Group: Development/Tools # the group or catagory in whiich the project belongs
Requires: tty,shellinabox,ansible,httpd,python2,aws,pip,libvirt,qemu-kvm,virt-manager # the tools required by the project
%description
This is my cloud.
# This section contains commands to be executed to install the files. Here the commands are for the buildroot directory and will be executed during the rpm build process but the same will happen during installing the rpm in the system.
%install
# Here are the commands that will copy the contents of html and cgi-bin folder present in the source directory to the /var/www/html , /var/www/cgi- bin directory respectively.
mkdir -p %{buildroot}/var/www/html
mkdir -p %{buildroot}/var/www/cgi-bin
cp -rvf %{_topdir}/SOURCES/myproject/cgi-bin/* %buildroot/var/www/cgi-bin/
cp -rvf %{_topdir}/SOURCES/myproject/html/* %buildroot/var/www/html/
# we set the permissions to the copied files and the files are moved from the buildroot to the system root /var/www/* .
%files
%defattr(0777, root,root)
/var/www/cgi-bin/*
/var/www/html/*
*****************************************************************************************************
5. Now run the following command to build the rpm.
$ rpmbuild -v -bb --clean ~/myprojectrpm/SPECS/myproject.spec
This command uses the named spec file to build a binary package (-bb for "build binary") with verbose output (-v). The build utility removes the build tree after the packages are made (--clean).
*rpmbuild performs these steps:
-Reads and parses the myproject.spec file.
-Runs the %prep section to copy the source code into a temporary directory. Here, the temporary directory is BUILD.
-Runs the %install section to install the code into directories on the build machine.
-Reads the list of files from the %files section, gathers them up, and creates a binary RPM (and source RPM files, if you elect).
6. The rpm created will be present in the RPM directory.
1. Create a directory with any name. for example myprojectrpm.
2. Now create BUILD RPMS SOURCES SPECS and SRPMS directory in myproject directory.
3. Go to SOURCES directory and create a directory with the name of your project and then copy your html and cgi-bin folder into that directory. example SOURCES/myproject/html/* and SOURCES/myproject/cgi-bin/*
4. Create SPECS/myproject.spec file. This file is the main file which has the specification for the rpm that is going to be created.
So the directory structure till now:
myprojectrpm-
|
|-- BUILD
|-- RPMS
|-- SOURCES -
| |-- myproject -
| |-- html -
| | |<all the html files css directory etc>
| |-- cgi-bin -
| |<all the cgi files etc>
|-- SPECS -
| |-- myproject.spec
|--SRPMS
The myproject.spec file
*************************************************************************************************
# %define is used to define a variable
%define _topdir /home/test/myprojectrpm # _topdir has the complete path to myprojectrpm dir.
%define name myproject # name of the project
%define release 1 # release of the project. Its 1 because it is the 1st release
%define version 1
%define buildroot %{_topdir}/%{name}-%{version}-root # It is the mock location where the project will be copied duriing the rpmbuild process where the project files will be packed into rpm.
# The specifications of the project
#
BuildRoot: %{buildroot} # value of buildroot is assigned to BuildRoot
Summary: This is my project
License: MY personal
Name: %{name}
Version: %{version}
Release: %{release}
Source: %{name}
Prefix: /var # the parent directory where the rpm will install the files
Group: Development/Tools # the group or catagory in whiich the project belongs
Requires: tty,shellinabox,ansible,httpd,python2,aws,pip,libvirt,qemu-kvm,virt-manager # the tools required by the project
%description
This is my cloud.
# This section contains commands to be executed to install the files. Here the commands are for the buildroot directory and will be executed during the rpm build process but the same will happen during installing the rpm in the system.
%install
# Here are the commands that will copy the contents of html and cgi-bin folder present in the source directory to the /var/www/html , /var/www/cgi- bin directory respectively.
mkdir -p %{buildroot}/var/www/html
mkdir -p %{buildroot}/var/www/cgi-bin
cp -rvf %{_topdir}/SOURCES/myproject/cgi-bin/* %buildroot/var/www/cgi-bin/
cp -rvf %{_topdir}/SOURCES/myproject/html/* %buildroot/var/www/html/
# we set the permissions to the copied files and the files are moved from the buildroot to the system root /var/www/* .
%files
%defattr(0777, root,root)
/var/www/cgi-bin/*
/var/www/html/*
*****************************************************************************************************
5. Now run the following command to build the rpm.
$ rpmbuild -v -bb --clean ~/myprojectrpm/SPECS/myproject.spec
This command uses the named spec file to build a binary package (-bb for "build binary") with verbose output (-v). The build utility removes the build tree after the packages are made (--clean).
*rpmbuild performs these steps:
-Reads and parses the myproject.spec file.
-Runs the %prep section to copy the source code into a temporary directory. Here, the temporary directory is BUILD.
-Runs the %install section to install the code into directories on the build machine.
-Reads the list of files from the %files section, gathers them up, and creates a binary RPM (and source RPM files, if you elect).
6. The rpm created will be present in the RPM directory.
0 Comments