Bug 1402856 - SRPM package should be installed when specified with '-F|--freshen' option ?
Summary: SRPM package should be installed when specified with '-F|--freshen' option ?
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: rpm
Version: 7.3
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Packaging Maintenance Team
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
Depends On:
Blocks: 1420851
TreeView+ depends on / blocked
 
Reported: 2016-12-08 13:23 UTC by Masaki Furuta ( RH )
Modified: 2020-01-17 16:19 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-07-12 14:42:10 UTC
Target Upstream Version:


Attachments (Terms of Use)

Description Masaki Furuta ( RH ) 2016-12-08 13:23:15 UTC
Description of problem:
   SRPM package should be installed when specified with '-F|--freshen' option ?
  
Version-Release number of selected component (if applicable):
  Fedora, RHEL.
  
How reproducible:
  Always, 100%
  
Steps to Reproduce:

1. customer had extracted all of hotfix packages we provided in the archive.
  
  # ls
  openstack-neutron-2015.1.4-11.el7ost.noarch.rpm                 openstack-neutron-ml2-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-2015.1.4-11.el7ost.src.rpm                    openstack-neutron-nec-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-bigswitch-2015.1.4-11.el7ost.noarch.rpm       openstack-neutron-nuage-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-brocade-2015.1.4-11.el7ost.noarch.rpm         openstack-neutron-ofagent-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-cisco-2015.1.4-11.el7ost.noarch.rpm           openstack-neutron-oneconvergence-nvsd-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-common-2015.1.4-11.el7ost.noarch.rpm          openstack-neutron-opencontrail-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-embrane-2015.1.4-11.el7ost.noarch.rpm         openstack-neutron-openvswitch-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-ibm-2015.1.4-11.el7ost.noarch.rpm             openstack-neutron-ovsvapp-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-linuxbridge-2015.1.4-11.el7ost.noarch.rpm     openstack-neutron-plumgrid-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-mellanox-2015.1.4-11.el7ost.noarch.rpm        openstack-neutron-sriov-nic-agent-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-metaplugin-2015.1.4-11.el7ost.noarch.rpm      openstack-neutron-vmware-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-metering-agent-2015.1.4-11.el7ost.noarch.rpm  python-neutron-2015.1.4-11.el7ost.noarch.rpm
  openstack-neutron-midonet-2015.1.4-11.el7ost.noarch.rpm         python-neutron-tests-2015.1.4-11.el7ost.noarch.rpm
  
2. And using '-Fvh' for upgrading, so I think they saw mockbuild error with it.
   I confirmed as follows that '-Fvh' also install src.rpm, though it's not existing on the box before running.
  
  [root@el72-osp7-all-virbr-br0 HOTFIX_CASE-01735001_BZ-1393175]# rpm -Fvh *rpm
  Preparing...                          ################################# [100%]
  Updating / installing...
     1:python-neutron-2015.1.4-11.el7ost################################# [ 10%]
     2:openstack-neutron-common-2015.1.4################################# [ 20%]  <=========== noarch.rpm
     3:openstack-neutron-2015.1.4-11.el7warning: /etc/neutron/l3_agent.ini created as /etc/neutron/l3_agent.ini.rpmnew
  ################################# [ 30%]
     4:openstack-neutron-ml2-2015.1.4-11################################# [ 40%]
     5:openstack-neutron-openvswitch-201################################# [ 50%]
  Cleaning up / removing...
     6:openstack-neutron-openvswitch-201################################# [ 60%]
     7:openstack-neutron-ml2-2015.1.4-2.################################# [ 70%]
     8:openstack-neutron-2015.1.4-2.el7o################################# [ 80%]
     9:openstack-neutron-common-2015.1.4################################# [ 90%]
    10:python-neutron-2015.1.4-2.el7ost ################################# [100%]
  Updating / installing...
     1:openstack-neutron-2015.1.4-11.el7################################# [100%]  <========== src.rpm
  warning: user mockbuild does not exist - using root
  warning: group mockbuild does not exist - using root
  warning: user mockbuild does not exist - using root
  ..
  ~~~

3. This is different from customer's expectation which clearly says we won't install packages which is not previously installed on the system.   
  
  RPM(8)
  ~~~
  rpm {-F|--freshen} [install-options] PACKAGE_FILE ...
          This will upgrade packages, but only ones for which an earlier version is installed.
  ~~~
  
  
