[PATCH 3/6] README: describe fuse module requirements

4 views
Skip to first unread message

Rob Browning

unread,
Jul 1, 2022, 3:22:51 PM7/1/22
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---

Pushed.

README.md | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/README.md b/README.md
index 53f84d2f..807dce78 100644
--- a/README.md
+++ b/README.md
@@ -136,6 +136,11 @@ From source
- Install the required python libraries (including the development
libraries).

+ For `bup fuse` you will need to install
+ [python-fuse](https://github.com/libfuse/python-fuse) rather than
+ [fusepy](https://github.com/fusepy/fusepy). For example, in
+ Debian, install python3-fuse rather than python3-fusepy.
+
On very recent Debian/Ubuntu versions, this may be sufficient (run
as root):

--
2.30.2

Rob Browning

unread,
Jul 1, 2022, 3:22:51 PM7/1/22
to bup-...@googlegroups.com, Johannes Berg
From: Johannes Berg <joha...@sipsolutions.net>

We really don't have any code path getting here without
a sha, so don't try to make up for it if it's missing,
just assert.

Signed-off-by: Johannes Berg <joha...@sipsolutions.net>
Reviewed-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---

Pushed.

lib/bup/git.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/bup/git.py b/lib/bup/git.py
index 5d46cc7b..f7ff94b0 100644
--- a/lib/bup/git.py
+++ b/lib/bup/git.py
@@ -855,8 +855,7 @@ class PackWriter(object):
def _write(self, sha, type, content):
if verbose:
log('>')
- if not sha:
- sha = calc_hash(type, content)
+ assert sha
size, crc = self._raw_write(_encode_packobj(type, content,
self.compression_level),
sha=sha)
--
2.30.2

Rob Browning

unread,
Jul 1, 2022, 3:22:52 PM7/1/22
to bup-...@googlegroups.com, Johannes Berg
From: Johannes Berg <joha...@sipsolutions.net>

Return the value instead of storing it in a global, that makes
it easier to use elsewhere in the future.

Signed-off-by: Johannes Berg <joha...@sipsolutions.net>
Reviewed-by: Rob Browning <r...@defaultvalue.org>
[r...@defaultvalue.org: rm guess_repo argument]
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---

Pushed.

lib/bup/git.py | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/bup/git.py b/lib/bup/git.py
index f7ff94b0..9163c409 100644
--- a/lib/bup/git.py
+++ b/lib/bup/git.py
@@ -1185,25 +1185,24 @@ def delete_ref(refname, oldvalue=None):
_git_wait('git update-ref', p)


-def guess_repo(path=None):
- """Set the path value in the global variable "repodir".
- This makes bup look for an existing bup repository, but not fail if a
- repository doesn't exist. Usually, if you are interacting with a bup
- repository, you would not be calling this function but using
- check_repo_or_die().
+def guess_repo():
+ """Return the global repodir or BUP_DIR when either is set, or ~/.bup.
+ Usually, if you are interacting with a bup repository, you would
+ not be calling this function but using check_repo_or_die().
+
"""
- global repodir
- if path:
- repodir = path
- if not repodir:
- repodir = environ.get(b'BUP_DIR')
- if not repodir:
- repodir = os.path.expanduser(b'~/.bup')
+ if repodir:
+ return repodir
+ repo = environ.get(b'BUP_DIR')
+ if not repo:
+ repo = os.path.expanduser(b'~/.bup')
+ return repo


def init_repo(path=None):
"""Create the Git bare repository for bup in a given path."""
- guess_repo(path)
+ global repodir
+ repodir = path or guess_repo()
d = repo() # appends a / to the path
parent = os.path.dirname(os.path.dirname(d))
if parent and not os.path.exists(parent):
@@ -1228,7 +1227,8 @@ def init_repo(path=None):

def check_repo_or_die(path=None):
"""Check to see if a bup repository probably exists, and abort if not."""
- guess_repo(path)
+ global repodir
+ repodir = path or guess_repo()
top = repo()
pst = stat_if_exists(top + b'/objects/pack')
if pst and stat.S_ISDIR(pst.st_mode):
--
2.30.2

Rob Browning

unread,
Jul 1, 2022, 3:22:52 PM7/1/22
to bup-...@googlegroups.com, Johannes Berg
From: Johannes Berg <joha...@sipsolutions.net>

When importing 'fuse', we might get either the libfuse or
the fusepy module, the latter doesn't have __version__ so
we just print

error: fuse module is too old for fuse.__version__

but that's misleading. Detect if we have fuse.FUSE and in
that case instead print

error: fuse module appears to be fusepy, not python-fuse
please install https://github.com/libfuse/python-fuse

Signed-off-by: Johannes Berg <joha...@sipsolutions.net>
Reviewed-by: Rob Browning <r...@defaultvalue.org>
[r...@defaultvalue.org: adjust commit message and error messages]
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---

Pushed.

lib/bup/cmd/fuse.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/bup/cmd/fuse.py b/lib/bup/cmd/fuse.py
index 27937123..78073eed 100644
--- a/lib/bup/cmd/fuse.py
+++ b/lib/bup/cmd/fuse.py
@@ -9,7 +9,13 @@ except ImportError:
file=sys.stderr)
sys.exit(2)
if not hasattr(fuse, '__version__'):
- print('error: fuse module is too old for fuse.__version__', file=sys.stderr)
+ if hasattr(fuse, 'FUSE'):
+ print('error: python fuse module appears to be fusepy, not python-fuse\n'
+ ' please install https://github.com/libfuse/python-fuse',
+ file=sys.stderr)
+ else:
+ print('error: fuse module may need to be upgraded (no fuse.__version__)',
+ file=sys.stderr)
sys.exit(2)
fuse.fuse_python_api = (0, 2)

--
2.30.2

Reply all
Reply to author
Forward
0 new messages