[Bug 421588] New: "install --force": documentation and implementation differ

https://bugzilla.novell.com/show_bug.cgi?id=421588 Summary: "install --force": documentation and implementation differ Product: openSUSE 11.0 Version: Final Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: P5 - None Component: libzypp AssignedTo: zypp-maintainers@forge.provo.novell.com ReportedBy: cmorve69@yahoo.es QAContact: qa@suse.de Found By: --- Both zypper in -h and man zypper only say this from the --force option of zypper install: "Install even if the item is already installed (reinstall).". In rpm that behavior is known like "--replacepkgs". rpm also has a "--force" option that is documented this way: "Same as using --replacepkgs, --replacefiles, and --oldpackage." Now, looking at zypper behavior: $ LANG=C zypper se -s --match-exact ffmpeg Reading installed packages... S | Name | Type | Version | Arch | Repository --+--------+---------+------------------------+--------+----------- i | ffmpeg | package | 0.4.9.13782-1.2 | x86_64 | VideoLan v | ffmpeg | package | 0.4.9svn-20080818.pm.0 | x86_64 | Packman v | ffmpeg | package | 0.4.9.13782-1.1 | i686 | VideoLan v | ffmpeg | package | 0.4.9svn-20080818.pm.0 | i686 | Packman v | ffmpeg | package | 0.4.9.13782-1.1 | i586 | VideoLan v | ffmpeg | package | 0.4.9svn-20080818.pm.0 | i586 | Packman -------------------------------------------- # LANG=C zypper in -D -r packman ffmpeg Reading installed packages... Problem: nothing provides requested ffmpeg > 0.4.9.13782-1.2 Have you enabled all requested repositories ? Solution 1: do not ask to install a solvable providing ffmpeg > 0.4.9.13782-1.2 Choose the above solution using '1' or cancel using 'c' [1/C]: 1 Resolving dependencies... Nothing to do. -------------------------------------------- # LANG=C zypper -v in -D -f -r packman ffmpeg Verbosity: 1 Non-option program arguments: 'ffmpeg' Initializing Target Checking whether to refresh metadata for Packman Reading installed packages... Force resolution: Yes Resolving dependencies... Force resolution: Yes Resolving dependencies... The following package is going to be downgraded: ffmpeg-0.4.9svn-20080818.pm.0.x86_64 (Packman, packman.links2linux.de) The following package is going to change vendor: ffmpeg-0.4.9svn-20080818.pm.0.x86_64 (Packman, packman.links2linux.de) Overall download size: 222.0 K. After the operation, additional 686.0 K will be used. Continue? [YES/no]: y committing (dry run) Downloading package ffmpeg-0.4.9svn-20080818.pm.0.x86_64 (1/1), 222.0 K (929.0 K unpacked) Downloading: ffmpeg-0.4.9svn-20080818.pm.0.x86_64.rpm [done] Installing: ffmpeg-0.4.9svn-20080818.pm.0 [done] committing (dry run) CommitResult 1 (errors 0, remaining 0, srcremaining 0) -------------------------------------------- looks like the "--force" option from zypper is the same that the "--force" option from rpm. I don't know if there is any other "surprise" behavior from "zypper in --force"... but if it is also supposed to allow downgrades the zypper documentation should be updated to look more like the rpm docs. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 Ján Kupec <jkupec@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|zypp-maintainers@forge.provo.novell.com |jkupec@novell.com Status|NEW |ASSIGNED Priority|P5 - None |P4 - Low -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=421588#c1 Ján Kupec <jkupec@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |zypp-maintainers@forge.provo.novell.com Status|ASSIGNED |NEEDINFO Info Provider| |schubi@novell.com Priority|P4 - Low |P2 - High --- Comment #1 from Ján Kupec <jkupec@novell.com> 2008-10-05 04:32:04 MDT --- No, --force should only trigger installation of a package even if it is alread installed. I guess this became broken when we switched to sat solover, but i'm not sure. 'zypper in --force' uses: PoolItem candidate = findCandidate(installed); // find better than the current one if (!candidate) candidate = installed; // fall back to the installed one if(!candidate.status().setToBeInstalled(zypp::ResStatus::USER)) candidate.status().setTransact(true, zypp::ResStatus::USER); This worked before, but now it triggers removal of the installed object instead of it's reinstallation. Schubi, what API should i use to force the solver to install the package despite it is already installed? -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 User schubi@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=421588#c2 Stefan Schubert <schubi@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |schubi@novell.com Status|NEEDINFO |ASSIGNED Info Provider|schubi@novell.com | --- Comment #2 from Stefan Schubert <schubi@novell.com> 2008-10-05 08:27:31 MDT --- If "installed" is really an installed item then this item will be deleted in your code: setTransact. So I believe that the "old" findCandite has returned an candidate everytime. (At least an item with the same NVRA as the installed) whereas findCanidate returns now NULL if there is no BETTER candidate available. So do not use setTransact. Just use setToBeInstalled. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=421588#c3 Ján Kupec <jkupec@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |NEEDINFO Info Provider| |schubi@novell.com --- Comment #3 from Ján Kupec <jkupec@novell.com> 2008-10-05 10:45:10 MDT --- (In reply to comment #2 from Stefan Schubert)
If "installed" is really an installed item then this item will be deleted in your code: setTransact.
Exactly.
So I believe that the "old" findCandite has returned an candidate everytime. (At least an item with the same NVRA as the installed) whereas findCanidate
Yes, that's why the behavior as described in this report. I fixed that already, but the --force issue is still not solved.
returns now NULL if there is no BETTER candidate available. So do not use setTransact. Just use setToBeInstalled.
Just setToBeInstalled does not work :O( It does nothing. It can be seen also from the implementation. If the status is installed, it just returns false: bool setToBeInstalled (TransactByValue causer) { if (isInstalled()) return false; return setTransact (true, causer); } But we need to make it install again. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 User schubi@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=421588#c4 Stefan Schubert <schubi@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Info Provider|schubi@novell.com |ma@novell.com --- Comment #4 from Stefan Schubert <schubi@novell.com> 2008-10-05 10:51:51 MDT --- Ok, then we will have to get the original candidate of the installed resolvable. Going to the complete pool is to find the right NVRA is not very powerfull. Michl, is there another possibility. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=421588#c5 --- Comment #5 from Ján Kupec <jkupec@novell.com> 2008-10-05 11:55:07 MDT --- Aaah, i see :O) OK, i will at least do it 'somehow' until Michl answers. But this should be fast enough: struct PoolItemGetter { PoolItem item; bool operator()(const PoolItem & pi) { item = pi; return false; } } PoolItem findInstalledItemInRepos(const PoolItem & installed) { const zypp::ResPool& pool = God->pool(); PoolItemGetter getter; invokeOnEach( pool.byIdentBegin(installed->kind(), installed->name()), pool.byIdentEnd(installed->kind(), installed->name()), functor::chain( functor::chain( resfilter::ByUninstalled(), resfilter::byEdition<CompareByEQ<Edition> >(installed->edition())), resfilter::byArch<CompareByEQ<Arch> >(installed->arch())), functor::functorRef<bool,PoolItem>(getter)); return getter.item; } I can also do it with a Selectable (we can add such method to the selectable) PoolItem Selectable::findInAvailable(const PoolItem & item) { PoolItemGetter getter; invokeOnEach( availableBegin(), availableEnd(), functor::chain( resfilter::byEdition<CompareByEQ<Edition> >(item->edition()), resfilter::byArch<CompareByEQ<Arch> >(item->arch()), functor::functorRef<bool,PoolItem>(getter)); return getter.item; } -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=421588#c6 Ján Kupec <jkupec@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status Whiteboard| |in-svn --- Comment #6 from Ján Kupec <jkupec@novell.com> 2008-10-05 12:12:36 MDT --- comment #5 done in svn. Zypper will now try to find the repo counterpart of the installed item. It it can't be found, it will complain and exit. Otherwise it will be reinstalled. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 User ma@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=421588#c7 Michael Andres <ma@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEEDINFO |ASSIGNED Info Provider|ma@novell.com | --- Comment #7 from Michael Andres <ma@novell.com> 2008-10-06 07:23:57 MDT --- Using byIdent iterator should be fast enough, as there's an index for it. - But 'pool.byIdentBegin(installed)' would be sufficient to construct the iterator. - PoolItemGetter does a common task, it picks the first match and stores it in a variable. I templated it and slightly rewrote it to get rid of the functorRef stuff. It's now in available in libzypp as functor::getFirst. - I also added filter::SameItemAs to libzypp, to encapsulate the 'is the same' package condition (it also includes a vendor check). Your code could look like this: PoolItem findInstalledItemInRepos( const PoolItem & installed) { zypp::ResPool pool(zypp::ResPool::instance()); PoolItem result; invokeOnEach( pool.byIdentBegin(installed), pool.byIdentEnd(installed), filter::SameItemAs( installed ), functor::getFirst( result ) ); return result; } -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 User ma@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=421588#c8 Michael Andres <ma@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ma@novell.com --- Comment #8 from Michael Andres <ma@novell.com> 2008-10-06 07:27:12 MDT --- I guess it needs a 'chain( resfilter::ByUninstalled(), filter::SameItemAs( installed )' -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.

https://bugzilla.novell.com/show_bug.cgi?id=421588 User jkupec@novell.com added comment https://bugzilla.novell.com/show_bug.cgi?id=421588#c9 Ján Kupec <jkupec@novell.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |RESOLVED Resolution| |FIXED Status Whiteboard|in-svn | --- Comment #9 from Ján Kupec <jkupec@novell.com> 2008-10-08 00:30:58 MDT --- submitted -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com