Use data() instead of c_str() where appropriate
Fix error message

This fixes the error message

  error: file `' was not found in the Nix search path (add it using $NIX_PATH or -I)
Don't use deletePath() to delete a single file
Fix a broken guard around utime()

Because of an outdated check for a timestamp of 0, we were calling
utime() even when it wasn't necessary.
On Linux, make the Nix store really read-only by using the immutable bit

I was bitten one time too many by Python modifying the Nix store by
creating *.pyc files when run as root.  On Linux, we can prevent this
by setting the immutable bit on files and directories (as in ‘chattr
+i’).  This isn't supported by all filesystems, so it's not an error
if setting the bit fails.  The immutable bit is cleared by the garbage
collector before deleting a path.  The only tricky aspect is in
optimiseStore(), since it's forbidden to create hard links to an
immutable file.  Thus optimiseStore() temporarily clears the immutable
bit before creating the link.
Fix chroots builds

Chroots are initialised by hard-linking inputs from the Nix store to
the chroot.  This doesn't work if the input has its immutable bit set,
because it's forbidden to create hard links to immutable files.  So
temporarily clear the immutable bit when creating and destroying the
chroot.

Note that making regular files in the Nix store immutable isn't very
reliable, since the bit can easily become cleared: for instance, if we
run the garbage collector after running ‘nix-store --optimise’.  So
maybe we should only make directories immutable.
Fix an uninitialised variable

The variable ‘useChroot’ was not initialised properly.  This caused
random failures if using the build hook.  Seen on Mac OS X 10.7 with Clang.
Thanks to KolibriFX for finding this :-)
Remove dependency on sqlite3_table_column_metadata

Not all SQLite builds have the function sqlite3_table_column_metadata.
We were only using it in a schema upgrade check for compatibility with
databases that were probably never seen in the wild.  So remove it.
build-remote.pl: don't wait forever for the upload lock

In the build hook, don't wait forever to get the upload lock.  This
ensures progress if another process gets stuck while holding the
upload lock.
Restore progress indication during nix-copy-closure
nix-worker: put the pid of the caller in argv[1]

This is useful for debugging.
Don't leak a file descriptor in commonChildInit()
Set the close-on-exec flag on file descriptors
nix-copy-closure: don't print copied path on stdout

We're already printing progress on stderr, so printing them on stdout
afterwards is kind of useless.
Fix compilation on FreeBSD

http://hydra.nixos.org/build/2213576

Not sure why compilation doesn't fail on other platforms...
Update bzip2 dependency
Fix tests
Ensure that Perl processes delete their entry in the temproots directory

By moving the destructor object to libstore.so, it's also run when
download-using-manifests and nix-prefetch-url exit.  This prevents
them from cluttering /nix/var/nix/temproots with stale files.
Clean up when building from a working tree
Drop the externals directory

Nix now requires SQLite and bzip2 to be pre-installed.  SQLite is
detected using pkg-config.  We required DBD::SQLite anyway, so
depending on SQLite is not a big problem.

The --with-bzip2, --with-openssl and --with-sqlite flags are gone.