[PATCH] docker rhel9: add support for rocky9

7 views
Skip to first unread message

joris.l...@gmail.com

unread,
Mar 28, 2025, 11:40:44 AMMar 28
to thg...@googlegroups.com
# HG changeset patch
# User Joris Lijssens <joris.l...@nokia.com>
# Date 1743157537 -3600
# Fri Mar 28 11:25:37 2025 +0100
# Node ID b9a4f40ab8e2f97b6b1cbd0f2baea0abae734a9d
# Parent 9806d49225a505445a9b2bbde5037e3ffa6f1006
docker rhel9: add support for rocky9

diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -89,3 +89,6 @@ docker-rhel7:

docker-rhel8:
$(MAKE) -C contrib/docker build-thg-rpm PLATFORM=rhel8 EXTRA_RPM_OPTS_TOPLEVEL=--arch-dependent
+
+docker-rhel9:
+ $(MAKE) -C contrib/docker build-thg-rpm PLATFORM=rhel9 EXTRA_RPM_OPTS_TOPLEVEL=--arch-dependent
diff --git a/contrib/docker/Makefile b/contrib/docker/Makefile
--- a/contrib/docker/Makefile
+++ b/contrib/docker/Makefile
@@ -15,7 +15,7 @@ REPOROOT = $(shell hg root)
DOCKERREPO = /thgrepo/
HGRPM = /mercurial.rpm

-EXTRA_RPM_OPTS = $(EXTRA_RPM_OPTS_TOPLEVEL) --requirements contrib/packaging/venv_py3/requirements-rhel.txt
+EXTRA_RPM_OPTS = $(EXTRA_RPM_OPTS_TOPLEVEL) --requirements contrib/packaging/venv_py3/requirements-rhel.txt --platform $(PLATFORM)

help:
@echo 'Make targets:'
diff --git a/contrib/docker/rhel8 b/contrib/docker/rhel8
--- a/contrib/docker/rhel8
+++ b/contrib/docker/rhel8
@@ -49,3 +49,6 @@ RUN yum install -y git openssl-devel &&

# wish is needed for Mercurial
RUN yum install tk -y
+
+# install libffi-devel
+RUN yum install -y libffi-devel
diff --git a/contrib/docker/rhel9 b/contrib/docker/rhel9
new file mode 100644
--- /dev/null
+++ b/contrib/docker/rhel9
@@ -0,0 +1,56 @@
+FROM rockylinux/rockylinux:9.3
+RUN yum install -y \
+ gcc \
+ gettext \
+ make \
+ python3-devel \
+ python3-docutils \
+ rpm-build \
+ tar
+
+# For creating repo meta data
+RUN yum install -y createrepo
+
+# Enable more packages
+RUN yum install 'dnf-command(config-manager)' -y
+RUN yum config-manager --set-enabled crb
+
+RUN --mount=type=cache,target=/var/cache/yum dnf config-manager --add-repo https://www.mercurial-scm.org/release/centos9/mercurial.repo
+# install this first to make sure we can install python3-qscintilla-qt5 next
+RUN yum install -y epel-release
+
+# THg GUI dependencies
+RUN yum install -y \
+ dejavu-sans-fonts \
+ dejavu-sans-mono-fonts \
+ python3-qt5-devel \
+ python3-iniparse \
+ python3-qscintilla-qt5
+
+# THg tests dependencies
+RUN yum install -y python3-pip && \
+ pip3 install mock nose
+
+# RPM build dependencies
+RUN yum install -y \
+ desktop-file-utils \
+ python3-sphinx
+
+# Install rust for rust-based optimizations
+RUN yum install -y cargo
+
+# Install Mercurial (so it can be called in our scripts)
+#RUN pip3 install mercurial --global-option="--rust"
+RUN --mount=type=cache,target=/var/cache/yum dnf config-manager --add-repo https://www.mercurial-scm.org/release/centos9/mercurial.repo
+RUN yum install mercurial -y
+
+# Install libgit2 to allow usage of pygit2
+RUN yum install -y git openssl-devel && \
+ mkdir /libgit2 && \
+ git clone -b v1.1.1 https://github.com/libgit2/libgit2.git /libgit2 && \
+ mkdir /libgit2/build && cd /libgit2/build && cmake .. && cmake --build . --target install
+
+# wish is needed for Mercurial
+RUN yum install tk -y
+
+RUN yum install -y libffi-devel
diff --git a/contrib/rpm.sh b/contrib/rpm.sh
--- a/contrib/rpm.sh
+++ b/contrib/rpm.sh
@@ -30,6 +30,12 @@ while [ "$1" ]; do
ARCH_DEPENDENT=1
shift
;;
+ --platform )
+ shift
+ PLATFORM="$1"
+ shift
+ ;;
+
* )
echo "Invalid parameter $1!" 1>&2
exit 1
@@ -41,6 +47,12 @@ if [ ! -z "$HGRPM" ]; then
sudo rpm -i $HGRPM
fi

