LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 12-11-2012, 04:13 AM   #1
project.linux.proj
Member
 
Registered: Dec 2012
Posts: 75

Rep: Reputation: Disabled
how to build a rpm


How can i create a Python rpm version 2.7. Can anybody give me the easy way to write the spec file ?

Thanks,
 
Old 12-11-2012, 05:33 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 869
Blog Entries: 2

Rep: Reputation: 216Reputation: 216Reputation: 216
I believe the modern way (that I've not used) involves a tool called "mock".
 
Old 12-14-2012, 12:32 AM   #3
project.linux.proj
Member
 
Registered: Dec 2012
Posts: 75

Original Poster
Rep: Reputation: Disabled
Hi,

I tried to build pkg using rpmbuild. I wrote specification as below but getting error when i check on the path /usr/src/redhat/BUILD . i get directory name starting with capital letter Python-3.3.0. As checked in error it tries to cd python-3.3.0 (starts with small letter). If it is the problem how to fix it?

==================================================
Specification

[root@localhost SPECS]# cat python-3.3.0.spec
Summary: python package
%define version 3.3.0
Group: Development/Application
Name: python
Prefix: /usr
Provides: python
Release: 0
License: GNU
Source: python-%{version}.tar
URL: http://www.python.org/download/release
Version: %{version}
Buildroot: /tmp/python
%description
The python is an application http://www.python.org/download/release

%prep

%setup -q

%build
./configure CXXFLAGS=-O3 --prefix=$RPM_BUILD_ROOT/usr
make

%install
rm -fr $RPM_BUILD_ROOT
make install

%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
/usr/bin/python
%doc /usr/doc/python-%{version}/license.htm
%doc /usr/man/man1/python.1*


===============================================

Ran below command to build the pkg

[root@localhost SPECS]# rpmbuild -ba python-3.3.0.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.38534
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf python-3.3.0
+ tar -xf /usr/src/redhat/SOURCES/python-3.3.0.tar
+ cd python-3.3.0
/var/tmp/rpm-tmp.38534: line 33: cd: python-3.3.0: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.38534 (%prep)


RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.38534 (%prep)
[root@localhost SPECS]# less python-3.3.0.spec
(reverse-i-search)`b ': cat /etc/fstab
[root@localhost SPECS]# rpmbuild -ba python-3.3.0.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.24452
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /usr/src/redhat/BUILD
+ rm -rf python-3.3.0
+ tar -xf /usr/src/redhat/SOURCES/python-3.3.0.tar
+ cd python-3.3.0
/var/tmp/rpm-tmp.24452: line 33: cd: python-3.3.0: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.24452 (%prep)


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




=====================================================

Error logs

#!/bin/sh

RPM_SOURCE_DIR="/usr/src/redhat/SOURCES"
RPM_BUILD_DIR="/usr/src/redhat/BUILD"
RPM_OPT_FLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables"
RPM_ARCH="i386"
RPM_OS="linux"
export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS
RPM_DOC_DIR="/usr/share/doc"
export RPM_DOC_DIR
RPM_PACKAGE_NAME="python"
RPM_PACKAGE_VERSION="3.3.0"
RPM_PACKAGE_RELEASE="0"
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
RPM_BUILD_ROOT="/tmp/python"
export RPM_BUILD_ROOT

PKG_CONFIG_PATH="/usr/lib/pkgconfig:/usr/share/pkgconfig"
export PKG_CONFIG_PATH

set -x
umask 022
cd /usr/src/redhat/BUILD

LANG=C
export LANG
unset DISPLAY


cd '/usr/src/redhat/BUILD'
rm -rf 'python-3.3.0'
tar -xf /usr/src/redhat/SOURCES/python-3.3.0.tar
cd 'python-3.3.0'
[ `/usr/bin/id -u` = '0' ] && /bin/chown -Rhf root .
[ `/usr/bin/id -u` = '0' ] && /bin/chgrp -Rhf root .
/bin/chmod -Rf a+rX,u+w,g-w,o-w .


exit 0




Thanks,
Mohit

Last edited by project.linux.proj; 12-14-2012 at 12:34 AM.
 
Old 12-14-2012, 06:07 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,267

Rep: Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661
First : No need to be root to build rpms. Not recommended.

Please try : $ rpm -Uvh python-2.7.3-6.fc17.src.rpm
http://dl.fedoraproject.org/pub/fedo...6.fc17.src.rpm
.. and the source code will be unpacked to /home/<name>/rpm*///

The spec file can be found in SPECS/.
Then you have the example "python.spec" for python-2.7.3 .


My preferred rpmbuild setup ...
http://www.linuxquestions.org/questi...1-a-766486/#13

.

Last edited by knudfl; 12-14-2012 at 06:13 AM.
 
2 members found this post helpful.
Old 01-07-2013, 01:49 PM   #5
project.linux.proj
Member
 
Registered: Dec 2012
Posts: 75

Original Poster
Rep: Reputation: Disabled
I am trying new spec still getting an error ... Below is the spec and error . I don't know why the path ( /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64 ) is being added as a prefix . Can anybody help plz

================================

# cat ocsinventory.spec
%define debug_package %{nil}

Name: ocsinventory-agent
Version: 2.0
Release: 0
Summary: ocsinventory-agent 2.0rc2
Group: Monitor
License: GPL
URL: http://glam.com/ocsagnet
Source: Ocsinventory-Agent-2.0rc2.tar.gz

Requires: perl , perl-Module* , perl-XML-Simple , perl-ExtUtils* , perl-Proc-PID-File , perl-Proc-Daemon.noarch , perl-Net-SNMP , perl-Net-IP

%description
Ocsinventory-Agent for Opera Solutions

#%prep
#%setup -n ocsinventory-agent

#%build
#cd /usr/src/redhat/BUILD/Ocsinventory-Agent-2.0
#make

#%install

%files
/etc/cron.d/ocsinventory-agent
/usr/local/share/man/man1/ocsinventory-agent.1
/usr/local/bin/ocsinventory-agent
/usr/lib64/perl5/perllocal.pod
%dir /root/Ocsinventory-Agent-2.0rc2/*
%dir /usr/local/share/perl5/Ocsinventory/*
%dir /var/lib/ocsinventory-agent/
%dir /etc/ocsinventory-agent/
%config(noreplace) /etc/ocsinventory-agent/modules.conf
%config(noreplace) /etc/ocsinventory-agent/ocsinventory-agent.cfg
#SSLeay
#end

Errors

# rpmbuild -bb ocsinventory.spec
Processing files: ocsinventory-agent-2.0-0.x86_64
error: File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/etc/cron.d/ocsinventory-agent
error: File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/usr/local/share/man/man1/ocsinventory-agent.1
error: File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/usr/local/bin/ocsinventory-agent
error: File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/usr/lib64/perl5/perllocal.pod
error: File not found by glob: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/root/Ocsinventory-Agent-2.0rc2/*
error: File not found by glob: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/usr/local/share/perl5/Ocsinventory/*
error: File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/var/lib/ocsinventory-agent
error: File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/etc/ocsinventory-agent
error: File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/etc/ocsinventory-agent/modules.conf
error: File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/etc/ocsinventory-agent/ocsinventory-agent.cfg


RPM build errors:
File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/etc/cron.d/ocsinventory-agent
File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/usr/local/share/man/man1/ocsinventory-agent.1
File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/usr/local/bin/ocsinventory-agent
File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/usr/lib64/perl5/perllocal.pod
File not found by glob: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/root/Ocsinventory-Agent-2.0rc2/*
File not found by glob: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/usr/local/share/perl5/Ocsinventory/*
File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/var/lib/ocsinventory-agent
File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/etc/ocsinventory-agent
File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/etc/ocsinventory-agent/modules.conf
File not found: /root/rpmbuild/BUILDROOT/ocsinventory-agent-2.0-0.x86_64/etc/ocsinventory-agent/ocsinventory-agent.cfg


# ll ../SOURCES/
total 1428
-rw-r--r-- 1 root root 1460018 Jan 7 13:11 Ocsinventory-Agent-2.0rc2.tar.gz

# pwd
/usr/src/redhat/SPECS
 
Old 01-07-2013, 04:09 PM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,267

Rep: Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661
# 5 : 'ocsinventory-agent 2.0rc2' is an old version, I'd guess.
Currently used stable versions are 2.0.4, 2.0.5 or 1.1.2.1 .

Suggest : Use an existing 'ocsinventory-agent.spec' file.
Available in SRC.RPMS for Fedora, Mandriva.

Example, Fedora 17 : ocsinventory-agent-2.0.5-1.fc17.src.rpm
http://dl.fedoraproject.org/pub/fedo...1.fc17.src.rpm

Which OS are you using ? Name and version, please.

.
 
Old 01-08-2013, 02:45 AM   #7
project.linux.proj
Member
 
Registered: Dec 2012
Posts: 75

Original Poster
Rep: Reputation: Disabled
below is the information

# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarchrinting-4.0-amd64rinting-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.2 (Final)
Release: 6.2
Codename: Final

Last edited by project.linux.proj; 01-08-2013 at 04:41 AM.
 
Old 01-08-2013, 05:19 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2014.08, Slack14.1 DebWheezy, +50+ other Linux OS, for test only.
Posts: 14,267

Rep: Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661Reputation: 2661
# 7

# yum install ocsinventory-agent
( Providing version 1.1.2.1 ).

The package ocsinventory-agent is in the EPEL.repo
https://fedoraproject.org/wiki/EPEL >
# rpm -Uvh http://ftp.crc.dk/fedora-epel/6/i386...6-7.noarch.rpm

The CentOS 6.x ocsinventory-agent source package with a .spec file :
http://dl.fedoraproject.org/pub/epel...ory-agent.html
> http://dl.fedoraproject.org/pub/epel...-1.el6.src.rpm

.

Last edited by knudfl; 01-08-2013 at 05:21 AM.
 
Old 01-08-2013, 12:48 PM   #9
project.linux.proj
Member
 
Registered: Dec 2012
Posts: 75

Original Poster
Rep: Reputation: Disabled
knudfl

Can we fix the existing spec ? Why below errors

# rpmbuild -ba /root/rpmbuild/SPECS/ocsinventory.spec
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.Hn4Kac
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf Ocsinventory-Agent-2.0rc2
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/Ocsinventory-Agent-2.0rc2.tar.gz
+ /bin/tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd Ocsinventory-Agent-2.0rc2
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
Processing files: ocs-agent-2.0-0.x86_64
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/etc/cron.d/ocsinventory-agent
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/usr/local/share/man/man1/ocsinventory-agent.1
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/usr/local/bin/ocsinventory-agent
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/usr/lib64/perl5/perllocal.pod
error: File not found by glob: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/root/Ocsinventory-Agent-2.0rc2/*
error: File not found by glob: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/usr/local/share/perl5/Ocsinventory/*
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/var/lib/ocsinventory-agent
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/etc/ocsinventory-agent
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/etc/ocsinventory-agent/modules.conf
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/etc/ocsinventory-agent/ocsinventory-agent.cfg


RPM build errors:
File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/etc/cron.d/ocsinventory-agent
File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/usr/local/share/man/man1/ocsinventory-agent.1
File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/usr/local/bin/ocsinventory-agent
File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/usr/lib64/perl5/perllocal.pod
File not found by glob: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/root/Ocsinventory-Agent-2.0rc2/*
File not found by glob: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/usr/local/share/perl5/Ocsinventory/*
File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/var/lib/ocsinventory-agent
File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/etc/ocsinventory-agent
File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/etc/ocsinventory-agent/modules.conf
File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/etc/ocsinventory-agent/ocsinventory-agent.cfg
 
Old 01-08-2013, 01:13 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,684
Blog Entries: 54

Rep: Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955
Quote:
Originally Posted by project.linux.proj View Post
Can we fix the existing spec ?
knudfl already pointed out that building packages isn't necessary if they are readily available. He also pointed out that you shouldn't use stale versions of software but use the current, stable, safe version. (And I'm adding to that that you should not build RPM packages as root account user.) Not responding to what knudlf said and stubbornly going your own way serves as further evidence that what you need isn't fixing %buildroot --prefix package building errors: you need to make a U-turn.
 
Old 01-09-2013, 06:29 AM   #11
project.linux.proj
Member
 
Registered: Dec 2012
Posts: 75

Original Poster
Rep: Reputation: Disabled
Unspawn/knudfl,

I am running this with root user because I am just copying configurations files/directories into the rpm as it is. Please correct me if i am doing mistake.I ran the below spec file on arch i386 and it ran successfully but when i ran on arch x86_64 it prefixes path "/root/rpmbuild/BUILDROOT" and gives error. It might be i need to change the buildroot value but i am not sure. Can you guys help me to diagnose it because i don't want U-Turn .

Spec on i386

%define debug_package %{nil}

Name: ocsinventory-agent
Version: 2.0
Release: 0
Summary: Ocsinventory-Agent-2.0rc2
Group: Monitor
License: GPL
URL: http://glam.com/ocsagnet
Source: Ocsinventory-Agent-2.0rc2.tar.gz

#Requires: perl-XML-Simple , perl-Compress-Zlib , perl-Net-IP , perl-Net-SSLeay , perl-Crypt-SSLeay , perl-Proc-Daemon , perl-Net-SNMP , perl-Proc-PID-File , pciutils , smartmontools
Requires: perl perl-Module* perl-XML-Simple perl-ExtUtils* perl-Proc-PID-File perl-Proc-Daemon.noarch perl-Net-SNMP perl-Net-IP

%description
Ocsinventory-Agent for Glam Techops team

#%prep
#%setup -n ocsinventory-agent

#%build
#cd /usr/src/redhat/BUILD/Ocsinventory-Agent-2.0
#make

#%install

%files
/usr/lib/perl5/site_perl/5.8.8/Ocsinventory/*
/usr/share/man/man1/ocsinventory-agent.1
/usr/share/man/man3/Ocsinventory::Agent::Common.3pm
/usr/share/man/man3/Ocsinventory::Agent::XML::Inventory.3pm
/usr/bin/ocsinventory-agent
/usr/bin/ipdiscover
%dir /var/lib/ocsinventory-agent/
%dir /etc/ocsinventory-agent/
%config(noreplace) /etc/ocsinventory-agent/modules.conf
%config(noreplace) /etc/ocsinventory-agent/ocsinventory-agent.cfg

#end


Error on x86_64
Processing files: ocs-agent-2.0-0.x86_64
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/etc/cron.d/ocsinventory-agent
error: File not found: /root/rpmbuild/BUILDROOT/ocs-agent-2.0-0.x86_64/usr/local/share/man/man1/ocsinventory-agent.1


Thanks,
 
Old 01-09-2013, 07:18 AM   #12
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,684
Blog Entries: 54

Rep: Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955Reputation: 2955
Quote:
Originally Posted by project.linux.proj View Post
I am running this with root user because I am just copying configurations files/directories into the rpm as it is.
Not a valid reason as you can 'sudo cp' configurations files/directories over. Plus any local customization shouldn't be part of stock packages as they're local to begin with.


Quote:
Originally Posted by project.linux.proj View Post
i don't want U-Turn
Like I said before you should not build RPM packages as root account user. Continuing to do so for no valid reason isn't an incentive for me to help you. So I'll leave you telling you to add this line
Code:
find $RPM_BUILD_ROOT -not -type d -printf "%%%attr(%%m,root,root) %%p\n" | sed -e "s|$RPM_BUILD_ROOT||g" > %{_tmppath}/%{name}_contents.txt
to the end of your %install section and replace your %files section with this line
Code:
%files -f %{_tmppath}/%{name}_contents.txt
 
  


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
RPM-Build hkillen Linux - Software 4 06-27-2006 05:38 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


All times are GMT -5. The time now is 07:20 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration