[pacman-dev] [RFC] New attempt at a better interface for adding/removing target

Xavier Chantry chantry.xavier at gmail.com
Tue Oct 19 16:39:37 EDT 2010

See http://code.toofishes.net/cgit/xavier/pacman.git/commit/?h=working&id=eeab3fac28ce4567ee0a7d3dfedebd8f66c4ebc9
alpm: deprecate old interface
Old interface is marked as deprecated:
int alpm_sync_target(char *target);
int alpm_sync_dbtarget(char *db, char *target);
int alpm_add_target(char *target);
int alpm_remove_target(char *target);

New recommended interface:
int alpm_add_pkg(pmpkg_t *pkg);
int alpm_remove_pkg(pmpkg_t *pkg);

Having interfaces dealing directly with pmpkg_t is more powerful and
more accurate.
Also see http://mailman.archlinux.org/pipermail/pacman-dev/2009-June/008847.html
However it's probably also less safe for bad frontends trying to do
stupid things and trying to pass invalid or outdated pmpkg.
I am not sure what the consequences could be, it might need some more
thinking and a few sanity checks.

I unified sync_pkg and add_pkg, however there was a slight behavior
difference between them, which should be fixed.
pacman/upgrade: switch to new interface
Note that there is a behavior change here : if the same package name
appeared several times in the target list, the alpm_add_target interface
chooses the new package, while alpm_add_pkg returns PKG_DUP.

I don't see why we cannot unify the behavior of -S and -U, and just
choose one behavior that applies to both.

Otherwise, it's always possible to handle these different behaviors in
the frontend, it just requires more work.

I just picked the two commits I found most relevant and for which I
saw some possible concerns, but there are ~10 commits related to this
interface rework on my branch.

More information about the pacman-dev mailing list