LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-20-2012, 09:02 AM   #1
pradiptart
Member
 
Registered: Sep 2007
Posts: 102

Rep: Reputation: 12
how to build a rpm .


Hi all,

I want to make one RPM,I want to create one application.

I am having doubts in all the stages of creating RPM
as i know first you have to create a spec file.

can any one tell me a simple example of spec file as I have a file called uselib.c and the purpose of this file is to print a message. so I want to create a RPM which will install this application to the location /root/myrpm/bin/ and when i run this this will print that message.

I have only the .C file.

Now I want the steps to create a RPM and also tell me a basic spec file structure for this application.

and i am confused that in spec file what is given in $prep section there is somethig called %setup -b but my doubt is who will compile my .c file and what i have to write in spec file for this.also in SOURCE folder of RPM directory a zip will be there so what i will put inside that zip the .C file or the .o file if .C then who will compile that and how everything will happen kindly tell me this whole procedure.

Thanks
 
Old 06-20-2012, 10:00 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
http://fedoraproject.org/wiki/How_to...an_RPM_package
http://www.rpm.org/max-rpm/s1-rpm-bu...spec-file.html
 
Old 06-20-2012, 10:14 AM   #3
pradiptart
Member
 
Registered: Sep 2007
Posts: 102

Original Poster
Rep: Reputation: 12
Hi TobiSGD,

Thanks for reply.
I got that links before asking this thread i am having these doubts after reading all that.

Thanks
 
Old 06-20-2012, 11:52 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Then I suggest you post your .spec file contents and then ask for comments. You should have one by now as the offered docs are easy to read and besides you were given links to RPM documentation months ago already.
 
Old 06-21-2012, 01:47 AM   #5
pradiptart
Member
 
Registered: Sep 2007
Posts: 102

Original Poster
Rep: Reputation: 12
hi,

Bellow is the content of my spec file,I am just coping the content of the folder where my .out file is present to a desired location.
what i understood ,to create rpm means just to give some command which will be executed during the installation in the form of an RPM file.If this is correct then here I am doing the .out file by myself and just want a copy operation each time I install a rpm ,no validation checking nothing ,I have the .out file in the source folder before making this rpm ,The spec file is in /root/MYRPMBUILD/rpmbuild/SPECS,it is my own build dir.Is this correct.

But since i am getting error during this is this correct,If not kindly tell me a simple example ,about this RPM creation process.


mysepc file
----------------

Summary: My first RPM
Name: mylib
Version: 0.1
Release: 1
Group: own
Vendor: Pradiptart
License: Pradita

%description
It is my first RPM which will install an application to show the hello message on the screen

%prep

%build

%install
cp /root/sharedlib/uselib /opt/my/

%clean

%files


Error I am getting
------------------------
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.44508
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ $'\r'
: command not found508: line 27:
error: Bad exit status from /var/tmp/rpm-tmp.44508 (%prep)


RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.44508 (%prep)

Last edited by pradiptart; 06-21-2012 at 01:48 AM.
 
Old 06-21-2012, 02:18 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
Quote:
Originally Posted by pradiptart View Post
what i understood ,to create rpm means just to give some command which will be executed during the installation in the form of an RPM file.If this is correct then here I am doing the .out file by myself and just want a copy operation each time I install a rpm ,no validation checking nothing ,I have the .out file in the source folder before making this rpm ,The spec file is in /root/MYRPMBUILD/rpmbuild/SPECS,it is my own build dir.Is this correct.
No it is not:
- Do not build packages as root but as unprivileged user.
- Do not enter garbage or bogus information.
- Do not skip any packaging stage. Do things as they were intended.
- Respect OS-specific carriage returns and line endings for file contents (see 'dos2unix').


Code:
%define debug_packages  %{nil}
%define debug_package %{nil}

%define name uselib
%define ver 1.2.3
%define rel 1

Name: %{name}
Summary: %{name} is a X library for purpose Y
Version: %{ver}
Release: %{rel}
Group: System Environment/Libraries
License: GPL
# Create a directory /home/pradiptart/redhat/SOURCES/uselib-1.2.3/ and place your source 
# there and compress it to /home/pradiptart/redhat/SOURCES/uselib-1.2.3.tar.gz

Source0: %{name}-%{ver}.%{rel}.tar.gz

%description
%{name} is a X library for purpose Y.

%prep
%setup %{name}

%build
# You should have a Makefile or else you will enter the required commands to compile below:

%install
# Another good reason not to build as root:
rm -rf $RPM_BUILD_ROOT
# Local additions don't go in "opt/my" but "/usr/local" so libraries are in /usr/local/lib
install -d $RPM_BUILD_ROOT/usr/local/lib
install -m 0755 %{name}.so $RPM_BUILD_ROOT/usr/local/lib
ln -sf $RPM_BUILD_ROOT/usr/local/lib/%{name}.so $RPM_BUILD_ROOT/usr/local/lib/%{name}.so.%{ver}
# Fedora trick to populate files section:
find $RPM_BUILD_ROOT -not -type d -printf "%%%attr(%%m,root,root) %%p\n" | grep -v etc/ | sed -e "s|$RPM_BUILD_ROOT||g" -e "s|.*/man/.*$|\0.gz|g" >> %{_tmppath}/%{name}_contents.txt

%clean
# Another good reason not to build as root:
rm -rf $RPM_BUILD_ROOT

%files -f %{_tmppath}/%{name}_contents.txt

%changelog
* Thu Jun 21 2012 %{packager} - %{ver}.
- Release %{rel}.
Next time use BB code tags (like [CODE]code here[/CODE]) for both .spec file and output.
Before you ask questions please reread the links TobiSGD gave you. Most of what you saw above could have been learned from there.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
self build rpm fails with missing dependencies on build host zhjim Linux - Software 1 09-24-2009 09:47 AM
How can I generate / build and RPM from *.src.rpm file sreekumartg Red Hat 3 02-23-2007 06:23 PM
How can I get the rpm command and rpm build command on my Debian box? abefroman Debian 6 11-28-2005 01:38 PM
cannot build source rpm/ rpm questions kpachopoulos Fedora 3 07-24-2005 10:15 AM
build rpm Santas Linux - Software 1 11-21-2003 06:45 PM


All times are GMT -5. The time now is 11:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration