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-16-2008, 04:41 AM   #16
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: failed to stat ./new: No such file or directory
Note that in post #3, under "Conventions" I already told you that a RPM should not execute processes trivially during install. Running 'test', when not explicitly advertised, is unexpcted behaviour that compromises the trust we put in packaging. Besides that the name 'test' could lead to unexpected results since on default installation there already is a 'test' binary (see '[', ']', 'test'). So you really should correct your mistakes, uninstall the "test" package, rename it and the .spec file and the binary to "mypackage" or something like that before continuing.

That said, and provided you have the package "test-1-1.i386.rpm" still installed, post:
- the output of 'rpm -ql test 2>&1',
- 'rpm -q --scripts test 2>&1'
- contents of your test .spec file.

Post complete information and output and do not leave out any details.
 
Old 06-16-2008, 06:03 AM   #17
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
here are the details.
I have changed the name from test to sample.

sample.spec file is


Name: sample
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 ./sample $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}.

rpmbuild -ba sample.spec gave output has



Executing(%prep): /bin/sh -e /home/uday_koganti/redhat/tmp/rpm-tmp.22506
+ umask 022
+ cd /home/uday_koganti/redhat/BUILD
+ cd sample-1.1
+ cp /home/uday_koganti/redhat/SOURCES/sample.c .
+ exit 0
Executing(%build): /bin/sh -e /home/uday_koganti/redhat/tmp/rpm-tmp.22506
+ umask 022
+ cd /home/uday_koganti/redhat/BUILD
+ cd sample-1.1
+ gcc -o sample sample.c
+ exit 0
Executing(%install): /bin/sh -e /home/uday_koganti/redhat/tmp/rpm-tmp.22506
+ umask 022
+ cd /home/uday_koganti/redhat/BUILD
+ cd sample-1.1
+ '[' -d /home/uday_koganti/redhat/tmp/sample-1/usr/local/bin ']'
+ install -m 0755 ./sample /home/uday_koganti/redhat/tmp/sample-1/usr/local/bin
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip
+ /usr/lib/rpm/brp-strip-static-archive
+ /usr/lib/rpm/brp-strip-comment-note
Processing files: sample-1-1
Provides: sample
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: libc.so.6 libc.so.6(GLIBC_2.0)
Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/uday_koganti/redhat/tmp/sample-1
Wrote: /home/uday_koganti/redhat/SRPMS/sample-1-1.src.rpm
Wrote: /home/uday_koganti/redhat/RPMS/i386/sample-1-1.i386.rpm
Executing(%clean): /bin/sh -e /home/uday_koganti/redhat/tmp/rpm-tmp.22506
+ umask 022
+ cd /home/uday_koganti/redhat/BUILD
+ '[' /home/uday_koganti/redhat/tmp/sample-1 = /home/uday_koganti/redhat/tmp/sample-1.1 ']'
+ exit 0


Now if we try to install by giving the command rpm -ivh sample-1-1.i386.rpm it is giving
an error as follows

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

If we login as a root user and try to install by giving the command rpm -ivh sample-1-1.i386.rpm it is giving output as follows

error: failed to stat ./new: No such file or directory
Preparing... ########################################### [100%]
1:sample ########################################### [100%]






And finally the ouput of 'rpm -ql sample 2>&1' is

/usr/local/bin/sample


And if we type rpm -q --scripts sample 2>&1

it is printing nothing.It is also not giving any errors.The cursor is just coming to the next line.



So now i want you to solve two errors.

1)if i login with my own user account instead of root and try to install the binary package , i am getting the error as

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


2)if i login as a root user and try to install the binary package , i am getting the error as

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



And one more small confirmation i need from ur side.
Is it mandatory to login as a root user inorder to install or uninstall the binary rpm packages?
 
Old 06-16-2008, 07:09 AM   #18
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
Now if we try to install by giving the command rpm -ivh sample-1-1.i386.rpm it is giving an error as follows
error: can't create transaction lock on /var/lib/rpm/__db.000
That's not an error. You must be root account user (or be allowed to use sudo) to install packages.


