New portfile writer looking for help with ConvertAll
Kevin Horton
kevin01 at kilohotel.com
Tue Jul 13 03:14:13 UTC 2021
> On Jul 12, 2021, at 6:48 PM, Kevin Horton <kevin01 at kilohotel.com> wrote:
>
>
>> On Jul 12, 2021, at 6:29 PM, Ryan Schmidt <ryandesign at macports.org <mailto:ryandesign at macports.org>> wrote:
>>
>> On Jul 12, 2021, at 20:13, Kevin Horton wrote:
>>
>>> I'm trying to create a port for ConvertAll - http://convertall.bellz.org <http://convertall.bellz.org/>. I've been using MacPorts for several years, but have never created a portfile before. I used Fink for many years before switching to MacPorts, and I was a maintainer for a handful of packages. I'm an enthusiastic amateur, not a coder.
>>>
>>> My attempts to get a ConvertAll portfile working are running into problems when MacPorts detects that the build process is trying to install files in /opt/local/share/convertall, and it fails with a permissions error. I'm baffled as to what is going on here.
>>>
>>> Current draft Portfile:
>>> # -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
>>>
>>> PortSystem 1.0
>>> PortGroup github 1.0
>>> PortGroup python 1.0
>>> PortGroup qt5 1.0
>>>
>>> github.setup doug-101 ConvertAll 0.8.0 v
>>> github.tarball_from releases
>>>
>>> python.versions 34 35 36 37 38 39
>>> python.default_version 38
>>>
>>> qt5.min_version 5.4
>>>
>>> name convertall
>>> version 0.8.0
>>> license GPL-2+
>>> categories math, science
>>
>> Remove the comma here.
>>
>>> platforms darwin
>>> maintainers {@khorton kilohotel.com <http://kilohotel.com/>:kevin01}
>>> description Extremely flexible unit converter
>>> long_description ConvertAll has a large database of units, and allows conversions \
>>> that use multiple units, e.g. convert from feet per decade to \
>>> nautical miles per fortnight.
>>> homepage http://convertall.bellz.org <http://convertall.bellz.org/>
>>>
>>> checksums rmd160 89fcc2aa9bad7ecc1de7bee4edea68fdff39706a \
>>> sha256 624c8a792b0bc7ff3776499c2c743b32273569efd0567615e570a7e739e8d521 \
>>> size 281055
>>>
>>> depends_lib-append port:py${python.version}-pyqt5
>>>
>>> use_configure no
>>> build.cmd ${python.bin} install.py
>>> build.args -p ${prefix} \
>>> -b ${destroot}
>>>
>>> post-patch {
>>> reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/install.py
>>> }
>>> ====================================
>>> Extract of build log showing failure:
>>
>> Looks like you just pasted the portfile again here. Can you show the failure log? I'm specifically interested in determining whether the failure is occurring in the build phase or in the destroot phase. If the latter, then it'll be because you only set build.cmd and build.args and didn't set destroot.cmd and destroot.args.
>>
>> Looks like you've set build.cmd and build.args reasonably for this build system, but MacPorts usually builds in the build phase and stages into the destroot in the destroot phase. If there is a way to tell this build system to do that, do so. In that case, you would probably need to set destroot.cmd and destroot.args too. If it is quite difficult to tell the build system to do that, then it is acceptable for the build phase to install the files into the destroot already and to have the destroot phase do nothing. In that case, you could disable the destroot phase by writing "destroot {}". Some ports do it the other way around, where the build phase does nothing ("build {}") and the destroot phase does the building and the destrooting.
>
>
> Whoops
>
> :info:build Checking dependencies...
> :info:build Python Version 3.8.11 -> OK
> :info:build Qt Version 5.15.2 -> OK
> :info:build PyQt Version 5.15.4 -> OK
> :info:build Installing files...
> :info:build Copying python files to /usr/local/share/convertall
> :info:build Traceback (most recent call last):
> :info:build File "install.py", line 308, in <module>
> :info:build main()
> :info:build File "install.py", line 229, in main
> :info:build copyDir('source', pythonBuildDir)
> :info:build File "install.py", line 92, in copyDir
> :info:build shutil.copy2(srcPath, os.path.join(dstDir, name))
> :info:build File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/shutil.py", line 435, in copy2
> :info:build copyfile(src, dst, follow_symlinks=follow_symlinks)
> :info:build File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/shutil.py", line 264, in copyfile
> :info:build with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
> :info:build PermissionError: [Errno 1] Operation not permitted: '/usr/local/share/convertall/unitedit.py'
> :info:build Command failed: cd "/opt/local/var/macports/build/_Users_kwh_sw_projects_git_macports_kwh_math_convertall/convertall/work/ConvertAll-0.8.0" && /opt/local/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 install.py build -j16 -p /opt/local -b /opt/local/var/macports/build/_Users_kwh_sw_projects_git_macports_kwh_math_convertall/convertall/work/destroot
> :info:build Exit code: 1
> :error:build Failed to build convertall: command execution failed
> :debug:build Error code: CHILDSTATUS 26196 1
> :debug:build Backtrace: command execution failed
> :debug:build while executing
> :debug:build "system {*}$notty {*}$callback {*}$nice $fullcmdstring"
> :debug:build invoked from within
> :debug:build "command_exec -callback portprogress::target_progress_callback build"
> :debug:build (procedure "portbuild::build_main" line 8)
> :debug:build invoked from within
> :debug:build "$procedure $targetname"
> :error:build See /opt/local/var/macports/logs/_Users_kwh_sw_projects_git_macports_kwh_math_convertall/convertall/main.log for details.
>
> Kevin
>
>
Well, I don't understand why ConvertAll's build system was apparently ignoring its advertised -p and -b flags, but it looks like it was. I brute forced it by reinplacing the applicable lines in install.py using a post-patch script. Now it installs without error and appears to run correctly.
Current draft Portfile:
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
PortSystem 1.0
PortGroup github 1.0
PortGroup python 1.0
PortGroup qt5 1.0
github.setup doug-101 ConvertAll 0.8.0 v
github.tarball_from releases
python.versions 34 35 36 37 38 39
python.default_version 38
qt5.min_version 5.4
name convertall
version 0.8.0
license GPL-2+
categories math science
platforms darwin
maintainers {@khorton kilohotel.com:kevin01}
description Extremely flexible unit converter
long_description ConvertAll has a large database of units, and allows conversions \
that use multiple units, e.g. convert from feet per decade to \
nautical miles per fortnight.
homepage http://convertall.bellz.org
checksums rmd160 89fcc2aa9bad7ecc1de7bee4edea68fdff39706a \
sha256 624c8a792b0bc7ff3776499c2c743b32273569efd0567615e570a7e739e8d521 \
size 281055
depends_lib-append port:py${python.version}-pyqt5
use_configure no
build.cmd ${python.bin} install.py
build.args -p ${prefix} \
-b ${destroot}
destroot {}
post-patch {
reinplace "s|/usr/local|${prefix}|g" ${worksrcpath}/install.py
reinplace "s|buildRoot = '/'|buildRoot = '${workpath}/destroot'|g" ${worksrcpath}/install.py
}
======================
I assume that I would submit this via Trac to see it possibly someday show up in MacPorts. I dig into the docs a bit more first to see if there are any other Portfile fields I should populate, or if I can find any best practices that I have violated.
Thanks,
Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20210712/d7908e06/attachment.htm>
More information about the macports-users
mailing list