##// END OF EJS Templates
packaging: add support for PyOxidizer...
packaging: add support for PyOxidizer I've successfully built Mercurial on the development tip of PyOxidizer on Linux and Windows. It mostly "just works" on Linux. Windows is a bit more finicky. In-memory resource files are probably not all working correctly due to bugs in PyOxidizer's naming of modules. PyOxidizer now now supports installing files next to the produced binary. (We do this for templates in the added file.) So a workaround should be available. Also, since the last time I submitted support for PyOxidizer, PyOxidizer gained the ability to auto-generate Rust projects to build executables. So we don't need to worry about vendoring any Rust code to initially support PyOxidizer. However, at some point we will likely want to write our own command line driver that embeds a Python interpreter via PyOxidizer so we can run Rust code outside the confines of a Python interpreter. But that will be a follow-up. I would also like to add packaging.py CLI commands to build PyOxidizer distributions. This can come later, if ever. PyOxidizer's new "targets" feature makes it really easy to define packaging tasks in its Starlark configuration file. While not much is implemented yet, eventually we should be able to produce MSIs, etc using a `pyoxidizer build` one-liner. We'll get there... Differential Revision: https://phab.mercurial-scm.org/D7450

File last commit:

r23399:fd5247a8 default
r44697:281b6690 default
Show More
entrypoint.sh
80 lines | 2.1 KiB | application/x-sh | BashLexer
#!/bin/bash
# This script gets executed on container start. Its job is to set up
# the Mercurial environment and invoke the server.
# Mercurial can be started in two modes.
# If the MERCURIAL_SOURCE environment variable is set and it points to a
# Mercurial source directory, we will install Mercurial from that directory.
# Otherwise, we download the Mercurial source and install it manually.
set -e
SOURCE_DIR=/var/hg/source
INSTALL_DIR=/var/hg/install
REPOS_DIR=/var/hg/repos
HTDOCS_DIR=/var/hg/htdocs
if [ ! -d ${SOURCE_DIR} ]; then
echo "Mercurial source not available at ${SOURCE_DIR}"
echo "You need to mount a volume containing the Mercurial source code"
echo "when running the container. For example:"
echo ""
echo " $ docker run -v ~/src/hg:/${SOURCE_DIR} hg-apache"
echo ""
echo "This container will now stop running."
exit 1
fi
echo "Installing Mercurial from ${SOURCE_DIR} into ${INSTALL_DIR}"
pushd ${SOURCE_DIR}
/usr/bin/python2.7 setup.py install --root=/ --prefix=${INSTALL_DIR} --force
popd
mkdir -p ${HTDOCS_DIR}
# Provide a default config if the user hasn't supplied one.
if [ ! -f ${HTDOCS_DIR}/config ]; then
cp /defaulthgwebconfig ${HTDOCS_DIR}/config
fi
if [ ! -f ${HTDOCS_DIR}/hgweb.wsgi ]; then
cat >> ${HTDOCS_DIR}/hgweb.wsgi << EOF
config = '${HTDOCS_DIR}/config'
import sys
sys.path.insert(0, '${INSTALL_DIR}/lib/python2.7/site-packages')
from mercurial import demandimport
demandimport.enable()
from mercurial.hgweb import hgweb
application = hgweb(config)
EOF
fi
mkdir -p ${REPOS_DIR}
if [ ! -d ${REPOS_DIR}/repo ]; then
${INSTALL_DIR}/bin/hg init ${REPOS_DIR}/repo
chown -R www-data:www-data ${REPOS_DIR}/repo
fi
# This is necessary to make debuginstall happy.
if [ ! -f ~/.hgrc ]; then
cat >> ~/.hgrc << EOF
[ui]
username = Dummy User <nobody@example.com>
EOF
fi
echo "Verifying Mercurial installation looks happy"
${INSTALL_DIR}/bin/hg debuginstall
. /etc/apache2/envvars
echo "Starting Apache HTTP Server on port 80"
echo "We hope you remembered to publish this port when running the container!"
echo "If this is an interactive container, simply CTRL^C to stop."
exec "$@"