]> arthur.barton.de Git - bup.git/log
bup.git
2 years agoftp: use sys.exc_info(); import traceback unconditionally
Rob Browning [Sun, 3 Oct 2021 19:11:43 +0000 (14:11 -0500)]
ftp: use sys.exc_info(); import traceback unconditionally

Since it appears that works across all the versions we support.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoAllow PANDOC path to contain spaces
Rob Browning [Fri, 17 Sep 2021 18:16:58 +0000 (13:16 -0500)]
Allow PANDOC path to contain spaces

Thanks to Arthur Ward for reporting the problem and proposing an
alternate solution.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agotest-index-check-device: unmount "lazily" to avoid potential crash
Rob Browning [Fri, 17 Sep 2021 17:56:38 +0000 (12:56 -0500)]
test-index-check-device: unmount "lazily" to avoid potential crash

Apparently the umount was failing on some systems, and since we're
already using loop, mke2fs, etc. which aren't really portable, and we
use "umount -l" in cleanup-mounts-under, just use it here too for now.

Thanks to Abdel Said for reporting the problem:

  ! t/test-index-check-device.sh:38 mke2fs -F -j -m 0 testfs.img ok
  ! t/test-index-check-device.sh:39 mount -o loop testfs.img /opt/bup/t/mnt/test-index-check-device.sh-YuNQZtU ok
  ! t/test-index-check-device.sh:41 chown root:root /opt/bup/t/mnt/test-index-check-device.sh-YuNQZtU ok
  ! t/test-index-check-device.sh:42 chmod 0700 /opt/bup/t/mnt/test-index-check-device.sh-YuNQZtU ok
  ! t/test-index-check-device.sh:45 date ok
  umount: /opt/bup/t/mnt/test-index-check-device.sh-YuNQZtU: device is busy.
  (In some cases useful info about processes that use
  the device is found by lsof(8) or fuser(1))
  ! t/test-index-check-device.sh:46 umount /opt/bup/t/mnt/test-index-check-device.sh-YuNQZtU FAILED

Additional discussion: https://groups.google.com/d/msg/bup-list/GhVonW0XGVE/8kIkJEOwCQAJ

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agopylint: enable inconsistent-return-statements
Johannes Berg [Fri, 27 Aug 2021 23:07:16 +0000 (01:07 +0200)]
pylint: enable inconsistent-return-statements

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: return early for dry run in import_duplicity exo]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agopylint: enable catching-non-exception
Johannes Berg [Fri, 27 Aug 2021 22:54:50 +0000 (00:54 +0200)]
pylint: enable catching-non-exception

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agopylint: add undefined-variable
Johannes Berg [Fri, 27 Aug 2021 22:40:16 +0000 (00:40 +0200)]
pylint: add undefined-variable

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: add missing %s in validate_vfs_path changes]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agopylint: enable unidiomatic-typecheck
Johannes Berg [Fri, 27 Aug 2021 22:33:13 +0000 (00:33 +0200)]
pylint: enable unidiomatic-typecheck

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: change isinstance str checks to compat.str_type]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agopylint: enable consider-using-in
Johannes Berg [Fri, 27 Aug 2021 22:30:41 +0000 (00:30 +0200)]
pylint: enable consider-using-in

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agopylint: enable useless-return
Johannes Berg [Fri, 27 Aug 2021 22:27:53 +0000 (00:27 +0200)]
pylint: enable useless-return

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agopylint: enable return-in-init
Johannes Berg [Fri, 27 Aug 2021 22:25:32 +0000 (00:25 +0200)]
pylint: enable return-in-init

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agopylint: check for trailing whitespace
Johannes Berg [Fri, 27 Aug 2021 22:08:38 +0000 (00:08 +0200)]
pylint: check for trailing whitespace

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agometadata: accept EOPNOTSUPP for lchmod()
Johannes Berg [Sun, 12 Sep 2021 18:58:45 +0000 (20:58 +0200)]
metadata: accept EOPNOTSUPP for lchmod()

On some systems (e.g. mine, Fedora 33) python2 has
(started to have?) lchmod(), as glibc has it, but
that always only returns EOPNOTSUPP if you really
try to operate on a symlink. Allow for that and
handle it just like ENOSYS.

Note that the handling of ENOSYS is wrong, since
integers can't be thrown or caught - pylint found
this as well, but since I'm fixing EOPNOTSUPP here
I need to fix that at the same time.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
2 years agoREADME: fix and simplify cirrus badges
Rob Browning [Sun, 12 Sep 2021 17:28:11 +0000 (12:28 -0500)]
README: fix and simplify cirrus badges

