LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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-22-2008, 06:14 PM   #31
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529

Quote:
Originally Posted by ukbhan View Post
i have created the source tarball sample.tar containing 5 files sample1.c,sample2.c,sample3.c,sample4.c,sample5.c.
Expanding your .spec file in post #17 you could change it to this:
Code:
%install
cd %{name}-%{version}.%{release}
[ -d $RPM_BUILD_ROOT/usr/local/bin ] || mkdir -p $RPM_BUILD_ROOT/usr/local/bin
for BIN in sample1 sample2 sample3 sample4 sample5; do
 install -m 0755 ./$BIN $RPM_BUILD_ROOT/usr/local/bin
done
and I think that's the easiest for now. A Makefile could look something like this:
Code:
CC	= gcc
CFLAGS	= -O2
BIN	= /usr/local/bin
all:	sample1 sample2 sample3 sample4 sample5

sample1:   sample1.c
	${CC} ${CFLAGS} $@ sample1.c
	@strip $@

sample2:   sample2.c
	${CC} ${CFLAGS} $@ sample2.c
	@strip $@

sample3:   sample3.c
	${CC} ${CFLAGS} $@ sample3.c
	@strip $@

sample4:   sample4.c
	${CC} ${CFLAGS} $@ sample4.c
	@strip $@

sample5:   sample5.c
	${CC} ${CFLAGS} $@ sample5.c
	@strip $@
clean:
	rm -f sample1 sample2 sample3 sample4 sample5 

install:
	cp sample1 $(BIN)/sample1
	cp sample2 $(BIN)/sample2
	cp sample3 $(BIN)/sample3
	cp sample4 $(BIN)/sample4
	cp sample5 $(BIN)/sample5
Under %build you could then issue "make all" and under %install "make install". Should adjust the paths though.
 
Old 06-23-2008, 01:08 AM   #32
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
I kindly request you to post what changes should be made in %prep and %build sections of my spec file.I tried to insert "for loop" accordingly in those sections.But i think i am going wrong in the syntax part.It showing errors in the lines "cp $RPM_SOURCE_DIR/%{name}.c" of the %prep section and "gcc -o %{name} %{name}.c" fo the %build section.
 
Old 06-23-2008, 02:51 AM   #33
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Please always post your .spec file in full and always post the contents of the .tmp file errors occur in, if any.
 
Old 06-23-2008, 05:17 AM   #34
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
This is my spec file.

Name: sample
Version: 1
Release: 1
Summary: %{name} prints differnt outputs
Group: Utilities/System
License: GPL
Source: $RPM_SOURCE_DIR/%{name}.tar
BuildRoot: %{_tmppath}/%{name}-%{version}
Provides: %{name}

%description
This package contains a different output example binaries.

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


%build
cd %{name}-%{version}.%{release}
for GCC in sample1 sample2 sample3 sample4 sample5;do
gcc -o %{name} $GCC.c
done

%install
cd %{name}-%{version}.%{release}
[ -d $RPM_BUILD_ROOT/usr/local/bin ] || mkdir -p $RPM_BUILD_ROOT/usr/local/bin
for BIN in sample1 sample2 sample3 sample4 sample5; do
install -m 0755 ./$BIN $RPM_BUILD_ROOT/usr/local/bin
done

%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}.



when i run

