Skip to content

Extract metadata from conaninfo.txt

What does this MR do and why?

This MR extracts the data from conaninfo.txt and replaces the info for the conan package with the json representation.

References

How to set up and validate locally

Supposing you have a conan remote called "gitlab-local" pointing to your local gitlab project. If not, you can set it up following the documentations: https://docs.gitlab.com/ee/user/packages/conan_repository/#add-a-remote-for-your-project

  1. Create a new conan package

    mkdir searchTestpkg && cd searchTestpkg
    conan new searchTest/1.2.3@gitlab-org+conan/stable --template=cmake_lib
    conan create . gitlab-org+conan/stable
  2. Upload the package

    conan upload searchTest/1.2.3@gitlab-org+conan/stable -r gitlab-local --all
  3. Open rails console to verify the metadata

    gdk rails console
    # We take the last package, assuming this is the latest uploaded.
    package=Packages::Package.last
    package_file=package_file=package.package_files.find{|p| p.file_name == "conaninfo.txt"}
    package_file.conan_file_metadatum.package_reference.info

    This can be compared with the built package file that can be found at:

    ~/.conan/data/searchTest/1.2.3/gitlab-org+conan/stable/package/<hash>/conaninfo.txt
  4. Check invalid conaninfo.txt

    Run the following commands to generate a profile that will give a big conaninfo:

    cp ~/.conan/profiles/default ~/.conan/profiles/big_conaninfo
    echo '    AAAAA=' >> ~/.conan/profiles/big_conaninfo
    printf 'A%.0s' {1..20001} >> ~/.conan/profiles/big_conaninfo

    This assumes that the [env] section is the last section in the default profile. Check that the ~/.conan/profiles/big_conaninfo file ends with:

    ...
    [env]
        AAAAA=AAAA....

    Create a new package with the new profile and publish it.

    mkdir bigTestpkg && cd bigTestpkg
    conan new bigTest/1.2.3@gitlab-org+conan/stable --template=cmake_lib
    conan create . gitlab-org+conan/stable -pr big_conaninfo
    conan upload bigTest/1.2.3@gitlab-org+conan/stable -r gitlab-local --all

    When checking the info field with the commands from step 3 you should get {} as a value


cc @oceane_scania

Related to #338926

💾 Database analysis

Edited by David Fernandez

Merge request reports

Loading