Blog Pseudoaccidentale

2008-08-28

BSD make on other systems

The topic of using a “BSD make” on other systems seems to pop up now and then. I haven’t really finished the automake-based ‘port’ of FreeBSD make that I started some time ago, but seeing that others are interested too is a bit nice. A recent post by Chuck Robey to the freebsd-arch mailing list brought up the issue again.

I’ve been trying to work on bmake since earlier this year, but then I switched jobs, and $real_life ate a large chunk of my summer, so the port started getting pretty stale. Then I finished a “minimal” set of changes that allow building FreeBSD make on Linux. The patches are still a bit messy and I have to cean them up a bit before they are pushed to hg.hellug.gr, but I think I should try to make the time to commit this now.

I wrote to freebsd-arch a few minutes ago with a description of the changes. A short textual description of the changes is not as useful as actually seeing the patchset itself, but first I want to verify that they work and that they are integrated with the original automake stuff.

With a bit of luck, I’ll have this ready for committing to the online tree by the end of the week.

Then we can start worrying about the trickier part of the “port”: how to reuse as much as possible of all the bsd.*.mk includes that the FreeBSD developers have developer over the years. That is going to be “fun”, but we’ll see how it goes.

2008-08-20

Interesting times ahead for FreeBSD

Ed Schouten’s MPSAFE-tty layer is now in the main tree of FreeBSD, but it i only one of the active projects which run in parallel. The excellent news is that the MPSAFE-tty layer brings down by one the count of kernel subsystems that require the big Giant lock for running within the threaded FreeBSD kernel. There are only a few more, i.e. the USB stack. Removing the requirement for Giant from some of the remaining Giant-dependent subsystems is already part of ongoing work.

The next few months are going to be “interesting” for FreeBSD in quite a few ways:

  • Now that Ed has committed his MPSAFE-tty layer, it will start getting more testing. We will have to fix any problems that surface during the first few weeks, as people start using the new kernel, or updating their thirdparty software & ports.
  • Kip Macy has started committing his Xen DomU support in the /head branch.
  • Alfred Perlstein is actively seeking approval to commit the new USB stack that Hans-Peter Selasky is developing outside of the main tree for a while now. More testing and bug-fixing will probably start once this hits the main tree too.
  • Robert Watson recently organized a “developer’s summit” in Cambridge, which seems to have gone pretty well. Judging from the blog posts by Philip Paeps, and the enthusiastic email by other people who attended, this was a huge success.

Now we are all looking forward to EuroBSDCon 2008. The conference is currently scheduled for 16-17 October (tutorial days) and 18-19 October (main conference talks). It will take place in Strasbourg, France and join for a few days a diverse group of BSD hackers, including people from FreeBSD, NetBSD, OpenBSD, Dragonfly BSD, and Darwin.

It’s been almost a couple of years now since I attended EuroBSDCon 2006, so this should be fun :-)

Ed Schouten commits new MPSAFE tty layer

After a long time of developing the code in Perforce, posting patches for review, patching userland application to remove explicit gropping into the “tty internals”, working with other committers to enhance, test and then test a bit more, Ed Schouten has committed his new MPSAFE tty layer to the FreeBSD kernel:

http://svn.freebsd.org/viewvc/base?view=revision&revision=181905

This removes one of the last remaining barriers of running with a completely “Giant-free” kernel.

Thank you Ed :-)

2008-08-08

Tweaking shell-script indentation in GNU Emacs

The default indentation levels of GNU Emacs for the case statements of sh(1) scripts (and derivative or compatible shells) are a bit smal for my taste (4 columns). This makes case statements in shell scripts look almost “ok”, but I don’t like the small indentation for the rest of my scripts. Here is how the default indentation would look for a part of my ~/.bashrc file:

A demo of the default Emacs indentation of 4 columns for case labels in sh-mode

I like 8 column indentation in nested statements, so one of the things I do in my ~/elisp/keramida-hooks.el startup file is:

(defun gker-setup-sh-mode ()
  "My own personal preferences for `sh-mode'.

This is a custom function that sets up the parameters I usually
prefer for `sh-mode'.  It is automatically added to
`sh-mode-hook', but is can also be called interactively."
  (interactive)
  (setq sh-basic-offset 8
        sh-indentation 8))
(add-hook 'sh-mode-hook 'gker-setup-sh-mode)

Setting the basic indentation to 8 columns has an undesired side-effect though. It indents the labels and the code of case statements too much for my taste. The default indentation levels set up by sh-mode for these statements indent the case label by sh-basic-offset columns and the commands after a case label by twice the same amount.

The same part of my ~/.bashrc file becomes then:

The effect of larger (8 column) indentation on case statements of sh-mode

The extra indentation of case labels seems a bit excessive now. It consumes 8 extra columns of precious horizontal space. For someone who likes reading source code in relatively narrow windows like me, this is a waste of space that would look more useful if it contained code instead of empty space / indentation.

GNU Emacs is, however, as I’ve written several times in the past, an infinitely customizable, extensible editor. There are, in fact, at least two different ways of customizing the indentation level of case labels and case commands (after those labels) in shell scripts. The first option is to modify the syntax table of sh-mode for these two syntax elements right there, inside the same hook that tweaks the default indentation offset from 4 columns to 8 columns:

(defun gker-setup-sh-mode ()
  "My own personal preferences for `sh-mode'.

This is a custom function that sets up the parameters I usually
prefer for `sh-mode'.  It is automatically added to
`sh-mode-hook', but is can also be called interactively."
  (interactive)
  (setq sh-basic-offset 8
        sh-indentation 8
        ;; Tweak the indentation level of case-related syntax elements, to avoid
        ;; excessive indentation because of the larger than default value of
        ;; `sh-basic-offset' and other indentation options.
        sh-indent-for-case-label 0
        sh-indent-for-case-alt '+)
(add-hook 'sh-mode-hook 'gker-setup-sh-mode)

This way of setting up the indentation for the two case-related syntax elements has the advantage that it is as close as possible to the sh-basic-offset and the other related changes. A small comment above the case-related syntax elements is sufficient to document why these syntax changes are needed.

Another option is to set the default values of these two syntax elements of sh-mode, by something like:

(setq-default sh-indent-for-case-label 0)
(setq-default sh-indent-for-case-alt '+)

This way of reducing the indentation for case-related shell script code should work too. It’s not as nice as the first option, but it can be used to achieve similar results, even if it runs outside of the mode hooks for sh-mode.

After one of these changes has been evaluated, the indentation of case-statements in sh-mode changes to

Indentation of case-labels and case commands fixed with sh-basic-offset at 8 columns

This is much better. At least it’s much better according to my taste, and it precisely matches the default style of indentation I use when I am writing scripts in that other popular editor.

As an extra, bonus side-effect, by configuring the syntax elements of sh-mode correctly, I can now mark any part of a shell script as the active region, and the M-x indent-region command (bound to C-M-\ by default in Emacs) will DTRT and indent the marked region with the correct style, i.e. the one I like using :-)

2008-08-03

Good luck, Christina Applegate

Filed under: Misc — keramida @ 01:36:29
Tags:

From the teen-idols-of-my-times department:

American actress Christina Applegate [imdb] has been diagnosed with an early form of breast cancer.

There isn’t really much to say or write about something like this, other than “good luck, and best wishes for a full, and speedy recovery” :-/

Blog at WordPress.com.