[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Upgrading a package (Do I use $1?)



Circa 2002-Jan-29 10:21:29 -0500 dixit Mike Baranski:

: -----BEGIN PGP SIGNED MESSAGE-----
: Hash: SHA1
: 
: Thanks, Jeff, that's about what I thought.  We need, however, to determine if 
: we're installing or upgrading, so:
: 
: if [$1 = 0]; then
: 	# Erase
: fi
: 
: if [$1 = 1]; then
: 	# New Install
: fi
: 
: if[$1 > 1]; then
: 	#upgrade
: fi
: 
: Right?

The value of "$1" depends on which scriptlet you're using.  "$1" is
really the number of packages with that name that will exist on the
system once the current transaction on the current package is finished.
For example:

  %pre
  # or %post
  if [ "$1" = 1 ]; then
    echo "This is either a first-time install or an upgrade."
  else
    # $1 can't be <= 0 after an install
    if [ "$1" = 2 ]; then
      noun="package"
      verb="was"
    else
      noun="packages"
      verb="were"
    fi
    echo "`expr \"$1\" - 1` %{name} ${noun} ${verb} already installed"
    echo "before installing this one."
  fi
  
  %preun
  # or %postun
  if [ "$1" = 0 ]; then
    echo "No %{name} packages are left on the system; you used 'rpm -e'."
  elif [ "$1" = 1 ]; then
    echo "Only %{name} package is left on the system; you probably used"
    echo "'rpm -U' or 'rpm -F', but you may have had two or more packages"
    echo "installed and used 'rpm -e' to explicitly remove them."
  else
    # $1 > 1
    echo "You had more than $1 %{name} packages on the system, and"
    echo "you just used 'rpm -e' to get rid of some of them."
  fi

Does that make it more clear?

-- 
jim knoble | jmknoble@pobox.com | http://www.pobox.com/~jmknoble/





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []