Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 144729 - sys-apps/busybox-1.2.1 nukes its symlinks on every second merge
Summary: sys-apps/busybox-1.2.1 nukes its symlinks on every second merge
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High critical (vote)
Assignee: Embedded Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-22 02:12 UTC by Jaco Kroon
Modified: 2019-04-27 17:37 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
busybox-symlinks.patch (busybox-symlinks.patch,3.76 KB, patch)
2006-08-27 22:54 UTC, SpanKY
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaco Kroon 2006-08-22 02:12:46 UTC
Background:

I'm building an embedded Gentoo armeb-softfloat-linux-uclibc initrd, I've set up an alias called armerge as 'KERNEL_DIR=/home/arm/kernel ROOT=/home/arm/root PORTAGE_CONFIGROOT=/home/arm/portage_conf emerge'.  We're still trying to get the busybox config just right for what we are doing and have found that with every second merge busybox doesn't have any of it's symlinks.  It seems that somewhere during the merge process a check is made whether the target file exists in the system, and if so, the symlink is not installed.  However, when the previous version of busybox gets unmerged it takes the symlinks with, leaving us without them.

Portage 2.1-r2 (default-linux/x86/2005.1, gcc-3.4.6, unavailable, 2.6.17.4 i686)
=================================================================
System uname: 2.6.17.4 i686 AMD Sempron(tm)
Gentoo Base System version 1.12.4
app-admin/eselect-compiler: [Not Present]
dev-lang/python:     2.3.5, 2.4.3-r1
dev-python/pycrypto: 2.0.1-r5
dev-util/ccache:     [Not Present]
dev-util/confcache:  [Not Present]
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r3
sys-devel/gcc-config: 1.3.13-r3
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r2
ACCEPT_KEYWORDS="arm"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-Os"
CHOST="armeb-softfloat-linux-uclibc"
CONFIG_PROTECT="/etc /usr/share/X11/xkb"
CONFIG_PROTECT_MASK="/etc/env.d /etc/gconf /etc/revdep-rebuild /etc/terminfo"
CTARGET="armeb-softfloat-linux-uclibc"
CXXFLAGS="-Os"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict strip"
GENTOO_MIRRORS="http://distfiles.gentoo.org http://distro.ibiblio.org/pub/linux/distributions/gentoo"
MAKEOPTS="-j1"
PKGDIR="/usr/portage/packages"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'"
PORTAGE_TMPDIR="/var/tmp/arm"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="arm acl berkdb bitmap-fonts cli crypt dlloader gpm isdnlog make-symlinks ncurses nptl nptlonly pam pcre pppd readline reflection savedconfig session spl ssl truetype-fonts type1-fonts userlocales xorg zlib elibc_glibc input_devices_keyboard input_devices_mouse input_devices_evdev kernel_linux userland_GNU video_cards_ati video_cards_chips video_cards_dummy video_cards_fbdevglint video_cards_mga video_cards_nv video_cards_s3 video_cards_s3virge video_cards_savage video_cards_sis video_cards_sisusb video_cards_tdfx video_cards_trident video_cards_v4l video_cards_vga video_cards_voodoo"
Unset:  EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS, PORTAGE_RSYNC_EXTRA_OPTS

Hmm, that doesn't list everything you may need, we also set CBUILD=i686-pc-linux-gnu and HOST_CC=${CBUILD}-gcc.

However, the problem seems to be in the ebuild, around lines 218 thru 224 (busybox-1.2.1) the following lines exist:

        local symlink
        for symlink in {,usr/}{bin,sbin}/* linuxrc ; do
            [[ -L ${symlink} ]] || continue
            [[ -e ${ROOT}/${symlink} ]] \
                && eerror "Deleting symlink ${symlink} because it exists in ${ROOT}" \
                && rm ${symlink}
        done

I suspect this logic is flawed.  In addition to checking that we are in fact working with a symlink, it should also check whether ${ROOT}/${symlink} is a symlink, and if so, if it is linked to an existing busybox install, and if it is, it should re-install the symlink (we're busy with an upgrade presumably?).

Modifying the above to instead read as follows fixes the problem for me:

        local symlink
        for symlink in {,usr/}{bin,sbin}/* linuxrc ; do
            [[ -L ${symlink} ]] || continue
            [[ -L ${ROOT}/${symlink} ]] && \
                [[ $(basename $(readlink ${ROOT}/${symlink})) == busybox ]] && \
                continue
            [[ -e ${ROOT}/${symlink} ]] \
                && eerror "Deleting symlink ${symlink} because it exists in ${ROOT}" \
                && rm ${symlink}
        done

The reasoning behind the embedded calls to basename and readlink is simple, some symlinks goes in /sbin so we can't rely on a simple check for busybox.  We _could_ use [[ `readlink ${ROOT}/${symlink}` == *busybox ]] but that may catch symlinks to stuff like foo.busybox, so using basename to rip everything off upto the last slash is probably the easiest.  It may be possible to use variable substitution for this as well, but I'm not too familiar with those :).
Comment 1 SpanKY gentoo-dev 2006-08-27 22:54:38 UTC
Created attachment 95246 [details, diff]
busybox-symlinks.patch

saner to just move the symlink stuff to pkg_postinst() where it belongs

please try the attached patch ... i havent tested it
Comment 2 Torsten Veller (RETIRED) gentoo-dev 2006-10-02 05:00:22 UTC
In <http://article.gmane.org/gmane.linux.gentoo.user.german/27922> a user built a package via quickpkg. Installation of the package fails because busybox-links.tar isn't packaged.

Moving files in $D at pkg_preinst almost ever breaks `quickpkg` packages.
Comment 3 Jaco Kroon 2006-10-02 05:02:15 UTC
Doesn't really bother me where it goes, as long as it works :).
Comment 4 Jonas Stein gentoo-dev 2015-11-15 12:04:21 UTC
This (critical/high) bug is now unsolved for 9 years. Is it already fixed in the latest version and can be closed?