Fix broken links (given the recent task name changes), and stop
reporting per-platform status since each one may have multiple tasks.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agosystem-info: report freebsd cpu and mem info
Rob Browning [Sat, 11 Sep 2021 18:23:50 +0000 (13:23 -0500)]
system-info: report freebsd cpu and mem info

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agocirrus: run pylint for python 2 and python 3
Rob Browning [Sat, 11 Sep 2021 17:47:57 +0000 (12:47 -0500)]
cirrus: run pylint for python 2 and python 3

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agoconfigure: add --with-pylint=[yes|no|maybe] defaulting to maybe
Rob Browning [Sat, 11 Sep 2021 21:02:19 +0000 (16:02 -0500)]
configure: add --with-pylint=[yes|no|maybe] defaulting to maybe

When set to no, don't run pylint from ./pylint, just exit
successfully.  When set to maybe, use dev/have-pylint to figure out if
pylint is available, and if so, run it, otherwise exit successfully
after describing the situation.  When set to yes, always try to run
pylint.

This may be useful more generally, but in particular, it makes it
possible to run this:

  ./configure --with-pylint=maybe
  make check-both

in situations where pylint is available for say python 3, but not
python 2.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoGNUmakefile: run "bup features" during test
Rob Browning [Sat, 11 Sep 2021 16:52:30 +0000 (11:52 -0500)]
GNUmakefile: run "bup features" during test

Provide additional information about what's being tested, particularly
in CI.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agotest: add pylint and test imports
Johannes Berg [Fri, 27 Aug 2021 20:23:37 +0000 (22:23 +0200)]
test: add pylint and test imports

Add pylint and test for unnecessary imports as a first step, which
requires cleaning them all up.

[rlb@defaultvalue.org: add and use ./pylint]

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agocirrus: adjust for new python-config based builds
Rob Browning [Wed, 8 Sep 2021 05:50:15 +0000 (00:50 -0500)]
cirrus: adjust for new python-config based builds

Adjust to accommodate the switch from PYTHON to BUP_PYTHON_CONFIG
cf. 4d9dd65141326b0f3ffa1658a0535348940ed017

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoprep-for-freebsd-build: switch to py38
Rob Browning [Wed, 8 Sep 2021 05:47:49 +0000 (00:47 -0500)]
prep-for-freebsd-build: switch to py38

That's what's now in 12.2 (which we use in ci).

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agocirrus: adjust test names (root vs non-root, etc.)
Rob Browning [Wed, 8 Sep 2021 05:43:48 +0000 (00:43 -0500)]
cirrus: adjust test names (root vs non-root, etc.)

The su tests run as non-root (bup), not root.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agodev/system-info: include df, mount, and git version
Rob Browning [Mon, 6 Sep 2021 16:50:37 +0000 (11:50 -0500)]
dev/system-info: include df, mount, and git version

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agobup: remove redundant allocation doubling
Rob Browning [Sat, 4 Sep 2021 19:08:02 +0000 (14:08 -0500)]
bup: remove redundant allocation doubling

Thanks to Johannes Berg for pointing out the issue.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agotest_git: be independent of user's git defaultBranch
Rob Browning [Sat, 4 Sep 2021 20:43:02 +0000 (15:43 -0500)]
test_git: be independent of user's git defaultBranch

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agotest-save-restore: be independent of user's git defaultBranch
Rob Browning [Sat, 4 Sep 2021 20:42:08 +0000 (15:42 -0500)]
test-save-restore: be independent of user's git defaultBranch

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agotest-misc: be independent of user's git defaultBranch
Rob Browning [Sat, 4 Sep 2021 20:40:57 +0000 (15:40 -0500)]
test-misc: be independent of user's git defaultBranch

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agotest_prune_older: be independent of user's git defaultBranch
Rob Browning [Sat, 4 Sep 2021 20:32:21 +0000 (15:32 -0500)]
test_prune_older: be independent of user's git defaultBranch

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agocmd/bup: add some missing safety checks
Rob Browning [Sun, 1 Aug 2021 19:45:26 +0000 (14:45 -0500)]
cmd/bup: add some missing safety checks

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoUse intprops for INTEGRAL_ASSIGNMENT_FITS INTEGER_TO_PY uadd
Rob Browning [Sat, 7 Aug 2021 17:41:55 +0000 (12:41 -0500)]
Use intprops for INTEGRAL_ASSIGNMENT_FITS INTEGER_TO_PY uadd