+if [ "$PLATFORM" == "rhel9" ]; then
+ SPEC_FILE="tortoisehg-rhel9.spec"
+else
+ SPEC_FILE="tortoisehg.spec"
+fi
+
mkdir -p ${RPMBUILDDIR}/{SOURCES,BUILD,RPMS,SRPMS,SPECS}
version=$(hg parents --template '{sub(r".*:", "", latesttag)}+{latesttagdistance}')
if [ $(expr "$version" : '.*+0$') -ne 0 ]; then
@@ -56,7 +68,7 @@ sed -e "s,^Version:.*,Version: $version,
-e "s,^Release:.*,Release: $release," \
-e "s/^%define __python .*/%define __python $PYTHONEXE/" \
-e "s,^%define requirements_txt .*,%define requirements_txt $REQUIREMENTS," \
- $(dirname $0)/tortoisehg.spec > ${RPMBUILDDIR}/SPECS/tortoisehg.spec
+ $(dirname $0)/${SPEC_FILE} > ${RPMBUILDDIR}/SPECS/tortoisehg.spec

if [ "${ARCH_DEPENDENT}" == "1" ]; then
sed -i -e "s/^%define _archdependent .*/%define _archdependent 1/" ${RPMBUILDDIR}/SPECS/tortoisehg.spec
diff --git a/contrib/tortoisehg-rhel9.spec b/contrib/tortoisehg-rhel9.spec
new file mode 100644
--- /dev/null
+++ b/contrib/tortoisehg-rhel9.spec
@@ -0,0 +1,112 @@
+%define __python python3
+%define _archdependent 0
+# don't generate a debug package
+%global debug_package %{nil}
+%define requirements_txt empty
+
+Name: tortoisehg
+Version: hg
+Release: hg
+Summary: Mercurial GUI command line tool thg
+Group: Development/Tools
+License: GPLv2+
+URL: https://foss.heptapod.net/mercurial/tortoisehg/thg
+Source0: %{name}-%{version}.tar.gz
+%if "%{_archdependent}" == "0"
+BuildArch: noarch
+%endif
+BuildRequires: python3-devel
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+# don't let rpmbuild add requirements itself,
+# it will add requirements that are already provided by the virtualenv
+AutoReqProv: no
+
+%description
+This package contains the thg command line tool, which provides a graphical
+user interface to the Mercurial distributed revision control system.
+
+%package nautilus
+Summary: Mercurial GUI plug-in to the Nautilus file manager
+Group: Development/Tools
+Requires: %{name} = %{version}-%{release}, nautilus-python
+Requires: python39
+
+%description nautilus
+This package contains the TortoiseHg Gnome/Nautilus extension, which makes the
+Mercurial distributed revision control system available in the file manager
+with a graphical interface.
+
+%prep
+%setup -q
+
+%build
+# we install the requirements here to be able to build tortoisehg, but do the install again in the install section
+# (as that directory gets cleared before the install section)
+# --> we could consider not doing anything in the build section and instead just do everything in the install section
+pip3 install -r %{requirements_txt} --prefix=%{buildroot}%{_prefix}/local/lib/thg-env --ignore-installed
+export PYTHONPATH=%{buildroot}%{_prefix}/local/lib/thg-env/lib/python3.9/site-packages:%{buildroot}%{_prefix}/local/lib/thg-env/lib64/python3.9/site-packages
+
+python3 setup.py build
+
+# make sure we can generate documentation
+# --> doing this in the Docker image at root level clashes with existing packages
+pip3 install sphinx --user
+
+(export PATH=$HOME/.local/bin:$PATH; cd doc && make html)
+rm -f doc/build/html/.buildinfo
+
+%install
+rm -rf $RPM_BUILD_ROOT
+echo $RPM_BUILD_ROOT
+
+pip3 install -r %{requirements_txt} --prefix=%{buildroot}%{_prefix}/local/lib/thg-env --ignore-installed
+# Mercurial binaries for RHEL are installed using rust support, so let's do the same for Mercurial shipped with Tortoisehg for RHEL
+pip3 install mercurial --prefix=%{buildroot}%{_prefix}/local/lib/thg-env --ignore-installed --global-option="--rust"
+export PYTHONPATH=%{buildroot}%{_prefix}/local/lib/thg-env/lib/python3.9/site-packages:%{buildroot}%{_prefix}/local/lib/thg-env/lib64/python3.9/site-packages
+
+python3 setup.py install -O1 --skip-build --root %{buildroot}%{_prefix}/local/lib/thg-env
+
+cat > %{buildroot}%{_prefix}/local/lib/thg-env/usr/lib/python3.9/site-packages/tortoisehg/util/config.py << EOT
+bin_path = "%{_prefix}/local/lib/thg-env/bin"
+license_path = "%{_docdir}/%{name}-%{version}/COPYING.txt"
+locale_path = "%{_prefix}/local/lib/thg-env/usr/share/locale"
+icon_path = "%{_prefix}/local/lib/thg-env/usr/share/pixmaps/tortoisehg"
+nofork = True
+EOT
+
+mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/mercurial/hgrc.d
+install contrib/mergetools.rc $RPM_BUILD_ROOT%{_sysconfdir}/mercurial/hgrc.d/thgmergetools.rc
+
+desktop-file-install --dir=%{buildroot}%{_datadir}/applications contrib/thg.desktop
+
+# add script to start tortoisehg
+mkdir -p %{buildroot}%{_prefix}/local/bin
+cat > %{buildroot}%{_prefix}/local/bin/thg << EOF
+#!/bin/sh
+export PYTHONPATH=%{_prefix}/local/lib/thg-env/lib/python3.9/site-packages/:\$PYTHONPATH
+export PYTHONPATH=%{_prefix}/local/lib/thg-env/lib64/python3.9/site-packages/:\$PYTHONPATH
+export PYTHONPATH=%{_prefix}/local/lib/thg-env/usr/lib/python3.9/site-packages/:\$PYTHONPATH
+export PATH=%{_prefix}/local/lib/thg-env/bin:\$PATH
+%{_prefix}/local/lib/thg-env/usr/bin/thg "\$@"
+EOF
+chmod +x %{buildroot}%{_prefix}/local/bin/thg
+
+#%find_lang %{name}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+
+%defattr(-,root,root,-)
+%doc COPYING.txt doc/build/html/
+/usr/local/bin/thg
+/usr/local/lib/thg-env
+%{_datadir}/applications/thg.desktop
+
+%config(noreplace) %attr(644,root,root) %{_sysconfdir}/mercurial/hgrc.d/thgmergetools.rc
+
+%files nautilus
+%defattr(-,root,root,-)
+
+%changelog

