On 06/16/16 17:34, Aaron Poffenberger wrote: > On 06/15/16 07:46, Stuart Henderson wrote: >> On 2016/06/15 07:12, Aaron Poffenberger wrote: >>> You are right. cabal can install from a local path. Is it possible to >>> feed a bunch of files into the process by adding them to distinfo? >> >> Aha: if you can list the distfiles in DISTFILES and point cabal at them >> locally that should work. >> >> Fetching will be a little messy if the files are in separate subdirs >> as I think they are on hackage, but it can be handled by using the >> filename{url}sufx syntax in DISTFILES for them, e.g. >> {path/to/}filename-$V.tar.gz which would be somewhat similar to what >> devel/cargo is doing (peril-sensitive glasses advised before looking >> at the regexp there ;) >> >> You can use EXTRACT_ONLY to stop ports infra from trying to unpack >> them itself, and ${FULLDISTDIR} to get the path. >> > Hi Stuart, > Thanks to your suggestion and a pointer to the Java "maven" thread by > Ian Darwin, I've updated the patches to ghc.port.mk to include fetching > the cabal dependencies using DISTFILES. > > I tested building pandoc with networking disabled. It works. > > I forgot that cabal expects package repos to have a specific structure > and manifest describing the repo. I've implemented the necessary code to > build it. Any comments on improving that section would be welcome. > > I'm using symlinks between the tarballs in ${FULLDISTDIR} and the local > cabal repo (MODGHC_CABAL_REPO). > > The cabal sandbox is also a local directory (MODGHC_CABAL_SANDBOX) by > default. > > Of the two, MODGHC_CABAL_SANDBOX is a good candidate for sharing between > sandboxed builds. You could create a shared repo (MODGHC_CABAL_REPO) but > since it's just symlinks and a manifest there's not much value. > > N.B. to anyone who uses a shared MODGHC_CABAL_SANDBOX, read the comment > in ghc.port.mk for instructions on proper initialization. > > Attached are the revised patch and example port of pandoc for testing with. > > --Aaron >
Attached are the same files as before plus a patch for port-modules.5. I documented the *sandbox* build action and added a "Defines" section to document use of three variables that porters will need to know about to sandbox. I also moved the explanation of the two variables MODGHC_SETUP_CONF_ARGS and MODGHC_SETUP_CONF_ENV from what was the final paragraph into the "Defines" section for consistency. --Aaron
pandoc-1.17.1.tgz
Description: Binary data
Index: ghc.port.mk =================================================================== RCS file: /home/cvs/ports/lang/ghc/ghc.port.mk,v retrieving revision 1.38 diff -u -p -u -r1.38 ghc.port.mk --- ghc.port.mk 20 Jan 2016 16:08:29 -0000 1.38 +++ ghc.port.mk 16 Jun 2016 22:22:35 -0000 @@ -1,3 +1,4 @@ +#-*- mode: Makefile; tab-width: 4; -*- # $OpenBSD: ghc.port.mk,v 1.38 2016/01/20 16:08:29 kili Exp $ # Module for Glasgow Haskell Compiler @@ -55,7 +56,21 @@ DIST_SUBDIR ?= ghc . if ${MODGHC_BUILD:L:Mcabal} MODGHC_SETUP_SCRIPT ?= Setup.lhs Setup.hs +. if ${MODGHC_BUILD:L:Msandbox} +BUILD_DEPENDS += devel/cabal-install +# Set MODGHC_CABAL_SANDBOX to system-wide value to reuse packages +# across builds. Be sure to initialize it first. +# mkdir -p ${MODGHC_CABAL_SANDBOX} +# cd ${MODGHC_CABAL_SANDBOX} && cabal sandbox init --sandbox . +MODGHC_CABAL_PKGS ?= +MODGHC_CABAL_REPO ?= ${WRKSRC}/.local-repo +MODGHC_CABAL_SANDBOX ?= ${WRKSRC}/.cabal-sandbox +MODGHC_SETUP_PROG ?= ${LOCALBASE}/bin/cabal +MODGHC_REGISTER_PROG ?= ${WRKSRC}/Setup +. else MODGHC_SETUP_PROG ?= ${WRKSRC}/Setup +MODGHC_REGISTER_PROG ?= ${MODGHC_SETUP_PROG} +. endif MODGHC_SETUP_CONF_ARGS ?= MODGHC_SETUP_CONF_ENV ?= @@ -76,6 +91,56 @@ MODGHC_SETUP_CONF_ARGS += --docdir=\$$da # Little hack to let ports still add CONFIGURE_STYLE = autoconf and go # without a do-configure: target (some Haskell ports are built with # Cabal but use autohell for the documentation): +. if ${MODGHC_BUILD:L:Msandbox} +# Build a cabal repo from downloaded packages +. for _pkg in ${MODGHC_CABAL_PKGS} +_ver := ${_pkg:C,.*-([0-9.]*)$,\1,} +_name := ${_pkg:C,-[0-9.]*$,,} +_path := ${_ver}/${_name} +_tgz := ${_pkg}.tar.gz +MODGHC_CABAL_PATHS +:= ${_path} +MODGHC_CABAL_LINK_CMDS +:= "ln -sf ${FULLDISTDIR}/${_pkg}/${_tgz} ${_path}" +MODGHC_CABAL_EXTRACT_CMDS +:="tar xzf ${_path}/${_tgz} ${_pkg}/${_name}.cabal" +MODGHC_CABAL_MOVE_CMDS +:= "mv ${_pkg}/${_name}.cabal ${_path}" +MODGHC_CABAL_RMDIR_CMDS +:= "rmdir ${_pkg}" +. endfor + +MODCABAL_configure = \ + mkdir -p ${MODGHC_CABAL_REPO}/packages && \ + cd ${MODGHC_CABAL_REPO}/packages && \ + for s in ${MODGHC_CABAL_PATHS}; do \ + mkdir -p "$$s"; \ + done && \ + for s in ${MODGHC_CABAL_LINK_CMDS}; do \ + $$s; \ + done && \ + for s in ${MODGHC_CABAL_EXTRACT_CMDS}; do \ + $$s; \ + done && \ + for s in ${MODGHC_CABAL_MOVE_CMDS}; do \ + $$s; \ + done && \ + for s in ${MODGHC_CABAL_RMDIR_CMDS}; do \ + $$s; \ + done && \ + find . -type f -name '*.cabal' >> files && \ + tar -cf 00-index.tar -I files && \ + rm -f files && \ + cd ${WRKSRC} && \ + ${MODGHC_SETUP_PROG} sandbox init --sandbox=${MODGHC_CABAL_SANDBOX} && \ + echo "local-repo: ${MODGHC_CABAL_REPO}/packages" > cabal.config && \ + ${MODGHC_SETUP_PROG} install --only-dependencies ${MODGHC_SETUP_CONF_ARGS} && \ + for s in ${MODGHC_SETUP_SCRIPT}; do \ + test -f "$$s" && \ + ${MODGHC_BIN} --make \ + -o ${MODGHC_REGISTER_PROG} "$$s" && \ + break; \ + done && \ + cd ${WRKBUILD} && exec ${SETENV} ${MAKE_ENV} ${MODGHC_SETUP_CONF_ENV} \ + ${MODGHC_SETUP_PROG} \ + configure -v -g -O --prefix=${PREFIX} \ + ${MODGHC_SETUP_CONF_ARGS} +. else MODCABAL_configure = \ cd ${WRKSRC} && \ for s in ${MODGHC_SETUP_SCRIPT}; do \ @@ -88,6 +153,7 @@ MODCABAL_configure = \ ${MODGHC_SETUP_PROG} \ configure -v -g -O --prefix=${PREFIX} \ ${MODGHC_SETUP_CONF_ARGS} +. endif CONFIGURE_STYLE += CABAL @@ -102,9 +168,9 @@ MODGHC_BUILD_TARGET += \ . if ${MODGHC_BUILD:L:Mregister} MODGHC_BUILD_TARGET += \ ;cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} \ - ${MODGHC_SETUP_PROG} register --gen-script; \ + ${MODGHC_REGISTER_PROG} register --gen-script; \ cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} \ - ${MODGHC_SETUP_PROG} unregister --gen-script + ${MODGHC_REGISTER_PROG} unregister --gen-script . endif MODGHC_INSTALL_TARGET = \
Index: port-modules.5 =================================================================== RCS file: /home/cvs/src/share/man/man5/port-modules.5,v retrieving revision 1.206 diff -u -p -u -r1.206 port-modules.5 --- port-modules.5 18 May 2016 19:13:02 -0000 1.206 +++ port-modules.5 17 Jun 2016 02:54:26 -0000 @@ -809,7 +809,9 @@ generate API documentation using .It Ar register create and include register/unregister scripts, .It Ar hackage -the distfiles are available on Hackage. +the distfiles are available on Hackage, +.It Ar sandbox +build package dependencies in cabal sandbox. .El .Pp Also affects @@ -835,11 +837,50 @@ registered as a library usable by (if .Ar register has been set). -Extra arguments and environment additions for the Setup configure -command can be specified with -.Ev MODGHC_SETUP_CONF_ARGS -and -.Ev MODGHC_SETUP_CONF_ENV . +.Pp +.Bl -tag -width MODGHC_SETUP_CONF_ARGS +Defines: +.It Ev MODGHC_CABAL_PKGS +List of cabal packages to be added to +.Ev DISTFILES when using +.Ar sandbox +build action. +.Pp +Each package should be listed as name-version without suffix. +.Em E.g. , +.Pp +.Ev MODGHC_CABAL_PKGS = pandoc-1.17.1 +.Pp +Defaults to empty. +.It Ev MODGHC_CABAL_REPO +Path to local cabal repo when using +.Ar sandbox +build action. Defaults to +.Pa ${WRKSRC}/.local-repo +.It Ev MODGHC_CABAL_SANDBOX +Path to cabal sandbox when using +.Ar sandbox +build action. +.Pp +Set +.Ev MODGHC_CABAL_SANDBOX to a common location to share built packages +across ghc builds. +.Pp +Shared sandboxes must be manually initialiazed with the following steps: +.It +mkdir -p +.Ev ${MODGHC_CABAL_SANDBOX} +.It +cd +.Ev ${MODGHC_CABAL_SANDBOX} && cabal sandbox init --sandbox . +.Pp +Defaults to +.Pa ${WRKSRC}/.cabal-sandbox +.It Ev MODGHC_SETUP_CONF_ARGS +Extra configure arguments for Setup configure command. +.It Ev MODGHC_SETUP_CONF_ENV +Extra configure environemnt options for Setup configure command. +.El .It lang/go Adds Go toolchain support. Requires