Skip to content

Commit

Permalink
alex: Bugfix
Browse files Browse the repository at this point in the history
* Addresses broken datadir issue: haskell/cabal#3586
  • Loading branch information
essandess authored and mascguy committed Sep 19, 2022
1 parent c9e6cd2 commit 18d8dd3
Showing 1 changed file with 53 additions and 35 deletions.
88 changes: 53 additions & 35 deletions devel/alex/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ PortSystem 1.0

name alex
version 3.2.7.1
revision 0
revision 1
categories devel haskell
maintainers nomaintainer
license GPL-3
Expand All @@ -25,54 +25,49 @@ checksums rmd160 5c47367e676b092e441890c959843561393789ad \
sha256 9bd2f1a27e8f1b2ffdb5b2fbd3ed82b6f0e85191459a1b24ffcbef4e68a81bec \
size 108229

# relative paths to ${prefix}
set alex_datadir share/${name}

set build_store_root {}
set build_store_dirname {}
set build_alex_datadir {}

# Fix for cabal data-files hardcoded path in binary
# See:
# https://github.com/commercialhaskell/stack/issues/848
# https://github.com/commercialhaskell/stack/issues/4857
# https://github.com/haskell/cabal/issues/462
# https://github.com/haskell/cabal/issues/3586
post-extract {
xinstall -m 0644 -W ${worksrcpath} \
${filespath}/Paths_NAME.hs ./src/Paths_${name}.hs

reinplace "s|@PREFIX@|${prefix}|g" \
${worksrcpath}/src/Paths_${name}.hs
reinplace "s|@NAME@|${name}|g" \
${worksrcpath}/src/Paths_${name}.hs
reinplace -E "s|(Version\[\[:space:\]\]+)\\\[\[\[:digit:\]\]+(,\[\[:digit:\]\]+){1,4}\\\]|\\1\[[join [split ${version} .] ,]\]|" \
${worksrcpath}/src/Paths_${name}.hs
}

variant stack \
description {Use stack to build.} {}

if { [variant_isset "stack"] } {
PortGroup haskell_stack 1.0

# relative paths to ${prefix}
set alex_datadir share/${name}

post-extract {
if {[geteuid] == 0} {
xinstall -o ${macportsuser} -d \
"[option haskell_stack.stack_root]" \
${destroot}${prefix}/${alex_datadir}
"[option haskell_stack.stack_root]"
} else {
xinstall -d \
"[option haskell_stack.stack_root]" \
${destroot}${prefix}/${alex_datadir}
"[option haskell_stack.stack_root]"
}

# Fix for cabal data-files hardcoded path in binary
# See:
# https://github.com/commercialhaskell/stack/issues/848
# https://github.com/commercialhaskell/stack/issues/4857
# https://github.com/haskell/cabal/issues/462
# https://github.com/haskell/cabal/issues/3586
xinstall -m 0644 -W ${worksrcpath} \
${filespath}/Paths_NAME.hs ./src/Paths_${name}.hs

reinplace "s|@PREFIX@|${prefix}|g" \
${worksrcpath}/src/Paths_${name}.hs
reinplace "s|@NAME@|${name}|g" \
${worksrcpath}/src/Paths_${name}.hs
reinplace -E "s|(Version\[\[:space:\]\]+)\\\[\[\[:digit:\]\]+(,\[\[:digit:\]\]+){1,4}\\\]|\\1\[[join [split ${version} .] ,]\]|" \
${worksrcpath}/src/Paths_${name}.hs
}

post-destroot {
# install cabal data-files
fs-traverse f ${worksrcpath}/.stack-work {
if { [file isdirectory ${f}]
&& [file tail ${f}] eq "${name}-${version}" } {
set stack_alex_datadir ${f}
xinstall -m 0644 {*}[glob ${stack_alex_datadir}/*] \
${destroot}${prefix}/${alex_datadir}
}
}
}
set build_store_root ${worksrcpath}/.stack-work
set build_store_dirname "${name}-${version}"
} else {
PortGroup haskell_cabal 1.0

Expand All @@ -84,4 +79,27 @@ if { [variant_isset "stack"] } {
}
default_variants-append \
+haskell_cabal_use_prebuilt

set build_store_root ${haskell_cabal.cabal_root}/store
set build_store_dirname share
}

post-destroot {
if {[geteuid] == 0} {
xinstall -o ${macportsuser} -d \
${destroot}${prefix}/${alex_datadir}
} else {
xinstall -d ${destroot}${prefix}/${alex_datadir}
}

# find cabal data-files
fs-traverse f ${build_store_root} {
if { [file isdirectory ${f}]
&& [file tail ${f}] eq ${build_store_dirname}} {
set build_alex_datadir ${f}
break
}
}
xinstall -m 0644 {*}[glob ${build_alex_datadir}/*.hs] \
${destroot}${prefix}/${alex_datadir}
}

0 comments on commit 18d8dd3

Please sign in to comment.