Hi Greg,

On Mon, Feb 22, 2021 at 08:26:43PM -0800, Greg Steuck wrote:
> Happily I can gradually work haskell ports over to the new infra without
> upgrading lang/ghc and then destroying and recreating the world.  Maybe
> it would've been less work total to do a big bang, but hopefully this is
> easier to swallow in little bits. Any rollback is less of a pain should
> it have to happen.
> 
> As a reminder, the eventual goal is to move every haskell binary port
> over to cabal.port.mk and thus deconstrain future upgrades of the ports
> and lang/ghc.

This looks good, at the moment I'm test-building happy (will take
some hours, because some dependency of ghc had been updated, so my
machine is rebuilding it, too).


However, I'm not sure wether devel/cabal is the right place for
cabal.port.mk. Shouldn't modules-only files to be put into
infrastructure/mk?

What do other ports people think?

Ciao,
        Kili

> >From 79f9ac90d524e4df33191fd73e09487cb7711a96 Mon Sep 17 00:00:00 2001
> From: Greg Steuck <g...@nest.cx>
> Date: Sun, 13 Sep 2020 17:04:03 -0700
> Subject: [PATCH 1/2] Add cabal.port.mk to more easily build haskell ports
> 
> Corrections by James Cook <falsif...@falsifian.org>
> ---
>  devel/cabal/cabal.port.mk | 155 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 155 insertions(+)
>  create mode 100644 devel/cabal/cabal.port.mk
> 
> diff --git a/devel/cabal/cabal.port.mk b/devel/cabal/cabal.port.mk
> new file mode 100644
> index 00000000000..7def1866116
> --- /dev/null
> +++ b/devel/cabal/cabal.port.mk
> @@ -0,0 +1,155 @@
> +# $OpenBSD$
> +
> +# Module for building Haskell programs with cabal-install.
> +# Inspired by FreeBSD cabal.mk by Gleb Popov.
> +
> +# Input variables:
> +#
> +#  MODCABAL_STEM - the name of the package on hackage.
> +#  MODCABAL_VERSION  - the version of the package.
> +#  MODCABAL_MANIFEST - hackage dependencies required by this package, triples
> +#    of space separate <package> <version> <revision>. Typically generated
> +#    with cabal-bundler program from cabal-extras, e.g.
> +#    cabal-bundler --openbsd darcs-2.16.2
> +#  MODCABAL_DATA_DIR - data-dir from .cabal file (if the port needs the data)
> +#    
> https://cabal.readthedocs.io/en/latest/cabal-package.html#pkg-field-data-dir
> +#  MODCABAL_REVISION - Numeric revision of .cabal file on hackage if one is
> +#    needed on top of .cabal file contained in the .tar.gz file.
> +#  MODCABAL_BUILD_ARGS - passed to cabal v2-build, e.g. make 
> MODCABAL_BUILD_ARGS=-v
> +#    is a nice debugging aid.
> +#  MODCABAL_FLAGS - passed to --flags= of cabal v2-build. Seemingly 
> superfluous given
> +#    MODCABAL_BUILD_ARGS, but it is useful to keep this value separate as it
> +#    is used to generate the build plan and will be available without 
> parsing.
> +#  MODCABAL_EXECUTABLES - Executable target in .cabal file, by default uses
> +#    the hackage package name.
> +#    https://cabal.readthedocs.io/en/latest/cabal-package.html#executables
> +#
> +# Available output variables:
> +#
> +#  MODCABAL_BUILT_EXECUTABLE_${_exe} is built for each of 
> MODCABAL_EXECUTABLES.
> +#    These are available for `make test` after `make build` phase.
> +#
> +# Special files:
> +#   files/cabal.project is used automatically.
> +
> +ONLY_FOR_ARCHS =     i386 amd64
> +
> +BUILD_DEPENDS +=     devel/cabal-install>=3.4.0.0 \
> +                     lang/ghc>=8.6.4
> +
> +# Takes over :9 site for hackage. The day when we have a port using
> +# both Go/Rust and Hackage we'll have to resolve their common
> +# insistance on grabbing :9.
> +MASTER_SITES9 =              https://hackage.haskell.org/package/
> +
> +DIST_SUBDIR ?=               hackage
> +
> +# The .cabal files are explicitly copied over the ones extracted from
> +# archives by the normal extraction rules.
> +EXTRACT_CASES += *.cabal) ;;
> +
> +DISTNAME ?=          ${MODCABAL_STEM}-${MODCABAL_VERSION}
> +HOMEPAGE ?=          ${MASTER_SITES9}${MODCABAL_STEM}
> +MASTER_SITES ?=              ${MASTER_SITES9}${DISTNAME}/
> +DISTFILES ?=         ${DISTNAME}.tar.gz
> +SUBST_VARS +=                MODCABAL_STEM MODCABAL_VERSION PKGNAME
> +
> +# Oftentime our port name and the executable name coincide.
> +MODCABAL_EXECUTABLES ?=      ${MODCABAL_STEM}
> +
> +# Cabal won't download anything from hackage if config file exists.
> +MODCABAL_post-extract = \
> +     mkdir -p ${WRKDIR}/.cabal \
> +     && touch ${WRKDIR}/.cabal/config
> +
> +# Some packages need an updated .cabal file from hackage to overwrite
> +# the one in the tar ball.
> +.if defined(MODCABAL_REVISION)
> +DISTFILES += 
> ${DISTNAME}_${MODCABAL_REVISION}{revision/${MODCABAL_REVISION}}.cabal
> +MODCABAL_post-extract += \
> +     && cp ${FULLDISTDIR}/${DISTNAME}_${MODCABAL_REVISION}.cabal \
> +             ${WRKSRC}/${MODCABAL_STEM}.cabal
> +.endif
> +
> +# The dependent sources get downloaded from hackage.
> +.for _package _version _revision in ${MODCABAL_MANIFEST}
> +DISTFILES += {${_package}-${_version}/}${_package}-${_version}.tar.gz:9
> +.  if ${_revision} > 0
> +DISTFILES += 
> ${_package}-${_version}_${_revision}{${_package}-${_version}/revision/${_revision}}.cabal:9
> +MODCABAL_post-extract += \
> +     && cp ${FULLDISTDIR}/${_package}-${_version}_${_revision}.cabal \
> +             ${WRKDIR}/${_package}-${_version}/${_package}.cabal
> +.  endif
> +# References all the locally available dependencies.  Ideally these
> +# should be command line options, tracking issue:
> +# https://github.com/haskell/cabal/issues/3585
> +MODCABAL_post-extract += \
> +     && echo "packages: ${WRKDIR}/${_package}-${_version}/${_package}.cabal" 
> >> ${WRKSRC}/cabal.project.local
> +.endfor  # MODCABAL_MANIFEST
> +
> +# Automatically copies the cabal.project file if any.
> +MODCABAL_post-extract += \
> +     && (test -f ${FILESDIR}/cabal.project \
> +         && cp -v ${FILESDIR}/cabal.project ${WRKSRC}; true)
> +
> +# Invokes cabal with HOME set up to use .cabal directory created in
> +# post-extract.
> +_MODCABAL_CABAL = ${SETENV} ${MAKE_ENV} HOME=${WRKDIR} ${LOCALBASE}/bin/cabal
> +
> +# Building a cabal package is merely an invocation of cabal v2-build.
> +_MODCABAL_BUILD_TARGET = \
> +     cd ${WRKBUILD} \
> +     && ${_MODCABAL_CABAL} v2-build --offline --disable-benchmarks 
> --disable-tests \
> +             -w ${LOCALBASE}/bin/ghc \
> +             -j${MAKE_JOBS} \
> +             --flags="${MODCABAL_FLAGS}" ${MODCABAL_BUILD_ARGS} \
> +             ${MODCABAL_EXECUTABLES:C/^/exe:&/}
> +
> +# Install fragment starts this way for uniformity of incremental 
> construction.
> +_MODCABAL_INSTALL_TARGET = true
> +
> +# Prepares wrapping fragments that only need to be set up once and
> +# reused across potentially multiple installed executables.
> +.if defined(MODCABAL_DATA_DIR)
> +_MODCABAL_LIBEXEC = libexec/cabal
> +_MODCABAL_INSTALL_TARGET += \
> +     && mkdir -p ${PREFIX}/${_MODCABAL_LIBEXEC}
> +
> +_MODCABAL_INSTALL_TARGET +=  \
> +     && ${INSTALL_DATA_DIR} ${WRKSRC}/${MODCABAL_DATA_DIR} 
> ${PREFIX}/share/${DISTNAME} \
> +     && cd ${WRKSRC}/${MODCABAL_DATA_DIR} && umask 022 && pax -rw . 
> ${PREFIX}/share/${DISTNAME}
> +.endif
> +
> +# Appends installation fragments for each executable.
> +.for _exe in ${MODCABAL_EXECUTABLES}
> +# Exports the path to the executable for testing. The location is
> +# somewhat hard to predict in advance, thus it is determined at runtime.
> +MODCABAL_BUILT_EXECUTABLE_${_exe} = $$(find ${WRKSRC}/dist-newstyle -name 
> ${_exe} -type f -perm -a+x)
> +.  if defined(MODCABAL_DATA_DIR)
> +# Installs the ELF binary into an auxiliary location and wraps it into
> +# a script which sets up the environment to point at the data-dir
> +# files if any.
> +_MODCABAL_INSTALL_TARGET += \
> +     && ${INSTALL_PROGRAM} \
> +             ${MODCABAL_BUILT_EXECUTABLE_${_exe}} \
> +             ${PREFIX}/${_MODCABAL_LIBEXEC}/${_exe} \
> +     && echo '\#!/bin/sh' > ${PREFIX}/bin/${_exe} \
> +     && echo 'export ${_exe}_datadir=${LOCALBASE}/share/${DISTNAME}' >> 
> ${PREFIX}/bin/${_exe} \
> +     && echo 'exec ${LOCALBASE}/${_MODCABAL_LIBEXEC}/${_exe} "$$@"' >> 
> ${PREFIX}/bin/${_exe} \
> +     && chmod +x ${STAGEDIR}${PREFIX}/bin/${_exe}
> +.  else
> +# Skips the launcher script indirection when MODCABAL_DATA_DIR is empty.
> +_MODCABAL_INSTALL_TARGET += \
> +     && ${INSTALL_PROGRAM} ${MODCABAL_BUILT_EXECUTABLE_${_exe}} ${PREFIX}/bin
> +.  endif
> +.endfor
> +
> +.if !target(do-build)
> +do-build:
> +     @${_MODCABAL_BUILD_TARGET}
> +.endif
> +
> +.if !target(do-install)
> +do-install:
> +     @${_MODCABAL_INSTALL_TARGET}
> +.endif
> -- 
> 2.30.1
> 

