Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Mar 2016 11:21:29 +0000 (UTC)
From:      Tijl Coosemans <tijl@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r411553 - in head/print/hplip-plugin: . files
Message-ID:  <201603211121.u2LBLTar040161@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tijl
Date: Mon Mar 21 11:21:28 2016
New Revision: 411553
URL: https://svnweb.freebsd.org/changeset/ports/411553

Log:
  - These binary plugins are compiled for Linux and some require glibc
    functions that our libc does not provide so they fail to load.  Implement
    the glibc functions in a wrapper library for each plugin.
  - Do all of the building and installing from do-build and do-install.  The
    upstream install scripts require too many hacks to stay inside the work
    directory.
  - Add LICENSE information.
  
  PR:		208142
  Tested by:	avg

Added:
  head/print/hplip-plugin/files/wrap.c   (contents, props changed)
Deleted:
  head/print/hplip-plugin/files/patch-installPlugin.py
  head/print/hplip-plugin/files/patch-plugin_install.py
Modified:
  head/print/hplip-plugin/Makefile
  head/print/hplip-plugin/pkg-descr
  head/print/hplip-plugin/pkg-plist

Modified: head/print/hplip-plugin/Makefile
==============================================================================
--- head/print/hplip-plugin/Makefile	Mon Mar 21 11:17:40 2016	(r411552)
+++ head/print/hplip-plugin/Makefile	Mon Mar 21 11:21:28 2016	(r411553)
@@ -3,6 +3,7 @@
 
 PORTNAME=	hplip-plugin
 PORTVERSION=	3.16.2
+PORTREVISION=	1
 CATEGORIES=	print
 MASTER_SITES=	http://hplipopensource.com/hplip-web/plugin/
 DISTNAME=	hplip-${DISTVERSION}-plugin
@@ -11,18 +12,18 @@ EXTRACT_SUFX=	.run
 MAINTAINER=	makc@FreeBSD.org
 COMMENT=	Binary plugin for some HP Printers and All-in-One devices
 
+LICENSE=	HPLIP_PLUGIN
+LICENSE_NAME=	HPLIP Driver Plug-in License
+LICENSE_PERMS=	none
+LICENSE_FILE=	${WRKSRC}/license.txt
+
 RUN_DEPENDS=	hp-plugin:${PORTSDIR}/print/hplip
 
 RESTRICTED=	License agreement is required
 
-USES=		python
-NO_BUILD=	yes
-WRKSRC=		${WRKDIR}/plugin_tmp
-HPLIP_FAKEDIR=	${WRKDIR}/hplip_fakedir
-
-ONLY_FOR_ARCHS=	amd64 i386
+ONLY_FOR_ARCHS=	amd64 i386 # arm
 
-PLUGIN_LINKS=	fax/plugins/fax_marvell \
+PLUGINS=	fax/plugins/fax_marvell \
 		prnt/plugins/hbpl1 \
 		prnt/plugins/lj \
 		scan/plugins/bb_escl \
@@ -30,12 +31,6 @@ PLUGIN_LINKS=	fax/plugins/fax_marvell \
 		scan/plugins/bb_soap \
 		scan/plugins/bb_soapht
 
-PLUGIN_DIRS=	data/firmware \
-		data/plugins \
-		fax/plugins \
-		prnt/plugins \
-		scan/plugins
-
 PLIST_SUB+=	LINARCH="${LINARCH}"
 
 .include <bsd.port.pre.mk>
@@ -47,36 +42,33 @@ LINARCH=	x86_64
 .endif
 
 do-extract:
-	@${MKDIR} ${WRKDIR}
-	@(cd ${WRKDIR} && ${SH} ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX} \
-		--keep --noexec --nox11)
-
-post-patch:
-	@${REINPLACE_CMD} -e 's|ok, ans = tui.enter_yes_no.*|ok, ans = 1, 1|' \
-		-e 's|/etc/hp|${HPLIP_FAKEDIR}|' \
-		${WRKSRC}/plugin_install.py \
-		${WRKSRC}/installPlugin.py
+	@${SH} ${DISTDIR}/${DISTNAME}${EXTRACT_SUFX} \
+		--keep --noexec --nox11 --target ${WRKSRC}
+
+do-build:
+	${CC} ${CFLAGS} -Wall -fPIC -c ${FILESDIR}/wrap.c -o ${WRKSRC}/wrap.o
+.for p in ${PLUGINS}
+	(cd ${WRKSRC} && ${BRANDELF} -t FreeBSD ${p:T}-${LINARCH}.so && \
+		${CC} ${CFLAGS} ${LDFLAGS} -shared -fPIC -o ${p:T}.so wrap.o \
+		${p:T}-${LINARCH}.so -Wl,-rpath,${PREFIX}/share/hplip/${p:H})
+.endfor
 
 do-install:
-# fake hplip installation
-	${MKDIR} ${HPLIP_FAKEDIR}
-	${SED} -e 's,${LOCALBASE}/share/hplip,${HPLIP_FAKEDIR},' \
-		${LOCALBASE}/etc/hp/hplip.conf > ${HPLIP_FAKEDIR}/hplip.conf
-	${MKDIR} ${HPLIP_FAKEDIR}
-	${LN} -sf ${LOCALBASE}/share/hplip/base ${HPLIP_FAKEDIR}
-	${LN} -sf ${LOCALBASE}/share/hplip/prnt ${HPLIP_FAKEDIR}
-	${CP} -R ${LOCALBASE}/share/hplip/installer ${HPLIP_FAKEDIR}
-	${REINPLACE_CMD} -e 's,HOMEDIR = .*,HOMEDIR = "${STAGEDIR}${PREFIX}/share/hplip",' \
-		-e 's,/var/lib/hp/hplip.state,${STAGEDIR}&,' \
-		${HPLIP_FAKEDIR}/installer/pluginhandler.py \
-		${HPLIP_FAKEDIR}/installer/core_install.py
-	${MKDIR} ${STAGEDIR}/var/lib/hp
-# install hplip-plugin
-	${MKDIR} ${PLUGIN_DIRS:S,^,${STAGEDIR}${PREFIX}/share/hplip/,}
-	(cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} -B \
-		plugin_install.py -i)
-.for i in ${PLUGIN_LINKS}
-	${LN} -sf ${i:T}-${LINARCH}.so ${STAGEDIR}${PREFIX}/share/hplip/${i}.so
+	${MKDIR} ${STAGEDIR}${PREFIX}/share/hplip/data/firmware
+	${INSTALL_DATA} ${WRKSRC}/*.fw.gz \
+		${STAGEDIR}${PREFIX}/share/hplip/data/firmware
+	${MKDIR} ${PLUGINS:H:S,^,${STAGEDIR}${PREFIX}/share/hplip/,}
+.for p in ${PLUGINS}
+	${INSTALL_LIB} ${WRKSRC}/${p:T}-${LINARCH}.so \
+		${STAGEDIR}${PREFIX}/share/hplip/${p}-${LINARCH}.so
+	${INSTALL_LIB} ${WRKSRC}/${p:T}.so \
+		${STAGEDIR}${PREFIX}/share/hplip/${p}.so
 .endfor
+	${INSTALL_DATA} ${WRKSRC}/plugin.spec ${STAGEDIR}${PREFIX}/share/hplip
+	${MKDIR} ${STAGEDIR}/var/lib/hp
+	${ECHO_CMD} '[plugin]' > ${STAGEDIR}/var/lib/hp/hplip.state
+	${ECHO_CMD} 'installed = 1' >> ${STAGEDIR}/var/lib/hp/hplip.state
+	${ECHO_CMD} 'eula = 1' >> ${STAGEDIR}/var/lib/hp/hplip.state
+	${ECHO_CMD} 'version = ${PORTVERSION}' >> ${STAGEDIR}/var/lib/hp/hplip.state
 
 .include <bsd.port.post.mk>

Added: head/print/hplip-plugin/files/wrap.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/print/hplip-plugin/files/wrap.c	Mon Mar 21 11:21:28 2016	(r411553)
@@ -0,0 +1,73 @@
+/* $FreeBSD$ */
+
+/* dummy implementation of glibc functions needed by plugins */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+
+void
+__assert_fail( const char *msg, const char *file, unsigned int line,
+	       const char *func ) {
+	fprintf( stderr, "Assertion failed: (%s), function %s, file %s, line %u\n",
+		 msg, func, file, line );
+	abort();
+}
+
+int
+__fprintf_chk( FILE *fp, int flag, char const *format, ... ) {
+	va_list ap;
+	int res;
+
+	va_start( ap, format );
+	res = vfprintf( fp, format, ap );
+	va_end( ap );
+	return( res );
+}
+
+int
+__printf_chk( int flag, char const *format, ... ) {
+	va_list ap;
+	int res;
+
+	va_start( ap, format );
+	res = vprintf( format, ap );
+	va_end( ap );
+	return( res );
+}
+
+int
+__snprintf_chk( char *s, size_t maxlen, int flag, size_t slen,
+		char const *format, ... ) {
+	va_list ap;
+	int res;
+
+	va_start( ap, format );
+	res = vsnprintf( s, maxlen, format, ap );
+	va_end( ap );
+	return( res );
+}
+
+char *
+__strcpy_chk( char *dest, char const *src, size_t destlen ) {
+	return( strcpy( dest, src ));
+}
+
+void
+__syslog_chk( int priority, int flag, char const *format, ... ) {
+	va_list ap;
+
+	va_start( ap, format );
+	vsyslog( priority, format, ap );
+	va_end( ap );
+}
+
+#undef stderr
+FILE *stderr;
+
+static __attribute__(( constructor )) void
+init_stderr( void ) {
+	stderr = __stderrp;
+}

Modified: head/print/hplip-plugin/pkg-descr
==============================================================================
--- head/print/hplip-plugin/pkg-descr	Mon Mar 21 11:17:40 2016	(r411552)
+++ head/print/hplip-plugin/pkg-descr	Mon Mar 21 11:21:28 2016	(r411553)
@@ -1,3 +1,3 @@
-Firmware and binary drivers from some HPLIP supported printers.
+Firmware and binary drivers for some HPLIP supported printers.
 
-WWW: http://hplipopensource.com/hplip-web/index.html
+WWW: http://hplipopensource.com/

Modified: head/print/hplip-plugin/pkg-plist
==============================================================================
--- head/print/hplip-plugin/pkg-plist	Mon Mar 21 11:17:40 2016	(r411552)
+++ head/print/hplip-plugin/pkg-plist	Mon Mar 21 11:21:28 2016	(r411553)
@@ -11,7 +11,6 @@ share/hplip/data/firmware/hp_laserjet_p1
 share/hplip/data/firmware/hp_laserjet_professional_p1102.fw.gz
 share/hplip/data/firmware/hp_laserjet_professional_p1102w.fw.gz
 share/hplip/data/firmware/hp_laserjet_professional_p1566.fw.gz
-share/hplip/data/plugins/license.txt
 share/hplip/fax/plugins/fax_marvell-%%LINARCH%%.so
 share/hplip/fax/plugins/fax_marvell.so
 share/hplip/plugin.spec



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201603211121.u2LBLTar040161>