# FreeBSD 10.0 and libiconv does not build



## michaelmichael (Mar 18, 2014)

Hi all,

since a couple of weeks I am having a severe problem with the fact that FreeBSD 10.0 RELEASE now has its native iconv. Because of that, I am unable to build converters/libiconv and many ports depend on it. This is not a problem for the jails where libiconv is already installed, because they have been created and the ports in there have been built before I migrated from 9.2 to 10.0 (following this guide in the FreeBSD handbook Chapter 23.2: http://www.freebsd.org/doc/handbook/updating-upgrading-freebsdupdate.html).

This practically keeps me from creating new jails or better said: building ports inside them.

I searched the web and the forums, slayed dragons - ate their heart, talked to a woman, got permit A38 and helped an old lady cross the street, but I did not find a solution, nor can I find out if there even is one, or if it is a bug (probably not, because then lots of people would talk about it).

Should anyone be able to give me a hint on how this issue can be solved or even if it can be solved at all I would be really grateful.

Cheers,
Michael


----------



## SirDice (Mar 18, 2014)

The solution is, as they say, almost staring you in the face. From /usr/ports/UPDATING:

```
20130904:
  AFFECTS: 10-CURRENT users with any port depending on converters/libiconv
  AUTHOR: madpilot@FreeBSD.org

  10-CURRENT after r254273 (committed on August 13, 2013) has an
  implementation of iconv enabled by default in libc.

  NOTE: after r341775 (committed on January 29, 2014) and other
  following commits, a few ports, including devel/glib20, depend
  on the devel/libiconv again due to missing functionality in the
  base iconv implementation.

  Due to this change some major overhauling of the ports tree has
  been necessary to move the ports to using that implementation.

  People using pkgng binary packages should have little problems,
  "pkg upgrade" will update all software to not depend on libiconv
  anymore, once updated packages are available. Please make sure to
  perform a "pkg autoremove" after that and check that libiconv is
  correctly removed by it.

  If you are using ports the update requires some manual intervention.
  The following procedure should be followed:

  # pkg query %ro libiconv >ports_to_update
  # pkg delete -f libiconv
  # cat ports_to_update | xargs portmaster

  or:

  # pkg query %ro libiconv >ports_to_update
  # pkg delete -f libiconv
  # cat ports_to_update | xargs portupgrade -f
```


----------



## michaelmichael (Mar 18, 2014)

I already read /usr/ports/UPDATING, as I usualy do before installing ports, but:


```
root@samba:~ # pkg query %ro libiconv
root@samba:~ # pkg delete -f libiconv
Package(s) not found!
```


```
root@samba:~ # uname -a
FreeBSD samba 10.0-RELEASE FreeBSD 10.0-RELEASE #0 r260789: Thu Jan 16 22:34:59 UTC 2014     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
```
That output is from inside a jail, same on the host system


----------



## SirDice (Mar 18, 2014)

Have those 9.2 jails been migrated to pkg correctly? Was the package database correctly migrated with pkg2ng?

If these are jails, wouldn't it be simpler to create a fresh new jail? That would be a 10.0-RELEASE, building ports in there shouldn't be a problem.


----------



## michaelmichael (Mar 18, 2014)

As stated in the first post I followed the FreeBSD handbook on how to migrate to 10.0-RELEASE.

Building converters/libiconv on the host seems to work now all of a sudden.
Building converters/libiconv in a jail that was migrated to 10.0-RELEASE does not work
Building converters/libiconv in a jail that has been created after the migration does not work.

The migration process - although not flawless - did succeed after some work, but now it seems that something is wrong with the jails. However, I have no clue on where to start. I do not have that much experience with FreeBSD yet.

By the way, do I have to use `pkg2ng` in every new jail even if the basejail is 10.0?


----------



## SirDice (Mar 18, 2014)

michaelmichael said:
			
		

> Building converters/libiconv in a jail that was migrated to 10.0-RELEASE does not work
> Building converters/libiconv in a jail that has been created after the migration does not work.


Why would you want to build it? Ports that require it shouldn't have a problem with 10.0's own iconv implementation. 



> By the way, do I have to use `pkg2ng` in every new jail even if the basejail is 10.0?


No, that command is only to be used to migrate from the old pkg_* registrations to the new PKGNG database. FreeBSD 10.0 only has PKGNG.


----------



## michaelmichael (Mar 19, 2014)

> Why would you want to build it? Ports that require it shouldn't have a problem with 10.0's own iconv implementation.


Exactly. The problem is that every port, that is dependent on it, tries to build it.

In one of your last posts you asked if the jails have been migrated properly. I did that cautiously, but I cannot say that everything is fine. Can you give me a hint of how to check if the problem lies there?


----------



## SirDice (Mar 19, 2014)

michaelmichael said:
			
		

> > Why would you want to build it? Ports that require it shouldn't have a problem with 10.0's own iconv implementation.
> 
> 
> Exactly. The problem is that every port, that is dependent on it, tries to build it.


It seems I misunderstood a few things myself. I have several ports depending on libiconv on my 10.0 machines. I though libiconv wasn't needed at all any more but this doesn't seem to be the case.



> In one of your last posts you asked if the jails have been migrated properly. I did that cautiously, but I cannot say that everything is fine. Can you give me a hint of how to check if the problem lies there?


Verify if all the old package registrations have been correctly migrated to PKGNG. That's usually a cause for problems.


----------



## michaelmichael (Mar 19, 2014)

Ok, I executed the following commands within one of the jails created AFTER the upgrade from 9.2-RELEASE to 10.0-RELEASE. Maybe this gives more insight.


```
root@samba:/usr/ports/net/samba41 # pkg_info
pkg_info: no packages installed
```
Again, this has been performed within a jail. On the host system the file `pkg_info` seems to be gone somehow.
When I list the installed packages with the new `pkg` as follows:

```
root@samba:/usr/ports/net/samba41 # pkg info
dialog4ports-0.1.5_2           Console Interface to configure ports
p5-Parse-Pidl-4.0.13           IDL compiler written in Perl
p5-Parse-Yapp-1.05             Perl extension for generating and using LALR parsers
perl5-5.16.3_7                 Practical Extraction and Report Language
pkg-1.2.6                      Package manager
```
... I get all the installed packages listed as it should be. `pkg_info` is empty as expected.

Also, here is /etc/make.conf of that jail

```
root@samba:/usr/ports/net/samba41 # cat /etc/make.conf
WITH_PKGNG="YES"

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

And yet, if I try to build net/samba41

```
root@samba:/usr/ports/net/samba41 # make install
[...]
====> Compressing man pages (compress-man)
===>  Installing for libiconv-1.14_2
===>  Checking if converters/libiconv already installed
===>   Registering installation for libiconv-1.14_2 as automatic
pkg-static: lstat(/var/pkg/basejail/usr/ports/converters/libiconv/work/stage/usr/local/lib/libcharset.so): No such file or directory
pkg-static: lstat(/var/pkg/basejail/usr/ports/converters/libiconv/work/stage/usr/local/lib/libcharset.so.1): No such file or directory
pkg-static: lstat(/var/pkg/basejail/usr/ports/converters/libiconv/work/stage/usr/local/lib/libiconv.so): No such file or directory
pkg-static: lstat(/var/pkg/basejail/usr/ports/converters/libiconv/work/stage/usr/local/lib/libiconv.so.3): No such file or directory
*** [fake-pkg] Error code 74

Stop in /basejail/usr/ports/converters/libiconv.
*** [install] Error code 1

Stop in /basejail/usr/ports/converters/libiconv.
*** [lib-depends] Error code 1

Stop in /basejail/usr/ports/devel/gettext.
*** [install] Error code 1

Stop in /basejail/usr/ports/devel/gettext.
*** [lib-depends] Error code 1

Stop in /basejail/usr/ports/lang/python27.
*** [install] Error code 1

Stop in /basejail/usr/ports/lang/python27.
*** [build-depends] Error code 1

Stop in /basejail/usr/ports/devel/talloc.
*** [build-depends] Error code 1

Stop in /basejail/usr/ports/net/samba41.
*** [install] Error code 1

Stop in /basejail/usr/ports/net/samba41.
```

Building other stuff works fine (for example devel/ccache)


----------



## SirDice (Mar 19, 2014)

The commit log is interesting reading, http://svnweb.freebsd.org/ports/head/co ... e?view=log

In a sense I was correct. In principle libiconv isn't needed any more because of the iconv implementation in FreeBSD's libc. But ports can still request to use libiconv if it has features or functions not yet implemented in FreeBSD's. 

For some reason it's failing to build a few libraries, I have all four of them on my systems. The port itself shouldn't be the problem.


----------



## michaelmichael (Mar 19, 2014)

I checked with some other port, ftp/wget, which is also dependent on converters/libiconv according to http://www.freshports.org (omg, theres more than 1k ports dependent on that library ! I hope the is some general solution rather than an individual one for each port..). Same story, so net/samba41 is not the problem.


----------



## jardows (Apr 2, 2014)

I had a similar problem when I upgraded.  I ran `portsnap fetch update`, then re-ran `portmaster -af`.  That fixed the problem.


----------



## michaelmichael (Apr 2, 2014)

I am sure that i ran `portmaster -af` after the upgrade to 10.0-RELEASE
However, I obviously did not run it inside the jails.
I tried in one jail (where the error first occurred) but the result is the same. `portmaster -af` will update the ports, but I still get the same error after trying to build anything that depends on converters/libiconv

Thanks for the input though


----------



## michaelmichael (Apr 7, 2014)

Ok, this is now beginning to become a serious problem.

Because of the "integration" of iconv into the 10.0-RELEASE base system I am having severe troubles.
I tried to de- and reinstall devel/gettext and converters/libiconv via the pkg system as building from the port systen would not work. These steps are proposed in ports/UPDATING


```
20130316:
  AFFECTS: users of converters/libiconv and devel/gettext
  AUTHOR: bapt@FreeBSD.org

  libiconv now handles the lib/charset.alias file instead of devel/gettext.
  If you are using pkgng 'and' upgrading from source with portupgrade or
  portmaster, first delete gettext, upgrade libiconv, then reinstall gettext.

  This will break sudo, so you *must* do this in a root shell (sudo -i)
  if you use sudo.

  # pkg delete -f devel/gettext
  # portmaster converters/libiconv devel/gettext
    or
  # pkg delete -f devel/gettext
  # portupgrade converters/libiconv devel/gettext
```

Now if I enter the jail where nginx and php-fpm are running I notice that php-fpm is NOT running because its missing libiconv:


```
root@www:/usr/ports # ps -A
  PID TT  STAT    TIME COMMAND
27402 ??  SsJ  0:00.00 /usr/sbin/syslogd -ss
27450 ??  IWsJ 0:00.00 nginx: master process /usr/local/sbin/nginx
27451 ??  SJ   0:00.02 nginx: worker process (nginx)
27452 ??  IJ   0:00.03 nginx: worker process (nginx)
27459 ??  IsJ  0:00.00 /usr/sbin/cron -J 15 -s
27489  0  IWJ  0:00.00 login [pam] (login)
27499  0  SJ   0:00.02 -csh (csh)
37274  0  R+J  0:00.00 ps -A

root@www:/usr/ports # php-fpm
Shared object "libiconv.so.3" not found, required by "php-fpm"
```

Also, for some reason, devel/ccache, devel/distcc and gcc refuse to cooperate. On the host system, the problem can be circumvented by disabling the line `WITH_CCACHE_BUILD="YES"` in /etc/make.conf. This does not work in the jails.

Further, `pkg` when run inside a jail does not find any repositories so I can not even install from packages to fix the worst at least.

The errors are accumulating and as I am not very experienced with FreeBSD I start to lose the capability of handling this.

Because of that all my websites using php are offline which is the preliminary stage of a disaster.
If there is a workaround, then I would really appreciate you to give me a hint. I feel like the more I do the less usable will the system become, not to say that I fear any loss of my data.

I wonder, however, that nobody else has the same problem as stated in tie original post as I am sure lots of folks have upgraded their machines to 10.0-RELEASE too. Which would mean I have fucked up something during the upgrade process. Right before the upgrade everyting was fine

If I do not find a solution soon I will have to reinstall the whole machine from scratch..

Cheers,
Michael


----------



## michaelmichael (Apr 8, 2014)

I finally got a temporary solution for the whole problem, as far as I can tell.

The pkg problem (no repositories found)
Assumed, you already migrated to the new pkgng. Otherwise follow this chapter in the FreeBSD handbook: http://www.freebsd.org/doc/handbook/pkgng-intro.html 
Then follow this guide to set up pkgng with the right repositories:
https://wiki.freebsd.org/pkgng
... especially chapter *Availability of binary pkgs for Download*
This has to be done inside every jail and the host system

The libiconv problem
Please read also /usr/ports/UPDATING!
Reinstall libiconv via the pkg system
`pkg install libiconv`
I know that building ports is better, blah, blah, but this is a compromise (leading to a COMPROMISED system..? RFC!).

That solved at least two of my major problems so far. I could get `php-fpm` back on by doing this in the www jail and I was able to finally build net/samba41 from the ports collection in the samba jail after installing libiconv via pkg there.

Phew! Not sure if this is a stable solution but at least it seems to work. I am willing to provide more information to the more experienced folks around here, if someone is interested in debugging this issue.

Cheers,
michael


----------



## michaelmichael (Apr 8, 2014)

SirDice said:
			
		

> Have those 9.2 jails been migrated to pkg correctly? Was the package database correctly migrated with pkg2ng?



Obviously not. I had to edit/create /etc/pkg/FreeBSD.conf according to this: https://wiki.freebsd.org/pkgng
In the described step-by-step migration process in the FreeBSD handbook (23.2. FreeBSD Update)I could not find this step, since it appears to be a more generic guide and not tailored to upgrading to 10.0.


----------

