LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to build a rpm . (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-build-a-rpm-4175412460/)

pradiptart 06-20-2012 08:02 AM

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

TobiSGD 06-20-2012 09:00 AM

http://fedoraproject.org/wiki/How_to...an_RPM_package
http://www.rpm.org/max-rpm/s1-rpm-bu...spec-file.html

pradiptart 06-20-2012 09:14 AM

Hi TobiSGD,

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

Thanks

unSpawn 06-20-2012 10:52 AM

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.

pradiptart 06-21-2012 12:47 AM

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)

unSpawn 06-21-2012 01:18 AM

Quote:

Originally Posted by pradiptart (Post 4708240)
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.


All times are GMT -5. The time now is 12:16 AM.