CESNET / netopeer2

NETCONF toolset
BSD 3-Clause "New" or "Revised" License
291 stars 186 forks source link

Dynamic linking of sysrepocfg and sysrepo #1499

Open bvirmani2022 opened 7 months ago

bvirmani2022 commented 7 months ago

Hi, Is it possible to dynamically link multiple sysrepocfg executable with multiple sysrepo repo path?

For eg : I have a different repository path set by env "SYSREPO_REPOSITORY_PATH=sysrepo1" And i want to have sysrepocfg executable as "sysrepocfg1"

SYSREPO_REPOSITORY_PATH=sysrepo2 ...... sysrepocfg2

As of now, I am facing issue with the dynamic linking as each time env "SYSREPO_REPOSITORY_PATH" points to the latest sysrepo and sysrepocfg also points to the same.

I am unable to separately execute sysrepocfg1 or sysrepocfg2. Tried setting "SYSREPOCFG_EXECUTABLE" env as well

Please help with the above.

jktjkt commented 7 months ago

It is unclear what exactly you're requesting. You could surely use some RPATH tricks to have a bunch of different libsysrepo.so.x.y files, and a bunch of sysrepocfg executables as well, but I don't think such a setup would be very useful. However, the most common way of achieving isolation for, say, unit testing is through setting the SYSREPO_REPOSITORY_PATH and SYSREPO_SHM_PREFIX env vars.

bvirmani2022 commented 7 months ago

Hi, Yes I am able to achieve isolation of sysrepo and shm via SYREPO_REPOSITORY_PATH and SYSREP_SHM_PREFIX env variables respectively. Now, what I want to achieve is the sysrepocfg executable linked with the sysrepo path.

sysrepocfg1 points to /sysrepo1 and /dev/shm/sr1

sysrepocfg2 points to /sysrepo2 and /dev/shm/sr2

There is an env defined in cmake for the same SYSREPOCFG_EXECUTABLE and SYSREPOCTL_EXECUTABLE

The env always points to the lastest sysrepocfg and while performing edit of configuration, the latest sysrepo path is pointed to.

So wanted to know , if it is possible to create sysrepocfg executables based on a particular sysrepo path

michalvasko commented 7 months ago

There is an env defined in cmake for the same SYSREPOCFG_EXECUTABLE and SYSREPOCTL_EXECUTABLE

They are used only for setup scripts, nothing else, so I do not think this is of any concern to you.

So wanted to know , if it is possible to create sysrepocfg executables based on a particular sysrepo path

You are not speaking clearly but I am going to assume you want to have several sysrepo executables each linked with a different sysrepo library. This is not possible (to my knowledge) because the dynamic libraries are managed globally on a system by ldconfig(8).

bvirmani2022 commented 7 months ago

Hi Michael, You got the query correct. I want to have several sysrepo executables each linked with a different sysrepo library. If I am exporting SYREPO_REPOSITORY_PATH and SYSREPO_SHM_PREFIX env with particular values, then sysrepocfg works seamless. But I want that my system must have multiple executables sysrepocfg1, ..2, ...3. And for this I cannot run export everytime. If I execute sysrepocfg1, then it must point to the sysrepo1.

If there is any way to achieve it?

michalvasko commented 7 months ago

Write scripts that will first set those variables correctly and only then run sysrepocfg, I really do not know what to tell you.

bvirmani2022 commented 7 months ago

Scripts with export vars cannot be used in the requirement, and that is the reason I wanted to check with you if any other way is there.

If not possible, then I will look into other possibilities.

michalvasko commented 7 months ago

I cannot help then, this feature was intended mostly for tests or similar use-cases, it is not meant for normal usage when a single global sysrepo "instance" is expected.

bvirmani2022 commented 7 months ago

No worries, Michael. Will try to see if anything works out.

Thanks for the support!!