HTTPS SSH

build-win-hg-packages

Build windows mercurial packages for SCM-Manager.

Create a package semi-automatically

hg clone https://bitbucket.org/sdorra/build-win-hg-packages
  • Download Windows 7 x64 Enterprise Edition from here and place it in veewee/iso
    • The filename should be 7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso
    • The md5 checksum should be 1d0d239a252cb53e466d39e752b17c28
  • run veewee from veewee directory
veewee vbox build 'windows-7-enterprise-amd64-winrm'
  • After the box is build, export it with the following command
veewee vbox export 'windows-7-enterprise-amd64-winrm'
  • Import the box with vagrant
vagrant box add 'windows-7-enterprise-amd64-winrm' 'windows-7-enterprise-amd64-winrm.box'
  • Now you are able to start the box and create the package. Go to the vagrant directory and execute the following command
vagrant up
  • After a while you should have a target directory inside of the vagrant directory with a fresh package

Create a package manually

  • Download and install Python with the "Windows x86 MSI Installer (2.x.x)" package (don't install it for all users)
  • Download and install Mercurial with the "Mercurial x.x MSI installer - x86 Windows - requires admin rights" package
  • Create new folder for the package hg.version-python.version
  • Copy the python installation in to a sub folder the package folder: python/version
  • Unzip the library.zip of the mercurial installation to a subfolder of the package folder: hg/version/lib
  • Copy the templates folder from the mercurial folder to the extracted library folder
  • Copy all pyd files from the mercurial installation to python/version directory
  • Create a new directory bin in the hg/version directory
  • Create a file hg.bat in that folder with the following content and replace @pythonVersion with your python version
@echo off
setlocal
set HG=%~f0
set PYTHONHOME=%~dp0..\..\..\python\@pythonVersion
set PYTHONPATH=%~dp0..\lib;%PYTHONHOME%\Lib
"%PYTHONHOME%\python.exe" "%~dp0hg.py" %*
exit /b %errorlevel%
  • Create a file hg.py in that folder with the following content
# mercurial - scalable distributed SCM
#
# Copyright 2005-2007 Matt Mackall <mpm@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.

import os
import sys

libdir = '../lib/python2.7/site-packages/'

if libdir != '@' 'LIBDIR' '@':
    if not os.path.isabs(libdir):
        libdir = os.path.join(os.path.dirname(os.path.realpath(__file__)),
                              libdir)
        libdir = os.path.abspath(libdir)
    sys.path.insert(0, libdir)

# enable importing on demand to reduce startup time
try:
    from mercurial import demandimport; demandimport.enable()
except ImportError:
    import sys
    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)

import mercurial.util
import mercurial.dispatch

for fp in (sys.stdin, sys.stdout, sys.stderr):
    mercurial.util.setbinary(fp)

mercurial.dispatch.run()

At the end your directory structure should look like the following (example with hg 3.0.0 and python 2.7.7):

hg/
hg/3.0.0/
hg/3.0.0/bin/
hg/3.0.0/bin/hg.bat
hg/3.0.0/bin/hg.py
hg/3.0.0/lib/
hg/3.0.0/lib/abc.pyc
...
hg/3.0.0/lib/templates/
...
python/
python/2.7.7/
...
python/2.7.7/python.exe
...
python/2.7.7/unicodedata.pyd

Now you can zip your new package (zip it without parent folder).