Rewrite INTEGRAL_ASSIGNMENT_FITS, INTEGER_TO_PY, and uadd using
intprops,  which also avoids needing all the custom (and historically
fragile) compiler option manipulations.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoMake intprops available as "bup/intprops.h"
Rob Browning [Sat, 7 Aug 2021 17:40:04 +0000 (12:40 -0500)]
Make intprops available as "bup/intprops.h"

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agoAdd Gnulib intprops.h
Rob Browning [Sat, 7 Aug 2021 17:38:51 +0000 (12:38 -0500)]
Add Gnulib intprops.h

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agoconfig.vars.in: add CC so a configure CC will be the default
Rob Browning [Sun, 1 Aug 2021 20:47:07 +0000 (15:47 -0500)]
config.vars.in: add CC so a configure CC will be the default

Add CC to config.vars.in (included by GNUMakefile) so that the CC
detected by ./configure will actually become the default.  Previously
it would still reflect GNU make's default, even after something like
this:

  CC=/some/where/gcc ./configure

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agogit: teach git_config_get() to read from a file
Johannes Berg [Wed, 18 Dec 2019 21:03:58 +0000 (22:03 +0100)]
git: teach git_config_get() to read from a file

We want to use git_config_get() to have a bup config file
in the future, so teach git_config_get() to read from a
file and add some tests for it.

Use this also to test the opttype conversions from the
previous patch.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agogit: use git's int parsing with pack.packSizeLimit config
Johannes Berg [Thu, 9 Jan 2020 12:27:35 +0000 (13:27 +0100)]
git: use git's int parsing with pack.packSizeLimit config

Our parse_num() understands a little more than git, in particular
 * T for terabytes
 * b suffix when you specify Kb, Mb, Gb or Tb.

Neither of those are understood by git, it only understands the
K, M and G suffixes (case-insensitive). However, a git repository
that actually states 'pack.packSizeLimit' as something that git
doesn't understand is broken for every single git command, and as
we call git, the added flexibility of parse_num() cannot be used.

Thus, simplify the code and just use opttype='int' for this.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agogit: allow config retrieval as bool or int
Johannes Berg [Wed, 8 Jan 2020 21:48:25 +0000 (22:48 +0100)]
git: allow config retrieval as bool or int

Allow retrieving configuration values as bool or int,
letting 'git config' normalize all the values instead
of trying to do it ourselves in bup.

Also use git config --null to avoid having to worry about
any whitespace issues, although .strip() on the output
would probably work just as well. Previously, the result
would include a terminating newline written out by the
git config command, which is not desirable.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agohashsplit: increase READ_SIZE to 8 MB
Johannes Berg [Tue, 28 Apr 2020 21:11:16 +0000 (23:11 +0200)]
hashsplit: increase READ_SIZE to 8 MB

It's not really possible to run bup with tiny amounts of memory,
so reading 1 MB or 8 MB doesn't make a significant difference
here.

However, python actually implements read() as mmap() (at least
on my Linux system), with the requested read size given to mmap
as the size. The kernel then doesn't appear to do any readahead
(which makes sense), which kills performance.

Even if this wasn't the case though, read() of 8MB isn't much
of an issue, so increase the size.

Note that 8 MB is also the size for the fadvise() code.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agosave: refactor the code using helper classes
Johannes Berg [Tue, 28 Jan 2020 20:24:09 +0000 (21:24 +0100)]
save: refactor the code using helper classes

Instead of keeping three lists, refactor the code to use
a helper class for a folder being collected, and an item
in that folder being collected.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agobup: make demux errors clearer
Johannes Berg [Mon, 1 Feb 2021 23:01:47 +0000 (00:01 +0100)]
bup: make demux errors clearer

If we hit the

    assert(n <= MAX_PACKET)

in the demux code then quite likely we've been reading
something that shouldn't even be demuxed, but got some
error message from ssh instead of a muxed connection
record.

