Message ID | 20250727011123.31634-3-laurent.pinchart@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi 2025. 07. 27. 3:11 keltezéssel, Laurent Pinchart írta: > When building containers, we favour packages from the Debian > repositories, and fall back to pip when minimum version requirements are > not met by Debian. This is open-coded for two packages (meson and > python3-pygments). Generalize the mechanism in preparation for adding > more packages. > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > .gitlab-ci/setup-container.sh | 43 +++++++++++++++++++---------------- > 1 file changed, 24 insertions(+), 19 deletions(-) > > diff --git a/.gitlab-ci/setup-container.sh b/.gitlab-ci/setup-container.sh > index 5e9b89da8431..c8b631c387b5 100755 > --- a/.gitlab-ci/setup-container.sh > +++ b/.gitlab-ci/setup-container.sh > @@ -93,6 +93,11 @@ PKGS_VIRTME_RUNTIME=( > udev > ) > > +PKGS_PIP_MIN_VERSIONS=( > + 'meson meson 1.2.0 remove' > + 'python3-pygments pygments 2.10.0 keep' > +) > + > archs=( amd64 ) > > declare -A components > @@ -192,34 +197,34 @@ dpkg_check_version() { > cbuild_fixups() { > echo "Applying miscellaneous fixups" > > - local min_version > local pip3_options > - local version > + local pkg > > if [[ $FDO_DISTRIBUTION_VERSION != 'bullseye' ]] ; then > pip3_options=--break-system-packages > fi > > - # Install meson from pip. > - min_version=1.2.0 > - version=$(dpkg_version meson) > - if dpkg_check_version $version $min_version ; then > - echo "meson $version too old, installing $min_version from pip" > + # Install packages from pip to ensure minimum versions. > + for pkg in "${PKGS_PIP_MIN_VERSIONS[@]}" ; do > + pkg=($pkg) And people say C++ is unreadable... > + local pkg_name=${pkg[0]} > + local pip_name=${pkg[1]} > + local min_version=${pkg[2]} > + local action=${pkg[3]} > > - apt remove -y meson > - apt install -y python3-pip > - pip3 install ${pip3_options} meson==${min_version} > - fi > + local version=$(dpkg_version $pkg_name) > > - # Install pygments from pip. > - min_version=2.10.0 > - version=$(dpkg_version python3-pygments) > - if dpkg_check_version $version $min_version ; then > - echo "pygments $version too old, installing $min_version from pip" > + if dpkg_check_version $version $min_version ; then > + echo "$pkg_name $version too old, installing $min_version from pip" > > - apt install -y python3-pip > - pip3 install ${pip3_options} pygments==${min_version} > - fi > + if [[ $action == 'remove' ]] ; then I haven't found out why some packages need to be kept/removed, and it's not clear to me at all. But it seems to do what I expect the code to do: https://gitlab.freedesktop.org/pobrn/libcamera/-/jobs/81380023 Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > + apt remove -y ${pkg_name} > + fi > + > + apt install -y python3-pip > + pip3 install ${pip3_options} ${pip_name}==${min_version} > + fi > + done > > # Create pybind11.pc manually if not provided by the distribution > # package.
On Mon, Jul 28, 2025 at 04:18:02PM +0200, Barnabás Pőcze wrote: > 2025. 07. 27. 3:11 keltezéssel, Laurent Pinchart írta: > > When building containers, we favour packages from the Debian > > repositories, and fall back to pip when minimum version requirements are > > not met by Debian. This is open-coded for two packages (meson and > > python3-pygments). Generalize the mechanism in preparation for adding > > more packages. > > > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > > --- > > .gitlab-ci/setup-container.sh | 43 +++++++++++++++++++---------------- > > 1 file changed, 24 insertions(+), 19 deletions(-) > > > > diff --git a/.gitlab-ci/setup-container.sh b/.gitlab-ci/setup-container.sh > > index 5e9b89da8431..c8b631c387b5 100755 > > --- a/.gitlab-ci/setup-container.sh > > +++ b/.gitlab-ci/setup-container.sh > > @@ -93,6 +93,11 @@ PKGS_VIRTME_RUNTIME=( > > udev > > ) > > > > +PKGS_PIP_MIN_VERSIONS=( > > + 'meson meson 1.2.0 remove' > > + 'python3-pygments pygments 2.10.0 keep' > > +) > > + > > archs=( amd64 ) > > > > declare -A components > > @@ -192,34 +197,34 @@ dpkg_check_version() { > > cbuild_fixups() { > > echo "Applying miscellaneous fixups" > > > > - local min_version > > local pip3_options > > - local version > > + local pkg > > > > if [[ $FDO_DISTRIBUTION_VERSION != 'bullseye' ]] ; then > > pip3_options=--break-system-packages > > fi > > > > - # Install meson from pip. > > - min_version=1.2.0 > > - version=$(dpkg_version meson) > > - if dpkg_check_version $version $min_version ; then > > - echo "meson $version too old, installing $min_version from pip" > > + # Install packages from pip to ensure minimum versions. > > + for pkg in "${PKGS_PIP_MIN_VERSIONS[@]}" ; do > > + pkg=($pkg) > > And people say C++ is unreadable... :-D > > + local pkg_name=${pkg[0]} > > + local pip_name=${pkg[1]} > > + local min_version=${pkg[2]} > > + local action=${pkg[3]} > > > > - apt remove -y meson > > - apt install -y python3-pip > > - pip3 install ${pip3_options} meson==${min_version} > > - fi > > + local version=$(dpkg_version $pkg_name) > > > > - # Install pygments from pip. > > - min_version=2.10.0 > > - version=$(dpkg_version python3-pygments) > > - if dpkg_check_version $version $min_version ; then > > - echo "pygments $version too old, installing $min_version from pip" > > + if dpkg_check_version $version $min_version ; then > > + echo "$pkg_name $version too old, installing $min_version from pip" > > > > - apt install -y python3-pip > > - pip3 install ${pip3_options} pygments==${min_version} > > - fi > > + if [[ $action == 'remove' ]] ; then > > I haven't found out why some packages need to be kept/removed, and it's not > clear to me at all. But it seems to do what I expect the code to do: > https://gitlab.freedesktop.org/pobrn/libcamera/-/jobs/81380023 If python3-pygments is uninstalled, python3-sphinx will be uninstalled as well as it depends on it. I'll add a comment to the code and send a v2. > Reviewed-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com> > > > + apt remove -y ${pkg_name} > > + fi > > + > > + apt install -y python3-pip > > + pip3 install ${pip3_options} ${pip_name}==${min_version} > > + fi > > + done > > > > # Create pybind11.pc manually if not provided by the distribution > > # package.
diff --git a/.gitlab-ci/setup-container.sh b/.gitlab-ci/setup-container.sh index 5e9b89da8431..c8b631c387b5 100755 --- a/.gitlab-ci/setup-container.sh +++ b/.gitlab-ci/setup-container.sh @@ -93,6 +93,11 @@ PKGS_VIRTME_RUNTIME=( udev ) +PKGS_PIP_MIN_VERSIONS=( + 'meson meson 1.2.0 remove' + 'python3-pygments pygments 2.10.0 keep' +) + archs=( amd64 ) declare -A components @@ -192,34 +197,34 @@ dpkg_check_version() { cbuild_fixups() { echo "Applying miscellaneous fixups" - local min_version local pip3_options - local version + local pkg if [[ $FDO_DISTRIBUTION_VERSION != 'bullseye' ]] ; then pip3_options=--break-system-packages fi - # Install meson from pip. - min_version=1.2.0 - version=$(dpkg_version meson) - if dpkg_check_version $version $min_version ; then - echo "meson $version too old, installing $min_version from pip" + # Install packages from pip to ensure minimum versions. + for pkg in "${PKGS_PIP_MIN_VERSIONS[@]}" ; do + pkg=($pkg) + local pkg_name=${pkg[0]} + local pip_name=${pkg[1]} + local min_version=${pkg[2]} + local action=${pkg[3]} - apt remove -y meson - apt install -y python3-pip - pip3 install ${pip3_options} meson==${min_version} - fi + local version=$(dpkg_version $pkg_name) - # Install pygments from pip. - min_version=2.10.0 - version=$(dpkg_version python3-pygments) - if dpkg_check_version $version $min_version ; then - echo "pygments $version too old, installing $min_version from pip" + if dpkg_check_version $version $min_version ; then + echo "$pkg_name $version too old, installing $min_version from pip" - apt install -y python3-pip - pip3 install ${pip3_options} pygments==${min_version} - fi + if [[ $action == 'remove' ]] ; then + apt remove -y ${pkg_name} + fi + + apt install -y python3-pip + pip3 install ${pip3_options} ${pip_name}==${min_version} + fi + done # Create pybind11.pc manually if not provided by the distribution # package.
When building containers, we favour packages from the Debian repositories, and fall back to pip when minimum version requirements are not met by Debian. This is open-coded for two packages (meson and python3-pygments). Generalize the mechanism in preparation for adding more packages. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> --- .gitlab-ci/setup-container.sh | 43 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 19 deletions(-)