Roy's Blog

A Hacker's musings on Code | Tech | Life

Whilst forking OpenRC from baselayout and tying it into a vanilla FreeBSD I found myself asking "Why the need to mount a memory disk?"Well, we need an area to save service states, lock files, the dependency tree and a few other goodies even if no physical disks are mounted read-write. This is a little more challenging for BSD as we can only create disks of a fixed size, which is hardly at the cutting edge of efficiency. However, as baselayout used to be entirely shell script based this was the only option, but as we're now backed by C for the most part I asked myself is there an alternative?There answer is, of course, yes there is. We can use System V Message Queues. I'll be looking into making an rc daemon which will handle service states, generate a dependency tree and use that to resolve the dependencies instead of each runscript instance trying to do this itself. This maybe a little complicated, and I have no experience of doing this so it make take a little while. Hopefully I can use semaphores to imitate the existing service exclusive file locks too.

Discuss this Post

#!/sbin/runscript
command=/usr/sbin/ntpd
pidfile=/var/run/ntpd.pid
command_args="-p ${pidfile} ${NTPD_OPTS}"
required_files=/etc/ntp.conf
depend() {
    need net
    use dns logger
    after ntp-client
}

OK, you don't get the comment about where the example is, but heh.

Discuss this Post

So I've been using vanilla FreeBSD-7.0-Beta2 for a few weeks now. I've also been extensively looking into it's rc system to see what it can do that openrc cannot. The answer is, well not much.

But there is one thing it does have which is very nice - and that's init script templates. Take this sample ntpd init script from Gentoo (line breaks and comments removed, sadly my blog removes the indents too)

#!/sbin/runscript
depend() {
        need net
        use dns logger
        after ntp-client
}
checkconfig() {
        if [! -f /etc/ntp.conf ]() ; then
                eerror "Please create /etc/ntp.conf"
                eerror "Sample conf: /usr/share/ntp/ntp.conf"
                return 1
        fi
        return 0
}
start() {
        checkconfig || return $?
        ebegin "Starting ntpd"
        start-stop-daemon --start --exec /usr/sbin/ntpd \
            --pidfile /var/run/ntpd.pid \
            -- -p /var/run/ntpd.pid ${NTPD_OPTS}
        eend $? "Failed to start ntpd"
}
stop() {
        ebegin "Stopping ntpd"
        start-stop-daemon --stop \
                --pidfile /var/run/ntpd.pid \
                --exec /usr/sbin/ntpd
        eend $? "Failed to stop ntpd"
}    

Now, here's a replacement using the template system.

#!/sbin/runscript
command=/usr/sbin/ntpd
pidfile=/var/run/ntpd.pid
command_args="-p ${pidfile} ${NTPD_OPTS}"
depend() {
        need net
        use dns logger
        after ntp-client
}
start_pre() {
        if [! -f /etc/ntp.conf ]() ; then
                eerror "Please create /etc/ntp.conf"
                eerror "Sample conf: /usr/share/ntp/ntp.conf"
                return 1
        fi
        return 0
}

This should make a fair few init scripts smaller, and remove the headache of using start-stop-daemon which some users find.

On another note, the openrc build system has been revamped so we support both FreeBSD make and GNU make 100%. This means it's easier to slip into FreeBSD as a potential port, and maybe the other BSD's too.

Discuss this Post

OK, a few people have been saying that Gentoo is falling apart, they will leave Gentoo too and the world will end as we know it. :O I can assure you that this is all lies ;)Basically baselayout will be split into two entities. Firstly, the bit that lays out the initial file system and provides the core system files shall remain as baselayout. The rest of it (ie, rc, init scripts, etc) will be forked off into a new package called OpenRC (working title). I will be upstream for it and continue developing it, fixing bugs, etc. The difference is that it will be an external project that Gentoo will use.This benefits me, as the Gentoo users can now rest easy knowing that it will be business as usual in regards to me leaving Gentoo.This also benefits Gentoo - it makes it easier to drop baselayout. Why is this a benefit? Well, there are other init systems available such as upstart, einit or init-ng all of which have pluses and minuses when compared to baselayout-2. As they are all external projects there should be no favouritism and it comes down to technical merit. Well, not quite as the entire Gentoo tree assumes baselayout is present, but it makes things easier anyway.Lastly this also benefits everyone else as it makes it easier to integrate into other distros / OS's. Especially as I intend to re-license it as a 2 clause BSD License. This essentially allows it to be used as a replacement for the BSD rc system. I could do this with its current GPL2 license, but it would never be allowed into the core system so it is needed. This will require some work as the BSD file layout is a bit different, and I'd also like it to work with existing BSD rc init scripts where possible.Speaking of re-licensing, I'm also doing the same to resolvconf-gentoo -> openresolv and dhcpcd-3.1 for the same reasons as above.If anyone posts any comments about GPL vs BSD license then I'll just ignore you. I believe that the core OS bits should be BSD licensed as they are pretty much generic these days, but things like GNOME and stuff should be GPL licensed as that's what the user actually uses. That's my view and I don't wish to debate it :P

Discuss this Post

I never thought I would write this, but it's true. I've retired from Gentoo. It's been a fun ride, I've made many new friends and thankfully few enemies. But our views no longer follow the same path. This is not a snap decision, I have been thinking about it in the back of my mind for a few weeks now.Why am I leaving? Well, my view of Gentoo has always been about choice. You know your USE flags? Well, you choose them. Choice. It's a good thing - it makes Gentoo a very powerful distro. I'm leaving because I'm being denied lack of choice with the underpinnings. The current Gentoo mindset is once the tool has been picked, embrace it to the exclusion of all other tools. The current idea is to have the entire GNU toolset available for portage to use. I find this unacceptable after I've strived to make baselayout work with the tools the base OS provides and even other init systems in portage. There is no technical reason why this cannot be done, or even dare I say allowed so we can at least try. But no, we cannot even do that.Speaking of baselayout, I am sorry to leave it behind just when the finishing post for it being unmasked was so close. But I may continue working on it as an external project if the Gentoo Trustees will allow it to be BSD licensed. I'm pretty sure I could do that anyway as I did write 99% of it from scratch, but I'm a nice guy so I asked. Gentoo can then either can on using it or get other devs to take it over or use something else.I have other projects to work on - maybe I'll now have the time to write that IPv6 stack for dhcpcd and actually get it into the various BSDs.I'll probably stop using Gentoo as well move into FreeBSD.I'd like to say a big "Thank you" to everyone who voted for me in the Council, and I'm sorry that I've let you down by leaving but when you're given a big flat out no, it does leave little choice. I'd also like to say thanks to the silent majority who wanted me to stay, but it's a bit late now isn't it? You have a voice, and you should use it more.Finally, a big thank to the users of my software - all the emails I got telling me how much you like my work means a lot to me! You guys make me keep going :) Although I'm going somewhere else, I think I've touched Gentoo enough to leave my mark on it for a little while.

Discuss this Post