Clarify this case a bit by printing out the data that
we got (under the assumption it's an error message) and
raising Exception("Connection broken") instead of just
asserting.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoget_argv: declare loop variable outside for()
Rob Browning [Sat, 5 Jun 2021 17:18:02 +0000 (12:18 -0500)]
get_argv: declare loop variable outside for()

Don't require a newer compiler/standard.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agomain: remove vestigial debug statement
Rob Browning [Sat, 5 Jun 2021 17:17:49 +0000 (12:17 -0500)]
main: remove vestigial debug statement

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agoSend *all* output before the BUPMUX header to stderr
Rob Browning [Sat, 29 May 2021 20:18:08 +0000 (15:18 -0500)]
Send *all* output before the BUPMUX header to stderr

This is just an incremental fix.  We may need to follow up with
additional improvements.

Thanks to Johannes Berg for diagnosing the problem.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agols: read metadata only if needed
Johannes Berg [Wed, 5 Feb 2020 21:24:01 +0000 (22:24 +0100)]
ls: read metadata only if needed

If we just want to get a list of files, there's no point in
reading metadata, since it simply isn't needed. Pass want_meta
to the appropriate functions only when we need the metadata,
and similarly call vfs.augment_item_meta() only then.

Note that the previous vfs change really made this effective,
we'd otherwise lose the information.

Note also that unfortunately this is necessary even for the
--file-type command line option because otherwise we cannot
identify FIFOs; for everything else the git mode appears to
be sufficient.

Together, this reduces the number of blob reads from 62 to 8
for 'bup ls' on a trivial folder (the bup git's root folder).

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agovfs: improve cache behaviour
Johannes Berg [Sun, 15 Mar 2020 21:38:15 +0000 (22:38 +0100)]
vfs: improve cache behaviour

If _commit_item_from_oid() is called first with require_meta=False,
and then again with require_meta=True, the second and further calls
will not use the cache, as the cached entry is without metadata.
Improve this by overwriting the cache entry if it couldn't be used.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agovfs: read metadata only if needed
Johannes Berg [Wed, 5 Feb 2020 21:21:18 +0000 (22:21 +0100)]
vfs: read metadata only if needed

If we get into contents(), we have an indication of whether or
not metadata is needed (the want_meta argument), but it doesn't
get passed down to revlist_items() and further down, so that in
cache_commit() we eventually call _revlist_item_from_oid() with
metadata always. This is wasteful.

Fix this by passing the information all the way down.

To make the caching work properly in this case, store a special
entry in the revlist dict (_HAS_META_ENTRY) indicating whether
or not metadata was cached, and if that's not set on a later
lookup, then don't return it if it doesn't have metadata but we
need the metadata.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoTest symlink target changes between stat and readlink
Johannes Berg [Thu, 31 Dec 2020 22:10:05 +0000 (23:10 +0100)]
Test symlink target changes between stat and readlink

Test the changes in "metadata: fix symlink stat() vs. readlink() race".

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: adjust commit message; rework to use injection]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agometadata: fix symlink stat() vs. readlink() race
Johannes Berg [Thu, 31 Dec 2020 22:29:58 +0000 (23:29 +0100)]
metadata: fix symlink stat() vs. readlink() race

We might stat() the file and get some size, but by the time
we readlink() the link has changed and the size is something
else.

Arguably, we can't really avoid races here if we don't have
a consistent snapshot of the filesystem to save, however, in
this case we later get an assertion failure when the data is
read back from the index (or repo), and it's easy to avoid.

Set the size from the actually recorded symlink target.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoTest file size changes during save
Johannes Berg [Thu, 31 Dec 2020 22:10:05 +0000 (23:10 +0100)]
Test file size changes during save

Test the changes in "save: fix race in data vs. metadata size".

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: adjust commit message; rework to use injection]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agosave: fix race in data vs. metadata size
Johannes Berg [Thu, 31 Dec 2020 22:20:53 +0000 (23:20 +0100)]
save: fix race in data vs. metadata size

Fix the race in data vs. metadata size by overriding the metadata
size with what we actually read and stored into the repository.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agobup-midx.md: don't include the index-cache in the --dir default
Rob Browning [Sat, 29 May 2021 18:57:56 +0000 (13:57 -0500)]
bup-midx.md: don't include the index-cache in the --dir default

We stopped including it in 6819a53d7c033b5b4e6b6efb87a4f9d4023be7a2

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agomidx: make passing idx files along with --dir work
Johannes Berg [Wed, 30 Dec 2020 22:10:19 +0000 (23:10 +0100)]
midx: make passing idx files along with --dir work

If you do something like

bup midx --dir /some/dir/ ...

with some idx files ("..."), then things don't actually work
properly because --dir gets ignored in this case. Fix that.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agobup.main: restore support for --x=y style arguments
Rob Browning [Sat, 22 May 2021 17:25:01 +0000 (12:25 -0500)]
bup.main: restore support for --x=y style arguments

Previously removed in 3a01e9021f7e7c5eafec996f4fd5d5613bb776ce.