> >From 135c51a1dbd54e93fc4c01073a410d6b992bab95 Mon Sep 17 00:00:00 2001
> From: Greg Steuck <g...@nest.cx>
> Date: Thu, 20 Aug 2020 11:54:08 -0700
> Subject: [PATCH 2/2] Use devel/cabal module for devel/happy (upgrade to 1.20)
> 
> Passes `make test` and produces a package good enough for ghc build.
> 
> This is the first package to rely on cabal.port.mk module.
> ---
>  devel/happy/Makefile  |  12 ++---
>  devel/happy/distinfo  |   4 +-
>  devel/happy/pkg/PLIST | 110 +++++++++++++++++++++---------------------
>  3 files changed, 64 insertions(+), 62 deletions(-)
> 
> diff --git a/devel/happy/Makefile b/devel/happy/Makefile
> index 341a5ba2d73..304db399a49 100644
> --- a/devel/happy/Makefile
> +++ b/devel/happy/Makefile
> @@ -2,9 +2,10 @@
>  
>  COMMENT=             parser generator for Haskell
>  
> -PORTROACH =          ignore:1
> +MODCABAL_STEM=               happy
> +MODCABAL_VERSION=    1.20.0
> +MODCABAL_DATA_DIR=   data
>  
> -DISTNAME=            happy-1.19.10
>  CATEGORIES=          devel
>  
>  HOMEPAGE=            http://www.haskell.org/happy/
> @@ -14,8 +15,7 @@ PERMIT_PACKAGE=     Yes
>  
>  WANTLIB=             c ffi gmp iconv m pthread
>  
> -MODULES=             lang/ghc
> -MODGHC_BUILD=                cabal hackage nort
> +MODULES=             devel/cabal
>  
>  LIB_DEPENDS=         converters/libiconv \
>                       devel/gmp \
> @@ -40,7 +40,7 @@ post-install:
>  
>  do-test:
>       @cd ${WRKBUILD}/tests && exec ${SETENV} ${MAKE_ENV} \
> -             ${MAKE_PROGRAM} HAPPY=${WRKBUILD}/dist/build/happy/happy \
> -             TEST_HAPPY_OPTS="-t ${WRKBUILD} --strict"
> +             ${MAKE_PROGRAM} -j${MAKE_JOBS} 
> HAPPY=${MODCABAL_BUILT_EXECUTABLE_happy} \
> +             TEST_HAPPY_OPTS="-t ${WRKBUILD}/data --strict"
>  
>  .include <bsd.port.mk>
> diff --git a/devel/happy/distinfo b/devel/happy/distinfo
> index 0e2838f9490..bb548e6c50c 100644
> --- a/devel/happy/distinfo
> +++ b/devel/happy/distinfo
> @@ -1,2 +1,2 @@
> -SHA256 (ghc/happy-1.19.10.tar.gz) = 
> IutgbJcQWzluHH3CfhIMoCAlqH8+RNLqUr5qZTpSyu0=
> -SIZE (ghc/happy-1.19.10.tar.gz) = 181506
> +SHA256 (hackage/happy-1.20.0.tar.gz) = 
> Ox06j5OicjtVTZ8Hss0Ta+GnsvyrGFWxK3qrXLrIhow=
> +SIZE (hackage/happy-1.20.0.tar.gz) = 184515
> diff --git a/devel/happy/pkg/PLIST b/devel/happy/pkg/PLIST
> index c6e8375e5f6..c4ade99b79c 100644
> --- a/devel/happy/pkg/PLIST
> +++ b/devel/happy/pkg/PLIST
> @@ -1,55 +1,57 @@
>  @comment $OpenBSD: PLIST,v 1.7 2020/05/15 21:50:24 kili Exp $
> -@bin bin/happy
> -share/doc/happy/
> -@comment share/doc/${DISTNAME}/
> -@comment share/doc/${DISTNAME}/LICENSE
> -share/doc/happy/fptools.css
> -share/doc/happy/happy-introduction.html
> -share/doc/happy/index.html
> -share/doc/happy/ix01.html
> -share/doc/happy/sec-AtrributeGrammarsInHappy.html
> -share/doc/happy/sec-AttrGrammarLimits.html
> -share/doc/happy/sec-AttributeGrammar.html
> -share/doc/happy/sec-AttributeGrammarExample.html
> -share/doc/happy/sec-Precedences.html
> -share/doc/happy/sec-compilation-time.html
> -share/doc/happy/sec-conflict-tips.html
> -share/doc/happy/sec-directives.html
> -share/doc/happy/sec-error.html
> -share/doc/happy/sec-finding-errors.html
> -share/doc/happy/sec-glr-misc.html
> -share/doc/happy/sec-glr-semantics.html
> -share/doc/happy/sec-glr-using.html
> -share/doc/happy/sec-glr.html
> -share/doc/happy/sec-grammar-files.html
> -share/doc/happy/sec-grammar.html
> -share/doc/happy/sec-happy-ghci.html
> -share/doc/happy/sec-info-files-conflicts.html
> -share/doc/happy/sec-info-files.html
> -share/doc/happy/sec-invoking.html
> -share/doc/happy/sec-license.html
> -share/doc/happy/sec-module-header.html
> -share/doc/happy/sec-module-trailer.html
> -share/doc/happy/sec-monad-alex.html
> -share/doc/happy/sec-monads.html
> -share/doc/happy/sec-multiple-parsers.html
> -share/doc/happy/sec-obtaining.html
> -share/doc/happy/sec-reporting-bugs.html
> -share/doc/happy/sec-sequences.html
> -share/doc/happy/sec-tips.html
> -share/doc/happy/sec-type-signatures.html
> -share/doc/happy/sec-using.html
> -share/${DISTNAME}/
> -share/${DISTNAME}/GLR_Base
> -share/${DISTNAME}/GLR_Lib
> -share/${DISTNAME}/GLR_Lib-ghc
> -share/${DISTNAME}/GLR_Lib-ghc-debug
> -share/${DISTNAME}/HappyTemplate
> -share/${DISTNAME}/HappyTemplate-arrays
> -share/${DISTNAME}/HappyTemplate-arrays-coerce
> -share/${DISTNAME}/HappyTemplate-arrays-coerce-debug
> -share/${DISTNAME}/HappyTemplate-arrays-debug
> -share/${DISTNAME}/HappyTemplate-arrays-ghc
> -share/${DISTNAME}/HappyTemplate-arrays-ghc-debug
> -share/${DISTNAME}/HappyTemplate-coerce
> -share/${DISTNAME}/HappyTemplate-ghc
> +bin/${MODCABAL_STEM}
> +libexec/cabal/
> +@bin libexec/cabal/${MODCABAL_STEM}
> +share/doc/${MODCABAL_STEM}/
> +@comment share/doc/${PKGNAME}/
> +@comment share/doc/${PKGNAME}/LICENSE
> +share/doc/${MODCABAL_STEM}/fptools.css
> +share/doc/${MODCABAL_STEM}/${MODCABAL_STEM}-introduction.html
> +share/doc/${MODCABAL_STEM}/index.html
> +share/doc/${MODCABAL_STEM}/ix01.html
> +share/doc/${MODCABAL_STEM}/sec-AtrributeGrammarsInHappy.html
> +share/doc/${MODCABAL_STEM}/sec-AttrGrammarLimits.html
> +share/doc/${MODCABAL_STEM}/sec-AttributeGrammar.html
> +share/doc/${MODCABAL_STEM}/sec-AttributeGrammarExample.html
> +share/doc/${MODCABAL_STEM}/sec-Precedences.html
> +share/doc/${MODCABAL_STEM}/sec-compilation-time.html
> +share/doc/${MODCABAL_STEM}/sec-conflict-tips.html
> +share/doc/${MODCABAL_STEM}/sec-directives.html
> +share/doc/${MODCABAL_STEM}/sec-error.html
> +share/doc/${MODCABAL_STEM}/sec-finding-errors.html
> +share/doc/${MODCABAL_STEM}/sec-glr-misc.html
> +share/doc/${MODCABAL_STEM}/sec-glr-semantics.html
> +share/doc/${MODCABAL_STEM}/sec-glr-using.html
> +share/doc/${MODCABAL_STEM}/sec-glr.html
> +share/doc/${MODCABAL_STEM}/sec-grammar-files.html
> +share/doc/${MODCABAL_STEM}/sec-grammar.html
> +share/doc/${MODCABAL_STEM}/sec-${MODCABAL_STEM}-ghci.html
> +share/doc/${MODCABAL_STEM}/sec-info-files-conflicts.html
> +share/doc/${MODCABAL_STEM}/sec-info-files.html
> +share/doc/${MODCABAL_STEM}/sec-invoking.html
> +share/doc/${MODCABAL_STEM}/sec-license.html
> +share/doc/${MODCABAL_STEM}/sec-module-header.html
> +share/doc/${MODCABAL_STEM}/sec-module-trailer.html
> +share/doc/${MODCABAL_STEM}/sec-monad-alex.html
> +share/doc/${MODCABAL_STEM}/sec-monads.html
> +share/doc/${MODCABAL_STEM}/sec-multiple-parsers.html
> +share/doc/${MODCABAL_STEM}/sec-obtaining.html
> +share/doc/${MODCABAL_STEM}/sec-reporting-bugs.html
> +share/doc/${MODCABAL_STEM}/sec-sequences.html
> +share/doc/${MODCABAL_STEM}/sec-tips.html
> +share/doc/${MODCABAL_STEM}/sec-type-signatures.html
> +share/doc/${MODCABAL_STEM}/sec-using.html
> +share/${PKGNAME}/
> +share/${PKGNAME}/GLR_Base
> +share/${PKGNAME}/GLR_Lib
> +share/${PKGNAME}/GLR_Lib-ghc
> +share/${PKGNAME}/GLR_Lib-ghc-debug
> +share/${PKGNAME}/HappyTemplate
> +share/${PKGNAME}/HappyTemplate-arrays
> +share/${PKGNAME}/HappyTemplate-arrays-coerce
> +share/${PKGNAME}/HappyTemplate-arrays-coerce-debug
> +share/${PKGNAME}/HappyTemplate-arrays-debug
> +share/${PKGNAME}/HappyTemplate-arrays-ghc
> +share/${PKGNAME}/HappyTemplate-arrays-ghc-debug
> +share/${PKGNAME}/HappyTemplate-coerce
> +share/${PKGNAME}/HappyTemplate-ghc
> -- 
> 2.30.1
> 

Reply via email to