diff --git a/make_osx.sh b/make_osx.sh new file mode 100755 --- /dev/null +++ b/make_osx.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +set -e + +# Extra args passed in, not version +OSXVERSIONFLAGS= + +# TODO: default MACOSX_DEPLOYMENT_TARGET=10.9 +# TODO: adjust ${OSXVER} accordingly + +rm -rf build/mercurial +python -m virtualenv build/mercurial/usr/local/mercurial +source build/mercurial/usr/local/mercurial/bin/activate + +# TODO: Don't install this into the virtual environment. Also, use docutils-python3 +python -m pip install docutils + +python setup.py install --optimize=1 \ + --root=build/mercurial/ --prefix=/usr/local/mercurial + +make -C doc all install DESTDIR="`pwd`/build/mercurial/" + +# Place a bogon .DS_Store file in the target dir so we can be +# sure it doesn't get included in the final package. +touch build/mercurial/.DS_Store + +# install zsh completions - this location appears to be +# searched by default as of macOS Sierra. +install -d build/mercurial/usr/local/share/zsh/site-functions/ +install -m 0644 contrib/zsh_completion build/mercurial/usr/local/share/zsh/site-functions/_hg + +# install bash completions - there doesn't appear to be a +# place that's searched by default for bash, so we'll follow +# the lead of Apple's git install and just put it in a +# location of our own. +install -d build/mercurial/usr/local/hg/contrib/ +install -m 0644 contrib/bash_completion build/mercurial/usr/local/hg/contrib/hg-completion.bash + +make -C contrib/chg \ + HGPATH=/usr/local/bin/hg \ + PYTHON=python \ + HGEXTDIR=/usr/local/mercurial/lib/python2.7/site-packages/hgext \ + DESTDIR=../../build/mercurial \ + PREFIX=/usr/local \ + clean install + +# Keep pip around so that things like evolve can be installed. +rm -f build/mercurial/usr/local/mercurial/bin/rst* \ + build/mercurial/usr/local/mercurial/bin/activate* \ + build/mercurial/usr/local/mercurial/bin/wheel \ + build/mercurial/usr/local/mercurial/bin/easy_install + +# LANG=C' to avoid "sed: RE error: illegal byte sequence" +LANG=C sed -i '' -e "s|`pwd`/build/mercurial||g" build/mercurial/usr/local/mercurial/bin/* + +# The virtualenv contains a symlink back to the real python install. We can +# either slim this down somehow (to avoid distributing whatever random packages +# are already installed), or build python from source with a custom --dest. +mkdir -p build/mercurial/usr/local/mercurial/Library/Frameworks/Python.framework/Versions +cp -R /Library/Frameworks/Python.framework/Versions/2.7 build/mercurial/usr/local/mercurial/Library/Frameworks/Python.framework/Versions +ln -s -f /usr/local/mercurial/Python.framework/Versions/2.7/Python build/mercurial/usr/local/mercurial/.Python + +# Running /usr/local/mercurial/Python.framework/Versions/2.7/bin/python2.7 and +# printing sys.paths lists out stuff in /Library/Frameworks/Python.framework, +# so this may not be totally detached from a standard python.org installation. +# sys.exec_prefix and sys.prefix also point there. That stuff appears to live +# in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/_sysconfigdata.py. +# The various *.pyc files that are copied over also have /Library/Frameworks strings +# in them. Then again, so do *.pyc files in a virtualenv. +ln -s /usr/local/mercurial/bin/hg build/mercurial/usr/local/bin/hg + +mkdir -p ${OUTPUTDIR:-dist} + +HGVER=$(python2 contrib/genosxversion.py ${OSXVERSIONFLAGS} \ + build/mercurial/usr/local/mercurial/lib/python2.7/site-packages/mercurial/__version__.py) && \ +OSXVER=$(sw_vers -productVersion | cut -d. -f1,2) && \ +PYVER=$(python -V 2>&1 | cut -d' ' -f2 | cut -d. -f1,2) && \ +pkgbuild --filter .DS_Store --root build/mercurial/ \ + --identifier org.mercurial-scm.mercurial \ + --version "${HGVER}" \ + build/mercurial.pkg && \ + +productbuild --distribution contrib/packaging/macosx/distribution.xml \ + --package-path build/ \ + --version "${HGVER}" \ + --resources contrib/packaging/macosx/ \ + "${OUTPUTDIR:-dist/}"/Mercurial-"${HGVER}"-py"${PYVER}"-macosx"${OSXVER}".pkg