# Using pkg to upgrade from EOL version of packages.



## Understudy (Oct 28, 2022)

I am looking to see if `pkg` can install an different number version as a way to upgrade.
Example :

```
php74-7.4.32: Tag: expiration_date Value: 2022-11-29
```
The newer version of PHP being PHP80 or PHP81. Is there a way to have `pkg` upgrade this?


----------



## Alain De Vos (Oct 28, 2022)

What happens when you do

```
pkg update -f
pkg install php81
```


----------



## Understudy (Oct 28, 2022)

Alain De Vos said:


> What happens when you do
> 
> ```
> pkg update -f
> ...




```
root@Spider:~ # pkg update -f
Updating FreeBSD repository catalogue...
Fetching meta.conf: 100%    163 B   0.2kB/s    00:01
Fetching packagesite.pkg: 100%    6 MiB   3.4MB/s    00:02
Processing entries: 100%
FreeBSD repository update completed. 32337 packages processed.
All repositories are up to date.
```


```
root@Spider:~ # pkg update -f
Updating FreeBSD repository catalogue...
Fetching meta.conf: 100%    163 B   0.2kB/s    00:01
Fetching packagesite.pkg: 100%    6 MiB   3.4MB/s    00:02
Processing entries: 100%
FreeBSD repository update completed. 32337 packages processed.
All repositories are up to date.
root@Spider:~ # pkg install php81
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        php81: 8.1.11

Number of packages to be installed: 1


The process will require 27 MiB more space.
4 MiB to be downloaded.

Proceed with this action? [y/N]: y
[1/1] Fetching php81-8.1.11.pkg: 100%    4 MiB   2.3MB/s    00:02
Checking integrity... done (2 conflicting)
  - php81-8.1.11 conflicts with php74-7.4.32 on /usr/local/bin/php
  - php81-8.1.11 conflicts with php74-json-7.4.32 on /usr/local/include/php/ext/json/php_json.h
Checking integrity... done (0 conflicting)
Conflicts with the existing packages have been found.
One more solver iteration is needed to resolve them.
The following 8 package(s) will be affected (of 0 checked):

Installed packages to be REMOVED:
        php74: 7.4.32
        php74-curl: 7.4.32
        php74-gd: 7.4.32
        php74-json: 7.4.32
        php74-mbstring: 7.4.32
        php74-mysqli: 7.4.32
        php74-zlib: 7.4.32

New packages to be INSTALLED:
        php81: 8.1.11

Number of packages to be removed: 7
Number of packages to be installed: 1

The operation will free 4 MiB.

Proceed with this action? [y/N]: y
[1/8] Deinstalling php74-zlib-7.4.32...
[1/8] Deleting files for php74-zlib-7.4.32: 100%
[2/8] Deinstalling php74-gd-7.4.32...
[2/8] Deleting files for php74-gd-7.4.32: 100%
[3/8] Deinstalling php74-mbstring-7.4.32...
[3/8] Deleting files for php74-mbstring-7.4.32: 100%
[4/8] Deinstalling php74-mysqli-7.4.32...
[4/8] Deleting files for php74-mysqli-7.4.32: 100%
[5/8] Deinstalling php74-curl-7.4.32...
[5/8] Deleting files for php74-curl-7.4.32: 100%
[6/8] Deinstalling php74-json-7.4.32...
[6/8] Deleting files for php74-json-7.4.32: 100%
[7/8] Deinstalling php74-7.4.32...
[7/8] Deleting files for php74-7.4.32: 100%
[8/8] Installing php81-8.1.11...
[8/8] Extracting php81-8.1.11: 100%
root@Spider:~ #
```

This is what happened after I check on things.

```
root@Spider:~ # pkg info |grep php
mod_php74-7.4.32_1             PHP Scripting Language
php81-8.1.11                   PHP Scripting Language (8.1.X branch)
```

Which is not so good. It removed all those php dependencies files even though they exist and may be needed.

php74-zlib-7.4.32  --> php81-zlib-8.1.11
php74-gd-7.4.32   --> php81-gd-8.1.11
php74-mbstring-7.4.32 --> php81-mbstring-8.1.11
And the list goes on. So I suspect that may not be a great way to do that. There might be a better way to put that command out there to include those. If you have any suggestions or ideas I am open. I know maybe a wildcard might work but that would install all the dependencies. 

Thank you


----------



## Alain De Vos (Oct 28, 2022)

If you want different parallel versions of php you can better install the different versions in different jails.
Because they write to the same files there is overlap & they take the dependencies with them.


----------



## Understudy (Oct 28, 2022)

Alain De Vos said:


> If you want different parallel versions of php you can better install the different versions in different jails.
> Because they write to the same files there is overlap & they take the dependencies with them.


Sorry for the confusion, not parallel. Remove the old version install the new version with the needed subsidiaries.  
I don't need to just update php. I need update php and every one of the other php types I had shown earlier. It is the fun thing to have to do with a webserver that has a gallery, It likes sql type DBs, PHP and a bunch of it's step children, and some other pkgs. I was hoping pkg update / upgrade would go in and deinstall all the 7.4 versions and replace them with the 8.1 versions without having to do each one individually. My apologies for the confusion.


----------



## Alain De Vos (Oct 28, 2022)

To have a list of all the new packages you want to install you can do:

```
pkg query %n | grep php74 | sed 's/74/80/'
```
To force the installation of them,

```
pkg query %n | grep php74 | sed 's/74/80/' | xargs -I {} pkg install -f  -y {}
```
That command will replace all php74- modules with php80- modules


----------



## Understudy (Oct 28, 2022)

Alain De Vos said:


> To have a list of all the new packages you want to install you can do:
> 
> ```
> pkg query %n | grep php74 | sed 's/74/80/'
> ...


Okay, that looks more like it. I will give that a try. Thank you very much.


----------



## SirDice (Oct 28, 2022)

Understudy said:


> Is there a way to have `pkg` upgrade this?


Read /usr/ports/UPDATING:

```
20220125:
  AFFECTS: users of lang/php74
  AUTHOR: tz@FreeBSD.org

  The default version of PHP has been switched from 7.4 to 8.0.

  If you use binary packages you should make a list of php packages
  before running 'pkg upgrade':

  # pkg info \*php7\* > ~/installed-php-ports-list

  After the upgrade, check with such list if all your php extensions
  are still installed, and reinstall them if needed.

  If you use mod_php74 you need to deinstall it and install mod_php80.
```


----------

