# Trouble upgrading graphics/png



## dougs (Jun 29, 2010)

On all of my FBSD servers, today I was able to upgrade graphics/png to 1.4.3 except for one server (7.3 p1) as follows:


```
root@test:/usr/ports/graphics/png# make install
===>  License check disabled, port has not defined LICENSE
===>  Found saved configuration for png-1.4.3
=> libpng-1.4.3.tar.xz doesn't seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://heanet.dl.sourceforge.net/project/libpng/01-libpng-master/1.4.3/.
libpng-1.4.3.tar.xz                           100% of  526 kB  256 kBps
===>  Extracting for png-1.4.3
=> MD5 Checksum OK for libpng-1.4.3.tar.xz.
=> SHA256 Checksum OK for libpng-1.4.3.tar.xz.
===>   png-1.4.3 depends on file: /usr/local/bin/xz - found
/usr/local/bin/xz: /usr/ports/distfiles//libpng-1.4.3.tar.xz: Memory usage limit reached
/usr/local/bin/xz: Limit was 46 MiB, but 65 MiB would have been needed
===>  Patching for png-1.4.3
===>  Applying FreeBSD patches for png-1.4.3
patch: **** can't cd to /usr/ports/graphics/png/work/libpng-1.4.3: No such file or directory
=> Patch patch-ac failed to apply cleanly.
*** Error code 1

Stop in /usr/ports/graphics/png.
*** Error code 1

Stop in /usr/ports/graphics/png.
root@test:/usr/ports/graphics/png#
```

It seems to me that this particular server doesn't have adequate memory:


```
root@test:/usr/ports/distfiles# dmesg | g memory
real memory  = 134217728 (128 MB)
avail memory = 115458048 (110 MB)
root@test:/usr/ports/distfiles# free
Mem: 18M Active, 45M Inact, 35M Wired, 3552K Cache, 21M Buf, 12M Free
Swap: 231M Total, 8808K Used, 222M Free, 3% Inuse
root@test:/usr/ports/distfiles#
```

It seems 'xz' has trouble expanding the zipped file. I'm unsure as to how to fix this. Suggestions?

~Doug


----------



## wblock@ (Jun 29, 2010)

Looks like you have enough memory, but xz is helpfully saving you from using too much of it.  There was a recent thread on the ports mailing list about this.

Please read the notes in xz(1) about -M.  You can edit /usr/ports/Mk/bsd.commands.mk to add that parameter and your choice of setting.  For example,

```
...
.if exists(/usr/bin/xz)
XZ_CMD?=        /usr/bin/xz [I][B]-Mmax[/B][/I]
.else
XZ_CMD?=        ${LOCALBASE}/bin/xz [I][B]-Mmax[/B][/I]
.endif
...
```

This is a temporary hack; updating the ports tree will wipe it out.  Should be able to set -M value in XZ_OPT, but evidently the ports system is getting the environment elsewhere because it's ignoring it for me.


----------



## dougs (Jun 30, 2010)

That was it! I set /usr/ports/Mk/bsd.commands.mk as follows:

```
...
.if exists(/usr/bin/xz)
XZ_CMD?=        /usr/bin/xz -M[B]70%[/B]
.else
XZ_CMD?=        ${LOCALBASE}/bin/xz -M[B]70%[/B]
.endif
...
```

and I was able to install graphics/png. Thank you!

I read the thread about proper memory utilization and I have to say I agree with his reasoning. Why limit it to 40% of system memory when there is actually more free memory for decompression? I did not find out the reasoning of the programmer for setting the limit to 40% so...

~Doug


----------



## wblock@ (Jun 30, 2010)

I've submitted PR 148250 with a less hacky way of doing this.


----------



## boril (Jul 11, 2010)

Great hint.
Get me out of the mess..


----------



## unixland (Jul 16, 2010)

dougs said:
			
		

> That was it! I set /usr/ports/Mk/bsd.commands.mk as follows:
> 
> ```
> ...
> ...



If you have less than 65 Mb Memory available (physical), this will not help. The -Mmax option disables the limit completely.


----------

