toposort to save the day

05 Aug 2005 • 2 min read

baselayout-1.12.0_pre4 hit portage today. The trace_dependencies() function in /lib/rcscripts/sh/ has caused a few headaches for many people. Symptoms include hanging, getting things in the wrong order and other such nasty voodoo. 😮

So I hacked in a toposort function which is faster then the "sort until nothing" approach we used previously. We can't use tsort (C toposort program) as that's in /usr/bin and isn't available at boot time, so it's in bash! The toposort function is also non-infinite by definition, so circular deps should be a thing of the past - well, for that function anyway! 😉

Here's a good reference to toposort.

I've also been chastised for my non-use of tabs (blame my vim settings 😛 ), so I've now been a good boy and added # vim:ts=4 to all my stuff in baselayout and re-indented with proper tabs.

Lastly, I've removed all the

e=$( iwconfig ${some_command} 2>&1) [-n ${e} ]([)] && eerror "dufus"

and replaced it with

if ! iwconfig ${some_command} ; then eerror "dufus"; fi

which is much nicer and should now work as the affected wireless-tools isn't in portage anymore. Or was it a driver problem? Either way, it's cleaner, better and here to stay. It works on my madwifi and prism54 so if it doesn't work for you then isn't that just teh sux0r! Bitch about it to the driver maintainers for your hardware }😃