When relisting an opam instance and the opam root directory is already
populated, the '--set-default' parameter must be provided otherwise the
following error is reported:
No switch is currently set. Please use 'opam switch' to set or install a switch
Related to swh/infra/sysadm-environment#4971.
Use subprocess.run instead of subprocess.call and subprocess.Popen to
call opam commands and set check parameter to True in order to raise
CalledProcessError exception when an opam command failed.
This should help spotting issues with the opam lister.
Related to swh/infra/sysadm-environment#4971.
The default behavior of subprocess is to pull executables from a
hardcoded list, which doesn't work when opam is installed manually in
the user's home directory.
That avoids having multiple distinct opam root directories per opam lister instance. The
current opam commands used by the lister are actually listing specifically per instance.
Related to P1171
We should avoid side-effects in the constructor as much as possible. That avoids
surprising behavior at object instantiation time. The state if needed must be
initialized into the `swh.lister.pattern.Lister.get_pages` method, as preconized in the
class docstring.
This also fixes the current test that actually bootstrap a real opam local "clone" in
/tmp.
Related to T3590