Reported-by: Mark J Hewitt <mjh@idnet.com>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoREADME: don't use a markdown link for irc at all
Rob Browning [Fri, 28 May 2021 19:16:13 +0000 (14:16 -0500)]
README: don't use a markdown link for irc at all

...since it's currently rendered in a way that hides all the useful
information.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agoREADME: use normal markdown link for ircs
Rob Browning [Fri, 28 May 2021 19:13:50 +0000 (14:13 -0500)]
README: use normal markdown link for ircs

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agoREADME: fix irc web interface link typo
Rob Browning [Fri, 28 May 2021 19:11:40 +0000 (14:11 -0500)]
README: fix irc web interface link typo

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agoREADME: fix IRC links and add a list mailto
Rob Browning [Fri, 28 May 2021 18:56:34 +0000 (13:56 -0500)]
README: fix IRC links and add a list mailto

2 years agoREADME: mention #bup
Rob Browning [Fri, 28 May 2021 17:36:02 +0000 (12:36 -0500)]
README: mention #bup

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agodev/checksum: don't rely on bash /dev/stdin
Rob Browning [Sun, 16 May 2021 17:09:45 +0000 (12:09 -0500)]
dev/checksum: don't rely on bash /dev/stdin

It's only supported by bash in redirections, so we can't use it as the
src path.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agodev/checksum: paper over platform differences
Rob Browning [Sun, 16 May 2021 02:14:24 +0000 (21:14 -0500)]
dev/checksum: paper over platform differences

Replace use of sha1sum with dev/checksum in order to accommodate
platform differences, i.e. coreutils sha1sum vs freebsd sha1.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agobup_limited_vint_pack: revert to malloc/free
Rob Browning [Sun, 16 May 2021 16:14:41 +0000 (11:14 -0500)]
bup_limited_vint_pack: revert to malloc/free

Replace PyMem_RawMalloc and PyMemRawFree with malloc and free,
reverting my adjustment in 3b98812aa98a1590e2bebbc83c113c07e4c002bc.

Python 2 doesn't support them, and at least right now, regardless of
what the current python docs suggest, at the moment, they're just
trivial wrappers around malloc and free.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agocirrus: upgrade to freebsd-12.2-release-amd64
Rob Browning [Sun, 16 May 2021 06:19:33 +0000 (01:19 -0500)]
cirrus: upgrade to freebsd-12.2-release-amd64

The previous version (12.1) had been failing like this:

  ld-elf.so.1: /usr/local/lib/libpython3.7m.so.1.0: Undefined symbol "close_range@FBSD_1.6"

and there was some indication it might be caused by an "incomplete
upgrade".

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agoweb: make leaf path component a link too
Rob Browning [Sat, 1 May 2021 19:35:47 +0000 (14:35 -0500)]
web: make leaf path component a link too

This allows it to serve the same purpose as the removed "." link,
without any additional clutter.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoweb: omit '.' link
Johannes Berg [Sun, 17 May 2020 20:03:24 +0000 (22:03 +0200)]
web: omit '.' link

There's no value in offering a link to go to the same place
you're already at, it's just clutter. Should it really be
necessary there's always a browser refresh instead.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agosave: fix symlink target race
Johannes Berg [Thu, 31 Dec 2020 22:33:03 +0000 (23:33 +0100)]
save: fix symlink target race

If the symlink target changes while save is running, we can end up
reading one target and recording it in the metadata, but then
recording a different one (with perhaps a different size) in the
blob.

Fix this by not reading the symlink again, but just using the one
we already have in the metadata.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agotest: test index vs. save file type change
Johannes Berg [Fri, 1 Jan 2021 10:04:59 +0000 (11:04 +0100)]
test: test index vs. save file type change

In this case, the item shouldn't be recorded at all.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agosave: skip/balk if an entry changed type since indexing
Johannes Berg [Sat, 2 Jan 2021 19:58:44 +0000 (20:58 +0100)]
save: skip/balk if an entry changed type since indexing

If an entry changed file type (link, regular file, ...) since
indexing, then all kinds of weird things can happen. Skip the
item in such cases and record an error.

This also requires adjusting the test that actually provokes
a failure in metadata read - now we don't store the file at
all, so modify the test to account for that behaviour in the
check.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agobup: add a test for index contents
Johannes Berg [Wed, 22 Jul 2020 19:35:32 +0000 (21:35 +0200)]
bup: add a test for index contents

