Bug 3769

Summary: smart: some packages can not be reinstalled
Product: [Runtime] Package Management Issues Reporter: Yi Zhao <yi.zhao>
Component: package-management-issuesAssignee: Bogdan Marinescu <bogdan.a.marinescu>
Status: VERIFIED NOTABUG QA Contact:
Severity: normal    
Priority: Medium CC: bluelightning, bogdan.a.marinescu, corneliux.stoicescu, hongxu.jia, liang.li2, mark.hatle, Qi.Chen
Version: 1.4   
Target Milestone: 1.4   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Yi Zhao 2013-01-22 09:22:52 UTC
Image location: http://autobuilder.yoctoproject.org/pub/nightly/20130115-2/
Tree/Branch: poky/master
Git Rev: 9eb88ceb39b7d0b8ddc6487e61ce8edadef10ec4

I found if some packages are pre-installed in rootfs, then run smart reinstall command can not reinstall them.

For example:
The package less is already installed in sato-sdk rootfs:
##########
root@beagleboard:~# smart channel --show
[rpmsys]
type = rpm-sys


root@beagleboard:~# 
root@beagleboard:~# smart query less --show-channels
Updating cache...               ######################################## [100%]

less-457-r0@armv7a_vfp_neon [rpmsys]

Saving cache... 
############

Then add a remote repo and reinstall it, would get the following message:
###########
root@beagleboard:~# smart channel --add myrpmmd type=rpm-md baseurl=http://140.211.169.59/nightly/20130115-2/rpm
Alias: myrpmmd
Type: rpm-md
Base URL: http://140.211.169.59/nightly/20130115-2/rpm

Include this channel? (y/N): y


root@beagleboard:~# 
root@beagleboard:~# smart update
Loading cache...
Updating cache...               ######################################## [100%]

Fetching information for 'myrpmmd'...                                          
-> http://140.211.169.59/nightly/20130115-2/rpm/repodata/repomd.xml            
repomd.xml                      ######################################## [ 50%]
-> http://140.211.169.59/nightly/20130115-2/rpm/repodata/primary.xml.gz        
-> http://140.211.169.59/nightly/20130115-2/rpm/repodata/filelists.xml.gz      
filelists.xml.gz                ######################################## [ 75%]
primary.xml.gz                  ######################################## [100%]

Updating cache...               ######################################## [100%]

Channels have 6324 new packages.
Saving cache...

root@beagleboard:~# 
root@beagleboard:~# smart query less --show-channels
Loading cache...
Updating cache...               ######################################## [100%]

less-457-r0@armv7a_vfp_neon [myrpmmd]
less-457-r0@armv7a_vfp_neon [rpmsys]


root@beagleboard:~# smart reinstall less
Loading cache...
Updating cache...               ######################################## [100%]

error: 'less-457-r0@armv7a_vfp_neon' is not available for reinstallation       

root@beagleboard:~# 
##############

But if I remove it by smart remove and install it again. Then the reinstall command could work.
##############
root@beagleboard:~# smart remove less
Loading cache...
Updating cache...               ######################################## [100%]

Computing transaction...

Removing packages (3):
  less-457-r0@armv7a_vfp_neon            packagegroup-core-sdk-1.0-r9@all       
  less-dev-457-r0@armv7a_vfp_neon        

134.6kB will be freed.

Confirm changes? (Y/n): y

Committing transaction...                                                      
Preparing...                    ######################################## [  0%]
   1:Removing less-dev          ######################################## [ 33%]
   2:Removing packagegroup-co.. ######################################## [ 66%]

   3:Removing less              ######################################## [100%]


update-alternatives: Linking //usr/bin/less to /bin/busybox                                


root@beagleboard:~# 
root@beagleboard:~# 
root@beagleboard:~# 
root@beagleboard:~# smart install less
Loading cache...
Updating cache...               ######################################## [100%]

Computing transaction...

Installing packages (1):
  less-457-r0@armv7a_vfp_neon            

71.0kB of package files are needed. 134.6kB will be used.

Confirm changes? (Y/n): y

Fetching packages...                                                           
-> http://140.211.169.59/nightly/20130115-2/.../less-457-r0.armv7a_vfp_neon.rpm
less-457-r0.armv7a_vfp_neon.rpm ######################################## [100%]

                                                                               
Committing transaction...
Preparing...                    ######################################## [  0%]
   1:Installing less            ######################################## [100%]
Output from less-457-r0@armv7a_vfp_neon:                                                                 
update-alternatives: Linking //usr/bin/less to /usr/bin/less.less              

Saving cache...

root@beagleboard:~# smart reinstall less
Loading cache...
Updating cache...               ######################################## [100%]

Computing transaction...

Installing packages (1):
  less-457-r0@armv7a_vfp_neon            

71.0kB of package files are needed. 134.6kB will be used.

Confirm changes? (Y/n): y

Fetching packages...                                                           
-> http://140.211.169.59/nightly/20130115-2/.../less-457-r0.armv7a_vfp_neon.rpm
less-457-r0.armv7a_vfp_neon.rpm ######################################## [100%]

                                                                               
Committing transaction...
Preparing...                    ######################################## [  0%]
   1:Installing less            ######################################## [100%]
Output from less-457-r0@armv7a_vfp_neon:                                       
update-alternatives: Linking //usr/bin/less to /usr/bin/less.less              


root@beagleboard:~# 
###########
Comment 1 Bogdan Marinescu 2013-01-29 15:01:18 UTC
This is indeed a bit weird, but it seems to be the correct behaviour as far as smart is concerned. The error comes from here (commands/reinstall.py):

    found = False
    for pkg in pkgs:
        if pkg.installed:
            found = True
            trans.enqueue(pkg, REINSTALL)
            for loader in pkg.loaders:
                if not loader.getInstalled():
                    break
            else:
                raise Error, _("'%s' is not available for "
                               "reinstallation") % pkg

smart will consider a package for reinstallation if it has at least one loader that reports it as not being installed. This behaviour is consistent with other parts of the smart code; for exampe, the code below can be found in control.py in a number of places:

loaders = [x for x in pkg.loaders if not x.getInstalled()]

Again, only the loaders that report the package as "not installed" are considered by smart. This behaviour might have something to do with this (check section "Smart transactions"):

http://zorked.net/smart/doc/README.html

(in particular this phrase: "Packages may even be reinstalled, IF different packages with the same name-version pair have different relations, and the one not installed is a considered better option.")
What I can gather from this is that smart works a bit differently than other package managers when it comes to reinstalling a package, but that's not necessarily an error, so I'm closing this bug. If you don't agree with this, please reopen it and add your comments.
Comment 2 Stoicescu Cornel 2013-02-22 13:23:48 UTC
Verified as per above comment.