Actual results:

  SRPM is installed with '-F' option  
  
Expected results:

  We should change documentation or SRPM should not be installed with '-F' option. 
  Looks SRPM is not considered as target package with '-F', and it should be by-design and need to fix doc / manpage.
  
Additional info:


  We comparing version with INSTALL_FRESHEN.

  rpm-4.13.0/lib/rpminstall.c
    
  367 /* On --freshen, verify package is installed and newer */
  368 static int checkFreshenStatus(rpmts ts, Header h)
  369 {
  370     rpmdbMatchIterator mi = NULL;
  371     const char * name = headerGetString(h, RPMTAG_NAME);
  372     const char *arch = headerGetString(h, RPMTAG_ARCH);
  373     Header oldH = NULL;
  374 
  375     if (name != NULL)
  376         mi = rpmtsInitIterator(ts, RPMDBI_NAME, name, 0);
  377     if (rpmtsColor(ts) && arch)                                      <====== 
  378         rpmdbSetIteratorRE(mi, RPMTAG_ARCH, RPMMIRE_DEFAULT, arch);  <====== Iterator is set here, but "src" arch is not defined,
                                                                                   so we cannot handle correctly even if stop "continue"ing at #553
  379 
  380     while ((oldH = rpmdbNextIterator(mi)) != NULL) {
  381         /* Package is newer than those currently installed. */
  382         if (rpmVersionCompare(oldH, h) < 0)
  383             break;
  384     }
  385 
  386     rpmdbFreeIterator(mi);
  387     return (oldH != NULL);
  388 }
  
  <...>
  
  403 /** @todo Generalize --freshen policies. */
  404 int rpmInstall(rpmts ts, struct rpmInstallArguments_s * ia, ARGV_t fileArgv)
  405 {
  
  <...>
  
  544         if (headerIsSource(h)) {
  545             rpmlog(RPMLOG_DEBUG, "\tadded source package [%d]\n",
  546                 eiu->numSRPMS);
  547             eiu->sourceURL = xrealloc(eiu->sourceURL,
  548                                 (eiu->numSRPMS + 2) * sizeof(*eiu->sourceURL));
  549             eiu->sourceURL[eiu->numSRPMS] = *eiu->fnp;
  550             *eiu->fnp = NULL;
  551             eiu->numSRPMS++;
  552             eiu->sourceURL[eiu->numSRPMS] = NULL;
  553             continue;                                     <============ we're "continue"ing here.
  554         }
  555 
  556         if (eiu->relocations) {
  557             struct rpmtd_s prefixes;
  558 
  559             headerGet(h, RPMTAG_PREFIXES, &prefixes, HEADERGET_DEFAULT);
  560             if (rpmtdCount(&prefixes) == 1) {
  561                 eiu->relocations->oldPath = xstrdup(rpmtdGetString(&prefixes));
  562                 rpmtdFreeData(&prefixes); 
  563             } else {
  564                 rpmlog(RPMLOG_ERR, _("package %s is not relocatable\n"),
  565                        headerGetString(h, RPMTAG_NAME));
  566                 eiu->numFailed++;
  567                 goto exit;
  568             }
  569         }
  570 
  571         if (ia->installInterfaceFlags & INSTALL_FRESHEN) <============ INSTALL_FRESHEN bit is checked here.
  572             if (checkFreshenStatus(ts, h) != 1) {
  573                 headerFree(h);
  574                 continue;
  575             }

Comment 1 Panu Matilainen 2016-12-08 13:55:56 UTC
An installed SRPM is an oxymoron to begin with, they're never installed in the rpm sense, only unpacked.

First time I've ever heard anybody throw src.rpm's into -F, but yeah optimally -F should probably not unpack src.rpms.

Comment 2 Masaki Furuta ( RH ) 2016-12-08 14:55:43 UTC
(In reply to Panu Matilainen from comment #1)

I agree.
Should we note that in the manpage (like "This only works with binary RPMs, not with source RPM") or just leave it as is ?

If it's too trivial, please close bz.

Comment 4 Florian Festi 2017-07-12 14:42:10 UTC
Fixed upstream as 10c1d10d6389a8389cfaf003365fb70ef4b4e00b.

It is still not important enough to fix in the current release IMHO. Closing.


Note You need to log in before you can comment on or make changes to this bug.