Add a test that checks that our index files are exactly
identical to the ones git would write. This is slightly
dangerous as git might introduce a new format, but that
seems unlikely now, it's been stable for a long time;
if it happens we can deal with it then.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
2 years agoPackWriter: match git's pack names
Johannes Berg [Wed, 22 Jul 2020 06:59:32 +0000 (08:59 +0200)]
PackWriter: match git's pack names

As reported by Jamie Wyrick, git appears to use the sha1 of
the entire pack file as the (default) name for it, not the
sha1(sorted-object-list) as the git-index-pack man page seems
to imply, since it says:

  Once the index has been created, the list of object names is
  sorted and the SHA-1 hash of that list is printed to stdout.
  If --stdin was also used then this is prefixed by either
  "pack\t", or "keep\t" if a new .keep file was successfully
  created. This is useful to remove a .keep file used as a lock
  to prevent the race with git repack mentioned above.

while also saying:

  If <pack-file> is not specified, the pack is written to
  objects/pack/ directory of the current Git repository with a
  default name determined from the pack content.

Originally, git-index-pack was used by bup, and when that was
changed, the naming convention was kept, presumably according
to this documentation; see commit 4cab9ab71fff ("Write idxs
directly rather than using git-index-pack.")

Change things to use the pack's entire content sha1, that we
calculate anyway, as the name.

This requires updating the 'gc' test to not compare by name
but by (index) content.

Also add a test that our behaviour matches git's.

Reported-by: Jamie Wyrick <terrifiedquack80@gmail.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
2 years agoprep-for-freebsd-build: install coreutils for sha1sum
Rob Browning [Fri, 30 Apr 2021 21:16:54 +0000 (16:16 -0500)]
prep-for-freebsd-build: install coreutils for sha1sum

Thanks to Johannes Berg for pointing out the omission.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agocmd.bloom: add missing sys import
Rob Browning [Fri, 30 Apr 2021 19:56:48 +0000 (14:56 -0500)]
cmd.bloom: add missing sys import

Fix imports changed by bd63c7829e011bc2991817212db07ebb5646cc20

Thanks to Johannes Berg for reporting the problem.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agometadata: mention that from_path is also used as a test hook
Rob Browning [Fri, 30 Apr 2021 19:42:36 +0000 (14:42 -0500)]
metadata: mention that from_path is also used as a test hook

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agometadata: implement write using encode, not vice versa
Johannes Berg [Fri, 31 Jan 2020 22:29:09 +0000 (23:29 +0100)]
metadata: implement write using encode, not vice versa

Using write() for encode() is slower due to the use of BytesIO,
and we never really stream the data out anyway since it is part
of an object that we build, so it's all in memory.

Thus, implement write() using encode() rather than the other
way around.

Together with the previous patches, this speeds up encoding the
metadata by about 54%, and indexing by about 15-20% (my system goes
from ~16.3k paths/sec to ~19.7k paths/sec when all the filesystem
data is already buffered in memory).

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agotest_vint: test packing of all 0, 1, and 2 element formats
Rob Browning [Sun, 2 May 2021 22:52:22 +0000 (17:52 -0500)]
test_vint: test packing of all 0, 1, and 2 element formats

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
2 years agovint: implement the typical pack() in C
Johannes Berg [Sat, 1 Feb 2020 21:47:09 +0000 (22:47 +0100)]
vint: implement the typical pack() in C

This estimates the size, and if we run over it falls back to the
slower python, and similarly if anything happens with the vuints/vints
contained in there, but it still speeds up the typical case
significantly, and improves raw index speed (on cached filesystem
data) by about 14% (~19.7k paths/sec to ~22.5k paths/sec).

Since it doesn't handle corner cases (very long strings or very large
numbers) add a few tests that cover the fallback to python.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: switch to PyMem_Raw*; rename to
 limited_vint_pack; use Py_ssize_t with PyTuple_GET_SIZE]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agovint: implement pack() without BytesIO
Johannes Berg [Fri, 31 Jan 2020 22:28:29 +0000 (23:28 +0100)]
vint: implement pack() without BytesIO

Using BytesIO here makes it slower since it resizes the
memory quite bit, using a list to collect and then joining
that list makes it faster.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
2 years agovint: implement encoding in C
Johannes Berg [Fri, 31 Jan 2020 22:27:14 +0000 (23:27 +0100)]
vint: implement encoding in C

The vuint/vint encoding is quite slow, possibly due to the use
of BytesIO and byte-wise writing, for what's really almost always
a fixed-size buffer since we typically don't deal with values
that don't fit into a 64-bit signed integer.

Implement this in C to make it faster, at least for those that
fit into signed 64-bit integers (long long, because python makes
overflow checking for unsigned 64-bit integers hard), and if the
C version throws an OverflowError, fall back to the python code.

Also add a test for something that doesn't actually fit into a
64-bit integer.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: adjusted bup_vuint_encode and bup_vint_encode
 to just directly return the PyBytes_FromStringAndSize result]
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
2 years agoGNUmakefile: use correct dev/python path when installing bup
Johannes Berg [Fri, 7 May 2021 20:06:34 +0000 (22:06 +0200)]
GNUmakefile: use correct dev/python path when installing bup

$(bup_python) no longer exists, we should use dev/python.
But since we change working directory, that needs a fully
qualified path.

Reported-by: Quaddle Me <quaddle.me@gmail.com>
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
[rlb@defaultvalue.org: use $(CURDIR) instead of $(PWD); add . target dir]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
3 years agogit: refactor PackWriter.new_commit() into create_commit_blob()
Johannes Berg [Fri, 3 Jan 2020 22:16:29 +0000 (23:16 +0100)]
git: refactor PackWriter.new_commit() into create_commit_blob()

Move most of the code into a new create_commit_blob() function that
can be used elsewhere as well.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
3 years agols: make multiple arguments match real ls
Johannes Berg [Tue, 28 Jul 2020 20:42:46 +0000 (22:42 +0200)]
ls: make multiple arguments match real ls

Currently, passing multiple arguments to ls causes it to print
them all in a single list, which can be very confusing as it'll
even columnate them together.

Make this match real ls behaviour (at least as observed on my
system) that prints which path it's giving the output for.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
3 years agoGNUmakefile: ensure DESTDIR and bup_shared_ldflags are defined
Rob Browning [Sun, 18 Apr 2021 18:27:17 +0000 (13:27 -0500)]
GNUmakefile: ensure DESTDIR and bup_shared_ldflags are defined

Satisfy --warn-undefined-variables

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
3 years agoftp: print pwd as part of the prompt
Johannes Berg [Tue, 28 Jul 2020 20:33:43 +0000 (22:33 +0200)]
ftp: print pwd as part of the prompt

Print the current directory as part of the prompt.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
3 years agoftp: honour pwd for ls
Johannes Berg [Tue, 28 Jul 2020 20:38:01 +0000 (22:38 +0200)]
ftp: honour pwd for ls

Honour the current working directory for 'ls' by changing
ls.within_repo() to get the pwd, and using posixpath to
build the correct path to do the ls for.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
3 years agogit: remove get_commit_dates()
Johannes Berg [Mon, 28 Dec 2020 21:56:02 +0000 (22:56 +0100)]
git: remove get_commit_dates()

This function is unused.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: likely orphaned by vfs overhaul]

3 years agogit: remove loose object handling
Johannes Berg [Thu, 23 Jan 2020 17:30:32 +0000 (18:30 +0100)]
git: remove loose object handling

This isn't necessary - bup never writes loose objects, and to
read uses cat-file. Just remove the dead code.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
3 years agogit: remove all_packdirs()
Johannes Berg [Wed, 30 Dec 2020 22:00:31 +0000 (23:00 +0100)]
git: remove all_packdirs()

This really never made sense - if you have a local repository
and want to run midx/bloom on it, then it doesn't make sense
to touch the index caches for other remote repositories.