Joris Lijssens

unread,
Mar 28, 2025, 11:52:48 AMMar 28
to thg...@googlegroups.com
# HG changeset patch
# User Joris Lijssens <joris.l...@nokia.com>
# Date 1743157537 -3600
# Fri Mar 28 11:25:37 2025 +0100
# Node ID 04540226d27d396fc51e8360dc9b18f54a778598

Yuya Nishihara

unread,
Mar 29, 2025, 8:41:02 AMMar 29
to joris.l...@gmail.com, thg...@googlegroups.com
On Fri, 28 Mar 2025 16:40:25 +0100, joris.l...@gmail.com wrote:
> # HG changeset patch
> # User Joris Lijssens <joris.l...@nokia.com>
> # Date 1743157537 -3600
> # Fri Mar 28 11:25:37 2025 +0100
> # Node ID b9a4f40ab8e2f97b6b1cbd0f2baea0abae734a9d
> # Parent 9806d49225a505445a9b2bbde5037e3ffa6f1006
> docker rhel9: add support for rocky9

The patch couldn't apply. Can you rebase onto the current stable tip?

joris.l...@gmail.com

unread,
Mar 30, 2025, 9:17:03 AMMar 30
to thg...@googlegroups.com
# HG changeset patch
# User Joris Lijssens <joris.l...@nokia.com>
# Date 1743157537 -3600
# Fri Mar 28 11:25:37 2025 +0100
# Branch stable
# Node ID 1518f88ec4f8e826135dd9eb91f8f80a14c302fa
# Parent cacdb641b2d6804486ea240177e92ec43e8449d4
docker rhel9: add support for rocky9

