Exemplo n.º 1
0
    def get_local_plugin_version(self, plugin, index_json, iocroot, jail_name):
        """
        Checks the primary_pkg key in the INDEX with the pkg version
        inside the jail.
        """
        version = {k: 'N/A' for k in ('version', 'revision', 'epoch')}

        if index_json is None:
            return version

        try:
            base_plugin = plugin.rsplit('_', 1)[0]  # May have multiple
            primary_pkg = index_json[base_plugin].get('primary_pkg') or plugin

            # Since these are plugins, we don't want to spin them up just to
            # check a pkg, directly accessing the db is best in this case.
            db_rows = self.read_plugin_pkg_db(
                f'{iocroot}/jails/{jail_name}/root/var/db/pkg/local.sqlite',
                primary_pkg)

            for row in db_rows:
                row = list(row)
                if '/' not in primary_pkg:
                    row[1] = row[1].split('/', 1)[-1]
                    row[2] = row[2].split('/', 1)[-1]

                if primary_pkg == row[1] or primary_pkg == row[2]:
                    version = ioc_common.parse_package_name(
                        f'{plugin}-{row[3]}')
                    break
        except (KeyError, sqlite3.OperationalError):
            pass

        return version
def test_02_revision():
    assert parse_package_name('ORBit2-2.14.19_2.txz')['revision'] == '2'
def test_04_version_revision_epoch():
    data = parse_package_name('dnsmasq-2.80_2,1')
    assert data['version'] == '2.80'
    assert data['revision'] == '2'
    assert data['epoch'] == '0'
def test_01_version_check():
    assert parse_package_name('ImageMagick7-7.0.8.47')['version'] == '7.0.8.47'
    assert parse_package_name('ImageMagick7-7.0.8.47')['revision'] == '0'
def test_03_epoch():
    assert parse_package_name('ap24-mod_perl2-2.0.10,3')['epoch'] == '3'