#72455 closed defect (fixed)

mercurial 7.0.2 is badly broken

Reported by: barracuda156 Owned by: danchr (Dan Villiom Podlaski Christiansen)
Priority: Normal Milestone:
Component: ports Version: 2.10.7
Keywords: Cc: danchr (Dan Villiom Podlaski Christiansen)
Port: mercurial

Description

The last update did not go well. The port does not build now.

To begin with, it does not respect MacPorts compiler settings and chosen Python – compiler is forced to cc when the build goes into docs directory. That is wrong, but not breaking, however it also forces python3, which is not found, expectedly (it is defined to that in Makefile). Once these are fixed, the build succeeds, but destroot fails with the error that hg does not exist, and portfile tries to run a command on it. (hg is in bin, but it is a symlink to something; I had no time today to look into that further.)

I will return to this with the log tomorrow, but at least for compiler and python choice it should be evident without a log either. I am not sure yet why destroot is broken.

  1. S. Also portfile is lacking compiler_blacklist_versions PG, which it should use, but that is inherited from 6.x and probably my own omission on an earlier update.

Attachments (2)

mercurial-20250509-fail.log (2.6 MB) - added by akierig (akierig) 11 months ago.
main.log (1.5 MB) - added by wyuenho (Jimmy Yuen Ho Wong) 11 months ago.
rust variant build log

Change History (18)

comment:1 in reply to:  description Changed 11 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to barracuda156:

compiler is forced to cc when the build goes into docs directory.

Yeah, that's caused by the post-build block just calling make manually, which doesn't use any of the MacPorts environment variables.

Instead of:

post-build {
    system -W "${worksrcpath}/contrib/chg" make
    system -W "${worksrcpath}/doc" make

    if {[variant_isset rust]} {
        system -W "${worksrcpath}" "make build-rhg"
    }
}

Maybe something like this (untested) would be better:

post-build {
    build.dir ${worksrcpath}/contrib/chg
    command_exec build
    build.dir ${worksrcpath}/doc
    command_exec build

    if {[variant_isset rust]} {
        build.dir ${worksrcpath}
        build.target build-rhg
        command_exec build
    }
}

That's assuming the build system still requires you to invoke all of those manually in different directories, which seems odd. I'd've assume their top-level Makefile would have targets for anything one might want to use, which could be added as needed. For example, why are we running make separately for the rust variant, rather than just adding build-rhg to build.target when the rust variant is selected?

comment:2 Changed 11 months ago by danchr (Dan Villiom Podlaski Christiansen)

My bad; I wanted to have the build system invoke the Python build directly while retaining the other parts. I’ll revert those change later today.

comment:3 Changed 11 months ago by danchr (Dan Villiom Podlaski Christiansen)

Owner: set to danchr
Status: newaccepted

comment:4 Changed 11 months ago by danchr (Dan Villiom Podlaski Christiansen)

In 1fc03cf7de2e2c1afe6e49afc47a1e1db44b2eb9/macports-ports (master):

mercurial: unbreak build

Mercurial seems to be in the process of moving from using a
Makefile-based build to a more normal Python-style build -- the Makefile
is still capable of building a wheel, but does so using Pip in a venv.
The previous solution was to try to call the GNU Make as a separate
invocation post-build, but that lost all sorts of environment variables.

As a temporary workaround, simply drop the parts that _must_ be built
with Make:

  • man-pages
  • /opt/local/bin/chg
  • /opt/local/bin/rhg (+rust only)

This should allow the port to build, while retaining the most important
functionality while I try to fix it.

See: #72455

Changed 11 months ago by akierig (akierig)

Attachment: mercurial-20250509-fail.log added

comment:5 Changed 11 months ago by akierig (akierig)

I just tried building it plain vanilla, sorry to report it's still failing for me on MacOS 15.4.1/Xcode 16.3 Build version 16E140.

Full debug log is attached above.

--->  Patching hg: 1s,.*,#!/opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13,
DEBUG: Executing reinplace: /usr/bin/sed 1s,.*,#!/opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13, </opt/local/var/
macports/build/_Users_akierig_proj_macports-ports_devel_mercurial/mercurial/work/destroot/opt/local/bin/hg >@file11
DEBUG: couldn't read file "/opt/local/var/macports/build/_Users_akierig_proj_macports-ports_devel_mercurial/mercurial/work/destroot/opt/local/
bin/hg": no such file or directory
    while executing
