tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Ocaml pkginstall fragment



On Thursday 17 March 2016 16:35:09 Thomas Klausner wrote:
> On Thu, Mar 17, 2016 at 03:31:15PM +0000, Jaap Boender wrote:
> > Okay, I've now got a working pkginstall fragment that registers and
> > deregisters ocaml libraries (thanks, wiz...)
> > 
> > What would be the best way of getting this out for testing? I can just
> > commit the work - it shouldn't affect any other packages, but then again
> > that's not something I'm willing to bet anything too valuable on...
> 
> Show us the diff :-)

It's mostly cribbed from install-info, so I may not have done things in the 
most efficient way. Anyway, here you are - one cvs diff, one file to go in 
mk/pkginstall/ocaml-findlib-register.

best,

  Jaap
Index: mk/ocaml.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/ocaml.mk,v
retrieving revision 1.6
diff -r1.6 ocaml.mk
16a17,20
> # OCAML_FINDLIB_DIRS
> # directories under OCAML_SITELIBDIR that this package installs into
> # OCAML_FINDLIB_REGISTER
> # register findlib directories into OCaml ld.conf
106a111,112
> OCAML_FINDLIB_DIRS?=	${OCAML_SITELIBDIR}/${PKGBASE}
> OCAML_FINDLIB_REGISTER?=	yes
Index: mk/pkginstall/bsd.pkginstall.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/bsd.pkginstall.mk,v
retrieving revision 1.64
diff -r1.64 bsd.pkginstall.mk
21a22
> 	OCAML_FINDLIB_REGISTER_VERBOSE \
788a790,809
> # OCAML_FINDLIB_REGISTER
> _INSTALL_OFR_FILE=	${_PKGINSTALL_DIR}/ocaml-findlib-register
> _INSTALL_UNPACK_TMPL+=		${_INSTALL_OFR_FILE}
> 
> ${_INSTALL_OFR_FILE}: ../../mk/pkginstall/ocaml-findlib-register
> .if defined(OCAML_FINDLIB_REGISTER)
> 	${RUN}${MKDIR} ${.TARGET:H}
> 	${RUN}${SED} ${FILES_SUBST_SED} \
> 		../../mk/pkginstall/ocaml-findlib-register > ${.TARGET}
> .endif
> 
> .PHONY: install-script-data-ocaml-findlib-register
> install-script-data: install-script-data-ocaml-findlib-register
> install-script-data-ocaml-findlib-register:
> .if defined(OCAML_FINDLIB_REGISTER)
> 		cd ${PKG_DB_TMPDIR} && ${PKGSRC_SETENV} ${INSTALL_SCRIPTS_ENV} \
> 		${_PKG_DEBUG_SCRIPT} ${INSTALL_FILE} ${PKGNAME} \
> 			UNPACK +OCAML_FINDLIB_REGISTER
> .endif
> 
986a1008
> OCAML_FINDLIB_REGISTER_VERBOSE?=	YES
989a1012
> OCAML_FINDLIB_REGISTER_VERBOSE?=	NO
1004a1028
> FILES_SUBST+=		OCAML_FINDLIB_REGISTER_VERBOSE=${OCAML_FINDLIB_REGISTER_VERBOSE:Q}
1034a1059
> FILES_SUBST+=		OCAML_FINDLIB_DIRS=${OCAML_FINDLIB_DIRS:Q}
Index: mk/pkginstall/deinstall
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/deinstall,v
retrieving revision 1.3
diff -r1.3 deinstall
4a5,10
>   #
>   # Unregister package from ocaml-findlib.
>   #
>   ${TEST} ! -x ./+OCAML_FINDLIB_REGISTER ||
>     ./+OCAML_FINDLIB_REGISTER REMOVE ${OCAML_FINDLIB_DIR}
> 
Index: mk/pkginstall/install
===================================================================
RCS file: /cvsroot/pkgsrc/mk/pkginstall/install,v
retrieving revision 1.3
diff -r1.3 install
72a73,78
> 
>   #
>   # Register package into ocaml-findlib.
>   #
>   ${TEST} ! -x ./+OCAML_FINDLIB_REGISTER ||
>     ./+OCAML_FINDLIB_REGISTER ADD ${PKG_METADATA_DIR}
# $NetBSD: info-files,v 1.4 2007/07/12 19:41:46 jlam Exp $
#
# Generate an +OCAML_FINDLIB_REGISTER script that handles registration for
# findlib after a binary installation
#
case "${STAGE},$1" in
UNPACK,|UNPACK,+OCAML_FINDLIB_REGISTER)
	${CAT} > ./+OCAML_FINDLIB_REGISTER << 'EOF'
#!@SH@
#
# +OCAML_FINDLIB_REGISTER - ocaml-findlib registration script
#
# Usage: ./+OCAML_FINDLIB_REGISTER ADD|REMOVE [findlib_pkg_dir]
#
# This script supports two actions, ADD and REMOVE, that will
# <do something cool>
#
ECHO="@ECHO@"
GREP="@GREP@"
MV="@MV@"
OCAML_FINDLIB_DIRS="@OCAML_FINDLIB_DIRS@"
PWD_CMD="@PWD_CMD@"
RM="@RM@"
TOUCH="@TOUCH@"

SELF=$0
ACTION=$1

LDCONF="@PREFIX@/lib/ocaml/ld.conf"

CURDIR=`${PWD_CMD}`
PKG_METADATA_DIR="${2-${CURDIR}}"
: ${PKGNAME=${PKG_METADATA_DIR##*/}}
: ${PKG_PREFIX=@PREFIX@}

case "${OCAML_FINDLIB_REGISTER_VERBOSE:-@OCAML_FINDLIB_REGISTER_VERBOSE@}" in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
	echo="${ECHO}"
	;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
	echo=":"
	;;
esac

${TOUCH} ${LDCONF}.tmp
for i in ${OCAML_FINDLIB_DIRS}
do
  ${GREP} -F -v -- "$i" < "${LDCONF}" >> "${LDCONF}.tmp"
  case $ACTION in
  ADD)
    $echo "${PKGNAME}: adding $i to ${LDCONF}"
    ${ECHO} "@PREFIX@/$i" >> "${LDCONF}.tmp"
	;;

  REMOVE)
    $echo "${PKGNAME}: removing $i from ${LDCONF}"
	;;
  esac
done
${MV} -f "${LDCONF}.tmp" "${LDCONF}"

EOF
	${CHMOD} +x ./+OCAML_FINDLIB_REGISTER
	;;
esac



Home | Main Index | Thread Index | Old Index