Solved portmaster -a fails

Anyone know of a fix for this?

portmaster -a fails at updating most ports with the following error:

Code:
file: File 5.25 supports only version 13 magic files. `/usr/share/misc/magic.mgc' is version 14
[: =: unexpected operator
- not found

I've tried checking out a new copy of the releng/10.3 source code, then recreating the magic database :
Code:
cat /usr/src/contrib/file/magic/Header \ /usr/src/contrib/file/magic/Localstuff \ /usr/src/contrib/file/magic/Magdir/* >magic

file -C magic

install -m 644 magic magic.mgc /usr/share/misc/

But that fails at the compiling step (no magic.mgc is created) with:
Code:
...
/usr/share/misc/magic, 11158: Warning: APPLE type `     ????tfil' has bad char '?'
/usr/share/misc/magic, 11166: Warning: APPLE type `     ????OTTO' has bad char '?'
/usr/share/misc/magic, 11255: Warning: APPLE type `     ????tfil' has bad char '?'
/usr/share/misc/magic, 11260: Warning: APPLE type `     ????OTTO' has bad char '?'
/usr/share/misc/magic, 13507: Warning: APPLE type `     ????TPIC' has bad char '?'
/usr/share/misc/magic, 14790: Warning: APPLE type `     ????icns' has bad char '?'
/usr/share/misc/magic, 16593: Warning: APPLE type `     ????devi' has bad char '?'
/usr/share/misc/magic, 18015: Warning: missing ')' in indirect offset
/usr/share/misc/magic, 18177: Warning: APPLE type `     ????L123' has bad char '?'
/usr/share/misc/magic, 18247: Warning: APPLE type `     ????L123' has bad char '?'
/usr/share/misc/magic, 18688: Warning: EXTENSION type ` @@@' has bad char '@'
/usr/share/misc/magic, 24936: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x (MVP)'
/usr/share/misc/magic, 24937: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x'
/usr/share/misc/magic, 25138: Warning: APPLE type `     ????TEXT' has bad char '?'
file: line 1898: Bad magic entry '      ????devr'

I've tried installing sysutils/file using pkg, and also from the ports tree. They both show version 5.23, so I don't know how the system sees version 5.25 as installed, or how to install a version that supports version 14 of magic files.

Any ideas?
 
I decided to try building the ports without portmaster and got what might be closer to the actual error:
Code:
...
/bin/rm -f /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/man/man3/uuid_generate_random.3.gz \
        /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/man/man3/uuid_generate_time.3.gz
(cd /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/man/man3; \
    /bin/ln -f uuid_generate.3 uuid_generate_random.3)
(cd /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/man/man3; \
    /bin/ln -f uuid_generate.3 uuid_generate_time.3)
install  -m 0644 uuid.pc /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/libdata/pkgconfig/uuid.pc
install  -s -m 555 libuuid.so.1.2 /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/lib/libuuid.so.1.2
/bin/sh ../../util/install-symlink --symlinks=../../util/symlinks /usr/local/lib/libuuid.so.1.2 \
        /usr/local/lib/libuuid.so.1 /usr/ports/misc/e2fsprogs-libuuid/work/stage
/bin/sh ../../util/install-symlink --symlinks=../../util/symlinks /usr/local/lib/libuuid.so.1 \
        /usr/local/lib/libuuid.so /usr/ports/misc/e2fsprogs-libuuid/work/stage
/sbin/ldconfig
gmake[5]: Leaving directory '/usr/ports/misc/e2fsprogs-libuuid/work/e2fsprogs-1.44.0/lib/uuid'
install  -s -m 555 /usr/ports/misc/e2fsprogs-libuuid/work/e2fsprogs-1.44.0/misc/uuidgen /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/bin/
install  -m 444 /usr/ports/misc/e2fsprogs-libuuid/work/e2fsprogs-1.44.0/misc/uuidgen.1 /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/man/man1/
install  -s -m 555 /usr/ports/misc/e2fsprogs-libuuid/work/e2fsprogs-1.44.0/misc/uuidd /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/sbin/
install  -m 444 /usr/ports/misc/e2fsprogs-libuuid/work/e2fsprogs-1.44.0/misc/uuidd.8 /usr/ports/misc/e2fsprogs-libuuid/work/stage/usr/local/man/man8/
/bin/mkdir -p /usr/ports/misc/e2fsprogs-libuuid/work/stage/var/run/libuuid
====> Compressing man pages (compress-man)
===> Staging rc.d startup script(s)
===>   Installing ldconfig configuration file
===>  Installing for e2fsprogs-libuuid-1.44.0
===>   Registering installation for e2fsprogs-libuuid-1.44.0 as automatic
*** Error code 70

Stop.
make[4]: stopped in /usr/ports/misc/e2fsprogs-libuuid
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/misc/e2fsprogs-libuuid
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/misc/e2fsprogs-libuuid
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/misc/e2fsprogs-libblkid
*** Error code 1

Stop.
make: stopped in /usr/ports/misc/e2fsprogs-libblkid

That's from running make deinstall reinstall inside /usr/ports/misc/e2fsprogs-libblkid/.
 
First of all, as you've also noted yourself, it's not Portmaster but the build/install process of the Port which is giving the error. Please be careful in making that distinction because one aspect could be a problem with Portmaster itself whereas the other is fully Port related.

Your paste is missing the actual error message(s). Try running: # portmaster -a |& tee build.log (on csh) or I guess if you're using sh you'd use: # portmaster -a 2>&1 | tee build.log. This will ensure that stderr is also captured.