"exec -ignorestderr -- {*}$cmdline"
Error: reinplace: couldn't read file "/opt/local/var/macports/build/_Users_akierig_proj_macports-ports_devel_mercurial/mercurial/work/destroot
/opt/local/bin/hg": no such file or directory
Error: Failed to destroot mercurial: reinplace sed(1) failed
DEBUG: Error code: NONE
DEBUG: Backtrace: reinplace sed(1) failed
    while executing
"$post $targetname"
DEBUG: dropping privileges: euid changed to 504, egid changed to 501.
Last edited 11 months ago by akierig (akierig) (previous) (diff)

comment:6 Changed 11 months ago by danchr (Dan Villiom Podlaski Christiansen)

That’s odd… Could you check the contents of the destroot? Is there a similar hg file somewhere? Does it have the right shebang?

comment:7 in reply to:  6 Changed 11 months ago by barracuda156

Replying to danchr:

That’s odd… Could you check the contents of the destroot? Is there a similar hg file somewhere? Does it have the right shebang?

It fails at destroot, like yesterday, even after today's update.

byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/verify.py to verify.cpython-313.pyc
byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/vfs.py to vfs.cpython-313.pyc
byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/win32.py to win32.cpython-313.pyc
byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/windows.py to windows.cpython-313.pyc
byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/wireprotoframing.py to wireprotoframing.cpython-313.pyc
byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/wireprotoserver.py to wireprotoserver.cpython-313.pyc
byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/wireprototypes.py to wireprototypes.cpython-313.pyc
byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/wireprotov1peer.py to wireprotov1peer.cpython-313.pyc
byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/wireprotov1server.py to wireprotov1server.cpython-313.pyc
byte-compiling /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial/worker.py to worker.cpython-313.pyc
running install_egg_info
running egg_info
writing mercurial.egg-info/PKG-INFO
writing dependency_links to mercurial.egg-info/dependency_links.txt
writing top-level names to mercurial.egg-info/top_level.txt
reading manifest file 'mercurial.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
adding license file 'COPYING'
writing manifest file 'mercurial.egg-info/SOURCES.txt'
Copying mercurial.egg-info to /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/mercurial-7.0.2-py3.13.egg-info
running install_scripts
creating /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin
copying build/scripts-3.13/hg -> /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin
changing mode of /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin/hg to 755
running install_completion
creating /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/share/bash-completion/completions
copying contrib/bash_completion -> /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/share/bash-completion/completions/hg
creating /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/share/zsh/site-functions
copying contrib/zsh_completion -> /opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/share/zsh/site-functions/_hg
--->  Patching hg: 1s,.*,#!/opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13,
Error: reinplace: couldn't read file "/opt/local/var/macports/build/_opt_local_ppcports_devel_mercurial/mercurial/work/destroot/opt/local/bin/hg": no such file or directory
Error: Failed to destroot mercurial: reinplace sed(1) failed
Error: See /opt/local/var/macports/logs/_opt_local_ppcports_devel_mercurial/mercurial/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there
is a bug.

comment:8 in reply to:  6 Changed 11 months ago by akierig (akierig)

Replying to danchr:

That’s odd… Could you check the contents of the destroot? Is there a similar hg file somewhere? Does it have the right shebang?

ah HAH! it does not.

here's the contents of /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin/hg

#!python
#
# mercurial - scalable distributed SCM
#
# Copyright 2005-2007 Olivia Mackall <olivia@selenic.com>
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.

from __future__ import annotations

import os
import sys

try:
    from hgdemandimport import tracing
except ImportError:
    sys.stderr.write(
        "abort: couldn't find mercurial libraries in [%s]\n"
        % ' '.join(sys.path)
    )
    sys.stderr.write("(check your install and PYTHONPATH)\n")
    sys.exit(-1)

with tracing.log('hg script'):
    # enable importing on demand to reduce startup time
    import hgdemandimport

    hgdemandimport.enable()

    from mercurial import dispatch

    dispatch.run()

