|
@@ -103,14 +103,6 @@ def chdir(path):
|
|
os.chdir(previous)
|
|
os.chdir(previous)
|
|
sys.stderr.write('cd {}\n'.format(shlex.quote(previous)))
|
|
sys.stderr.write('cd {}\n'.format(shlex.quote(previous)))
|
|
|
|
|
|
-def dpkg_search(path_search_pattern):
|
|
|
|
- assert isinstance(path_search_pattern, str)
|
|
|
|
- return re.findall(
|
|
|
|
- '^(\S+): (.*)$\n',
|
|
|
|
- $(dpkg --search @(path_search_pattern)),
|
|
|
|
- flags=re.MULTILINE,
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
def dpkg_welse(cmd):
|
|
def dpkg_welse(cmd):
|
|
pkg_name, _ = dpkg_which(cmd)
|
|
pkg_name, _ = dpkg_which(cmd)
|
|
return $(dpkg --listfiles @(pkg_name)).split('\n')[:-1]
|
|
return $(dpkg --listfiles @(pkg_name)).split('\n')[:-1]
|
|
@@ -118,10 +110,9 @@ def dpkg_welse(cmd):
|
|
def dpkg_which(cmd):
|
|
def dpkg_which(cmd):
|
|
cmd_path = shutil.which(cmd)
|
|
cmd_path = shutil.which(cmd)
|
|
assert cmd_path, 'cmd {!r} not found'.format(cmd)
|
|
assert cmd_path, 'cmd {!r} not found'.format(cmd)
|
|
- matches = dpkg_search(cmd_path)
|
|
+ search_match = re.search('^(\S+): ', $(dpkg --search @(cmd_path)))
|
|
- assert len(matches) != 0, '{!r} not installed via dpkg'.format(cmd_path)
|
|
+ assert search_match, f'{cmd_path!r} not installed via dpkg'
|
|
- assert len(matches) == 1
|
|
+ return search_match.group(1), cmd_path
|
|
- return matches[0]
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
@contextlib.contextmanager
|
|
def encfs_mount(root_dir_path, mount_point_path, extpass=None):
|
|
def encfs_mount(root_dir_path, mount_point_path, extpass=None):
|