LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   "bad tty" & "file descriptor error" while building RPM on F13 (http://www.linuxquestions.org/questions/linux-software-2/bad-tty-and-file-descriptor-error-while-building-rpm-on-f13-851488/)

gosssamer 12-20-2010 10:48 PM

"bad tty" & "file descriptor error" while building RPM on F13
 
Hi,

I have an FC13 x86_64 server and having trouble building RPMs, but I don't think it's specifically an RPM problem. I think it's a tty management or other type of problem.

When spec files have a "%files -f filelist.txt", which contains the list of files for the RPM, it calls the /usr/lib/check-files script, which sorts the files that are supposed to be in the RPM and compares them with the files that are in the built RPM before they are packaged.

The trouble is that the sort fails. Here's the trace from the check-files script:

+ find /root/rpmbuild/BUILDROOT/sed-4.2.1-5.fc13.x86_64 -type f -o -type l
+ LC_ALL=C
+ sort
+ LC_ALL=C
+ sort
sort: stat failed: -: Bad file descriptor
+ diff -d /tmp/rpmv4Db1s /tmp/rpmPdDsKU

The above doesn't show that the output from sort is redirected into those /tmp files. The first sort succeeds because it reads data sent by the "find" in the same shell. The second sort fails because (I think) it cannot read data from stdin for some reason.

What could possibly cause this? I've checked various permissions, libraries, even used strace extensively, all of which is inconclusive.

This is one of my test server boxes, so this problem is something that I've caused, but I have no idea what.

libc controls input and output, correct? Could it somehow be a glibc problem, or a devpts problem? I can run a simple command and pipe it to sort with no problem. It appears to only be related to sub-shells.

I also replaced sort with cat and just tried to redirect stdin in that file to a temporary file, and that also fails.

I've tried running it with selinux disabled and that has no effect.

Ideas greatly appreciated.
Thanks,
Alex

kbp 12-21-2010 04:24 PM

Where are you placing filelist.txt ?

gosssamer 12-22-2010 08:20 PM

Quote:

Originally Posted by kbp (Post 4199306)
Where are you placing filelist.txt ?

Hi,

The filelist in this case is "sed.lang", which is generated by the sed.spec %find_lang %{name} macro, and it contains lines like:

Code:

%lang(pt) /usr/share/locale/pt/LC_MESSAGES/sed.mo
%lang(ko) /usr/share/locale/ko/LC_MESSAGES/sed.mo

The whole %files -f %{name}.lang section is as follows:

Code:

%files -f %{name}.lang
%defattr(-,root,root)
%doc BUGS NEWS THANKS README AUTHORS sedfaq.txt.gz COPYING COPYING.DOC
%{_bindir}/sed
%{_infodir}/*.info*
%{_mandir}/man*/*

So I assume it expands these macros to create the temp files that are created by /usr/lib/rpm/check-files:

Code:

FILES_DISK=`mktemp $TMPDIR/rpmXXXXXX`
FILES_RPM=`mktemp $TMPDIR/rpmXXXXXX`

find $RPM_BUILD_ROOT -type f -o -type l | LC_ALL=C sort > $FILES_DISK
LC_ALL=C sort > $FILES_RPM

I assume the second sort receives its data from stdin passed to it by rpm, sorts them, then redirects it to a temporary file before comparing with the actual list from the files on the disk. Is this correct?

I really could use some help. I'd really hate to lose this whole system. I could end up reinstalling and making the same mistake again..

Thanks,
Alex

unSpawn 12-23-2010 11:33 AM

For some reason (might be http://docs.fedoraproject.org/drafts...n/ch09s05.html can't remember) I'm using "%{_tmppath}" as in '%files -f %{_tmppath}/%{name}_filessection'?

gosssamer 12-23-2010 12:36 PM

Quote:

Originally Posted by unSpawn (Post 4201287)
For some reason (might be http://docs.fedoraproject.org/drafts...n/ch09s05.html can't remember) I'm using "%{_tmppath}" as in '%files -f %{_tmppath}/%{name}_filessection'?

Hi, thanks for your help. This can't be the problem because the files aren't stored in /var/tmp:

Processing files: sed-4.2.1-5.fc13.x86_64
error: Could not open %files file /var/tmp/sed.lang: No such file or directory

It's not having a problem finding the files because when it is left as "%files -f %{name}.lang" it proceeds, but when using %{_tmppath} it quits, as shown above.

When compiling the bash SRPM, I receive a message like:

Code:

+ echo /home/alex/rpmbuild/BUILDROOT/bash-4.1.7-1.x86_64/usr/share/man/man1/ulimit.1.gz
+ sed -e 's#^/home/alex/rpmbuild/BUILDROOT/bash-4.1.7-1.x86_64#  #g'
sed: couldn't flush stdout: Broken pipe

This is from the check for unpackaged files (/usr/lib/rpm/check-files), and I believe it is related. It prints this broken pipe message after every line it processes with sed.

Code:

+ /bin/sort
/bin/sort: stat failed: -: Bad file descriptor
+ diff -d /tmp/rpm60vSB7 /tmp/rpm9boU0c
+ grep '^< '
+ cut -c3-
+ read f
+ echo /root/rpmbuild/BUILDROOT/bash-4.1.7-1.x86_64/bin/bash
+ sed -e 's#^/root/rpmbuild/BUILDROOT/bash-4.1.7-1.x86_64#  #g'
sed: couldn't flush stdout: Broken pipe

I believe this message is related. What could cause this?

How does sed and sort receive the data to stdin from the rpm process?

Thanks,
Alex

unSpawn 12-23-2010 04:11 PM

Interesting. Could you post your complete spec in BB code tags please?

gosssamer 12-23-2010 08:53 PM

2 Attachment(s)
Quote:

Originally Posted by unSpawn (Post 4201522)
Interesting. Could you post your complete spec in BB code tags please?

I found a spec file that fails, and it doesn't have the "%files -f %{name}.lang" and still fails. It's from the rpm-4.8.1 SRPM. I've included the full spec and build log.

I think given that it's the spec included with the rpm package, chances are very good it's not a problem with how the spec is created. Note specifically the sort and "sh: no job control" errors.

Thanks,
Alex

Code:

Summary: hello -- hello, world rpm
Name: hello
Version: 1.0
Release: 1
Group: Utilities
License: GPL
Distribution: RPM test suite.
Vendor: Red Hat Software
Packager: Red Hat Software <bugs@redhat.com>
URL: http://www.redhat.com
Source0: hello-1.0.tar.gz
Excludearch: lsi
Excludeos: cpm
Provides: hi
Conflicts: goodbye
Obsoletes: howdy
Prefix: /usr
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

%description
Simple rpm demonstration.

%prep
%setup -q

%build
make

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/bin
make DESTDIR=$RPM_BUILD_ROOT install

%clean
rm -rf $RPM_BUILD_ROOT

%pre

%post

%preun

%postun

%files
%defattr(-,root,root)
%doc        FAQ
#%readme README
#%license COPYING
%attr(0751,root,root)        /usr/local/bin/hello

%changelog
* Tue Oct 20 1998 Jeff Johnson <jbj@redhat.com>
- create.


Code:

#                            -*- compilation -*-
43. rpmbuild.at:23: testing ...
./rpmbuild.at:25:
rm -rf ${TOPDIR}
as_dir=${TOPDIR}/SOURCES; as_fn_mkdir_p

cp "${abs_srcdir}"/data/SOURCES/hello-1.0.tar.gz ${TOPDIR}/SOURCES

run rpmbuild \
  -ba "${abs_srcdir}"/data/SPECS/hello.spec

stderr:
sh: line 0: fg: no job control
+ umask 022
+ cd /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILD
+ cd /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILD
+ rm -rf hello-1.0
+ /usr/bin/gzip -dc /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/SOURCES/hello-1.0.tar.gz
+ /bin/tar -xf -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd hello-1.0
+ exit 0
+ umask 022
+ cd /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILD
+ cd hello-1.0
+ make
hello.c: In function 'main':
hello.c:4: warning: incompatible implicit declaration of built-in function 'printf'
+ exit 0
+ umask 022
+ cd /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILD
+ cd hello-1.0
+ rm -rf /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILDROOT/hello-1.0-1.x86_64
+ mkdir -p /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILDROOT/hello-1.0-1.x86_64/usr/local/bin
+ make DESTDIR=/home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILDROOT/hello-1.0-1.x86_64 install
+ /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing//usr/lib/rpm/brp-compress
+ /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing//usr/lib/rpm/brp-strip
+ /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing//usr/lib/rpm/brp-strip-static-archive
+ /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing//usr/lib/rpm/brp-strip-comment-note
+ umask 022
+ cd /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILD
+ cd hello-1.0
+ DOCDIR=/home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILDROOT/hello-1.0-1.x86_64/usr/share/doc/hello-1.0
+ export DOCDIR
+ rm -rf /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILDROOT/hello-1.0-1.x86_64/usr/share/doc/hello-1.0
+ /bin/mkdir -p /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILDROOT/hello-1.0-1.x86_64/usr/share/doc/hello-1.0
+ cp -pr FAQ /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILDROOT/hello-1.0-1.x86_64/usr/share/doc/hello-1.0
+ exit 0
sort: stat failed: -: Bad file descriptor
error: Installed (but unpackaged) file(s) found:
  /usr/local/bin/hello
  /usr/share/doc/hello-1.0/FAQ
    Installed (but unpackaged) file(s) found:
  /usr/local/bin/hello
  /usr/share/doc/hello-1.0/FAQ
stdout:
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.UdWceT
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.ep7X3B
make[4]: Entering directory `/usr/src/engarde/community-3.0.24/engarde/BUILD/rpm-4.8.1/tests/testing/build/BUILD/hello-1.0'
cc    hello.c  -o hello
make[4]: Leaving directory `/usr/src/engarde/community-3.0.24/engarde/BUILD/rpm-4.8.1/tests/testing/build/BUILD/hello-1.0'
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.Us7xcl
make[4]: Entering directory `/usr/src/engarde/community-3.0.24/engarde/BUILD/rpm-4.8.1/tests/testing/build/BUILD/hello-1.0'
install -m 0755 hello /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILDROOT/hello-1.0-1.x86_64/usr/local/bin
make[4]: Leaving directory `/usr/src/engarde/community-3.0.24/engarde/BUILD/rpm-4.8.1/tests/testing/build/BUILD/hello-1.0'
Processing files: hello-1.0-1.x86_64
Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.wEYIY4
Provides: hi
Requires(interp): /bin/sh /bin/sh /bin/sh /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(pre): /bin/sh
Requires(post): /bin/sh
Requires(preun): /bin/sh
Requires(postun): /bin/sh
Requires: libc.so.6()(64bit) libc.so.6(GLIBC_2.2.5)(64bit) rtld(GNU_HASH)
Conflicts: goodbye
Obsoletes: howdy
Checking for unpackaged file(s): /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing//usr/lib/rpm/check-files /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing/build/BUILDROOT/hello-1.0-1.x86_64


RPM build errors:
./rpmbuild.at:25: exit code was 1, expected 0
43. rpmbuild.at:23: 43. rpmbuild -ba *.spec (rpmbuild.at:23): FAILED (rpmbuild.at:25)


unSpawn 12-28-2010 05:02 PM

Quote:

Originally Posted by gosssamer (Post 4201651)
Code:

#                            -*- compilation -*-
43. rpmbuild.at:23: testing ...
./rpmbuild.at:25:
(..)
./rpmbuild.at:25: exit code was 1, expected 0
43. rpmbuild.at:23: 43. rpmbuild -ba *.spec (rpmbuild.at:23): FAILED (rpmbuild.at:25)


Apparently you have tried building RPM by hand and because of that helper scripts exist in non-standard directories (/home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/testing//usr/lib/rpm/check-files ?) that may lead to unexpected results. For instance I also see a %buildroot that resolves to "/usr/src/engarde/community-3.0.24/engarde/BUILD/rpm-4.8.1/" somewhere. The output you have shown above means you run all commands from the RPM test suite. More information should be available if you run with the "-dvx" args (see /home/packman/rpmbuild/BUILD/rpm-4.8.1/tests/rpmtests). I wonder if running 'rpmbuild' itself directly builds the package OK (run as 'rpmbuild -vv -bb' for more nfos) and why you are not running rpm-4.8.1-2.fc13.x86_64.rpm because that's what F13 x86_64 comes with?..


All times are GMT -5. The time now is 07:15 PM.