[FreeBSD] portsをmakeすると、/usr/ports/Mk/bsd.port.mkでMalformed conditionalエラーが発生する。

環境

この記事の内容は、FreeBSD 4.8-RELEASEで確認しました。

問題点

なんらかのportsをmakeすると、以下のエラーが発生します(はてなダイアリーの文法を回避するため、一部にスペースを挿入しています)。

/ports/Mk/bsd.port.mk", line 2424: warning: String comparison operator should be either == or !=
"/usr/ports/Mk/bsd.port.mk", line 2424: warning: String comparison operator should be either == or !=
"/usr/ports/Mk/bsd.port.mk", line 2424: Malformed conditional (((${OSVERSION} < 504105 || (${OSVERSION} >= 600000 && ${OSVERSION} < 600103) || (${OSVERSION} >= 700000 && ${OSVERSION} < 700012)) && ${PKGORIGIN} != "ports-mgmt/pkg_install") || exists(${LOCALBASE}/sbin/pkg_info))
"/usr/ports/Mk/bsd.port.mk", line 2425: warning: String comparison operator should be either == or !=
"/usr/ports/Mk/bsd.port.mk", line 2425: warning: String comparison operator should be either == or !=
"/usr/ports/Mk/bsd.port.mk", line 2425: Malformed conditional ( (${OSVERSION} < 504105 || (${OSVERSION} >= 600000 && ${OSVERSION} < 600103) || (${OSVERSION} >= 700000 && ${OSVERSION} < 700012)) && ${PKGORIGIN} != "ports-mgmt/pkg_install")
"/usr/ports/Mk/bsd.port.mk", line 2440: if-less else
"/usr/ports/Mk/bsd.port.mk", line 2440: Need an operator
"/usr/ports/Mk/bsd.port.mk", line 2454: if-less endif
"/usr/ports/Mk/bsd.port.mk", line 2454: Need an operator
"/usr/ports/Mk/bsd.port.mk", line 6386: if-less endif
"/usr/ports/Mk/bsd.port.mk", line 6386: Need an operator
make: fatal errors encountered -- cannot continue

解決方法

以下のパッチを適用します。

--- /usr/ports/Mk/bsd.port.mk.orig      Fri Jul 20 05:20:34 2007
+++ /usr/ports/Mk/bsd.port.mk   Fri Jul 20 05:30:44 2007
@@ -2421,8 +2421,8 @@
 PKGORIGIN?=            ${PKGCATEGORY}/${PORTDIRNAME}


-.if ((${OSVERSION} < 504105 || (${OSVERSION} >= 600000 && ${OSVERSION} < 600103) || (${OSVERSION} >= 700000 && ${OSVERSION} < 700012)) && ${PKGORIGIN} != "ports-mgmt/pkg_install") || exists(${LOCALBASE}/sbin/pkg_info)
-.if (${OSVERSION} < 504105 || (${OSVERSION} >= 600000 && ${OSVERSION} < 600103) || (${OSVERSION} >= 700000 && ${OSVERSION} < 700012)) && ${PKGORIGIN} != "ports-mgmt/pkg_install"
+.if ( ( ${OSVERSION} < 504105 || ( ${OSVERSION} >= 600000 && ${OSVERSION} < 600103 ) || ( ${OSVERSION} >= 700000 && ${OSVERSION} < 700012 ) ) && ${PKGORIGIN} != "ports-mgmt/pkg_install" ) || exists(${LOCALBASE}/sbin/pkg_info)
+.if ( ${OSVERSION} < 504105 || ( ${OSVERSION} >= 600000 && ${OSVERSION} < 600103 ) || ( ${OSVERSION} >= 700000 && ${OSVERSION} < 700012 ) ) && ${PKGORIGIN} != "ports-mgmt/pkg_install"
 EXTRACT_DEPENDS+=      ${LOCALBASE}/sbin/pkg_info:${PORTSDIR}/ports-mgmt/pkg_install
 .endif
 .if !defined(DESTDIR)