And if you want to operate manually on the cache for some odd
reason (it's maintained automatically) then you anyway need to
(and should) pass the --dir option for it explicitly.

Remove this to make things easier to reason about.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
[rlb@defaultvalue.org: previous behavior also didn't respect the
 documentation in bup-bloom(1).]

3 years ago.gitignore: update (include C .d files, etc.)
Rob Browning [Sun, 18 Apr 2021 17:40:43 +0000 (12:40 -0500)]
.gitignore: update (include C .d files, etc.)

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
3 years ago_helpers: remove empty PyArg_ParseTuple() from METH_NOARGS
Johannes Berg [Sun, 24 Jan 2021 20:24:03 +0000 (21:24 +0100)]
_helpers: remove empty PyArg_ParseTuple() from METH_NOARGS

With METH_NOARGS, args is NULL, and thus PyArg_ParseTuple()
will segfault. Remove it, since it's unnecessary anyway.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
3 years agoconfigure: fix readline.h detection
Johannes Berg [Sun, 24 Jan 2021 20:22:32 +0000 (21:22 +0100)]
configure: fix readline.h detection

Unfortunately, readline.h requires stdio.h to be included first,
except where it has been patched (e.g. Debian). Do that in the
configure script so we correctly detect readline.h on systems
that have an unpatched readline version.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
3 years agomidx: correct path_msg() use in an error path
Johannes Berg [Sun, 24 Jan 2021 20:28:35 +0000 (21:28 +0100)]
midx: correct path_msg() use in an error path

pathmsg() doesn't exist, it should be path_msg(). Fix that.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
3 years agoftp: fix tab completion
Rob Browning [Sun, 11 Apr 2021 20:06:37 +0000 (15:06 -0500)]
ftp: fix tab completion

We need the 'repo' variable in enter_completion() which assumes
it's global, so make it global.

Fixes: c4d10541ed1e ("ftp: convert to internal command")
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
3 years agohelpers: adjust macos linkage
Rob Browning [Sun, 11 Apr 2021 19:53:21 +0000 (14:53 -0500)]
helpers: adjust macos linkage

Apparently macos needs -bundle and -undefined dynamic_lookup since
around 2003.  cpython does something similar via its own sysconfig
LDSHARED command.

Thanks to Johannes Berg for finding the solution.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
3 years agoConvert bup to binary executable and run python subcommands directly
Rob Browning [Sat, 3 Apr 2021 20:17:01 +0000 (15:17 -0500)]
Convert bup to binary executable and run python subcommands directly

Don't execute python subcommands in a child process, run them
directly.  Convert bup (and dev/python, etc.) to be C executables.
See the commit messages, comments, and doc changes (e.g. DESIGN) for
more information.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
3 years agowvtest-bup.sh: set _wvtop to the physical path
Rob Browning [Sun, 28 Mar 2021 21:11:03 +0000 (16:11 -0500)]
wvtest-bup.sh: set _wvtop to the physical path

The previous fix was insufficient:
96da3f0142c8f41fc379db4e4e31df2426d466b5

The problem can be demonstrated via:

  ln -s bup-real bup
  cd bup
  make check

cf. 7a8f8d91501525d4710918a1638b5df1fd4c54a5

Thanks to Johannes Berg for tracking down the solution.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
3 years agocirrus: drop py2 on freebsd
Rob Browning [Sun, 28 Mar 2021 20:30:54 +0000 (15:30 -0500)]
cirrus: drop py2 on freebsd

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
3 years agocirrus: drop py2 on macos since brew did
Rob Browning [Sun, 28 Mar 2021 19:22:50 +0000 (14:22 -0500)]
cirrus: drop py2 on macos since brew did

  Homebrew provided a python@2 formula until the end of 2019, at which
  point it was removed due to the Python 2 deprecation.

  -- https://docs.brew.sh/Homebrew-and-Python

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
3 years agoid-other-than: pass strings to getpwnam/getgrnam
Rob Browning [Sun, 28 Mar 2021 18:14:26 +0000 (13:14 -0500)]
id-other-than: pass strings to getpwnam/getgrnam

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
3 years agobup: cat-file: fix error print
Johannes Berg [Sun, 21 Mar 2021 14:23:33 +0000 (15:23 +0100)]
bup: cat-file: fix error print

Some variable renaming and bytes issues, if a target cannot
be found in cat-file.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
3 years agoexe_parent_dir: allow arbitrary proc readlink path lengths
Rob Browning [Sun, 28 Mar 2021 17:01:07 +0000 (12:01 -0500)]
exe_parent_dir: allow arbitrary proc readlink path lengths

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
3 years agoexe_parent_dir: allow arbritrary macos path lengths
Rob Browning [Sun, 28 Mar 2021 17:00:12 +0000 (12:00 -0500)]
exe_parent_dir: allow arbritrary macos path lengths

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
3 years agoRedirect to GNU make when possible
Rob Browning [Sat, 27 Mar 2021 22:05:39 +0000 (17:05 -0500)]
Redirect to GNU make when possible

Rename Makefile to GNUmakefile and add a Makefile that for at least
FreeBSD make will redirect the build to GNU make, and don't fail if
make is not GNU make without checking gmake.

Thanks to Greg Troxel for a reminder about the issue.

Signed-off-by: Rob Browning <rlb@defaultvalue.org
Tested-by: Rob Browning <rlb@defaultvalue.org>
3 years agoMove Makefile to GNUmakefile
Rob Browning [Sat, 27 Mar 2021 21:59:12 +0000 (16:59 -0500)]
Move Makefile to GNUmakefile

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