Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 157538 - sys-kernel/genkernel-3.4.5-r1 fails to build initrd with dmraid
Summary: sys-kernel/genkernel-3.4.5-r1 fails to build initrd with dmraid
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: genkernel (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Genkernel Maintainers
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2006-12-08 13:47 UTC by devsk
Modified: 2008-05-02 00:11 UTC (History)
0 users

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


Attachments
as a unified patch (genkernel.patch,570 bytes, patch)
2006-12-08 14:21 UTC, devsk
Details | Diff
patch for /usr/share/genkernel/gen_compile.sh (gen_compile.patch,1.54 KB, patch)
2006-12-13 21:43 UTC, devsk
Details | Diff
The patch for the ebuild itself (genkernel-3.4.5-r1-selinux.patch,491 bytes, patch)
2006-12-13 21:44 UTC, devsk
Details | Diff
genkernel.patch (genkernel.patch,1.48 KB, patch)
2006-12-14 08:25 UTC, Chris Gianelloni (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description devsk 2006-12-08 13:47:27 UTC
It seems like dmraid link line needs to include -lselinux for the static link because libdevmapper.a won't have the symbols from libselinux.a although they refer to them. dynamic link would just work fine, but will require libdevmapper libs to be present in initrd.

--------------------------------------------------------------------
gcc -o dmraid dmraid.o commands.o toollib.o -L/var/tmp/genkernel/9008.19588.27156.8193/device-mapper/lib -static -L../lib \
              -L/lib -ldmraid -lz -ldevmapper
/var/tmp/genkernel/9008.19588.27156.8193/device-mapper/lib/libdevmapper.a(libdm-common.o): In function `dm_set_selinux_context':
libdm-common.c:(.text+0x4da): undefined reference to `is_selinux_enabled'
libdm-common.c:(.text+0x4f3): undefined reference to `matchpathcon'
libdm-common.c:(.text+0x533): undefined reference to `lsetfilecon'
libdm-common.c:(.text+0x541): undefined reference to `freecon'
libdm-common.c:(.text+0x59c): undefined reference to `freecon'
collect2: ld returned 1 exit status
make[1]: *** [dmraid] Error 1
make[1]: Leaving directory `/var/tmp/genkernel/9008.19588.27156.8193/dmraid/1.0.0.rc13/tools'
make: *** [tools] Error 2
* Gentoo Linux Genkernel; Version 3.4.5^[[0m
* Running with options: --gensplash=emergence --dmraid --gensplash-res=1280x1024 --no-initrdmodules initrd

* ERROR: Failed to compile the "" target...
* -- Grepping log... --
* -- End log... --
* Please consult /var/log/genkernel.log for more information and any
* errors that were reported above.
* Report any genkernel bugs to bugs.gentoo.org and
* assign your bug to genkernel@gentoo.org. Please include
* as much information as you can in your bug report; attaching
-----------------------------------------------------------------------
Comment 1 devsk 2006-12-08 14:14:38 UTC
this change fixes it.

# cd /usr/share/genkernel

# diff -u gen_compile.sh.orig gen_compile.sh
--- gen_compile.sh.orig 2006-12-08 13:53:07.000000000 -0800
+++ gen_compile.sh      2006-12-08 13:55:55.000000000 -0800
@@ -511,7 +511,8 @@
                                gen_die 'Configure of dmraid failed!'

                        #We dont necessarily have selinux installed yet .. look into selinux global support in the future.
-                       sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
+                       # sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
+                       echo "DMRAIDLIBS += -lselinux -lsepol" >> tools/Makefile
                mkdir -p "${TEMP}/dmraid"
                print_info 1 'dmraid: >> Compiling...'
                        compile_generic '' utils
Comment 2 devsk 2006-12-08 14:21:31 UTC
Created attachment 103647 [details, diff]
as a unified patch

the diff's formatting got screwed, sorry.
Comment 3 Chris Gianelloni (RETIRED) gentoo-dev 2006-12-13 09:55:11 UTC
Thanks... I've fixed this in subversion and it should be good to go in genkernel 3.4.6...
Comment 4 devsk 2006-12-13 10:35:39 UTC
After, I posted the patch, I realized that this will force libselinux and libsepol on users without the ebuild specifically requiring it. So, the right solution for the problem at hand is:

use the selinux USE flag, put a dep in genkernel ebuild for libselinux and pass --disable-selinux explicitly to device-mapper configure in gen_compile.sh if selinux is not in USE. device-mapper devs decided that they will enable selinux by default and users have to disable it explicitly if they don't want it, and this is what lead to the undefined variables. So, this approach will resolve the undefined symbols (this bug) as well as keep the deps sane.

We need to modify the patch I posted earlier and make it link to selinux and sepol only if selinux is in use.

wolf, is it possible for you to handle this or do I need to put a patch out? sorry for any confusion I might have caused.
Comment 5 Chris Gianelloni (RETIRED) gentoo-dev 2006-12-13 11:46:04 UTC
If you can come up with a patch, that would be great.  Otherwise, I'll try to get it into the next genkernel release.
Comment 6 devsk 2006-12-13 21:43:47 UTC
Created attachment 104001 [details, diff]
patch for /usr/share/genkernel/gen_compile.sh

This takes hasq() and use() code from ebuild.sh shamelessly and uses 'emerge --info' to get USE variable required to for use() function.
Comment 7 devsk 2006-12-13 21:44:47 UTC
Created attachment 104002 [details, diff]
The patch for the ebuild itself

It simply puts selinux in IUSE and puts a depend on libselinux for USE flag selinux.
Comment 8 devsk 2006-12-13 21:46:32 UTC
wolf, let me know if any of this looks good to you. I have tested it here on amd64 and it works with and without libselinux and libsepol. ebuild is patched for 3.4.5-r1 in portage tree currently.
Comment 9 Chris Gianelloni (RETIRED) gentoo-dev 2006-12-14 08:10:06 UTC
We can't rely on anything "portage-specific" within genkernel itself.  This is due to the design of genkernel, which allows it to be used on any distribution.

The likely best solution is to check for USE=selinux and modify the sources for genkernel at install time, rather than checking "emerge --info" at runtime.  It looks like it is simple enough, so I'll probably get to it today using the information in your patches.  Thanks for the help.  =]
Comment 10 devsk 2006-12-14 08:16:52 UTC
would you please put out a test patch here? thanks.

PS: I always thought genkernel was a gentoo thing...thanks for correcting on that front!
Comment 11 Chris Gianelloni (RETIRED) gentoo-dev 2006-12-14 08:23:46 UTC
OK... now I've made the gen_compile.sh default to working without selinux, since that's the Gentoo "default"... when I update the ebuild, USE=selinux will uncomment the two places required for selinux support.
Comment 12 Chris Gianelloni (RETIRED) gentoo-dev 2006-12-14 08:25:35 UTC
Created attachment 104050 [details, diff]
genkernel.patch

This patch is what I've committed... of course, if you're testing it, you'll need to manually remove the 2 "###" in front of the selinux stuff.  Basically, I'm going to have the following in the ebuild:

use selinux && dosed -i 's/###//' gen_compile.sh
Comment 13 devsk 2006-12-14 09:25:06 UTC
+		###mymapperconf="--disable-selinux ${mymapperconf}"

in the patch will become:

mymapperconf="--disable-selinux ${mymapperconf}"

if selinux is in the USE. We want the opposite.

I think it was desired that we explicitly disable selinux for the default setup because that's how device-mapper devs want it i.e. enable selinux by default (there is collision between gentoo default and device-mapper default).

In nutshell, with your patch, we will still see the undefined variables. I think maybe something like this in the ebuild might work:

use selinux && sed -e "s/--disable-selinux//g" ....

and have the --disable-selinux in mymapperconf by default with the patch.
Comment 14 Chris Gianelloni (RETIRED) gentoo-dev 2006-12-14 10:15:16 UTC
Bleh... you're right... for some reason I was thinking the "--disable-selinux" was for enabling it.  Anyway, I've got it adjusted now in SVN.
Comment 15 Chris Gianelloni (RETIRED) gentoo-dev 2007-01-04 09:21:38 UTC
Fixed in 3.4.6
Comment 16 Steve Arnold archtester gentoo-dev 2008-04-26 19:13:41 UTC
This now happens on amd64 during the lvm build; adding --disable-selinux to the configure line in gen_compile.sh allows it to build correctly.
Comment 17 Chris Gianelloni (RETIRED) gentoo-dev 2008-05-02 00:11:51 UTC
Could you file a new bug for that, since it's a different (though related) issue and doesn't belong on this resolved bug?