packaging in linux platform

I have never did packaging in linux platform and had faced a lot of problem in creating a simple spec file. Now as I have through with it I want to share this information in my Blog.
The major portion in linux packaging process is to create a right spec file. Here I am giving a sample and simplest spec file. Assumptions here are we want software get install in /opt/package- name/lib and /opt/package- name/bin directory. Given below is the containt of “Package name”.spec file :-

Summary: Write name of project
Name: Package name
Version: 0.0.1
Release: 1
License: GPL
Group: wite any group name (for detail could go any link given below)
Source: /usr/src/packages/SOURCES/-.tar.gz
BuildRoot: /usr/src/packages/RPMS/x86_64/opt

%description
Project description that will come as information after installation of package.

%prep
%setup -q

%install
mkdir -p $RPM_BUILD_ROOT/opt/write you package name/bin/
mkdir -p $RPM_BUILD_ROOT/opt/write your package name /lib/

install -s -m 0755 /usr/src/packages/BUILD/-/opt/write you package name/bin/* $RPM_BUILD_ROOT/opt/write you package name/bin/
install -s -m 0755 /usr/src/packages/BUILD/-/opt/write you package name/lib/*.so* $RPM_BUILD_ROOT/opt/write you package name/lib/

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(1777,root,root)

/opt/write you package name/bin/*
/opt/write you package name/lib/*.so*

———–
Done
Now simply you need to run following commands

1) Create a rpm file in default folder of /usr/src/packages/RPMS
rpmbuild -ba /usr/src/packages/SPECS/package_name.spec
2) Install rpmfile to the location provided by you in spec file
rpm -ivh /usr/src/packages/RPMS/******.rpm
3) Remove software from the platform
rpm -e magnum-lda
4) Query the package and get detail that you have specified in spec file.
rpm -qpl magnum-lda-1.0.0-1.x86_64.rpm

Advertisements
This entry was posted in Solaris/Linux. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s