Remove useless code in main.py around the -d option

While debugging another problem with BUP_DIR, I saw a part of the
code that looked kinda suspicious (not in itself, but in the context of
the file):

  115 subcmd_env = os.environ
  116 if dest_dir:
  117     subcmd_env.update({"BUP_DIR" : dest_dir})

the subcmd_env variable is never used in main.py. However, when I
removed that part, the -d option stopped working and bup used ~/.bup
instead: so it _is_ doing what we want it to.

The reason why it's working is that line 115 is actually not creating a
copy of the dict, but rather simply pointing to the same dict. so the
call to update() actually changes the environment for the main program,
which is actually quite alright (e.g. it supercedes the environment
variable and ensures that the path given to -d is inherited into
subprocesses)

Now the problem is that this code is very not obvious about what it
does. Plus, it's a couple of useless lines that we need to maintain.
Let's just remove any extraneous work and make the addition to the
environment triggered by the -d option as obvious and concise as
possible.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Add BUP_DIR to the subprocess environment during set-dir on the server.

In the normal flow of a remote backup, the client indicates to the
server end where it wants to save data (e.g. where the bup repository
is) by issuing a "set-dir path" command.

This command on the server end records the path in a global variable.
But it doesn't place it in the environment. This causes any subprocess
forked on the server end to be ignorant about the location of the
bup repository and causes errors such as this one:

Traceback (most recent call last):
  File "/usr/lib/bup/cmd/bup-midx", line 231, in <module>
    git.check_repo_or_die()
  File "/usr/lib/bup/bup/git.py", line 851, in check_repo_or_die
    init_repo()
  File "/usr/lib/bup/bup/git.py", line 828, in init_repo
    _git_wait('git init', p)
  File "/usr/lib/bup/bup/git.py", line 887, in _git_wait
    raise GitError('%s returned %d' % (cmd, rv))
bup.git.GitError: git init returned 1
['/usr/bin/bup', 'midx', '--auto', '--dir',
'/backup/test/objects/pack']: returned 1

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Don't try to restore read-only chattr(1) attributes.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
On ENOTTY or ENOSYS, assume filesystem doesn't support Linux attributes.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Fix types and add missing elements to Entry.__repr__() format string.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Record the file size as Metadata.size when possible.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Fix typo in _create_via_common_rec() exception message.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Add symbolic mode information to xstat output, i.e. (drwxr-xr-x).

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Make "bup meta -tvv" output identical to "bup xstat".

Move the bits of xstat-cmd.py that generate the detailed metadata
representation to metadata.py and xstat.py to support their use from
both "bup xstat" and "bup meta -tvv".

Add size to detailed metadata description when available.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Make "bup meta -tv" output look somewhat like "ls -l" output.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Don't attempt to remove the Linux attr extents flag (see chattr(1)).

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Fix metadata._set_up_path() to allow restoration of top-level files.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Change metadata "owner" to "user" everywhere to match stat(2), tar, etc.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Save metadata during "bup save".

Record metadata in a hidden/mangled file named .bup in each directory,
so that the metadata for /foo/ is stored in /foo/.bup, with the first
entry being the metadata for foo itself.  Record an empty index file
for each special file so that the index entries and .bupm entries
correspond.

For now, record "/" metadata only when there are no strip/graft
options.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Default to stdin/stdout in bup meta when -f is not specified.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Restore any metadata during "bup restore"; add "bup meta --edit".

Use "bup meta --edit" to test "bup restore" and the new tar/rsync-like
restoration behaviors.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Add preliminary hardlink support for review.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Unmount testfs properly during "make clean".

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Re-enable metadata tests by default since this is the metadata dev branch.

Disable the root-level test-meta.sh tests when the uname output
doesn't match Linux since they're not likely to work elsewhere right
now.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Defer errors when the restore target doesn't support relevant metadata.

When the restore target doesn't support POSIX1e ACLs, extended
attributes, or Linux attributes, handle the failures via add_error()
(i.e. defer them).

Test these cases by creating a loopback VFAT filesystem
(testfs-limited) and using it as a restore target.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>