tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg_add -f bugfixes



I'd like a review of a small pkg_install change.  There are currently
a couple of bugs related to 'pkg_add -f' for forced installs:

 - 'pkg_add -f' for a package which is already installed will return
   1, when without the -f we return 0.

 - 'pkg_add -uf' will return success, but will have removed the
   package metadata whilst leaving the contents on disk.

The first bug was exposed by pkgin, where 'pkg_add -f' is used as the
default install command, yet we were seeing failures in the logs with
apparently successful commands.  The second bug was exposed during my
testing of the fix below.

How to repeat:

  # -f returns wrong exit status
  $ pkg_add digest-20121220.tgz
  pkg_add: package `digest-20121220' already recorded as installed

  $ echo $?
  0

  $ pkg_add -f digest-20121220.tgz
  pkg_add: A different version of digest-20121220 is already installed: 
digest-20121220
  pkg_add: 1 package addition failed

  $ echo $?
  1

  # -fu is considered harmful
  $ pkg_add -u digest-20121220.tgz
  pkg_add: package `digest-20121220' already recorded as installed

  $ echo $?
  0

  $ pkg_add -uf digest-20121220.tgz
  $ echo $?
  0

  $ pkg_info -e digest; echo $?
  1

  $ pkg_add digest-20121220.tgz
  pkg_add: Conflicting PLIST with digest-20121220: bin/digest
  pkg_add: 1 package addition failed

The diff is simple:

  -----
  RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/perform.c,v
  retrieving revision 1.103
  diff -u -r1.103 perform.c
  --- files/add/perform.c       31 Jan 2013 10:25:30 -0000      1.103
  +++ files/add/perform.c       20 Aug 2013 14:11:54 -0000
  @@ -413,9 +413,6 @@
                return 1;
        }
  
  -     if (Force)
  -             return 1;
  -
        /* We can only arrive here for explicitly requested packages. */
        if (!Automatic && is_automatic_installed(pkg->pkgname)) {
                if (Fake ||
  -----

Ok?  I'm wary of breaking some exotic behaviour, hence the request for a
review.

Thanks,

-- 
Jonathan Perkin  -  Joyent, Inc.  -  www.joyent.com


Home | Main Index | Thread Index | Old Index