Last edited 11 months ago by akierig (akierig) (previous) (diff)

Changed 11 months ago by wyuenho (Jimmy Yuen Ho Wong)

Attachment: main.log added

rust variant build log

comment:9 Changed 11 months ago by wyuenho (Jimmy Yuen Ho Wong)

The rust variant build failed as well

:info:destroot creating /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/share/bash-completion/completions
:info:destroot copying contrib/bash_completion -> /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/share/bash-completion/completions/hg
:info:destroot creating /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/share/zsh/site-functions
:info:destroot copying contrib/zsh_completion -> /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_mercurial/mercurial/work/destroot/opt/local/Library/Frameworks/Python.framework/Versions/3.13/share/zsh/site-functions/_hg
:debug:destroot Executing proc-post-org.macports.destroot-destroot-0
:debug:destroot Executing proc-post-org.macports.destroot-destroot-1
:info:destroot --->  Patching hg: 1s,.*,#!/opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13,
:debug:destroot Executing reinplace: /usr/bin/sed 1s,.*,#!/opt/local/Library/Frameworks/Python.framework/Versions/3.13/bin/python3.13, </opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_mercurial/mercurial/work/destroot/opt/local/bin/hg >@file12
:debug:destroot couldn't read file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_mercurial/mercurial/work/destroot/opt/local/bin/hg": no such file or directory
:debug:destroot     while executing
:debug:destroot "exec -ignorestderr -- {*}$cmdline"
:error:destroot reinplace: couldn't read file "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_mercurial/mercurial/work/destroot/opt/local/bin/hg": no such file or directory
:error:destroot Failed to destroot mercurial: reinplace sed(1) failed
:debug:destroot Error code: NONE
:debug:destroot Backtrace: reinplace sed(1) failed
:debug:destroot     while executing
:debug:destroot "$post $targetname"
:debug:destroot dropping privileges: euid changed to 502, egid changed to 501.
:error:destroot See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_devel_mercurial/mercurial/main.log for details.

comment:10 Changed 11 months ago by danchr (Dan Villiom Podlaski Christiansen)

In f7051f1f5c9144311c71adc941ba2412c553ef94/macports-ports (master):

mercurial: really unbreak build

The precise order of different post-destroot doesn't seem
well-defined, as sometimes, the one in the port gets executed before the
symlinking done by Python PortGroup. Regardless, this inconsistency
exposed a bug: We should of course be fixing the shebang in the *target*
if the symlink in /opt/local/bin/hg.

See: #72455

comment:11 Changed 11 months ago by danchr (Dan Villiom Podlaski Christiansen)

Okay, I really do hope I got it building this time 🤞 I'll keep this bug open as the port is still somewhat broken, lacking its man-pages and so on. I'll try to find a nice way of adressing that.

comment:12 Changed 11 months ago by akierig (akierig)

yeah it did build for me, thanks! both with and without +rust

and man hg gave me... This manpage is not compatible with mandoc(1) and might display incorrectly. but still looked qfine.

comment:13 Changed 11 months ago by wyuenho (Jimmy Yuen Ho Wong)

Yep, works now. Thanks for the fix!

comment:14 Changed 11 months ago by barracuda156

The portgroup still missing, but otherwise it builds now.

comment:15 Changed 11 months ago by danchr (Dan Villiom Podlaski Christiansen)

Not sure which manual pages you were seeing, but I doubt they were from the port. I posted a PR that should address that, along with moving the Rust extensions to a separate port so that both can get nice binary builds. I'm not 100% certain, but there should only be a small runtime overhead to allow Mercurial to search for them if they're not present.

comment:16 Changed 11 months ago by danchr (Dan Villiom Podlaski Christiansen)

Resolution: fixed
Status: acceptedclosed

In 0f7c62a0200e1add72f13d4af9806f055f24c4f9/macports-ports (master):

mercurial: fix issues in port

This reinstates the experimental Rust extensions as a separate port,
configures Mercurial to optionally load them, and reintroduces the
manual pages, which still require GNU Make to build.

Fixes: #72455

Note: See TracTickets for help on using tickets.