Bug 476240 - Install problem: Invalid cross-device link
Summary: Install problem: Invalid cross-device link
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: gawk
Version: rawhide
Hardware: x86_64
OS: Linux
low
high
Target Milestone: ---
Assignee: Stepan Kasal
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-12-12 17:05 UTC by Horst H. von Brand
Modified: 2009-02-27 17:15 UTC (History)
3 users (show)

Fixed In Version: gawk-3.1.6-4.fc11.x86_64
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2009-02-27 17:15:23 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Horst H. von Brand 2008-12-12 17:05:45 UTC
Description of problem:
Trying to update gawk today I got:

  # rpm -Uhv /var/cache/yum/rawhide/packages/gawk-3.1.6-3.fc11.x86_64.rpm 
  Preparing...                ########################################### [100%]
     1:gawk                   ########################################### [100%]
  error: unpacking of archive failed on file /bin/pgawk-3.1.6a;494298a6: cpio: link failed - Invalid cross-device link

Version-Release number of selected component (if applicable):
gawk-3.1.6-3.fc11.x86_64

How reproducible:
Always I try to update ;-)

Steps to Reproduce:
1. (See above)
2.
3.
  
Actual results:
Error; package isn't installed

Expected results:
Installed package

Additional info:
Here /usr is another partition

Comment 1 Valdis Kletnieks 2008-12-14 07:18:45 UTC
Yes, I got bit by this too, because /usr is a separate partition here too. (Our local standards say /usr/share, /usr/local, and /usr/src should *also* be separate if feasible)

Comment 2 Michal Jaegermann 2008-12-20 22:32:23 UTC
Any chance to see that blatant spec file hiccup fixed?  It is enough to replace a hardlink with a symlink. So far even on koji the latest package is gawk-3.1.6-3.fc11 from 2008-12-11 14:17:53

Comment 3 Horst H. von Brand 2009-01-04 00:57:51 UTC
I just looked at the spec file, finding nothing fishy. But looking at the RPM I see:

  $ rpm2cpio gawk-3.1.6-3.fc11.x86_64.rpm | cpio -tv | grep pgawk
  3936 blocks
  -rw-r--r--   2 root     root        25837 Jan  3 21:17 ./usr/share/man/man1/pgawk.1.gz
  -rwxr-xr-x   2 root     root            0 Jan  3 21:17 ./bin/pgawk-3.1.6a
  -rwxr-xr-x   2 root     root       360800 Jan  3 21:17 ./usr/bin/pgawk

So it installs pgawk into /usr/bin, and tries to link /bin/pgawk-3.1.6a to it. But I just can't see where it is doing that. Makefile.am (after "rpmbuild -bp") contains:

  install-exec-hook:
        (cd $(DESTDIR)$(bindir); \
        $(LN) gawk$(EXEEXT) gawk-$(VERSION)$(EXEEXT) 2>/dev/null ; \
        $(LN) pgawk$(EXEEXT) pgawk-$(VERSION)$(EXEEXT) 2>/dev/null ; \
        if [ ! -f awk$(EXEEXT) ]; \
        then    $(LN_S) gawk$(EXEEXT) awk$(EXEEXT); \
        fi; exit 0)

I don't see how this can give the bizarre situation above. Building gawk myself, the "rpmbuild -ba" output contains:

  make[2]: Entering directory `/home/vonbrand/RPM/BUILD/gawk-3.1.6'
  test -z "/bin" || /bin/mkdir -p "/home/vonbrand/RPM/BUILDROOT/gawk-3.1.6-3.fc11.x86_64/bin"
    ./install-sh -c 'gawk' '/home/vonbrand/RPM/BUILDROOT/gawk-3.1.6-3.fc11.x86_64/bin/gawk'
    ./install-sh -c 'pgawk' '/home/vonbrand/RPM/BUILDROOT/gawk-3.1.6-3.fc11.x86_64/bin/pgawk'
  make 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' 'LDFLAGS=-export-dynamic' 
  install-exec-hook
  make[3]: Entering directory `/home/vonbrand/RPM/BUILD/gawk-3.1.6'
  (cd /home/vonbrand/RPM/BUILDROOT/gawk-3.1.6-3.fc11.x86_64/bin; \
        ln gawk gawk-3.1.6a 2>/dev/null ; \
        ln pgawk pgawk-3.1.6a 2>/dev/null ; \
        if [ ! -f awk ]; \
        then    ln -s gawk awk; \
        fi; exit 0)

I fail to see how this sets up the reported mess.

Comment 4 Michal Jaegermann 2009-01-04 03:31:35 UTC
> I fail to see how this sets up the reported mess.

Just look at the spec file.  It does 

rm -f $RPM_BUILD_ROOT/bin/{,p}gawk-%{version} $RPM_BUILD_ROOT%{_infodir}/dir

to avoid the issue.  The trouble is that it is very specific and you just produced gawk-3.1.6a and pgawk-3.1.6a where %{version} is 3.1.6. If the line in question would be

rm -f $RPM_BUILD_ROOT/bin/{,p}gawk-* ....

then nothing bad would happen.  I rebuild the package with that modification and clearly that installs just fine.

Comment 5 Valdis Kletnieks 2009-01-04 05:23:56 UTC
Umm... Guys?  The problem here is that $RPM_BUILD_ROOT is almost certainly one filesystem, so you can hardlink ln $BUILDROOT/usr/bin/awk and $BUILDROOT/bin/awk because they're on the same file system.

The *PROBLEM* starts when you try to then *install* that on a system that has a / partition and a separate /usr partition.

$ rpm2cpio gawk-3.1.6-3.fc11.x86_64.rpm | cpio -tv | grep pgawk
...
  -rwxr-xr-x   2 root     root            0 Jan  3 21:17 ./bin/pgawk-3.1.6a
  -rwxr-xr-x   2 root     root       360800 Jan  3 21:17 ./usr/bin/pgawk

See that '2 links'? That *will lose* if ./bin and ./usr/bin end up on different filesystems.

Comment 6 Michal Jaegermann 2009-01-04 18:06:28 UTC
> Umm... Guys?  The problem here is that $RPM_BUILD_ROOT is almost certainly one
> filesystem, so you can hardlink ...

Yes, precisely.  I have / and /usr as separate file systems and I eventually got bored waiting for a fixed packages of gawk.  So I rebuild the src.rpm in question with a modification described in comment #4.  If I do now 'rpm -qlv | grep /bin/' then I see:

           4 Dec 28 15:36 /bin/awk -> gawk          
      360800 Dec 28 15:36 /bin/gawk
          14 Dec 28 15:36 /usr/bin/awk -> ../../bin/gawk
          14 Dec 28 15:36 /usr/bin/gawk -> ../../bin/gawk 
        3091 Dec 28 15:36 /usr/bin/igawk
      360800 Dec 28 15:36 /usr/bin/pgawk

with all link counts at 1.  Exactly like in older gawk packages.  Try for yourself.

Comment 7 Horst H. von Brand 2009-02-27 17:15:23 UTC
gawk-3.1.6-4.fc11.x86_64 fixed this.


Note You need to log in before you can comment on or make changes to this bug.