Quote:
Originally Posted by ukbhan View Post
If we login as a root user and try to install by giving the command rpm -ivh sample-1-1.i386.rpm it is giving output as follows
error: failed to stat ./new: No such file or directory
Preparing... ########################################### [100%]
1:sample ########################################### [100%]
So the install runs OK. I can't see where the reference to the item called "new" comes from.
- Uninstall the sample package. List your installed packages ('rpm -q test') and see if there's any "test" package left to uninstall.
- If there is none, list the database contents: 'rpm -q --dump|grep -i new' and post the output.
- If there is none, try running 'rpm -i -v -v -v sample-1-1.i386.rpm' and post the output.


Quote:
Originally Posted by ukbhan View Post
And if we type rpm -q --scripts sample 2>&1
it is printing nothing.It is also not giving any errors.The cursor is just coming to the next line.
That is good.


Quote:
Originally Posted by ukbhan View Post
So now i want you to solve two errors.
Please be careful how you ask for assistance. Try "Can you help me solve these two errors please?".
 
Old 06-17-2008, 12:14 AM   #19
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
I am extremely sorry for not asking your help in a pleasing manner.Here after i shall not do like that.I kindly request you to forgive me.

The output for rpm -i -v -v -v sample-1-1.i386.rpm is as follows

D: ============== sample-1-1.i386.rpm
D: Expected size: 4007 = lead(96)+sigs(180)+pad(4)+data(3727)
D: Actual size: 4007
D: sample-1-1.i386.rpm: Header SHA1 digest: OK (ee890b5b9b93855567066b620631b30d a3a4c7c9)
D: added binary package [0]
D: found 0 source and 1 binary packages
D: opening db environment /var/lib/rpm/Packages joinenv
D: opening db index /var/lib/rpm/Packages rdonly mode=0x0
D: locked db index /var/lib/rpm/Packages
D: ========== +++ sample-1-1 i386/linux 0x1
D: opening db index /var/lib/rpm/Depends create mode=0x0
D: opening db index /var/lib/rpm/Providename rdonly mode=0x0
D: opening db index /var/lib/rpm/Pubkeys rdonly mode=0x0
D: read h# 334 Header sanity check: OK
D: ========== DSA pubkey id b44269d0 4f2a6fd2 (h#334)
D: read h# 183 Header V3 DSA signature: OK, key ID 4f2a6fd2
D: Requires: libc.so.6 YES (db provides)
D: Requires: libc.so.6(GLIBC_2.0) YES (db provides)
D: Requires: rpmlib(CompressedFileNames) <= 3.0.4-1 YES (rpmlib provides )
D: Requires: rpmlib(PayloadFilesHavePrefix) <= 4.0-1 YES (rpmlib provides )
D: opening db index /var/lib/rpm/Conflictname rdonly mode=0x0
D: closed db index /var/lib/rpm/Pubkeys
D: closed db index /var/lib/rpm/Depends
D: closed db index /var/lib/rpm/Conflictname
D: closed db index /var/lib/rpm/Providename
D: closed db index /var/lib/rpm/Packages
D: closed db environment /var/lib/rpm/Packages
D: ========== recording tsort relations
D: ========== tsorting packages (order, #predecessors, #succesors, tree, depth, breadth)
D: 0 0 0 0 1 0 +sample-1-1.i386
D: installing binary packages
D: opening db environment /var/lib/rpm/Packages joinenv
D: opening db index /var/lib/rpm/Packages create mode=0x42
D: mounted filesystems:
D: i dev bsize bavail iavail mount point
error: failed to stat ./new: No such file or directory
D: sanity checking 1 elements
D: opening db index /var/lib/rpm/Name create mode=0x42
D: running pre-transaction scripts
D: computing 1 file fingerprints
Preparing packages for installation...
D: computing file dispositions
D: opening db index /var/lib/rpm/Basenames create mode=0x42
D: ========== +++ sample-1-1 i386-linux 0x1
D: Expected size: 4007 = lead(96)+sigs(180)+pad(4)+data(3727)
D: Actual size: 4007
D: sample-1-1: Header SHA1 digest: OK (ee890b5b9b93855567066b620631b30da3a4c7c9)
D: install: sample-1-1 has 1 files, test = 0
sample-1-1
D: ========== Directories not explicitly included in package:
D: 0 /usr/local/bin/
D: ==========
D: fini 100755 1 ( 0, 0) 4582 /usr/local/bin/sample;48574678
GZDIO: 1 reads, 4844 total bytes in 0.000127 secs
D: +++ h# 931 Header SHA1 digest: OK (ee890b5b9b93855567066b620631b30da3a4 c7c9)
D: adding "sample" to Name index.
D: adding "sample" to Basenames index.
D: opening db index /var/lib/rpm/Group create mode=0x42
D: adding "Utilities/System" to Group index.
D: opening db index /var/lib/rpm/Requirename create mode=0x42
D: adding 4 entries to Requirename index.
D: opening db index /var/lib/rpm/Providename create mode=0x42
D: adding 2 entries to Providename index.
D: opening db index /var/lib/rpm/Dirnames create mode=0x42
D: adding "/usr/local/bin/" to Dirnames index.
D: opening db index /var/lib/rpm/Requireversion create mode=0x42
D: adding 4 entries to Requireversion index.
D: opening db index /var/lib/rpm/Provideversion create mode=0x42
D: adding 2 entries to Provideversion index.
D: opening db index /var/lib/rpm/Installtid create mode=0x42
D: adding 1 entries to Installtid index.
D: opening db index /var/lib/rpm/Sigmd5 create mode=0x42
D: adding 1 entries to Sigmd5 index.
D: opening db index /var/lib/rpm/Sha1header create mode=0x42
D: adding "ee890b5b9b93855567066b620631b30da3a4c7c9" to Sha1header index.
D: opening db index /var/lib/rpm/Filemd5s create mode=0x42
D: adding 1 entries to Filemd5s index.
D: opening db index /var/lib/rpm/Triggername create mode=0x42
D: running post-transaction scripts
D: closed db index /var/lib/rpm/Filemd5s
D: closed db index /var/lib/rpm/Sha1header
D: closed db index /var/lib/rpm/Sigmd5
D: closed db index /var/lib/rpm/Installtid
D: closed db index /var/lib/rpm/Provideversion
D: closed db index /var/lib/rpm/Requireversion
D: closed db index /var/lib/rpm/Dirnames
D: closed db index /var/lib/rpm/Triggername
D: closed db index /var/lib/rpm/Providename
D: closed db index /var/lib/rpm/Requirename
D: closed db index /var/lib/rpm/Group
D: closed db index /var/lib/rpm/Basenames
D: closed db index /var/lib/rpm/Name
D: closed db index /var/lib/rpm/Packages
D: closed db environment /var/lib/rpm/Packages
D: May free Score board((nil))


And the output for rpm -q --dump|grep -i new is

rpmq: no arguments given for query


It is not listing out the contents of the database.I think there is something wrong in the expression.
 
Old 06-17-2008, 04:07 AM   #20
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Code:
D: sanity checking 1 elements
D: computing 1 file fingerprints
D: adding 1 entries to Filemd5s index.
Your output of 'rpm -i -v -v -v sample-1-1.i386.rpm' shows there's just one file in the package, which is good. You listed the .spec file before and it shows there you didn't use any scripts, which is good. Still the "error: failed to stat ./new: No such file or directory" warning is shown, so something must have gone wrong earlier. Try removing the temp files: 'rm -f /var/lib/rpm/__db.00?', then try again. If it still shows the warning you don't need to post the output.


Quote:
rpmq: no arguments given for query
Yes, try 'rpm -qa --dump|grep -i new'.
 
Old 06-17-2008, 06:00 AM   #21
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
I have removed the temp files.But it still shows the warning.

And the output for rpm -qa --dump|grep -i new is very huge number of lines.Shall i post it ?
 
Old 06-17-2008, 06:36 AM   #22
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
And the output for rpm -qa --dump|grep -i new is very huge number of lines.Shall i post it ?
No thanks. Let's try Something Completely Different:


Quote:
Originally Posted by ukbhan View Post
I have removed the temp files.But it still shows the warning.
OK, one final thing to try and that's a rebuild of the RPMDB:
0. Be root.
1. Make a backup of the original database so it can be restored: 'tar --xattrs -c -f /var/lib/rpm_original.tar /var/lib/rpm && echo OK || echo "FAILED ($?)".
* If it doesn't return "OK" for whatever reason don't proceed but post the errors.
2. Run 'rpm -v --rebuilddb >/var/lib/rpm_rebuilddb.log 2>&1'. Output is directed to a log (use 'tail -f /var/lib/rpm_rebuilddb.log' to see what's going on while it's running).
* This operation may take a while.
3. When finished, check the log for errors.
4. If no errors try the sample rpm again.
 
Old 06-18-2008, 12:13 AM   #23
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
Instead that i had done freshly on a new unix machine.It's working now.I heartfully thank you for providing your assistance continuously.
 
Old 06-18-2008, 10:38 AM   #24
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.

If you find the time do try a 'rpm --rebuilddb', because now you don't know if it would have fixed it plus it's good to practice troubleshooting and recovery.
 
Old 06-18-2008, 11:42 PM   #25
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
i kindly request you to solve one more new issue.

Intially there was a sample.c sourcefile which prints "hello world".
We have written sample.spec file to create source and binary rpm packages.
The corresponding source package is sample-1-1.src.rpm and
the corresponding binary package is sample-1-1.i386.rpm.


Now the sample.c source file is modified to print "how are you".
Also I have modified the Version and Release to 2 in the sample.spec file.
So now i have created the source package sample-2-2.src.rpm
and binary package sample-2-2.i386.rpm.

I had first installed the sample-1-1.i386.rpm and run it.
It prints "hello world".

Next i had updated the sample-1-1.i386.rpm with sample-2-2.i386.rpm.
It should print "how are you".

But it is not doing so.It's printing "hello world " only.

The content of /usr/local/bin/sample is "hello world".It's not getting updated to "how are you".


could u please suggest where i have gone wrong ?
 
Old 06-19-2008, 06:25 PM   #26
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Could you list (rpm -ql) the contents of both packages?
What does 'rpm -qf /usr/local/bin/sample' return?
 
Old 06-20-2008, 02:28 AM   #27
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
i got my issue solved.i havent placed the spec file in the right directory on this new unix machine.

Intially we have packed only one sample.c file.Now i want to pack say 5 files.let them be sample1.c ,sample2.c,sample3.c,sample4.c,sample5.c.

where should i make changes in my spec file?
I kindly request you to post how should my complete spec file look or else
what changes should i make to my previous spec file.



In general what would be the timelines for packing 5files ,25 files and 100 files?
 
Old 06-20-2008, 08:24 AM   #28
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
Also the 5 files may not be .c files.
2 of them be .c files
2 of them be .txt files
1 of them be a directory containing .h file.

Please kindly post me how to write a spec file inorder to pack the above mentioned source files.
 
Old 06-20-2008, 10:26 AM   #29
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 amount of source files really does not matter, though it is easier to keep them together in a %source0 tarball, else you'll have to specify them all separately like %source0, %source1, %source2, etc cetera. The amount of %files really does not matter, what matters is how you install them. If you use a "makefile install" type of install it's easier to just output with something like
Code:
find $RPM_BUILD_DIR -not -type d -printf "%%attr(%m,root,root) %p\n"
, else you'll have to specify installs manually or succumb to %files globbing like "/usr/share/packagename/*".

In short: make source tarball, make install script and use that in your .spec. Try it and post errors if any.
 
Old 06-21-2008, 05:38 AM   #30
ukbhan
LQ Newbie
 
Registered: Jun 2008
Posts: 26

Original Poster
Rep: Reputation: 15
i have created the source tarball sample.tar containing 5 files sample1.c,sample2.c,sample3.c,sample4.c,sample5.c .These files prints different outputs.

But i am stuck up in writing the make install script.I havent ever written it before.My experience on linux is just 2 months.So i kindly request you to post how my make install script looks like so that i can Know exactly how to write the install scripts.I have googled a lot to write the makeinstall script.But it seems difficult to me to put it into practice for my program.
 
  


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 10:16 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