renovate/lib/datasource/repology
Sergei Zharinov 00e2b51071
refactor(datasource/repology): Convert to class (#14132)
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
2022-02-11 08:05:55 +00:00
..
__fixtures__ fix: Update repology multi package project filtering (#13368) 2022-01-05 08:49:11 +01:00
__snapshots__ Return null in case of ambiguous package name resolution in Repology (#11654) 2021-09-10 05:08:31 +00:00
index.spec.ts refactor(datasource/repology): Convert to class (#14132) 2022-02-11 08:05:55 +00:00
index.ts refactor(datasource/repology): Convert to class (#14132) 2022-02-11 08:05:55 +00:00
readme.md docs: fix repology sample (#12192) 2021-10-16 09:57:07 +00:00
types.ts refactor: extract types to new files (#9951) 2021-05-11 12:51:21 +02:00

Repology supports looking up package versions from a wide variety of package repositories and can be used in combination with regex managers to keep dependencies up-to-date which are not specifically supported by Renovate.

To specify which specific repository should be queried when looking up a package, the lookupName has to contain the repository identifier and the package name itself, separated by a slash. As an example, alpine_3_12/gcc would look for a binary or source package called gcc within the alpine_3_12 repository.

A list of all supported repositories can be found on the Repology homepage. To determine the correct identifier, click on a repository of your choice and make note of the identifier in the URL: https://repology.org/repository/<identifier>

As an example, the Alpine Linux 3.12 repository points to https://repology.org/repository/alpine_3_12 and therefor has the repository identifier alpine_3_12.

Usage Example

A real world example for this specific datasource would be maintaining system packages within a Dockerfile, as this allows to specifically pin each dependency without having to manually keep the versions up-to-date. This can be achieved by configuring a generic regex manager in renovate.json for files named Dockerfile:

{
  "regexManagers": [
    {
      "fileMatch": ["^Dockerfile$"],
      "matchStrings": [
        "#\\s*renovate:\\s*datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sENV .*?_VERSION=\"(?<currentValue>.*)\"\\s"
      ],
      "versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}"
    }
  ]
}

Now you may use regular comments in your Dockerfile to automatically update dependencies, which could look like this:

FROM alpine:3.12.0@sha256:a15790640a6690aa1730c38cf0a440e2aa44aaca9b0e8931a9f2b0d7cc90fd65

# renovate: datasource=repology depName=alpine_3_12/gcc versioning=loose
ENV GCC_VERSION="9.3.0-r2"
# renovate: datasource=repology depName=alpine_3_12/musl-dev versioning=loose
ENV MUSL_DEV_VERSION="1.1.24-r8"

RUN apk add --no-cache \
    gcc="${GCC_VERSION}" \
    musl-dev="${MUSL_DEV_VERSION}"

It is often wise to use the loose versioning for distribution packages as the version number usually does not strictly match the semver specification which is used by default. Now whenever the OS package for gcc of Alpine Linux 3.12 is being updated, Renovate will automatically adjust the value of the environment variable to the newest version.