diff --git a/contrib/docker/Makefile b/contrib/docker/Makefile
--- a/contrib/docker/Makefile
+++ b/contrib/docker/Makefile
@@ -15,7 +15,7 @@ REPOROOT = $(shell hg root)
DOCKERREPO = /thgrepo/
HGRPM = /mercurial.rpm

-EXTRA_RPM_OPTS = $(EXTRA_RPM_OPTS_TOPLEVEL) --requirements contrib/packaging/venv_py3/requirements-rhel.txt
+EXTRA_RPM_OPTS = $(EXTRA_RPM_OPTS_TOPLEVEL) --requirements contrib/packaging/venv_py3/requirements-rhel.txt --platform $(PLATFORM)

help:
@echo 'Make targets:'
diff --git a/contrib/docker/rhel9 b/contrib/docker/rhel9
--- a/contrib/docker/rhel9
+++ b/contrib/docker/rhel9
@@ -1,4 +1,4 @@
-FROM rockylinux/rockylinux:9
+FROM rockylinux/rockylinux:9.3
RUN yum install -y \
gcc \
gettext \
@@ -14,6 +14,9 @@ RUN yum install -y createrepo
RUN yum install 'dnf-command(config-manager)' -y
RUN yum config-manager --set-enabled crb

+# install this first to make sure we can install python3-qscintilla-qt5 next
+RUN yum install -y epel-release
+
# THg GUI dependencies
RUN yum install -y \
dejavu-sans-fonts \
@@ -37,7 +40,8 @@ RUN yum install -y \
RUN yum install -y cargo

# Install Mercurial (so it can be called in our scripts)
-RUN pip3 install mercurial --global-option="--rust"
+RUN --mount=type=cache,target=/var/cache/yum dnf config-manager --add-repo https://www.mercurial-scm.org/release/centos9/mercurial.repo
+RUN yum install mercurial -y

# Install libffi-devel for pygit2
RUN yum install -y libffi-devel
@@ -50,3 +54,5 @@ RUN yum install -y git openssl-devel &&

# wish is needed for Mercurial
RUN yum install tk -y
+

Yuya Nishihara

unread,
Mar 30, 2025, 10:30:09 AMMar 30
to joris.l...@gmail.com, thg...@googlegroups.com
On Sun, 30 Mar 2025 15:16:23 +0200, joris.l...@gmail.com wrote:
> # HG changeset patch
> # User Joris Lijssens <joris.l...@nokia.com>
> # Date 1743157537 -3600
> # Fri Mar 28 11:25:37 2025 +0100
> # Branch stable
> # Node ID 1518f88ec4f8e826135dd9eb91f8f80a14c302fa
> # Parent cacdb641b2d6804486ea240177e92ec43e8449d4
> docker rhel9: add support for rocky9

Queued, thanks.

> +
> +RUN yum install -y libffi-devel

This looks redundant, so removed. Please let me know if it has to be
installed twice.
Reply all
Reply to author
Forward
0 new messages