You are not logged in.

#1 2020-12-07 21:51:12

MountainX
Member
Registered: 2016-02-08
Posts: 371

Example of how to compare package versions in installer script

I found this one example:

https://bbs.archlinux.org/viewtopic.php?pid=913891

  # In an upgrade from 1.0.1-1 or older, the wireless-regdom file moves from the crda package
  # to the new wireless-regdb package. If the user changed the file, it is save to overwrite the one
  # from wireless-regdb by the user-defined one
  if [ $(vercmp $2 1.0.1-2) -lt 0 ]; then
    if [ -f /etc/conf.d/wireless-regdom.pacorig -a -n "$(grep -v ^# /etc/conf.d/wireless-regdom.pacorig 2>/dev/null | grep -v ^$)" ]; then
      ...
    fi
  fi

Is that an example of the best practice approach?

In my case, I have this:

# old version is like: 1.0.r53-2 or 1.0.r54-1
# new version is: 1.0.r55-1

## arg 1:  the new package version
## arg 2:  the old package version
pre_upgrade() {
    if [[ $(vercmp "$2" "1.0.r55-1") -lt 0 ]]; then
        # do something here;
    fi
}

Can that be improved?

BTW, I'm getting a 504 Gateway Time-out when I try to do this search on here:
Keyword search: proto.install new package version
Searched in: Pacman & Package Upgrade Issues, Creating & Modifying Packages

Offline

#2 2020-12-07 21:54:20

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,384
Website

Re: Example of how to compare package versions in installer script

This approach is good.

Offline

#3 2020-12-07 21:56:03

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: Example of how to compare package versions in installer script

Allan wrote:

This approach is good.

Thank you

Offline

Board footer

Powered by FluxBB