Conan: Make hash depending on linux distro

Created on 12 Apr 2018  路  2Comments  路  Source: conan-io/conan

I'm using a ncurses conan package for some projects. In configuration of ncurses the path to terminfo is set. This path depends on the linux distribution. On ubuntu it is /lib and on centos it is /usr/share. Therefor I use OSInfo to determine the distro:

def build(self):
    env_build = AutoToolsBuildEnvironment(self)
    args = ["--without-debug"]
    if self.options.shared:
        args += ["--with-shared", "--without-normal"]
    info = OSInfo()
    if info.is_linux and info.linux_distro in ("debian", "ubuntu"):
        args += ["--datadir=/lib"]
    env_build.configure(configure_dir="src", args=args, build=False, host=False, target=False)
    env_build.make()

The settings tuple contains:

"os", "compiler", "build_type", "arch"

As far as I understand following can happen.

  1. I build this package on ubuntu and upload the package.

  2. I use a centos with same compiler, arch and build_type.

  3. Conan genrates the same hash on centos and ubuntu and downloads the ubuntu package on centos with wrong datadir.

How can I avoid this problem? I'd like to add something like os.distro into the settings tuple.

question

Most helpful comment

Yes, the best solution would be to augment the settings.yml with something like:

os:
    ...
    WindowsStore:
        version: ["8.1", "10.0"]
    Linux:
         distro: ["Ubuntu", "RHEL6", ...]

As it is a subsetting of os for Linux, it will generate different packages in the different distros.
You probably want to add distro=Ubuntu, etc., in your profiles and default profiles

Please remember that both the settings.yml and the profiles can be shared automatically with conan config install command.

All 2 comments

Yes, the best solution would be to augment the settings.yml with something like:

os:
    ...
    WindowsStore:
        version: ["8.1", "10.0"]
    Linux:
         distro: ["Ubuntu", "RHEL6", ...]

As it is a subsetting of os for Linux, it will generate different packages in the different distros.
You probably want to add distro=Ubuntu, etc., in your profiles and default profiles

Please remember that both the settings.yml and the profiles can be shared automatically with conan config install command.

As this a common question, I have opened an issue in the docs to add it to the FAQ: conan-io/docs#1137

I think the solution is pretty clear so I am considering this question as solved, but please feel free to comment any other idea.
Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

db4 picture db4  路  3Comments

niosHD picture niosHD  路  3Comments

tonka3000 picture tonka3000  路  3Comments

liberforce picture liberforce  路  3Comments

mpdelbuono picture mpdelbuono  路  3Comments