LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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-10-2008, 01:47 AM   #1
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Rep: Reputation: 15
what is the error in my rpm spec file


test.c is a small c file written to print hello world.

The below one is the test.spec file written for packaging the test.c file.
Summary:This prints hello world
Name:test
Version:1
Release:1
License:GPL
Group:Applications/System
Source:test.c
BuildRoot:/home/uday_koganti/testing
%description
This package prints hello world when executed
%prep

%build
gcc -o /home/uday_koganti/testing/test /home/uday_koganti/testing/test.c
%install
./test

After writing this spec file i had run the command rpmbuild -bs test.spec to create the source rpm package.
It ran successfully.After that i had run the command rpmbuild -ba test.spec to create binary rpm package.
But it gives an error

RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.65419 (%install)
I feel that there should be some thing wrong in the install section of my test.spec file.

Could any one please find the solution for this problem.
 
Old 06-10-2008, 04:46 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
The "/var/tmp/rpm-tmp.65419" serves as kind of a logfile you can use for debugging, so what are the contents?
 
Old 06-11-2008, 01:56 AM   #3
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
The contents of var/tmp/rpm-tmp.65419 are


#!/bin/sh

RPM_SOURCE_DIR="/usr/src/redhat/SOURCES"
RPM_BUILD_DIR="/usr/src/redhat/BUILD"
RPM_OPT_FLAGS="-O2 -g -march=i386 -mcpu=i686"
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="test"
RPM_PACKAGE_VERSION="1"
RPM_PACKAGE_RELEASE="1"
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
RPM_BUILD_ROOT="/home/uday_koganti/testing"
export RPM_BUILD_ROOT


set -x
umask 022
cd /usr/src/redhat/BUILD
install ./test

/usr/lib/rpm/brp-compress
/usr/lib/rpm/brp-strip
/usr/lib/rpm/brp-strip-static-archive
/usr/lib/rpm/brp-strip-comment-note
 
Old 06-11-2008, 06:11 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
- The initial error messages you posted where not complete. Sure the line you posted contains the error, but in troubleshooting it is often "better" (easier, more efficient) to provide any lines before and after the error line for troubleshooting purposes.

- Building as root?
Quote:
Originally Posted by ukbhan View Post
RPM_BUILD_DIR="/usr/src/redhat/BUILD"
(..)cd /usr/src/redhat/BUILD
The /usr/src/redhat tree is only used by the root account user to build RPMs. You should not use the root account for testing and building RPMs but an unprivileged user account.

- Conventions
Quote:
Originally Posted by ukbhan View Post
install ./test
In the %install section of the .spec file a Makefile is expected when handling a "default" packaging process. If there is no Makefile then you can use 'cp', but it is better (easier, more efficient) to use 'install'.

- Conventions
A RPM should not execute processes trivially during install. Running 'test', when not explicitly advertised, is unexpcted behaviour that could compromise the trust we put in RPM. Besides that the name 'test' could lead to unexpected results since on default installation there already is a 'test' binary (see '[', ']', 'test').

- Spec file. Unless you cut off your file contents, your .spec file is not complete (and please use BB code next time).
Your .spec file could look like this, note I used RPM-style %{formatting}:
Code:
Name: test
Version: 1
Release: 1
Summary: %{name} prints hello world
Group: Utilities/System # See /usr/share/docs/rpm-*/GROUPS
License: GPL
Source: $RPM_SOURCE_DIR/%{name}.c
BuildRoot: %{_tmppath}/%{name}-%{version}
Provides: %{name}

%description
This package contains a "hello world" example binary.

# or %setup if a tarball
%prep # This preps dir $RPM_BUILD_DIR/%{name}-%{version}.%{release}/.
# We're in the BuildRoot now. Make certain:
cd $RPM_BUILD_DIR/%{name}-%{version}.%{release}/
# Copy files in that aren't packaged:
cp $RPM_SOURCE_DIR/%{name}.c .

%build
gcc -o %{name} %{name}.c

%install
# Create dirs leading up to if necessary:
[ -d /usr/local/bin ] || mkdir -p /usr/local/bin
install -m 0755 ./test $RPM_BUILD_ROOT/usr/local/bin

%clean
[ "$RPM_BUILD_ROOT" = "%{_tmppath}/%{name}-%{version}" ] && rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%attr(755,root,root) /usr/local/bin/%{name}