I can pretty much rule out any errors with the port itself because it has no problems building/installing on my end ( # make deinstall install clean) so it's something specific for your setup. Because the error occurs during the installation my assumption is that something is getting in the way.

Some ideas: Have you perhaps tried mixing ports and packages? Maybe there's an pkg instance running somewhere (cron sometimes does this to check system integrity)?

Anyway, start by identifying the actual error.
 
First of all, as you've also noted yourself, it's not Portmaster but the build/install process of the Port which is giving the error. Please be careful in making that distinction because one aspect could be a problem with Portmaster itself whereas the other is fully Port related.

Your paste is missing the actual error message(s). Try running: # portmaster -a |& tee build.log (on csh) or I guess if you're using sh you'd use: # portmaster -a 2>&1 | tee build.log. This will ensure that stderr is also captured.

I can pretty much rule out any errors with the port itself because it has no problems building/installing on my end ( # make deinstall install clean) so it's something specific for your setup. Because the error occurs during the installation my assumption is that something is getting in the way.

Some ideas: Have you perhaps tried mixing ports and packages? Maybe there's an pkg instance running somewhere (cron sometimes does this to check system integrity)?

Anyway, start by identifying the actual error.

What do you see that makes you think it isn't the actual error?

I've tried again with a different port and got the same magic version mismatch error. Then tried with print/freetype2 and got the same abort after trying to register the installation of the port:
Code:
[root@- /usr/ports/ftp/curl]#  make deinstall reinstall clean
===>  Deinstalling for curl
===>   curl not installed, skipping
===>   curl-7.59.0 depends on executable: gmake - found
===>   curl-7.59.0 depends on package: pkgconf>=1.3.0_1 - found
===>   curl-7.59.0 depends on package: perl5>=5.24<5.25 - found
===>   curl-7.59.0 depends on shared library: libnghttp2.so - not found
===>  Installing for libnghttp2-1.31.0
===>   Registering installation for libnghttp2-1.31.0 as automatic
Installing libnghttp2-1.31.0...
===>   curl-7.59.0 depends on shared library: libnghttp2.sofile: compiled magic version [532] does not match with shared library magic version [524]
/usr/share/misc/magic, 1898: Warning: APPLE type `      ????devr' has bad char '?'
/usr/share/misc/magic, 2673: Warning: APPLE type `      ????LHA' has bad char '?'
/usr/share/misc/magic, 4673: Warning: cannot get string from `^using[[:space:]]+(namespace )?std(::)?[[:alpha:]]*[[:space:]]*'
/usr/share/misc/magic, 4675: Warning: Current entry does not yet have a description for adding a MIME type
/usr/share/misc/magic, 4683: Warning: cannot get string from `^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]'
/usr/share/misc/magic, 4685: Warning: Current entry does not yet have a description for adding a MIME type
/usr/share/misc/magic, 7494: Warning: Printf format `#' is not valid for type `lelong' in description `, seed %#x'
/usr/share/misc/magic, 7502: Warning: type `der seq' invalid
/usr/share/misc/magic, 7503: Warning: type `der set' invalid
/usr/share/misc/magic, 7504: Warning: type `der seq' invalid
/usr/share/misc/magic, 7505: Warning: type `der obj_id3=550406' invalid
/usr/share/misc/magic, 7506: Warning: type `der prt_str=x       \b, countryName=%s' invalid
/usr/share/misc/magic, 7507: Warning: type `der set' invalid
/usr/share/misc/magic, 7508: Warning: type `der seq' invalid
/usr/share/misc/magic, 7509: Warning: type `der obj_id3=550408' invalid
/usr/share/misc/magic, 7510: Warning: type `der utf8_str=x      \b, stateOrProvinceName=%s' invalid
/usr/share/misc/magic, 7511: Warning: type `der set' invalid
/usr/share/misc/magic, 7512: Warning: type `der seq' invalid
/usr/share/misc/magic, 7513: Warning: type `der obj_id3=55040a' invalid
/usr/share/misc/magic, 7514: Warning: type `der utf8_str=x      \b, organizationName=%s' invalid
/usr/share/misc/magic, 7515: Warning: type `der set' invalid
/usr/share/misc/magic, 7516: Warning: type `der seq' invalid
/usr/share/misc/magic, 7517: Warning: type `der obj_id3=550403' invalid
/usr/share/misc/magic, 7518: Warning: type `der utf8_str=x      \b, commonName=%s' invalid
/usr/share/misc/magic, 7519: Warning: type `der seq' invalid
/usr/share/misc/magic, 7522: Warning: type `der seq' invalid
/usr/share/misc/magic, 7523: Warning: type `der seq' invalid
/usr/share/misc/magic, 7524: Warning: type `der int1=00         DER Encoded Certificate request' invalid
/usr/share/misc/magic, 7528: Warning: type `der seq' invalid
/usr/share/misc/magic, 7529: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7530: Warning: type `der int65=x' invalid
/usr/share/misc/magic, 7531: Warning: type `der int3=010001     DER Encoded Key Pair, 512 bits' invalid
/usr/share/misc/magic, 7533: Warning: type `der seq' invalid
/usr/share/misc/magic, 7534: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7535: Warning: type `der int129=x' invalid
/usr/share/misc/magic, 7536: Warning: type `der int3=010001     DER Encoded Key Pair, 1024 bits' invalid
/usr/share/misc/magic, 7538: Warning: type `der seq' invalid
/usr/share/misc/magic, 7539: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7540: Warning: type `der int257=x' invalid
/usr/share/misc/magic, 7541: Warning: type `der int3=010001     DER Encoded Key Pair, 2048 bits' invalid
/usr/share/misc/magic, 7543: Warning: type `der seq' invalid
/usr/share/misc/magic, 7544: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7545: Warning: type `der int513=x' invalid
/usr/share/misc/magic, 7546: Warning: type `der int3=010001     DER Encoded Key Pair, 4096 bits' invalid
/usr/share/misc/magic, 7548: Warning: type `der seq' invalid
/usr/share/misc/magic, 7549: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7550: Warning: type `der int1025=x' invalid
/usr/share/misc/magic, 7551: Warning: type `der int3=010001     DER Encoded Key Pair, 8192 bits' invalid
/usr/share/misc/magic, 7553: Warning: type `der seq' invalid
/usr/share/misc/magic, 7554: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7555: Warning: type `der int2049=x' invalid
/usr/share/misc/magic, 7556: Warning: type `der int3=010001     DER Encoded Key Pair, 16k bits' invalid
/usr/share/misc/magic, 7558: Warning: type `der seq' invalid
/usr/share/misc/magic, 7559: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7560: Warning: type `der int4097=x' invalid
/usr/share/misc/magic, 7561: Warning: type `der int3=010001     DER Encoded Key Pair, 32k bits' invalid
/usr/share/misc/magic, 7564: Warning: type `der seq' invalid
/usr/share/misc/magic, 7565: Warning: type `der seq' invalid
/usr/share/misc/magic, 7566: Warning: type `der int2=0dfa       DER Encoded Certificate, 512 bits' invalid
/usr/share/misc/magic, 7567: Warning: type `der int2=0dfb       DER Encoded Certificate, 1024 bits' invalid
/usr/share/misc/magic, 7568: Warning: type `der int2=0dfc       DER Encoded Certificate, 2048 bits' invalid
/usr/share/misc/magic, 7569: Warning: type `der int2=0dfd       DER Encoded Certificate, 4096 bits' invalid
/usr/share/misc/magic, 7570: Warning: type `der int2=0dfe       DER Encoded Certificate, 8192 bits' invalid
/usr/share/misc/magic, 7571: Warning: type `der int2=0dff       DER Encoded Certificate, 16k bits' invalid
/usr/share/misc/magic, 7572: Warning: type `der int2=0e04       DER Encoded Certificate, 32k bits' invalid
/usr/share/misc/magic, 7573: Warning: type `der int2=x          DER Encoded Certificate, ? bits (%s)' invalid
/usr/share/misc/magic, 7574: Warning: type `der seq' invalid
/usr/share/misc/magic, 7575: Warning: type `der obj_id9=2a864886f70d010105      \b, sha1WithRSAEncryption' invalid
/usr/share/misc/magic, 7576: Warning: type `der obj_id9=x                       \b, ? Encryption (%s)' invalid
/usr/share/misc/magic, 7577: Warning: type `der null' invalid
/usr/share/misc/magic, 7578: Warning: type `der seq' invalid
/usr/share/misc/magic, 7579: Warning: type `der set' invalid
/usr/share/misc/magic, 7580: Warning: type `der seq' invalid
/usr/share/misc/magic, 7581: Warning: type `der obj_id3=550406' invalid
/usr/share/misc/magic, 7582: Warning: type `der prt_str=x       \b, countryName=%s' invalid
/usr/share/misc/magic, 7583: Warning: type `der set' invalid
/usr/share/misc/magic, 7584: Warning: type `der seq' invalid
/usr/share/misc/magic, 7585: Warning: type `der obj_id3=550408' invalid
/usr/share/misc/magic, 7586: Warning: type `der prt_str=x       \b, stateOrProvinceName=%s' invalid
/usr/share/misc/magic, 7587: Warning: type `der set' invalid
/usr/share/misc/magic, 7588: Warning: type `der seq' invalid
/usr/share/misc/magic, 7589: Warning: type `der obj_id3=550407' invalid
/usr/share/misc/magic, 7590: Warning: type `der prt_str=x       \b, localityName=%s' invalid
/usr/share/misc/magic, 7591: Warning: type `der set' invalid
/usr/share/misc/magic, 7592: Warning: type `der seq' invalid
/usr/share/misc/magic, 7593: Warning: type `der obj_id3=55040a' invalid
/usr/share/misc/magic, 7594: Warning: type `der prt_str=x       \b, organizationName=%s' invalid
/usr/share/misc/magic, 7595: Warning: type `der set' invalid
/usr/share/misc/magic, 7596: Warning: type `der seq' invalid
/usr/share/misc/magic, 7597: Warning: type `der obj_id3=55040b' invalid
/usr/share/misc/magic, 7598: Warning: type `der prt_str=x       \b, organizationUnitName=%s' invalid
/usr/share/misc/magic, 7599: Warning: type `der set' invalid
/usr/share/misc/magic, 7600: Warning: type `der seq' invalid
/usr/share/misc/magic, 7601: Warning: type `der obj_id3=550403' invalid
/usr/share/misc/magic, 7602: Warning: type `der prt_str=x       \b, commonName=%s' invalid
/usr/share/misc/magic, 7603: Warning: type `der set' invalid
/usr/share/misc/magic, 7604: Warning: type `der seq' invalid
/usr/share/misc/magic, 7605: Warning: type `der obj_id9=2a864886f70d010901' invalid
/usr/share/misc/magic, 7606: Warning: type `der ia5_str=x       \b, emailAddress=%s' invalid
/usr/share/misc/magic, 7607: Warning: type `der seq' invalid
/usr/share/misc/magic, 7608: Warning: type `der utc_time=x      \b, utcTime=%s' invalid
/usr/share/misc/magic, 7609: Warning: type `der utc_time=x      \b, utcTime=%s' invalid
/usr/share/misc/magic, 11158: Warning: APPLE type `     ????tfil' has bad char '?'
/usr/share/misc/magic, 11166: Warning: APPLE type `     ????OTTO' has bad char '?'
/usr/share/misc/magic, 11255: Warning: APPLE type `     ????tfil' has bad char '?'
/usr/share/misc/magic, 11260: Warning: APPLE type `     ????OTTO' has bad char '?'
/usr/share/misc/magic, 13507: Warning: APPLE type `     ????TPIC' has bad char '?'
/usr/share/misc/magic, 14790: Warning: APPLE type `     ????icns' has bad char '?'
/usr/share/misc/magic, 16593: Warning: APPLE type `     ????devi' has bad char '?'
/usr/share/misc/magic, 18015: Warning: missing ')' in indirect offset
/usr/share/misc/magic, 18177: Warning: APPLE type `     ????L123' has bad char '?'
/usr/share/misc/magic, 18247: Warning: APPLE type `     ????L123' has bad char '?'
/usr/share/misc/magic, 18688: Warning: EXTENSION type ` @@@' has bad char '@'
/usr/share/misc/magic, 24936: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x (MVP)'
/usr/share/misc/magic, 24937: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x'
/usr/share/misc/magic, 25138: Warning: APPLE type `     ????TEXT' has bad char '?'
file: File 5.25 supports only version 13 magic files. `/usr/share/misc/magic.mgc' is version 14
[: =: unexpected operator
 - not found
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/ftp/curl
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/ftp/curl
*** Error code 1

Stop.
make: stopped in /usr/ports/ftp/curl
[root@- /usr/ports/ftp/curl]#
Code:
====> Compressing man pages (compress-man)
===>  Installing for freetype2-2.8_1
===>   Registering installation for freetype2-2.8_1 as automatic
*** Error code 70

Stop.
make[5]: stopped in /usr/ports/print/freetype2
*** Error code 1

Stop.
make[4]: stopped in /usr/ports/print/freetype2
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/print/freetype2
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/x11-fonts/fontconfig
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/x11-fonts/fontconfig
*** Error code 1

Stop.
make: stopped in /usr/ports/x11-fonts/fontconfig
[root@ /usr/ports/x11-fonts/fontconfig]#

I've now also tried checking out a new copy of the ports tree with portsnap, but the problem persists.
 
What do you see that makes you think it isn't the actual error?
It wasn't so much the error but establishing what triggered it. In your original post those error messages came pretty much out of the blue for me.

There's obviously something wrong with /usr/share/misc/magic and when I read the steps on how you tried to recreate it then I can't help think that's where things went wrong. Try this:
Code:
# cd /usr/src/contrib/file/magic
# cat Header Localstuff Magdir/* >> /usr/share/misc/magic
# chown root:wheel /usr/share/misc/magic && chmod 444 /usr/share/misc/magic
That should fix something.

(edit): be sure to remove /usr/share/misc/magic first of course!
 
It wasn't so much the error but establishing what triggered it. In your original post those error messages came pretty much out of the blue for me.

There's obviously something wrong with /usr/share/misc/magic and when I read the steps on how you tried to recreate it then I can't help think that's where things went wrong. Try this:
Code:
# cd /usr/src/contrib/file/magic
# cat Header Localstuff Magdir/* >> /usr/share/misc/magic
# chown root:wheel /usr/share/misc/magic && chmod 444 /usr/share/misc/magic
That should fix something.

(edit): be sure to remove /usr/share/misc/magic first of course!

Thanks ShelLuser. But I'm still getting the same magic version error messages. Something is really messed up, though. When I try to make deinstall install clean security/openvpn to update it, I get the the magic error, but it proceeds anyway, breaking on installing an updated dependency:
Code:
'/usr/share/misc/magic, 24936: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x (MVP)'
/usr/share/misc/magic, 24937: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x'
/usr/share/misc/magic, 25138: Warning: APPLE type `     ????TEXT' has bad char '?'
file: File 5.25 supports only version 13 magic files. `/usr/share/misc/magic.mgc' is version 14
[: =: unexpected operator
 - not found
===>  Installing for lzo2-2.10_1
===>  Checking if lzo2 already installed
===>   lzo2-2.10_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 lzo2
      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 /usr/ports/archivers/lzo2
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/archivers/lzo2
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/security/openvpn
*** Error code 1

Stop.
make: stopped in /usr/ports/security/openvpn

So I run it again, with FORCE_PKG_REGISTER=1 make deinstall install clean, and this time it breaks when registering the dependency.
Code:
[...]
/usr/share/misc/magic, 11158: Warning: APPLE type `     ????tfil' has bad char '?'
/usr/share/misc/magic, 11166: Warning: APPLE type `     ????OTTO' has bad char '?'
/usr/share/misc/magic, 11255: Warning: APPLE type `     ????tfil' has bad char '?'
/usr/share/misc/magic, 11260: Warning: APPLE type `     ????OTTO' has bad char '?'
/usr/share/misc/magic, 13507: Warning: APPLE type `     ????TPIC' has bad char '?'
/usr/share/misc/magic, 14790: Warning: APPLE type `     ????icns' has bad char '?'
/usr/share/misc/magic, 16593: Warning: APPLE type `     ????devi' has bad char '?'
/usr/share/misc/magic, 18015: Warning: missing ')' in indirect offset
/usr/share/misc/magic, 18177: Warning: APPLE type `     ????L123' has bad char '?'
/usr/share/misc/magic, 18247: Warning: APPLE type `     ????L123' has bad char '?'
/usr/share/misc/magic, 18688: Warning: EXTENSION type ` @@@' has bad char '@'
/usr/share/misc/magic, 24936: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x (MVP)'
/usr/share/misc/magic, 24937: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x'
/usr/share/misc/magic, 25138: Warning: APPLE type `     ????TEXT' has bad char '?'
file: File 5.25 supports only version 13 magic files. `/usr/share/misc/magic.mgc' is version 14
[: =: unexpected operator
 - not found
===>  License GPLv2 accepted by the user
===>   lzo2-2.10_1 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by lzo2-2.10_1 for building
===>  Extracting for lzo2-2.10_1
=> SHA256 Checksum OK for lzo-2.10.tar.gz.
===>  Patching for lzo2-2.10_1
===>  Applying FreeBSD patches for lzo2-2.10_1
===>  Configuring for lzo2-2.10_1
configure: loading site script /usr/ports/Templates/config.site
configure: Configuring LZO 2.10
checking build system type... amd64-portbld-freebsd10.3
[...]
Done.
+ exit 0
./tests/align
Align init: 0x801406000 ( 0x801406000 )
Alignment test passed.
./tests/chksum
Checksum test passed.
./examples/simple

LZO real-time data compression library (v2.10, Mar 01 2017).
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.

compressed 131072 bytes into 593 bytes
decompressed 593 bytes back into 131072 bytes
Simple compression test passed.
./minilzo/testmini

LZO real-time data compression library (v2.10, Mar 01 2017).
Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.

compressed 131072 bytes into 593 bytes
decompressed 593 bytes back into 131072 bytes

miniLZO simple compression test passed.

===== All tests passed. Now you are ready to install LZO. =====

===>  Staging for lzo2-2.10_1
===>   Generating temporary packing list
 /bin/mkdir -p '/usr/ports/archivers/lzo2/work/stage/usr/local/lib'
 [...]
 
cd /usr/ports/archivers/lzo2/work/lzo-2.10 && /usr/bin/sed -i.bak -e 's,doc/,,' NEWS README
install  -m 0644 /usr/ports/archivers/lzo2/work/lzo-2.10/AUTHORS /usr/ports/archivers/lzo2/work/stage/usr/local/share/doc/lzo2/
install  -m 0644 /usr/ports/archivers/lzo2/work/lzo-2.10/BUGS /usr/ports/archivers/lzo2/work/stage/usr/local/share/doc/lzo2/
install  -m 0644 /usr/ports/archivers/lzo2/work/lzo-2.10/COPYING /usr/ports/archivers/lzo2/work/stage/usr/local/share/doc/lzo2/
install  -m 0644 /usr/ports/archivers/lzo2/work/lzo-2.10/NEWS /usr/ports/archivers/lzo2/work/stage/usr/local/share/doc/lzo2/
install  -m 0644 /usr/ports/archivers/lzo2/work/lzo-2.10/README /usr/ports/archivers/lzo2/work/stage/usr/local/share/doc/lzo2/
install  -m 0644 /usr/ports/archivers/lzo2/work/lzo-2.10/THANKS /usr/ports/archivers/lzo2/work/stage/usr/local/share/doc/lzo2/
install  -m 0644        /usr/ports/archivers/lzo2/work/lzo-2.10/doc/* /usr/ports/archivers/lzo2/work/stage/usr/local/share/doc/lzo2/
/bin/mkdir -p /usr/ports/archivers/lzo2/work/stage/usr/local/share/examples/lzo2
install  -m 0644        /usr/ports/archivers/lzo2/work/lzo-2.10/examples/[a-z]*.[ch] /usr/ports/archivers/lzo2/work/stage/usr/local/share/examples/lzo2/
====> Compressing man pages (compress-man)
===>  Installing for lzo2-2.10_1
===>   Registering installation for lzo2-2.10_1 as automatic
*** Error code 70

Stop.
make[3]: stopped in /usr/ports/archivers/lzo2
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/archivers/lzo2
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/security/openvpn
*** Error code 1

Stop.
make: stopped in /usr/ports/security/openvpn

I tried updating archivers/lzo2 first, too, in case that's causing the hangup, but it deinstall install's fine.

BTW, it's not just specific to lzo2, since I've gone through and uninstalled other programs like ftp/curl in hopes of fixing this issue, but it just crashes on whichever one I try next.
 
But I'm still getting the same magic version error messages. Something is really messed up, though.
Yups, this doesn't seem like a basic issue of one corrupt file.

Which leads up to: What FreeBSD version are you using, what file system type(s) do you use and are you sure your filesystem isn't corrupted? Also: what type of kernel (GENERIC or did you roll your own)?

Next: do you have anything specific set up in /etc/make.conf? If so what happens if you move that file out of the way and then try to build a port?
 
Yups, this doesn't seem like a basic issue of one corrupt file.

Which leads up to: What FreeBSD version are you using, what file system type(s) do you use and are you sure your filesystem isn't corrupted? Also: what type of kernel (GENERIC or did you roll your own)?

Next: do you have anything specific set up in /etc/make.conf? If so what happens if you move that file out of the way and then try to build a port?

On this box, GENERIC, 10.3-RELEASE still (once this is fixed I'll upgrade to 10.4 or 11.2), ZFS, and updates performed via freebsd-update (and portsnap / portmaster for ports).
Code:
[root@- ~]# uname -a ; freebsd-version -u ; zfs list
FreeBSD - 10.3-RELEASE-p24 FreeBSD 10.3-RELEASE-p24 #0: Wed Nov 15 04:57:40 UTC 2017     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64
10.3-RELEASE-p28
NAME                 USED  AVAIL  REFER  MOUNTPOINT
zroot               14.3G  7.87G    19K  none
zroot/ROOT          4.56G  7.87G    19K  none
zroot/ROOT/default  4.56G  7.87G  3.39G  legacy
zroot/usr           9.72G  7.87G  4.98G  /usr
zroot/usr/ports      541M  7.87G   541M  /usr/ports
zroot/usr/src       1.85G  7.87G  1.85G  /usr/src
[root@- ~]# cat /etc/make.conf
cat: /etc/make.conf: No such file or directory

On other boxes, I compile from source and buildworld. I also use packages on other boxes, but this one is strictly ports. Except,
Code:
[root@- ~]# history | grep "pkg install"
  199  pkg install sysutils/smartmontools
  334  pkg install file
  512  history | grep "pkg install"

The pkg install file was an attempt to fix the magic error by dumping that port and installing its package. The sysutils/smartmontools package was deleted in history event 204.
 
So I've carefully re-read the thread once more because in my first message I did the same thing: focused my attention on the magic file and glossed over a few other possible issues. This is also why I asked you to provide more logs. Studying those now made this stand out for me:

Code:
===>   curl-7.59.0 depends on shared library: libnghttp2.sofile: compiled magic version [532] does not match with shared library magic version [524]
/usr/share/misc/magic, 1898: Warning: APPLE type `      ????devr' has bad char '?'
/usr/share/misc/magic, 2673: Warning: APPLE type `      ????LHA' has bad char '?'
Sure, it complains about /usr/share/misc/magic but if you followed my instructions then I'm pretty sure that this file is now properly set up. As such we can probably rule out any cause of problems here. So re-reading the log snippet above makes me believe that these errors occur as soon as Curl gets build against libnghttp2.so. The error tells us as much (I should have seen this sooner!): "compiled magic version does not match with shared library magic version".

In other words: the library was build against version "x" of the magic file. You changed stuff thus creating version "y" and now it has detected a mismatch and can no longer properly function.

Solution: compile against the current magic file. First let us determine which port is responsible for all this:

Code:
peter@unicron:/home/peter $ pkg which -o `locate libnghttp2.so`
/usr/local/lib/libnghttp2.so was installed by package www/libnghttp2
/usr/local/lib/libnghttp2.so.14 was installed by package www/libnghttp2
/usr/local/lib/libnghttp2.so.14.16.0 was installed by package www/libnghttp2
Therefor you should re-install www/libnghttp2. But also re-build ports which rely on this library:

Code:
peter@unicron:/home/peter $ pkg info -rx libng
libnghttp2-1.31.0:
        apache24-2.4.29_2
        curl-7.59.0
As such my suggestion: # portmaster -r libnghttp2. This will also re-build Curl after which I think your problems will soon be over.
 
So I've carefully re-read the thread once more because in my first message I did the same thing: focused my attention on the magic file and glossed over a few other possible issues. This is also why I asked you to provide more logs. Studying those now made this stand out for me:

Code:
===>   curl-7.59.0 depends on shared library: libnghttp2.sofile: compiled magic version [532] does not match with shared library magic version [524]
/usr/share/misc/magic, 1898: Warning: APPLE type `      ????devr' has bad char '?'
/usr/share/misc/magic, 2673: Warning: APPLE type `      ????LHA' has bad char '?'
Sure, it complains about /usr/share/misc/magic but if you followed my instructions then I'm pretty sure that this file is now properly set up. As such we can probably rule out any cause of problems here. So re-reading the log snippet above makes me believe that these errors occur as soon as Curl gets build against libnghttp2.so. The error tells us as much (I should have seen this sooner!): "compiled magic version does not match with shared library magic version".

In other words: the library was build against version "x" of the magic file. You changed stuff thus creating version "y" and now it has detected a mismatch and can no longer properly function.

Solution: compile against the current magic file. First let us determine which port is responsible for all this:

Code:
peter@unicron:/home/peter $ pkg which -o `locate libnghttp2.so`
/usr/local/lib/libnghttp2.so was installed by package www/libnghttp2
/usr/local/lib/libnghttp2.so.14 was installed by package www/libnghttp2
/usr/local/lib/libnghttp2.so.14.16.0 was installed by package www/libnghttp2
Therefor you should re-install www/libnghttp2. But also re-build ports which rely on this library:

Code:
peter@unicron:/home/peter $ pkg info -rx libng
libnghttp2-1.31.0:
        apache24-2.4.29_2
        curl-7.59.0
As such my suggestion: # portmaster -r libnghttp2. This will also re-build Curl after which I think your problems will soon be over.

1. I've tried to walk the thin line between providing just the relevant info and not leaving anything of relevance out. I didn't mention that I've already reinstalled www/libnghttp2. I was getting the same error message I'm getting with archivers/lzo2 now about using FORCE_PKG_REGISTER, so I tried to fix it with a manual re-installation. That was a few days ago:

Code:
[root@- /usr/src/contrib/file]# fc -l 300 305
300      cd /usr/ports/www/libnghttp2/
301      make clean deinstall reinstall clean
302      vim /tmp/portmasterfail.txt
303      bash /tmp/portmasterfail.txt
304      make clean all deinstall reinstall clean
305      pkg install file

[root@- /usr/src/contrib/file]# fc -l -1
525      fc -l 300 305

2. You'll note I already tried recreating /usr/share/misc/magic in my OP. I then also recreated it using your steps (which are essentially the same, just without using install or compiling magic.mgc with file -C). Here's what happens:

Code:
[root@- /usr/src/contrib/file]# cd /usr/src/contrib/file/magic/
[root@- /usr/src/contrib/file/magic]# rm /usr/share/misc/magic
[root@- /usr/src/contrib/file/magic]# cat Header Localstuff Magdir/* >> /usr/share/misc/magic
[root@- /usr/src/contrib/file/magic]# cd /usr/share/misc/magic
-bash: cd: /usr/share/misc/magic: Not a directory
[root@- /usr/src/contrib/file/magic]# cd /usr/share/misc/
[root@- /usr/share/misc]# chown root:wheel magic && chmod 444 magic
[root@- /usr/share/misc]# file -C magic
file: compiled magic version [532] does not match with shared library magic version [524]
/usr/share/misc/magic, 1898: Warning: APPLE type `      ????devr' has bad char '?'
/usr/share/misc/magic, 2673: Warning: APPLE type `      ????LHA' has bad char '?'
/usr/share/misc/magic, 4673: Warning: cannot get string from `^using[[:space:]]+(namespace )?std(::)?[[:alpha:]]*[[:space:]]*'
/usr/share/misc/magic, 4675: Warning: Current entry does not yet have a description for adding a MIME type
/usr/share/misc/magic, 4683: Warning: cannot get string from `^[[:space:]]*class[[:space:]]+[[:digit:][:alpha:]:_]+[[:space:]'
/usr/share/misc/magic, 4685: Warning: Current entry does not yet have a description for adding a MIME type
/usr/share/misc/magic, 7494: Warning: Printf format `#' is not valid for type `lelong' in description `, seed %#x'
/usr/share/misc/magic, 7502: Warning: type `der seq' invalid
/usr/share/misc/magic, 7503: Warning: type `der set' invalid
/usr/share/misc/magic, 7504: Warning: type `der seq' invalid
/usr/share/misc/magic, 7505: Warning: type `der obj_id3=550406' invalid
/usr/share/misc/magic, 7506: Warning: type `der prt_str=x       \b, countryName=%s' invalid
/usr/share/misc/magic, 7507: Warning: type `der set' invalid
/usr/share/misc/magic, 7508: Warning: type `der seq' invalid
/usr/share/misc/magic, 7509: Warning: type `der obj_id3=550408' invalid
/usr/share/misc/magic, 7510: Warning: type `der utf8_str=x      \b, stateOrProvinceName=%s' invalid
/usr/share/misc/magic, 7511: Warning: type `der set' invalid
/usr/share/misc/magic, 7512: Warning: type `der seq' invalid
/usr/share/misc/magic, 7513: Warning: type `der obj_id3=55040a' invalid
/usr/share/misc/magic, 7514: Warning: type `der utf8_str=x      \b, organizationName=%s' invalid
/usr/share/misc/magic, 7515: Warning: type `der set' invalid
/usr/share/misc/magic, 7516: Warning: type `der seq' invalid
/usr/share/misc/magic, 7516: Warning: type `der seq' invalid
/usr/share/misc/magic, 7517: Warning: type `der obj_id3=550403' invalid
/usr/share/misc/magic, 7518: Warning: type `der utf8_str=x      \b, commonName=%s' invalid
/usr/share/misc/magic, 7519: Warning: type `der seq' invalid
/usr/share/misc/magic, 7522: Warning: type `der seq' invalid
/usr/share/misc/magic, 7523: Warning: type `der seq' invalid
/usr/share/misc/magic, 7524: Warning: type `der int1=00         DER Encoded Certificate request' invalid
/usr/share/misc/magic, 7528: Warning: type `der seq' invalid
/usr/share/misc/magic, 7529: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7530: Warning: type `der int65=x' invalid
/usr/share/misc/magic, 7531: Warning: type `der int3=010001     DER Encoded Key Pair, 512 bits' invalid
/usr/share/misc/magic, 7533: Warning: type `der seq' invalid
/usr/share/misc/magic, 7534: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7535: Warning: type `der int129=x' invalid
/usr/share/misc/magic, 7536: Warning: type `der int3=010001     DER Encoded Key Pair, 1024 bits' invalid
/usr/share/misc/magic, 7538: Warning: type `der seq' invalid
/usr/share/misc/magic, 7539: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7540: Warning: type `der int257=x' invalid
/usr/share/misc/magic, 7541: Warning: type `der int3=010001     DER Encoded Key Pair, 2048 bits' invalid
/usr/share/misc/magic, 7543: Warning: type `der seq' invalid
/usr/share/misc/magic, 7544: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7545: Warning: type `der int513=x' invalid
/usr/share/misc/magic, 7546: Warning: type `der int3=010001     DER Encoded Key Pair, 4096 bits' invalid
/usr/share/misc/magic, 7548: Warning: type `der seq' invalid
/usr/share/misc/magic, 7549: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7550: Warning: type `der int1025=x' invalid
/usr/share/misc/magic, 7551: Warning: type `der int3=010001     DER Encoded Key Pair, 8192 bits' invalid
/usr/share/misc/magic, 7553: Warning: type `der seq' invalid
/usr/share/misc/magic, 7554: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7555: Warning: type `der int2049=x' invalid
/usr/share/misc/magic, 7556: Warning: type `der int3=010001     DER Encoded Key Pair, 16k bits' invalid
/usr/share/misc/magic, 7558: Warning: type `der seq' invalid
/usr/share/misc/magic, 7559: Warning: type `der int1=00' invalid
/usr/share/misc/magic, 7560: Warning: type `der int4097=x' invalid
/usr/share/misc/magic, 7561: Warning: type `der int3=010001     DER Encoded Key Pair, 32k bits' invalid
/usr/share/misc/magic, 7564: Warning: type `der seq' invalid
/usr/share/misc/magic, 7565: Warning: type `der seq' invalid
/usr/share/misc/magic, 7566: Warning: type `der int2=0dfa       DER Encoded Certificate, 512 bits' invalid
/usr/share/misc/magic, 7567: Warning: type `der int2=0dfb       DER Encoded Certificate, 1024 bits' invalid
/usr/share/misc/magic, 7568: Warning: type `der int2=0dfc       DER Encoded Certificate, 2048 bits' invalid
/usr/share/misc/magic, 7569: Warning: type `der int2=0dfd       DER Encoded Certificate, 4096 bits' invalid
/usr/share/misc/magic, 7570: Warning: type `der int2=0dfe       DER Encoded Certificate, 8192 bits' invalid
/usr/share/misc/magic, 7571: Warning: type `der int2=0dff       DER Encoded Certificate, 16k bits' invalid
/usr/share/misc/magic, 7572: Warning: type `der int2=0e04       DER Encoded Certificate, 32k bits' invalid
/usr/share/misc/magic, 7573: Warning: type `der int2=x          DER Encoded Certificate, ? bits (%s)' invalid
/usr/share/misc/magic, 7574: Warning: type `der seq' invalid
/usr/share/misc/magic, 7575: Warning: type `der obj_id9=2a864886f70d010105      \b, sha1WithRSAEncryption' invalid
/usr/share/misc/magic, 7576: Warning: type `der obj_id9=x                       \b, ? Encryption (%s)' invalid
/usr/share/misc/magic, 7577: Warning: type `der null' invalid
/usr/share/misc/magic, 7578: Warning: type `der seq' invalid
/usr/share/misc/magic, 7579: Warning: type `der set' invalid
/usr/share/misc/magic, 7580: Warning: type `der seq' invalid
/usr/share/misc/magic, 7581: Warning: type `der obj_id3=550406' invalid
/usr/share/misc/magic, 7582: Warning: type `der prt_str=x       \b, countryName=%s' invalid
/usr/share/misc/magic, 7583: Warning: type `der set' invalid
/usr/share/misc/magic, 7584: Warning: type `der seq' invalid
/usr/share/misc/magic, 7585: Warning: type `der obj_id3=550408' invalid
/usr/share/misc/magic, 7586: Warning: type `der prt_str=x       \b, stateOrProvinceName=%s' invalid
/usr/share/misc/magic, 7587: Warning: type `der set' invalid
/usr/share/misc/magic, 7588: Warning: type `der seq' invalid
/usr/share/misc/magic, 7589: Warning: type `der obj_id3=550407' invalid
/usr/share/misc/magic, 7590: Warning: type `der prt_str=x       \b, localityName=%s' invalid
/usr/share/misc/magic, 7591: Warning: type `der set' invalid
/usr/share/misc/magic, 7592: Warning: type `der seq' invalid
/usr/share/misc/magic, 7593: Warning: type `der obj_id3=55040a' invalid
/usr/share/misc/magic, 7594: Warning: type `der prt_str=x       \b, organizationName=%s' invalid
/usr/share/misc/magic, 7595: Warning: type `der set' invalid
/usr/share/misc/magic, 7596: Warning: type `der seq' invalid
/usr/share/misc/magic, 7597: Warning: type `der obj_id3=55040b' invalid
/usr/share/misc/magic, 7598: Warning: type `der prt_str=x       \b, organizationUnitName=%s' invalid
/usr/share/misc/magic, 7599: Warning: type `der set' invalid
/usr/share/misc/magic, 7600: Warning: type `der seq' invalid
/usr/share/misc/magic, 7601: Warning: type `der obj_id3=550403' invalid
/usr/share/misc/magic, 7602: Warning: type `der prt_str=x       \b, commonName=%s' invalid
/usr/share/misc/magic, 7603: Warning: type `der set' invalid
/usr/share/misc/magic, 7604: Warning: type `der seq' invalid
/usr/share/misc/magic, 7605: Warning: type `der obj_id9=2a864886f70d010901' invalid
/usr/share/misc/magic, 7606: Warning: type `der ia5_str=x       \b, emailAddress=%s' invalid
/usr/share/misc/magic, 7607: Warning: type `der seq' invalid
/usr/share/misc/magic, 7608: Warning: type `der utc_time=x      \b, utcTime=%s' invalid
/usr/share/misc/magic, 7609: Warning: type `der utc_time=x      \b, utcTime=%s' invalid
/usr/share/misc/magic, 11158: Warning: APPLE type `     ????tfil' has bad char '?'
/usr/share/misc/magic, 11166: Warning: APPLE type `     ????OTTO' has bad char '?'
/usr/share/misc/magic, 11255: Warning: APPLE type `     ????tfil' has bad char '?'
/usr/share/misc/magic, 11260: Warning: APPLE type `     ????OTTO' has bad char '?'
/usr/share/misc/magic, 13507: Warning: APPLE type `     ????TPIC' has bad char '?'
/usr/share/misc/magic, 14790: Warning: APPLE type `     ????icns' has bad char '?'
/usr/share/misc/magic, 16593: Warning: APPLE type `     ????devi' has bad char '?'
/usr/share/misc/magic, 18015: Warning: missing ')' in indirect offset
/usr/share/misc/magic, 18177: Warning: APPLE type `     ????L123' has bad char '?'
/usr/share/misc/magic, 18247: Warning: APPLE type `     ????L123' has bad char '?'
/usr/share/misc/magic, 18688: Warning: EXTENSION type ` @@@' has bad char '@'
/usr/share/misc/magic, 24936: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x (MVP)'
/usr/share/misc/magic, 24937: Warning: Printf format `#' is not valid for type `lelong' in description `version %#x'
/usr/share/misc/magic, 25138: Warning: APPLE type `     ????TEXT' has bad char '?'
file: line 1898: Bad magic entry '      ????devr'

[root@- /usr/share/misc]# stat -x magic.mgc | grep Ch
Change: Thu Mar 22 11:36:57 2018

3. From what I've seen while trying to resolve this issue, I think it's a problem with the magic file. Otherwise, compiling the new magic.mgc file should work. Or, maybe a problem during the registration of a package that's being installed. That's my guess, anyway.

Here's the log file of the following commands (attached):
Code:
[root@- /usr/share/misc]# fc -l "pkg which -o" | head
501      pkg which -o `locate libnghttp2.so`
502      cd /usr/ports/www/libnghttp2/
503      make clean deinstall install clean
504      portmaster -r libnghttp2
505      echo /usr/ports/**/openvpn
506      cd /usr/ports/security/openvpn
507      make clean deinstall install clean
[...]

Thanks again for the help.
 

Attachments

No, it's not the magic file itself which is causing problems. You can see this for yourself in the error message I posted. The problem is with a program (or library) which was compiled against one version and now detects another. I stand corrected on the www/libnghttp2 approach, that's not it.

But I think I got it.... I used truss to check what happens when you run file to identify something and then I noticed this:
Code:
openat(AT_FDCWD,"/usr/share/misc/magic.mgc",O_RDONLY,00) = 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=100165,size=4814280,blksize=131072 }) = 0 (0x0)
mmap(0x0,4814280,PROT_READ|PROT_WRITE,MAP_PRIVATE,3,0x0) = 34382807040 (0x801600
000)
close(3)                                         = 0 (0x0)
And what do you know: that file exists: /usr/share/misc/magic.mgc. So then I discovered magic(5) but that only mentions the regular magic file. Then I studied file(1) once more and as said: I think I got it:

Code:
     -C, --compile
             Write a magic.mgc output file that contains a pre-parsed version
             of the magic file or directory.
So my suggestion now is to remove /usr/share/misc/magic.mgc and then use # cd /usr/share/misc && file -C. I'm somewhat certain that this should fix things.
 
No, it's not the magic file itself which is causing problems. You can see this for yourself in the error message I posted. The problem is with a program (or library) which was compiled against one version and now detects another. I stand corrected on the www/libnghttp2 approach, that's not it.

But I think I got it.... I used truss to check what happens when you run file to identify something and then I noticed this:
Code:
openat(AT_FDCWD,"/usr/share/misc/magic.mgc",O_RDONLY,00) = 3 (0x3)
fstat(3,{ mode=-r--r--r-- ,inode=100165,size=4814280,blksize=131072 }) = 0 (0x0)
mmap(0x0,4814280,PROT_READ|PROT_WRITE,MAP_PRIVATE,3,0x0) = 34382807040 (0x801600
000)
close(3)                                         = 0 (0x0)
And what do you know: that file exists: /usr/share/misc/magic.mgc. So then I discovered magic(5) but that only mentions the regular magic file. Then I studied file(1) once more and as said: I think I got it:

Code:
     -C, --compile
             Write a magic.mgc output file that contains a pre-parsed version
             of the magic file or directory.
So my suggestion now is to remove /usr/share/misc/magic.mgc and then use # cd /usr/share/misc && file -C. I'm somewhat certain that this should fix things.

Unfortunately, I've tried that already a few times (see my previous posts). It fails at creating /usr/share/misc/magic.mgc. Let's compare what you get when you recompile that file. Do you get a wall of (warning) error messages like I do, and end up with no new /usr/share/misc/magic.mgc? (See #2 in my previous post from today.)
 
I'll show you:

Code:
peter@unicron:/usr/src/contrib/file/magic $ cat Header Localstuff Magdir* >> ~/magic/magic
peter@unicron:/home/peter/magic $ ls -l
total 1027
-rw-r--r--  1 peter  peter  922437 Mar 24 21:38 magic
peter@unicron:/home/peter/magic $ file -m ./magic -C
./magic, 7494: Warning: Printf format is too long for type `lelong' in description `, seed %#x'
./magic, 18688: Warning: EXTENSION type ` @@@' has bad char '@'
./magic, 24936: Warning: Printf format is too long for type `lelong' in description `version %#x (MVP)'
./magic, 24937: Warning: Printf format is too long for type `lelong' in description `version %#x'
file: line 18688: Bad magic entry ' @@@'
Ergo: that's probably not how you make a proper magic file. When I try to run file -m ./magic -C it complains and doesn't build.

So when all else fails: base.txz. Get that file from ftp.freebsd.org (or a mirror), then extract usr/share/misc/magic and use that to replace the original.
 
I'll show you:

Code:
peter@unicron:/usr/src/contrib/file/magic $ cat Header Localstuff Magdir* >> ~/magic/magic
peter@unicron:/home/peter/magic $ ls -l
total 1027
-rw-r--r--  1 peter  peter  922437 Mar 24 21:38 magic
peter@unicron:/home/peter/magic $ file -m ./magic -C
./magic, 7494: Warning: Printf format is too long for type `lelong' in description `, seed %#x'
./magic, 18688: Warning: EXTENSION type ` @@@' has bad char '@'
./magic, 24936: Warning: Printf format is too long for type `lelong' in description `version %#x (MVP)'
./magic, 24937: Warning: Printf format is too long for type `lelong' in description `version %#x'
file: line 18688: Bad magic entry ' @@@'
Ergo: that's probably not how you make a proper magic file. When I try to run file -m ./magic -C it complains and doesn't build.

So when all else fails: base.txz. Get that file from ftp.freebsd.org (or a mirror), then extract usr/share/misc/magic and use that to replace the original.

That did it. Needed both magic and magic.mgc, but once they were installed archivers/lzo2 was able to be reinstalled properly during security/openvpn's updating process. Funnily enough, the magic version does not match shared library version errors persist (see below). :rolleyes:

Code:
[root@- /usr/share/misc]# cd /tmp/
[root@- /tmp]# fetch ftp://149.20.1.200/pub/FreeBSD/releases/amd64/10.3-RELEASE/base.txz -o - | tar --unlink -xpvf - ./usr/share/misc/magic
-                                              57% of   67 MB 5457 kBps 00m05sx ./usr/share/misc/magic
-                                             100% of   67 MB 4981 kBps 00m13s
[root@- /tmp]# mv usr/share/misc/magic /usr/share/misc/
[root@- /tmp]# fetch ftp://149.20.1.200/pub/FreeBSD/releases/amd64/10.3-RELEASE/base.txz -o - | tar --unlink -xpvf - ./usr/share/misc/magic.mgc
-                                              57% of   67 MB 5272 kBps 00m06sx ./usr/share/misc/magic.mgc
-                                             100% of   67 MB 4821 kBps 00m15s
[root@- /tmp]# mv usr/share/misc/magic.mgc /usr/share/misc/

[root@- /tmp]# cd !?openvpn?:%
cd /usr/ports/security/openvpn
[root@- /usr/ports/security/openvpn]# make clean deinstall install clean
===>  Cleaning for lzo2-2.10_1
===>  Cleaning for openvpn-2.4.5
===>  Deinstalling for openvpn
===>   openvpn not installed, skipping
===>  License GPLv2 accepted by the user
===>   openvpn-2.4.5 depends on file: /usr/local/sbin/pkg - found
===> Fetching all distfiles required by openvpn-2.4.5 for building
===>  Extracting for openvpn-2.4.5
=> SHA256 Checksum OK for openvpn-2.4.5.tar.xz.
===>  Patching for openvpn-2.4.5
===>  Applying FreeBSD patches for openvpn-2.4.5
===>   openvpn-2.4.5 depends on package: pkgconf>=1.3.0_1 - found
===>   openvpn-2.4.5 depends on shared library: liblzo2.sofile: compiled magic version [532] does not match with shared library magic version [524]
- found (/usr/local/lib/liblzo2.so)
===>   openvpn-2.4.5 depends on shared library: liblz4.sofile: compiled magic version [532] does not match with shared library magic version [524]
- found (/usr/local/lib/liblz4.so)
===>  Configuring for openvpn-2.4.5

[...]

====> Compressing man pages (compress-man)
===> Staging rc.d startup script(s)
===>  Installing for openvpn-2.4.5
===>  Checking if openvpn already installed
file: compiled magic version [532] does not match with shared library magic version [524]
file: compiled magic version [532] does not match with shared library magic version [524]
===>   Registering installation for openvpn-2.4.5
Installing openvpn-2.4.5...
### ------------------------------------------------------------------------
###  Edit /etc/rc.conf[.local] to start OpenVPN automatically at system
###  startup. See /usr/local/etc/rc.d/openvpn for details.
### ------------------------------------------------------------------------
###  Connect to VPN server as a client with this command to include
###  the client.up/down scripts in the initialization:
###  openvpn-client <spec>.ovpn
### ------------------------------------------------------------------------
###  For compatibility notes when interoperating with older OpenVPN
###  versions, please, see <http://openvpn.net/relnotes.html>
### ------------------------------------------------------------------------

===> SECURITY REPORT:
      This port has installed the following files which may act as network
      servers and may therefore pose a remote security risk to the system.
/usr/local/sbin/openvpn

      This port has installed the following startup scripts which may cause
      these network services to be started at boot time.
/usr/local/etc/rc.d/openvpn

      If there are vulnerabilities in these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included in the Ports Collection. Please type 'make deinstall'
      to deinstall the port if this is a concern.

      For more information, and contact details about the security
      status of this software, see the following webpage:
http://openvpn.net/index.php/open-source.html
[root@- /usr/ports/security/openvpn]#

Conclusion (for any future Internet searchers): magic and magic.mgc file corruption can break port updates.
 
Back
Top