# HG changeset patch # User Kyle Lippincott # Date 2021-02-05 01:34:20 # Node ID 90481550467ca8d117678bf26cfc359a5b6e636a # Parent 0a23ace80e5489563796222cd2b7ac1278e3850f debian: support a "chg-first" installation mechanism (hg is actually chg) This mechanism builds chg such that it looks for `hg` to be available at /usr/lib/mercurial/hg instead of in the $PATH as `hg`, and makes the `hg` in /usr/bin be a symlink to `chg`. It's important to note that the hg binary must continue to be named `hg`. If we wanted to instead place it at /usr/bin/pyhg or something similar, we would need to modify Mercurial to allow that basename. Failure to do so would break Mercurial's shell aliases that use `hg`, `chg`, or `$HG`. I don't know if we should ever have a setup like this be the default setup, but I'm willing to get more information on our experience with it for making such a determination. Actually making it the default might be rather involved, as we don't maintain the official debian packaging rules. Differential Revision: https://phab.mercurial-scm.org/D10020 diff --git a/contrib/packaging/debian/rules b/contrib/packaging/debian/rules --- a/contrib/packaging/debian/rules +++ b/contrib/packaging/debian/rules @@ -18,6 +18,10 @@ # DEB_HG_PYTHON_VERSIONS="3.7 3.8" make deb DEB_HG_MULTI_VERSION?=0 +# Set to 1 to make /usr/bin/hg a symlink to chg, and move hg to +# /usr/lib/mercurial/hg. +DEB_HG_CHG_BY_DEFAULT?=0 + CPUS=$(shell cat /proc/cpuinfo | grep -E ^processor | wc -l) # By default, only build for the version of python3 that the system considers @@ -40,6 +44,12 @@ else DEB_HG_PYTHON_VERSIONS?=$(shell py3versions -vd) endif +ifeq ($(DEB_HG_CHG_BY_DEFAULT), 1) + # Important: the "real" hg must have a 'basename' of 'hg'. Otherwise, hg + # behaves differently when setting $HG and breaks aliases that use that. + export HGPATH=/usr/lib/mercurial/hg +endif + export HGPYTHON3=1 export PYTHON=python3 @@ -86,3 +96,8 @@ override_dh_auto_install: $(DEB_HG_PYTHO cp contrib/bash_completion "$(CURDIR)"/debian/mercurial/usr/share/bash-completion/completions/hg mkdir -p "$(CURDIR)"/debian/mercurial/usr/share/zsh/vendor-completions cp contrib/zsh_completion "$(CURDIR)"/debian/mercurial/usr/share/zsh/vendor-completions/_hg + if [[ "$(DEB_HG_CHG_BY_DEFAULT)" -eq 1 ]]; then \ + mkdir -p "$(CURDIR)"/debian/mercurial/usr/lib/mercurial; \ + mv "$(CURDIR)"/debian/mercurial/usr/bin/hg "$(CURDIR)"/debian/mercurial/usr/lib/mercurial/hg; \ + ln -s chg "$(CURDIR)"/debian/mercurial/usr/bin/hg; \ + fi