[root@rhel4rac2 SPECS]# rpmbuild -ba sample.spec
the output is as follows

Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.73597
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd sample-1.1
+ cp /usr/src/redhat/SOURCES/sample.tar .
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.73597
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd sample-1.1
+ for GCC in sample1 sample2 sample3 sample4 sample5
+ gcc -o sample sample1.c
+ for GCC in sample1 sample2 sample3 sample4 sample5
+ gcc -o sample sample2.c
+ for GCC in sample1 sample2 sample3 sample4 sample5
+ gcc -o sample sample3.c
+ for GCC in sample1 sample2 sample3 sample4 sample5
+ gcc -o sample sample4.c
+ for GCC in sample1 sample2 sample3 sample4 sample5
+ gcc -o sample sample5.c
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.82321
+ umask 022
+ cd /usr/src/redhat/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd sample-1.1
+ '[' -d /var/tmp/sample-1/usr/local/bin ']'
+ for BIN in sample1 sample2 sample3 samplee4 sample5
+ install -m 0755 ./sample1 /var/tmp/sample-1/usr/local/bin
install: cannot stat `./sample1': No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.82321 (%install)


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

and the contents of /var/tmp/rpm-tmp.82321 file are

#!/bin/sh

RPM_SOURCE_DIR="/usr/src/redhat/SOURCES"
RPM_BUILD_DIR="/usr/src/redhat/BUILD"
RPM_OPT_FLAGS="-O2 -g -pipe -m32 -march=i386 -mtune=pentium4"
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="sample"
RPM_PACKAGE_VERSION="1"
RPM_PACKAGE_RELEASE="1"
export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE
RPM_BUILD_ROOT="/var/tmp/sample-1"
export RPM_BUILD_ROOT


set -x
umask 022
cd /usr/src/redhat/BUILD
LANG=C
export LANG
unset DISPLAY

cd sample-1.1
[ -d $RPM_BUILD_ROOT/usr/local/bin ] || mkdir -p $RPM_BUILD_ROOT/usr/local/bin
for BIN in sample1 sample2 sample3 sample4 sample5; do
install -m 0755 ./$BIN $RPM_BUILD_ROOT/usr/local/bin
done





/usr/lib/rpm/redhat/brp-compress
/usr/lib/rpm/redhat/brp-strip /usr/bin/strip
/usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
/usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump

~
 
Old 06-23-2008, 06:16 AM   #35
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
It's probably due to the prep stage 'n such not conforming to standards. Try this, should work "better":

0. Make sure the contents of your %{name}.tar.gz tarball get listed as:
Code:
sample-1.1/sample1.c
sample-1.1/sample2.c
sample-1.1/sample3.c
sample-1.1/sample4.c
sample-1.1/sample5.c
1. Use this .spec file:
Code:
%define debug_packages	%{nil}
%define debug_package %{nil}
Name: sample
Version: 1
Release: 1
Summary: %{name} prints differnt outputs
Group: Utilities/System # See /usr/share/docs/rpm-*/GROUPS
License: GPL
Source: $RPM_SOURCE_DIR/%{name}-%{version}.%{release}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}.%{release}
Provides: %{name}
Vendor: none

%description
This package contains a different output example binaries.

%prep

%setup -n %{name}-%{version}.%{release}

%build
for n in $(seq 1 5); do
	gcc -o %{name}${n} %{name}${n}.c
done

%install
[ -d $RPM_BUILD_ROOT/tmp ] || mkdir -p $RPM_BUILD_ROOT/usr/local/bin
for n in $(seq 1 5); do
	install -m 0755 %{name}${n} $RPM_BUILD_ROOT/usr/local/bin
done

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

%files
%defattr(-,root,root)
%attr(700,root,root) /usr/local/bin/%{name}1
%attr(700,root,root) /usr/local/bin/%{name}2
%attr(700,root,root) /usr/local/bin/%{name}3
%attr(700,root,root) /usr/local/bin/%{name}4
%attr(700,root,root) /usr/local/bin/%{name}5

%changelog
* Mon Jun 23 2008 user -
- Update spec.
Should build OK now.

BTW, I see lines like "cd /usr/src/redhat/BUILD".
Didn't I ask you to build RPMs as unprivileged user?
 
Old 06-23-2008, 10:25 AM   #36
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
It has run successfully.
I have given the command
rpmbuild -ba sample.spec
It has created both binary package and source package in the respective directories.

The name of the binary package is sample-1-1.i386.rpm which is created in /RPMS/i386 directory.

Now i tried to install the package giving the command

rpm -ivh sample-1-1.i386.rpm

It is showing an error saying

error: can't create transaction lock on /var/lock/rpm/transaction


could u please help me in solving this error?
 
Old 06-23-2008, 10:43 AM   #37
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
Originally Posted by ukbhan View Post
error: can't create transaction lock on /var/lock/rpm/transaction
Are you running the command as root? (good)
Is anything holding the lock? (bad)
If yes, what? ('/sbin/fuser /var/lock/rpm/transaction')
Is that a daemon process?
If yes, can it be (temporarily) shut down?
After you shut down any daemons and before you try again do remove the lock.
And please note that if I ask questions I'd like answers too, OK?
 
Old 06-23-2008, 11:29 AM   #38
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
yes ,i am running the command as root.

could you please tell me
how to check whether anything is holding the lock or not?

i have given the command as stated by you

[root@rhel4rac2 i386]# /sbin/fuser /var/lock/rpm/transaction
it has given the output as /var/lock/rpm/transaction: 15499

I havent encountered this error beforea and also i am just a starter in linux.

so could you please post
how to check whether it is a daemon process or not
and if it is a daemon process how to temporarily shut down
and also how to remove the lock
 
Old 06-23-2008, 12:27 PM   #39
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
Originally Posted by ukbhan View Post
could you please tell me how to check whether anything is holding the lock or not?
Yeah, I forgot to finish that off. You already did the checking by running '/sbin/fuser /var/lock/rpm/transaction', the PID is 15499. Now you can either do 'readlink -f /proc/15499/exe; cat -v /proc/15499/cmdline; echo' or '/usr/sbin/lsof -w -n -p 15499' to see what the the process details are. I'm thinking it'll be either something like "up2date" or "yumsd" running in the background or a stray "rpm" that didn't finish somehow. Just post what you find.


Quote:
Originally Posted by ukbhan View Post
and if it is a daemon process how to temporarily shut down and also how to remove the lock
If it is a daemon there'll be a service initialisation script in /etc/init.d/ so you can do for example "/etc/rc.d/init.d/yumsd stop" or "service up2date stop". The lock removal line should be 'rm /var/lock/rpm/transaction'.


BTW, if you don't mind me asking, what's this all for? What are you working on?
 
Old 06-24-2008, 01:06 AM   #40
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
i have done
[root@rhel4rac2 ~]# readlink -f /proc/15499/exe; cat -v /proc/15499/cmdline; echo

The output is

/bin/rpm
rpm^@-ivh^@program-1-1.i386.rpm^@

i have also tried
[root@rhel4rac2 ~]# /etc/rc.d/init.d/yumsd stop

the output is

-bash: /etc/rc.d/init.d/yumsd: No such file or directory

i have also tried
[root@rhel4rac2 ~]# service up2date stop

the output is

up2date: unrecognized service


so i think it is yumsd and up2date service are not running in the background.I think it is the stray "rpm" that didnt finish somehow.Am i correct ?

so could you please post what should i do now?

i have tried it installing again by removing the lock.It's not showing anything.It has strucked.



And all this is because i need to try creating rpms practically on the machine for 1 file, 5 files and 25files and say 100 files and just note the time lines taken to pack these files.
 
Old 06-24-2008, 04:48 AM   #41
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
Originally Posted by ukbhan View Post
The output is

/bin/rpm
rpm^@-ivh^@program-1-1.i386.rpm^@

so i think it is yumsd and up2date service are not running in the background.I think it is the stray "rpm" that didnt finish somehow.Am i correct ?
so could you please post what should i do now?
As root type 'kill -9 15499'. Then verify by the same methods the PID 15499 is gone, then remove the lock. Then 'rm -f /bin/rm -f /var/lib/rpm/__db.00?' and *then* try again.


Quote:
Originally Posted by ukbhan View Post
And all this is because i need to try creating rpms practically on the machine for 1 file, 5 files and 25files and say 100 files and just note the time lines taken to pack these files.
No, it's definately not the "time to pack", it's you being new to building packages and not knowing any system administration (yet).
So far you're doing pretty well I'd say. You might want to look at some generic administration docs like from Red Hat and Rute once you find the time.
 
Old 06-24-2008, 05:34 AM   #42
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
As root i tried to kill by giving the below command

[root@rhel4rac2 /]# kill -9 15499

Then i have verified whether the PID is gone or not .But it's not gone

[root@rhel4rac2 /]# /sbin/fuser /var/lock/rpm/transaction
/var/lock/rpm/transaction: 15499

so it's not getting killed.

could you please post what should i do next inorder to kill this PID and go further?
 
Old 06-24-2008, 06:39 AM   #43
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Is it running suspended (control+z) somewhere in another terminal?

What we need to see if its parent is 1 or not, and if it's not what process it is. Here's a Bash function I use to determine a process parent.
- save this to a file (say "/tmp/f_ppidOf":
Code:
ppidOf() { showproc() { /bin/ps --no-headers ax -eo %C -eoppid,pid,args | awk -v VAR=$REPLY '($3 ~ VAR) {print $1, $3, $4}'; }
 [ -n "$1" ] && { /usr/bin/pgrep -P "$1" | while read; do showproc; pgrep -P $REPLY | while read; do showproc; done; done; }; }
- then source it: 'source /tmp/f_ppidOf'
- then run 'ppidOf 15499' and post the output please.

If the machine allows it and you do not want to muck with his further, then instead you may want to reboot it to get it over with.

Last edited by unSpawn; 06-24-2008 at 06:44 AM.
 
Old 06-24-2008, 07:19 AM   #44
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
i have done as specified above by you.It's printing nothing.It's just coming to the next line.

IT is indicated as below.

[root@rhel4rac2 uday_koganti]# source /tmp/f_ppidOf
[root@rhel4rac2 uday_koganti]# ppidOf 15499
[root@rhel4rac2 uday_koganti]#
 
Old 06-24-2008, 07:33 AM   #45
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
OK. Then we've tried it all and we should move on. Reboot the machine and clean up lock and temp files as described above.
 
  


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


All times are GMT -5. The time now is 11:00 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