# 10.1-RELEASE -> ezjail + portmaster - issues with upgrades



## generic (Apr 9, 2015)

Hello,

lately I have issues with upgrades with portmaster within the jail. I didn't had any issues on the same machine but without jail, but I do not have as many ports installed there as within my jails.

Almost daily I'm having issues, always with the same message:


```
===> <port> is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of <port>
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
```

It's sometimes: textproc/libxml2 or devel/pcre or devel/gettext-runtime or textproc/expat2.

When I'm upgrading my ports I'm always checking the /usr/ports/UPDATING.

For example - I can't upgrade python, because it says that libffi is already installed. It fails even when I remove (by make deinstall from within port directory) and it installs it by itself as an dependency.


```
===>   libffi-3.2.1 is already installed
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of libffi
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Stop.
make[3]: stopped in /basejail/usr/ports/devel/libffi
*** Error code 1

Stop.
make[2]: stopped in /basejail/usr/ports/devel/libffi
*** Error code 1

Stop.
make[1]: stopped in /basejail/usr/ports/lang/python27
*** Error code 1

Stop.
make: stopped in /basejail/usr/ports/lang/python27

===>>> make build failed for lang/python27
===>>> Aborting update

===>>> Update for lang/python27 failed
===>>> Aborting update

===>>> The following actions were performed:
        Installation of devel/libffi (libffi-3.2.1)


===>>> You can restart from the point of failure with this command line:
       portmaster <flags> lang/python27
```

I can't find definite answer to my problem. I have even reinstalled ports-mgmt/portmaster, ran pkg2ng but none of these helps.

Any ideas what might be wrong?


----------



## talsamon (Apr 9, 2015)

Nothings wrong. Either you deinstall and reinstall the port(s) or you do `make install clean FORCE_PKG_REGISTER=yes` in the port.


----------



## generic (Apr 9, 2015)

So you say that:

0. lang/python27 requires devel/libffi.
1. portmaster installs devel/libffi because it's missing.
2. portmaster fails at upgrade of python27 due to devel/libffi already installed (in step 1).

and that's ok? ;-)

I do believe ports-mgmt/portmaster should take care of upgrades flawlessly. Of course I can re-install port, but then the whole idea of using ports-mgmt/portmaster falls apart.

Or am I missing something?


----------



## talsamon (Apr 9, 2015)

I am also very unhappy with the stops of `portmaster` with the FORCE_PKG_REGISTER-Message. But I never figured out, why this happened.


----------



## kpa (Apr 9, 2015)

The correct fix would be indeed to use `make reinstall` to update/reinstall the ports. I just took a quick look at the ports-mgmt/portmaster and for some reason it doesn't use the reinstall target at all. I'd say this is a bug in ports-mgmt/portmaster and needs to be fixed.


----------



## talsamon (Apr 9, 2015)

If I am right, I think portmaster gets from the port 
	
	



