Bug 434882

Summary: creation of stage2 breaks relative links -> broken HAL -> no disks
Product: [Fedora] Fedora Reporter: Will Woods <wwoods>
Component: anacondaAssignee: Anaconda Maintenance Team <anaconda-maint-list>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: low    
Version: rawhide   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-03-10 22:10:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Will Woods 2008-02-25 23:40:17 UTC
scripts/upd-instroot does the following:

    (cd $p/bin; find) | (cd $p/bin; /bin/cpio --quiet -pdmu $p/usr/bin)
    (cd $p/sbin; find) | (cd $p/sbin; /bin/cpio --quiet -pdmu $p/usr/sbin)

moving everything from /sbin to /usr/sbin will break any relative symlinks into
/bin or /sbin.. like /usr/bin/udevinfo (which is how HAL discovers devices):
    /usr/bin/udevinfo -> ../../sbin/udevadm
(this was changed 5 days ago for bug #432878)

A simple hack to work around this would be to do:
    ln -sf /sbin/udevadm $p/usr/bin/udevinfo
since we have udev in stage1 these days. On the other hand, here's a bash script
that should fix up the links:

    # Fix relative links like /usr/bin/udevinfo -> ../../sbin/udevadm
    for brokenlink in $(find $p/usr/{bin,sbin} -follow -lname '*'); do
        target="$(readlink $brokenlink)"
        for pathbit in bin sbin; do
            # if it starts with "../../sbin/", remove that
            newtarget="${target##../../$pathbit/}"
            # if we removed something, replace it with the proper path
            if [ "$newtarget" != "$target" ]; then
                # make it ../sbin/ instead
                ln -sf "../$pathbit/$newtarget" "$brokenlink"
            fi
        done
    done

Comment 1 Jeremy Katz 2008-02-26 02:13:08 UTC
Ugh.  Added in git

Comment 2 Will Woods 2008-03-10 22:10:39 UTC
Fixed in current rawhide, AFAICT.