From 165a94cf56677eb93ba97ffef379d692f56862dd Mon Sep 17 00:00:00 2001 From: Blockstream Satellite Date: Thu, 2 Mar 2023 18:51:37 -0300 Subject: [PATCH] deps: Install gr-dvbs2rx from binary packages --- CHANGELOG.md | 8 +- blocksatcli/dependencies.py | 136 ++---------------------------- blocksatcli/verify_deps_instal.py | 15 ++++ doc/sdr.md | 12 +-- 4 files changed, 33 insertions(+), 138 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b52fc26..7f49e30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,16 +13,16 @@ ## 0.4.5 -Release Date: 2023-02-17 +Release Date: 2023-03-03 ### Added +- Support for the gr-dvbs2rx SDR receiver implementation selected with the new + `--impl` option on the `sdr` command and installed by the `deps install` + command on Ubuntu 22.04+ and Fedora 36+. - Support for password-based authentication with the Satellite Monitoring API, enabled automatically with the `--report` option. - Command `reporting password` to set/reset the Monitoring API password. - Command `reporting info` to show the Monitoring API registration info. -- Support for the gr-dvbs2rx SDR receiver implementation selected with the new - `--impl` option on the `sdr` command and installed by command - `deps install --gr-dvbs2rx` on Ubuntu 22.04+ and Fedora 36+. - Option `--disable` to disable selected Linux media modules when building the TBS drivers with the `deps tbs-drivers` command. - Non-interactive modes for the `gqrx` and `sdr` commands. diff --git a/blocksatcli/dependencies.py b/blocksatcli/dependencies.py index 5e0109d..70ca67f 100644 --- a/blocksatcli/dependencies.py +++ b/blocksatcli/dependencies.py @@ -15,8 +15,6 @@ from . import config, defs, util -GR_DVBS2RX_VERSION = '1.0.0' - logger = logging.getLogger(__name__) runner = util.ProcessRunner(logger) @@ -371,11 +369,7 @@ def _install_common(interactive=True, update=False, btc=False): update) -def _install_specific(cfg_dir, - target, - interactive=True, - update=False, - grdvbs2rx=False): +def _install_specific(cfg_dir, target, interactive=True, update=False): """Install setup-specific dependencies""" key = next(key for key, val in target_map.items() if val == target) @@ -391,122 +385,17 @@ def _install_specific(cfg_dir, pkg_map[key]['yum'], interactive, update) # On Fedora >= 36 or Ubuntu >= 22.04, both of which have GNU Radio 3.10 - # available on the main package repo, install gr-dvbs2rx for SDR receivers - # if so desired: - if target == defs.sdr_setup_type and grdvbs2rx: - _install_dvbs2rx(cfg_dir, interactive, update) - - -def _install_dvbs2rx(cfg_dir, interactive, update): - """Install gr-dvbs2rx by building the binary package from source""" - src_dir = os.path.join(cfg_dir, "src") - proj_dir = os.path.join(src_dir, "gr-dvbs2rx") - - util.print_header( - "{} gr-dvbs2rx".format("Updating" if update else "Installing")) - + # available on the main package repo, install gr-dvbs2rx: distro_id = distro.id() distro_ver = distro.version() - fc36_or_higher = distro_id == 'fedora' and int(distro_ver) >= 36 ubuntu22_or_higher = distro_id == 'ubuntu' and LooseVersion( distro_ver) >= '22.04' - if not (fc36_or_higher or ubuntu22_or_higher): - logger.error("gr-dvbs2rx is only supported on Fedora >= 36 " - "and Ubuntu >= 22.04") - return - - if _is_package_installed('gr-dvbs2rx', GR_DVBS2RX_VERSION): - logger.info(f"gr-dvbs2rx {GR_DVBS2RX_VERSION} is already installed") - return - - gr_dvbs2rx_pkg_map = { - 'apt': [ - # gr-dvbs2rx build deps - 'cmake', - 'doxygen', - 'g++', - 'git', - 'gnuradio-dev', - 'graphviz', - 'libsndfile1-dev', - 'libspdlog-dev', - 'pkg-config', - 'pybind11-dev', - 'python3-packaging', - # debian packaging deps - 'debhelper', - 'devscripts', - 'dh-python' - ], - 'dnf': [ - # gr-dvbs2rx build deps - 'cmake', - 'doxygen', - 'fftw-devel', - 'gcc-c++', - 'git', - 'gmp-devel', - 'gnuradio-devel', - 'graphviz', - 'libsndfile-devel', - 'pybind11-devel', - 'python3-packaging', - 'spdlog-devel', - # rpm packaging deps - 'coreutils', - 'dnf-utils', - 'rpm-build', - 'rpm-devel', - 'rpmdevtools' - ], - 'yum': [] # no distro with yum support GR 3.10 - } - - _install_packages(gr_dvbs2rx_pkg_map['apt'], gr_dvbs2rx_pkg_map['dnf'], - gr_dvbs2rx_pkg_map['yum'], interactive, update) - - runner.create_dir('src', cwd=cfg_dir) - - if os.path.exists(proj_dir): - runner.run(['git', 'checkout', GR_DVBS2RX_VERSION], cwd=proj_dir) - else: - runner.run([ - 'git', 'clone', '--recursive', - 'https://github.com/igorauad/gr-dvbs2rx/', '-b', GR_DVBS2RX_VERSION - ], - cwd=src_dir) - - # Build the gr-dvbs2rx package from source - if distro_id == 'ubuntu': - arch = runner.run(['dpkg', '--print-architecture'], - capture_output=True).stdout.decode().replace( - "\n", "") - dist = runner.run(['lsb_release', '-s', '-c'], - capture_output=True).stdout.decode().replace( - "\n", "") - res_dir = None - pkg_name = os.path.join( - proj_dir, '.packaging/build/' + dist + '-' + arch, - "gr-dvbs2rx_" + GR_DVBS2RX_VERSION + '-1_' + arch + '.deb') - runner.run(['.packaging/scripts/pkg-debian.sh'], cwd=proj_dir) - else: - arch = runner.run(['rpmbuild', '--eval', '%{_arch}'], - capture_output=True).stdout.decode().replace( - "\n", "") - dist = runner.run(['rpmbuild', '--eval', '%{dist}'], - capture_output=True).stdout.decode().replace( - "\n", "") - pkg_name = "gr-dvbs2rx-" + GR_DVBS2RX_VERSION + '-1' + dist + '.' + \ - arch + '.rpm' - res_dir = os.path.join(util.get_home_dir(), 'rpmbuild/RPMS/', arch) - runner.run(['.packaging/scripts/pkg-rpm.sh'], cwd=proj_dir) - - # Install the gr-dvbs2r package that was just built - _install_packages([pkg_name], [pkg_name], [], - interactive, - update, - cwd=res_dir) + if target == defs.sdr_setup_type and \ + (fc36_or_higher or ubuntu22_or_higher): + _install_packages(['gr-dvbs2rx', 'gr-osmosdr'], + ['gr-dvbs2rx', 'gr-osmosdr'], [], interactive, + update) def _print_help(args): @@ -550,10 +439,6 @@ def subparser(subparsers): # pragma: no cover action='store_true', default=False, help="Install bitcoin-satellite") - p1.add_argument("--gr-dvbs2rx", - action='store_true', - default=False, - help="Install gr-dvbs2rx") p1.set_defaults(func=run, update=False) p2 = subsubp.add_parser('update', @@ -568,10 +453,6 @@ def subparser(subparsers): # pragma: no cover action='store_true', default=False, help="Update bitcoin-satellite") - p2.add_argument("--gr-dvbs2rx", - action='store_true', - default=False, - help="Update gr-dvbs2rx") p2.set_defaults(func=run, update=True) p3 = subsubp.add_parser('tbs-drivers', @@ -626,8 +507,7 @@ def run(args): _install_specific(args.cfg_dir, target, interactive=interactive, - update=args.update, - grdvbs2rx=args.gr_dvbs2rx) + update=args.update) def drivers(args): diff --git a/blocksatcli/verify_deps_instal.py b/blocksatcli/verify_deps_instal.py index 536ee27..32434e9 100644 --- a/blocksatcli/verify_deps_instal.py +++ b/blocksatcli/verify_deps_instal.py @@ -2,6 +2,10 @@ import logging import unittest import os +from distutils.version import LooseVersion + +import distro + from . import dependencies, util @@ -38,6 +42,17 @@ def test_sdr_deps(self): expected_apps = ["rtl_sdr", "leandvb", "ldpc_tool", "tsp"] self.assertTrue(dependencies.check_apps(expected_apps)) + # gr-dvbs2rx on fc >= 36 and Ubuntu >= 22.04. + distro_id = distro.id() + distro_ver = distro.version() + fc36_or_higher = distro_id == 'fedora' and int(distro_ver) >= 36 + ubuntu22_or_higher = distro_id == 'ubuntu' and LooseVersion( + distro_ver) >= '22.04' + if fc36_or_higher or ubuntu22_or_higher: + self.assertTrue(dependencies.check_apps(["dvbs2-rx"])) + else: + self.assertFalse(dependencies.check_apps(["dvbs2-rx"])) + def test_standalone_deps(self): """Test the installation of standalone receiver dependencies""" args = self.gen_args("standalone") diff --git a/doc/sdr.md b/doc/sdr.md index 72ddd8f..34a0f3d 100644 --- a/doc/sdr.md +++ b/doc/sdr.md @@ -38,7 +38,7 @@ The SDR setup is connected as follows: The SDR-based setup relies on the applications listed below: -- [leandvb](http://www.pabr.org/radio/leandvb/leandvb.en.html): a software-based DVB-S2 receiver application. +- [leandvb](http://www.pabr.org/radio/leandvb/leandvb.en.html) or [gr-dvbs2rx](https://github.com/igorauad/gr-dvbs2rx): the software-based DVB-S2 receiver application. - [rtl_sdr](https://github.com/osmocom/rtl-sdr): reads samples taken by the RTL-SDR and feeds them into [leandvb](http://www.pabr.org/radio/leandvb/leandvb.en.html). - [TSDuck](https://tsduck.io/): unpacks the output of leandvb and produces IP packets to be fed to [Bitcoin Satellite](bitcoin.md). - [Gqrx](https://gqrx.dk): useful for spectrum visualization during antenna pointing. @@ -99,18 +99,18 @@ A Docker image is available for running the SDR host on a container. Please refe ### gr-dvbs2rx Receiver -An alternative software-defined DVB-S2 receiver implementation named gr-dvbs2rx is available on the CLI starting from version 0.4.5. This alternative application is based on the [GNU Radio](https://www.gnuradio.org) framework for software-defined radio. +An alternative software-defined DVB-S2 receiver implementation named gr-dvbs2rx is available on the CLI starting from version 0.4.5. This application is based on the [GNU Radio](https://www.gnuradio.org) framework for software-defined radio, and it is supported on Fedora 36 and Ubuntu 22.04 or later versions only. -To try gr-dvbs2rx, first, run the command below to install it. The installation is supported on Fedora 36 and Ubuntu 22.04 or later versions. +The CLI installs gr-dvbs2rx automatically when available. However, if you are running an existing setup configured with a CLI version preceding 0.4.5, please rerun the installation command: ``` -blocksat-cli deps install --gr-dvbs2rx +blocksat-cli deps install ``` -Then, use the `--impl gr-dvbs2rx` option when launching the receiver, as follows: +Then, relaunch the SDR receiver with the regular command below. The CLI will choose the gr-dvbs2rx application by default when available. However, you can always toggle the implementation using option `--impl`. ``` -blocksat-cli sdr --impl gr-dvbs2rx +blocksat-cli sdr ``` ### Manual Installation of SDR Software