%changelog
* Wed June 10 2008 %{packager}
- Initialise .spec file for %{name}-%{ver}.
Before you use your unprivileged user account to build RPMs perform the next three steps to set up the environment:

0. Create a file "/home/uday_koganti/.rpmmacros" with minimally the following contents:
Code:
%_topdir         /home/uday_koganti/redhat
%_tmppath      %{_topdir}/tmp
%fname          %{name}-%{version}.%{release}
%_builddir      %{_topdir}/BUILD
%_rpmdir        %{_topdir}/RPMS
%_sourcedir    %{_topdir}/SOURCES
%_specdir       %{_topdir}/SPECS
%_srcrpmdir    %{_topdir}/SRPMS
%distribution    none
%vendor         none
1. Then create the necessary directories with: 'mkdir -p /home/uday_koganti/redhat/{BUILD,RPMS,SOURCES,SPECS,SRPMS}'

2. Place your "test.c" in /home/uday_koganti/redhat/SOURCES and your "test.spec" in /home/uday_koganti/redhat/SPECS.

Last edited by unSpawn; 06-11-2008 at 06:17 AM.
 
Old 06-12-2008, 06:38 AM   #5
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
I had followed all the instructions give above by you .But even then i am getting the error has follows
[uday_koganti@silunx-fc4 SPECS]$ rpmbuild -ba test.spec


Executing(%prep): /bin/sh -e /home/uday_koganti/redhat/tmp/rpm-tmp.77791
+ umask 022
+ cd /home/uday_koganti/redhat/BUILD
+ cd /home/uday_koganti/redhat/BUILD/test-1.1/
/home/uday_koganti/redhat/tmp/rpm-tmp.77791: line 23: cd: /home/uday_koganti/redhat/BUILD/test-1.1/: No such file or directory
error: Bad exit status from /home/uday_koganti/redhat/tmp/rpm-tmp.77791 (%prep)


RPM build errors:
Bad exit status from /home/uday_koganti/redhat/tmp/rpm-tmp.77791 (%prep)
 
Old 06-12-2008, 08:19 AM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by ukbhan View Post
/home/uday_koganti/redhat/tmp/rpm-tmp.77791: line 23: cd: /home/uday_koganti/redhat/BUILD/test-1.1/: No such file or directory
That's because the directory isn't made according to specs. Try this one.

Code:
Name: test
Version: 1
Release: 1
Summary: %{name} prints hello world
Group: Utilities/System
License: GPL
Source: $RPM_SOURCE_DIR/%{name}.c
BuildRoot: %{_tmppath}/%{name}-%{version}
Provides: %{name}

%description
This package contains a "hello world" example binary.

%prep
mkdir %{name}-%{version}.%{release}
cd %{name}-%{version}.%{release}
cp $RPM_SOURCE_DIR/%{name}.c .

%build
cd %{name}-%{version}.%{release}
gcc -o %{name} %{name}.c

%install
cd %{name}-%{version}.%{release}
[ -d $RPM_BUILD_ROOT/usr/local/bin ] || mkdir -p $RPM_BUILD_ROOT/usr/local/bin
install -m 0755 ./test $RPM_BUILD_ROOT/usr/local/bin

%clean
[ "$RPM_BUILD_ROOT" = "%{_tmppath}/%{name}-%{version}.%{release}" ] && rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%attr(755,root,root) /usr/local/bin/%{name}

%changelog
* FILL IN THE DATE SPEC %{packager}
- Initialise .spec file for %{name}-%{ver}.
* Searching the Internet for the document "Maximum RPM" should be beneficial as it will provide the information you need for learning how to build RPMs.
 
Old 06-12-2008, 11:56 PM   #7
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
I have tried the above one also.But still i am getting the below errors.

[uday_koganti@silunx-fc4 SPECS]$ rpmbuild -ba test.spec

