[workaroud/fix for] buildworld fails on FreeBSD 7.x for HEAD from 19.04.2012

Jan Sieka jps at semihalf.com
Fri Apr 27 12:14:04 UTC 2012

On 2012.04.22 21:07, Garrett Cooper wrote:
> On Apr 22, 2012, at 10:34 AM, Dimitry Andric wrote:
>> Well, I wouldn't want to run autoconf during build, firstly because it
>> is horribly slow, and second because the results will be less
>> predictable.  Maybe during the bootstrap stage, it would be acceptable.
> Sure -- that seems reasonable.
>> But even then, one of the configure scripts could fail due to too-old
>> system components, and you would be SOL.
> … but it would be a step forward from where things are currently at. I'm not sure how well tested "source upgrade" paths are, but being able to upgrade from the lowest supported version to the latest supported version, then upgrading to CURRENT (at the very least) would be nice.
>> Usually, if something is arch-dependent in a config.h file, we simply
>> surround it with #ifdefs.
> Makes sense (assumption being that it can be controlled via the config.h/configure.{ac,in} file). However, jemalloc recently disproved this>_<.
>> Apparently the file(1) build needs a 'mkmagic' tool, which generates
>> .mgc files (the 'compiled' version of magic files).  This requirement
>> was originally added in r81845, more than 10 years ago.
> I tested out removing libmagic from Makefile.inc1 and see that there's some dependency magic going on there where building the library failed.
>> Yes, it might work, but there is no guarantee.  I'm not sure if there is
>> enough incentive to change this policy.  It would potentially require a
>> lot effort to make it always work.
> Understood and I guess the ownness is upon the stakeholders to fix this, but there are a lot of companies that depend on things like this working (at least to reduce pain when doing source upgrades). This would probably be less of an issue for developers that use freebsd-update or for companies that roll their own freebsd-update (and servers). I have yet to run into a company that does this though (not saying there aren't groups that could or do do this, but it's not the standard path).
>> I wasn't aware of any chroot hackery?
> A publicly available example is available in FreeNAS ( http://freenas.svn.sourceforge.net/viewvc/freenas?view=revision&revision=8193 ); the hangup is building packages for a target system that doesn't match the build host.
> Cheers!
> -Garrett

I have prepared workaround/fix for this issue. It has been tested on FreeBSD 7.3 
and 9.0 (both RELEASE) with good results: world build finishes OK. I attach the 
patch in case someone else is hit by this issue. Feel free to use it.

Thanks for all suggestions and comments.


Jan Sieka

-------------- next part --------------
diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile
index 9c35c35..e9b8240 100644
--- a/lib/libmagic/Makefile
+++ b/lib/libmagic/Makefile
@@ -10,9 +10,16 @@ DPADD=	${LIBZ}
 LDADD=	-lz
 MAN=	libmagic.3 magic.5
+HOSTOSRELDATE!=	echo ${VERSION} | cut -d " " -f 4
+.if ${HOSTOSRELDATE} < 800000
+GETLINE_C=	getline.c
 SRCS=	apprentice.c apptype.c ascmagic.c cdf.c cdf_time.c compress.c \
 	encoding.c fsmagic.c funcs.c \
-	is_tar.c magic.c print.c readcdf.c readelf.c softmagic.c
+	is_tar.c magic.c print.c readcdf.c readelf.c softmagic.c ${GETLINE_C}
 INCS=	magic.h
 MAGICPATH?=	/usr/share/misc
@@ -39,7 +46,8 @@ magic.mgc: mkmagic magic
 CLEANFILES+=	mkmagic
 build-tools: mkmagic
-mkmagic: apprentice.c funcs.c magic.c print.c
+mkmagic: apprentice.c funcs.c magic.c print.c ${GETLINE_C}
 FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \
diff --git a/lib/libmagic/config.h b/lib/libmagic/config.h
index 06ed4ec..3fe103e 100644
--- a/lib/libmagic/config.h
+++ b/lib/libmagic/config.h
@@ -39,7 +39,11 @@
 #define HAVE_FSEEKO 1
 /* Define to 1 if you have the `getline' function. */
-#define HAVE_GETLINE 1
+#if (__FreeBSD_version >= 800000)
+#define	HAVE_GETLINE 1
+#define	HAVE_GETLINE 0
 /* Define to 1 if you have the <getopt.h> header file. */
 #define HAVE_GETOPT_H 1

More information about the freebsd-current mailing list