openSUSE / libsolv

Library for solving packages and reading repositories
http://en.opensuse.org/openSUSE:Libzypp_satsolver
Other
509 stars 151 forks source link

Alien versionning through callbacks #523

Open AntoinePrv opened 1 year ago

AntoinePrv commented 1 year ago

Hello,

Say users would like to use the libsolv but have an extremely complicated or private versioning and dependency scheme (unicode why not, or some database lookup). What functions would they need to provide to work with libsolv?

Taking inspiration from conda functions (I am actually investigating this in the context of Mamba), it seems that around six functions would be required:

// Compare two version as ` const char*`
int pool_evrcmp_alien(const Pool *pool, const char *evr1, const char *evr2, int mode);
// Check if a solvable matches a given version
int solvable_alien_matchversion(Solvable *s, const char *version);
// Add solvables satifying the version to whatprovides. Could it be derived from the solvable_alien_matchversion?
Id pool_addrelproviders_alien(Pool *pool, Id name, Id evr, Queue *plist);
// Split a reldep into name/evr
Id pool_alien_matchspec(Pool *pool, const char *name);
// Add negative exclusion rules between `n` and `dep`
void add_conda_constrains_rule(Solver *solv, Id n, Id dep, int dontfix);
// Some function to set solution priority (policy)
...

For repository specifications, the users could write their own repo_add_alien without requiring modification in libsolv.

Is that a reasonable view of how libsolv handles different format? Would you consider a PR that lets user define their own REL_ALIEN/DISTTYPE_ALIEN by providing function callbacks?

mlschroe commented 1 year ago

Just a random remark: one of the really useful features is that the solver can write a testcase that can be analyzed later with the testsolv tool. That would no longer work with a custom version comparison.