```
exit 1
```
. Needs a special return- oder exit-code to react right. (To know it's not any error and deinstall the port and reinstall it).

/usr/port/Mk/bsd.port.mk

```
3610  ${ECHO_MSG} "  You may wish to \`\`make deinstall'' and install this port again"; \
3611  ${ECHO_MSG} "  by \`\`make reinstall'' to upgrade it properly."; \
3612  ${ECHO_MSG} "  If you really wish to overwrite the old port of ${PKGBASE}"; \
3613  ${ECHO_MSG} "  without deleting it first, set the variable \"FORCE_PKG_REGISTER\""; \
3614  ${ECHO_MSG} "  in your environment or the \"make install\" command line."; \
3615  exit 1; \
3616  fi
```

You see it gets
	
	



```
exit 1
```
 - means ANY error.


----------



## kpa (Apr 9, 2015)

https://github.com/freebsd/portmaster/issues/43


----------



## kpa (Apr 9, 2015)

talsamon said:


> If I am right, I think portmaster gets from the port
> 
> 
> 
> ...


It's reacting to `pkg delete` failing because the port it's trying to delete is still required by other ports. The exit code 1 gets passed all the way up because it's not handled anywhere in between the pkg-delete(8) and portmaster(8)'s main loop.


----------



## talsamon (Apr 9, 2015)

Then that's the fault. Should not do `pkg delete`, but `cd /usr/ports/category/portname && make deinstall clean.`
Makes no difference portmaster do it or the user do it, or portmaster should ask if it should do it.


----------



## kpa (Apr 9, 2015)

talsamon said:


> Then that's the fault. Should not do `pkg delete`, but `cd /usr/ports/category/portname && make deinstall clean.`
> Makes no difference portmaster do it or the user do it, or portmaster should ask if it should do it.



The `make deinstall` command does the same actually, it just calls `pkg delete` on the installed port. It would be cleaner though if portmaster(8) didn't try to be too clever and use the knowledge of the ports internals to make shortcuts such as this one.


----------



## talsamon (Apr 9, 2015)

But it's a annoying issue, portmaster could do in this case, what the user at last has to do (In some cases it could save a lot of time).


----------



## talsamon (Apr 9, 2015)

I sent a request to the maintainer, if he could do anything against it.


----------



## kpa (Apr 9, 2015)

It turns out I can't reproduce the issue at all. I tried reinstalling devel/pcre that is the usual culprit in many of the similiar problem cases such as this but it worked just fine. All settings at default and no /usr/local/etc/portmaster.rc file.

To the OP generic, I think this is an sysutils/ezjail problem and nothing to with ports-mgmt/portmaster itself.


----------



## talsamon (Apr 9, 2015)

In the other thread it was a problem with graphics/png. I also could not reproduce the error. But if the user could fix it with two simple commands, I think portmaster also can do it. It is not a problem if it is one port, but it is if you try recompile more ports recursively and the message appears more than one times.


----------



## amdmi3@ (Apr 9, 2015)

I've never experienced any problems similar to described, I suspect it's local problem. However if there really is portmaster(8) problem, it should never be fixed by `FORCE_PKG_REGISTER` or `make reinstall` (which is the same as it uses `FORCE_PKG_REGISTER` internally).


----------



## generic (Apr 9, 2015)

Thank you all for your input, appreciated.



kpa said:


> To the OP generic, I think this is an sysutils/ezjail problem and nothing to with ports-mgmt/portmaster itself.



Well, that is possible, but I am not sure yet how to track it down.


----------



## wblock@ (Apr 9, 2015)

I use portmaster routinely in jails, and have never needed to manually deinstall a port or use FORCE_PKG_REGISTER.  Brute force can make immediate problems go away, but often results in long-term mysterious problems that are difficult to diagnose and cure.


----------



## talsamon (Apr 9, 2015)

Can't imagine that. With 9.3 portmaster often stops with this message. With 10.1 it is not so often. But if you recursively recompile, you can be sure it interrupts at least one time. Could anyone explain why this happened?. I don't understand. If I deinstall in the port and reinstall everything's okay. What's the difference, and why portmaster can't  handle it. kpa wrote, `make deinstall` calls also `pkg delete` - this is not logical.


----------



## generic (Apr 9, 2015)

Well, I just tested that on another system (not within jail) and had no issues. Another step towards ezjail issue.


----------



## kpa (Apr 9, 2015)

Something I've overlooked totally is that a port build now builds a package that is installed as an update or reinstallation of the port (you can tell I've used my own built binary packages only...). This is what allows `make install` to work even if the port is required by other installed ports. The crucial mechanism to enable this is the new staging system introduced some time ago.

To generic, can you post your /etc/make.conf from the jail where the build is failing if you have one.


----------



## wblock@ (Apr 10, 2015)

talsamon said:


> With 9.3 portmaster often stops with this message. With 10.1 it is not so often. But if you recursively recompile, you can be sure it interrupts at least one time. Could anyone explain why this happened?



First guess: something is wrong with your system.  You have posted many suggestions for overriding default behavior and forcing the system to do things in a nonstandard way.  Doing things that way usually has repercussions sooner or later.  If it were me, I would remove every custom setting possible from /etc/make.conf, then follow the portmaster procedure to get a list of installed ports, delete them all, then build them all.  Rather than keep repeating those steps, I just created a thread for it: https://forums.freebsd.org/threads/rebuilding-all-ports-with-portmaster.51210/.


----------



## generic (Apr 10, 2015)

kpa said:


> To generic, can you post your /etc/make.conf from the jail where the build is failing if you have one.



Sure, it's pretty generic ezjail /etc/make.conf:


```
WRKDIRPREFIX=  /var/ports
DISTDIR=  /var/ports/distfiles
PACKAGES=  /var/ports/packages
INDEXDIR=  /var/ports
```

As a test I have added: 
	
	



```
WITH_PKGNG=YES
```
 to it, even if it's not necessary, but that did not changed a thing (as expected).


----------



## kpa (Jun 5, 2015)

If you're using source based updates/upgrades and you're still struggling to install/update ports without using FORCE_PKG_REGISTER, this piece of information from another thread could help you:

https://forums.freebsd.org/threads/...ing-force_pkg_register-yes.51762/#post-290486

Basically you should run `# make -C /usr/src delete-old delete-old-libs` to make sure there are no leftover files in /usr/share/mk or anywhere else that might affect ports building.


----------