Executing(%prep): /bin/sh -e /home/uday_koganti/redhat/tmp/rpm-tmp.48211
+ umask 022
+ cd /home/uday_koganti/redhat/BUILD
+ mkdir test-1.1
+ cd test-1.1
+ cp /home/uday_koganti/redhat/SOURCES/test.c .
+ exit 0
Executing(%build): /bin/sh -e /home/uday_koganti/redhat/tmp/rpm-tmp.48211
+ umask 022
+ cd /home/uday_koganti/redhat/BUILD
+ cd test-1.1
+ gcc -o test test.c
+ exit 0
Executing(%install): /bin/sh -e /home/uday_koganti/redhat/tmp/rpm-tmp.11521
+ umask 022
+ cd /home/uday_koganti/redhat/BUILD
+ cd test-1.1
+ '[' -d /home/uday_koganti/redhat/tmp/test-1/usr/local/bin ']'
+ mkdir -p
mkdir: too few arguments
Try `mkdir --help' for more information.
error: Bad exit status from /home/uday_koganti/redhat/tmp/rpm-tmp.11521 (%install)


RPM build errors:
Bad exit status from /home/uday_koganti/redhat/tmp/rpm-tmp.11521 (%install)
 
Old 06-13-2008, 10:26 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by ukbhan View Post
+ '[' -d /home/uday_koganti/redhat/tmp/test-1/usr/local/bin ']'
+ mkdir -p
mkdir: too few arguments
"too few arguments" means the 'mkdir' command doesn't have any or enough arguments to work on. In the .spec file I defined the line as "[ -d $RPM_BUILD_ROOT/usr/local/bin ] || mkdir -p $RPM_BUILD_ROOT/usr/local/bin". Did you by any chance not copy it completely?
 
Old 06-14-2008, 12:13 AM   #9
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
It's working now.I got the desired output.I am highly thankful to you for helping me through this forum.
 
Old 06-14-2008, 05:11 AM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
You're welcome.
BTW, could you tell me if the problem was with copying the line right or something else?
And if something else post the fix?
Thanks in advance.
 
Old 06-15-2008, 11:35 PM   #11
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
yes,i had not copied it completely.
 
Old 06-16-2008, 01:49 AM   #12
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
I had created the source rpm and the binary rpm successfully.
But after that i tried to install the binary rpm by giving the command

rpm -ivh test-1-1.i386.rpm

it,s giving an error saying

error: can't create transaction lock on /var/lib/rpm/__db.000


how to get rid of this error
 
Old 06-16-2008, 02:05 AM   #13
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
I had tried to install the source rpm package by giving the command

rpm -i test-1-1.src.rpm

It ran successfully.

but when i tried to uninstall the source rpm package by giving the command

rpm -e test

or

rpm -e test-1-1.src.rpm
it's giving an error saying that

error: package program-1-1.src.rpm is not installed


how to get rid of the above errors while installing and uninstalling the rpm package
 
Old 06-16-2008, 03:10 AM   #14
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by ukbhan View Post
error: can't create transaction lock on /var/lib/rpm/__db.000
See if there are other (background?) processes using the RPMDB, like Yumsd, and (temporarily) stop them before you try again.


Quote:
Originally Posted by ukbhan View Post
when i tried to uninstall the source rpm package by giving the command rpm -e test or rpm -e test-1-1.src.rpm it's giving an error saying that error: package program-1-1.src.rpm is not installed
The command 'rpm -e test' is to uninstall an installed package named "test". Uninstalling using the format 'rpm -e test-1-1.src.rpm' is an error because that references a file, a package archive and not a package known to the RPMDB. The only times you use extensions like ".rpm" or ".src.rpm" is to query them (-p) or install them. Source packages are not "installed" (not known in the RPMDB) but unpacked to the RPM tree (see ~/.rpmrc or if root, the default /usr/src/redhat). Since .src.rpms are not installed, to uninstall them you must remove the contents manually.
 
Old 06-16-2008, 04:25 AM   #15
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
when i install rpm binary package ,
by giving the command

rpm -ivh test-1-1.i386.rpm

i got the error initially.
error: can't create transaction lock on /var/lib/rpm/__db.000

Now it is solved. But even then i am getting a new error as follows

error: failed to stat ./new: No such file or directory



how to get rid of this error
 
  


Reply



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
rpm spec file help AutoC Fedora 3 01-30-2008 08:25 AM
Wrote spec file, installed RPM, binary gives relocation error and refers to build dir hollywoodb Red Hat 2 05-19-2007 10:27 AM
rpm spec file alrawab Linux - General 2 03-28-2007 06:39 AM
RPM Spec file adddy Linux - Software 8 11-07-2006 05:02 AM
RPM Spec file creation: %file section question davidas Linux - Newbie 0 03-16-2004 10:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:26 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
Open Source Consulting | Domain Registration