Fixing build failures with dash is cool.

January 20th, 2008 by lucas

The bad thing with fixing build failures with dash is that there are still a lot of open bugs. (Remember, the 0-day NMU policy applies to those, so it’s a good opportunity to improve your NMU karma. And I will sponsor your NMUs if you can’t upload!).

The good thing is that you sometimes run into funny code, like:
clean:
    dh_testdir
    dh_testroot
    pushd docs ; $(MAKE) distclean || true ; popd

Since pushd/popd is a bashism, the Ubuntu patch changed this to:
clean:
    dh_testdir
    dh_testroot
    cd docs ; $(MAKE) distclean || true ; cd $(CURDIR)

Which works, but is … interesting? :-)

11 Responses to “Fixing build failures with dash is cool.”

  1. fatal wrote on 01/20/08 at 5:32 pm :

    how about “make -c docs distclean” ?

  2. Ken Bloom wrote on 01/20/08 at 5:49 pm :

    Doesn’t GNU Make now execute each line of a makefile in a new shell, so it should automatically cd back before the next line of the makefile? (Of course, that’s very non-obvious.)

  3. dominiko wrote on 01/20/08 at 5:55 pm :

    > Since pushd/popd is a bashism, the Ubuntu patch changed this to:
    > clean:
    > dh_testdir
    > dh_testroot
    > cd docs ; $(MAKE) distclean || true ; cd $(CURDIR)
    >
    > Which works, but is … interesting? :-)

    ... and which is also useless since every line in a Makefile works in its own subshell. You don't need to worry about preserving the directory, it's already preserved for you. You might as well write:


    clean:
    dh_testdir
    dh_testroot
    $(MAKE) distclean || true

    The || true is to ignore failure when doing distclean, you might as well write:


    clean:
    dh_testdir
    dh_testroot
    -$(MAKE) distclean

  4. Tester wrote on 01/20/08 at 6:05 pm :

    Considering how inferior to bash dash is, I really fail to understand why you guys insist on using it as /bin/sh for your build environment…

  5. dominiko wrote on 01/20/08 at 6:13 pm :

    Ooops. In my previous comment, I forgot that your command was temporarily going into the docs directory. Anyway, since it is in a subshell, no need to cd back into the old directory. So this will do:

    clean:
    dh_testdir
    dh_testroot
    cd docs ; $(MAKE) distclean || true

  6. Marius Gedminas wrote on 01/20/08 at 9:46 pm :

    Tester: dash is smaller and faster. See https://wiki.ubuntu.com/DashAsBinSh

  7. Smarter wrote on 01/20/08 at 9:49 pm :

    Tester: dash is intended for script not daily use.

  8. Anonymous wrote on 01/20/08 at 11:07 pm :

    In addition to size and speed, dash also has fewer extensions to standards, so using dash tends to reveal non-standard constructs.

  9. Anonymous wrote on 01/20/08 at 11:08 pm :

    @fatal: -C, but yeah, that seems like the best approach.

  10. mike wrote on 01/21/08 at 2:11 am :

    Another possibility that might be more robust would be something like this

    $ (cd docs; $(MAKE) distclean)

    The commands are run in a sub shell, and the “pop” will happen automatically when the sub shell exits.

  11. Good For The Environment wrote on 02/4/08 at 1:54 am :

    Diving in the exotic environment of Fernando de Noronha…

    Fernando de Noronha is a Brazilian island located in the middle of the Atlantic Ocean which divers from all points of the world wish to meet. It offers not only great diving opportunities but also a very impressing and exotic natural environment. If yo…