Welcome

Username:

Password:


Remember me

[ Signup ]
[ Forgot password? ]


Get Legal!

Online
Guests: 5
Members: 0
On this page: 1
Members: 133, newest: FrederickBecky33

Articles
bullet Articles Front Page ...

bullet HOW-TO (7)

bullet Implementing a Postfix mail server with spam and antivirus protection
bullet Introduction to Shell Scripting--The Basics
bullet Create rpm-packages
bullet AIDE and CHKROOTKIT
bullet Andutteye Surveillance
bullet Review: Kanotix LiveCD makes Debian simple
bullet Knoppix Hard Disk Installation HOWTO

News Headlines










Last updated: 08 Sep : 10:12
Details

W3C Compliance
Valid XHTML 1.1!
Valid CSS!

Backend
Our headlines can be syndicated by using either our rss or text feeds.
news.xml - news.txt

Counter
Today: 0 (unique:0)
Ever: 1247940 (unique:1245747)
Record: 2558 (unique:2550)

Create rpm-packages
Create rpm-packages
A short rpm-package howto
DrHook Wednesday 29 September 2004

Usally you rpm topdir are located under /usr/src/redhat if you are using the Redhat distribution.

If you are building you own rpm:s its possible that you want to change this toplevel rpm structure. That you can do by creating a .rpmmacros file in /root that overides the default settings. This is an example on how it can look.


%_topdir /home/rpmbuild
%_signature gpg
%_gpg_path /home/rpmbuild/.gnupg
%_gpg_name andutt@superman
%_gpgbin /usr/bin/gpg
%packager Andutt http://andutt
%distribution AnduttLinux
%vendor Andutt homestudio


Now we can start to build some rpm-packages, Create RPMS, SRPMS, SPEC, BUILD, SOURCES directorys under /home/rpmbuild that now are our rpm creation topdirectory. Now here is a short explanation on what thoose directorys shall include.


RPMS=New created rpm-packages
SRPMS=New created rpm-sourcepackages
SPECS=rpm specifikation files
BUILD=Unpacked source directorys
SOURCES=Source tar-bundles that shall be rpm-packages


Now to be able to create a rpm-package you have to bundle your files in a compressed tarball and put this under the SOURCES directory. That is the files that shall be included in the binary rpm-package. Now you have to crete a specification that the rpmbuild command can understand. This is how an empty spec file can look like.

cat /home/rpmbuild/SPEC/mysoftware-1.0-1.spec


# The Summary: line should be expanded to about here -----^
Name: anduttsoft
Version: 1.0
Release: 4
Group: System Environment/Base
License: GPL
Source: anduttsoft-%{version}-%{release}-bin.tar.gz
#NoSource: 0
BuildRoot: /home/rpmbuild/BUILD/%{name}-root
# Following are optional fields
#URL: http://www.example.net/anduttsoft/
#Distribution: Red Hat Contrib-Net
#Patch: anduttsoft-%{version}.patch
#Prefix: /.
BuildArch: noarch
#Requires:
Conflicts: anduttsoft < 1.0-4
#Obsoletes:
#BuildRequires:

%description
anduttsoft Software version 1.0

%prep
%setup -c 'anduttsoft-%{version}'
#%patch

%install
%__cp -a . "${RPM_BUILD_ROOT-/}"

%clean
[ "$RPM_BUILD_ROOT" != "/" ] && chmod -R 777 "$RPM_BUILD_ROOT" && rm -rf "$RPM_BUILD_ROOT"

%pre
echo "Checking if all anduttsoft needs are installed"
if [ ! -f /tmp/anduttsoft.needed ]
then
echo "ERROR needed file dont exist"
exit 1
fi

%post
echo "Registering anduttsoft in runlevel 3 and 5"
chkconfig --add anduttsoft
chkconfig --level 35 anduttsoft on

%files
%defattr(-,root,root)
%dir /./
%dir /./opt/
%dir /./opt/scripts/
%dir /./opt/scripts/anduttsoft/
%defattr(0755,root,root) /opt/scripts/anduttsoft/anduttdiscover
%dir /./opt/scripts/anduttsoft/etc/
%config /./opt/anduttsoft/etc/help

%changelog
* Mon Jul 07 2004 root
- Initial created by andutt


As you can see the rpm-package is very powerful since you can perform tasks before and after the rpm-package have been installed and that it also keeps track of your version and releases,
if it should conflict with another package or if its dependent of another package.

If you are deticated you can create a completely automatic procedure
for something that can be really tricky to do by hand for other users.

But creating theese specfiles by hand can take some time.

But we are lucky! A guy called Gabiell V have craeted av very good tool for making creation of spec files more easy. You can download Autospec here

Then its really easy, Do like this, bundle your files to a nice tarball. Mine is called anduttsoft-1.14-4-bin.tar.gz and are placed correctly under the SOURCES tree. Use the autospec program to create a rpm specification file.


tar -tzf SOURCES/anduttsoft-1.14-4-bin.tar.gz | autospec -bd -g "System Environment/Base" -n anduttsoft-1.14 -l ''
>SPECS/anduttsoft-1.14-4.spec



Thats it, autospec have created a spec file based on you input, now just fill in your pre and post stages if they shall preform any tasks.


When the specfile is finished its time to build it, that you do with the rpmbuild command, like this


rpmbuild -bb /home/rpmbuild/SPEC/mysoftware-1.0-1.spec


You rpm package is now beeing buildt after your rpmspecification.

Good luck rpm:ing


email to someone printer friendly
>> List articles in this category
<< Back to articles front page
Rating

You must be logged in to post comments on this site - please either log in or if you are not registered click here to signup
Render time: 0.6575 second(s).