Exemple #1
0
def i_enable_disable_repository(ctx, state, repository):
    """
    Enable/Disable repository with given name.
    """
    repofile = REPO_TMPL.format(repository)
    conf = file_utils.read_ini_file(repofile)
    conf.set(repository, "enabled", str(state))
    ctx.table = conf2table(conf)
    step_an_ini_file_filepath_with(ctx, repofile)
Exemple #2
0
def i_enable_disable_repository(ctx, state, repository):
    """
    Enable/Disable repository with given name.
    """
    repofile = REPO_TMPL.format(repository)
    conf = file_utils.read_ini_file(repofile)
    conf.set(repository, "enabled", str(state))
    ctx.table = conf2table(conf)
    step_an_ini_file_filepath_with(ctx, repofile)
Exemple #3
0
def given_repository_metadata_signed_by(ctx, repository, gpgkey):
    """
    Signs repodata.xml for a given repository using the given GPG key and
    updates the repo file with gpgkey URL.
    Should be used after the repo is created or updated.

    .. note::

        The default dnf settings is *repo_gpgcheck = False*.

    Examples:

    .. code-block:: gherkin

       Feature: Repodata signatures

         Scenario: Setup repository with signed metadata
           Given GPG key "JamesBond"
             And GPG key "JamesBond" imported in rpm database
             And repository "TestRepo" with packages signed by "JamesBond"
               | Package | Tag | Value |
               | TestA   |     |       |
             And repository "TestRepo" metadata signed by "JamesBond"
             And a repo file of repository "TestRepo" modified with
               | Key           | Value |
               | repo_gpgcheck | True  |
    """
    # sign the repomd.xml file
    repodir = repo_utils.get_repo_dir(repository)
    gpg = which("gpg2")
    cmd = "{!s} --detach-sig --armor --default-key '{!s}' {!s}/repodata/repomd.xml".format(
        gpg, gpgkey, repodir)
    step_i_successfully_run_command(ctx, cmd)
    # update the repo file with path to the gpg key
    pubkey = GPGKEY_FILEPATH_TMPL.format(gpgkey, "pubkey")
    keyurl = "file://{!s}".format(pubkey)
    repofile = REPO_TMPL.format(repository)
    conf = file_utils.read_ini_file(repofile)
    conf.set(repository, "gpgkey", keyurl)
    file_utils.create_file_with_contents(repofile, conf)
def given_repository_metadata_signed_by(ctx, repository, gpgkey):
    """
    Signs repodata.xml for a given repository using the given GPG key and
    updates the repo file with gpgkey URL.
    Should be used after the repo is created or updated.

    .. note::

        The default dnf settings is *repo_gpgcheck = False*.

    Examples:

    .. code-block:: gherkin

       Feature: Repodata signatures

         Scenario: Setup repository with signed metadata
           Given GPG key "JamesBond"
             And GPG key "JamesBond" imported in rpm database
             And repository "TestRepo" with packages signed by "JamesBond"
               | Package | Tag | Value |
               | TestA   |     |       |
             And repository "TestRepo" metadata signed by "JamesBond"
             And a repo file of repository "TestRepo" modified with
               | Key           | Value |
               | repo_gpgcheck | True  |
    """
    # sign the repomd.xml file
    repodir = repo_utils.get_repo_dir(repository)
    gpg = which("gpg2")
    cmd = "{!s} --detach-sig --armor --default-key '{!s}' {!s}/repodata/repomd.xml".format(gpg, gpgkey, repodir)
    step_i_successfully_run_command(ctx, cmd)
    # update the repo file with path to the gpg key
    pubkey = GPGKEY_FILEPATH_TMPL.format(gpgkey, "pubkey")
    keyurl = "file://{!s}".format(pubkey)
    repofile = REPO_TMPL.format(repository)
    conf = file_utils.read_ini_file(repofile)
    conf.set(repository, "gpgkey", keyurl)
    file_utils.create_file_with_contents(repofile, conf)