Commits

Jan Borsodi  committed 99d0fbd

Added building of HTML documentation using asciidoc.
Added support for ISS installation system.
More patches for mercurial related to installer files.

  • Participants
  • Parent commits e315c7c

Comments (0)

Files changed (5)

File installer/hg-patches/cutehg-extension

+Regisering cutehg extension in the mercurial.ini file.
+
+diff -r 4f13ed6ee544 -r 177ed49630b8 contrib/win32/mercurial.ini
+--- a/contrib/win32/mercurial.ini	Thu Apr 23 15:40:10 2009 -0500
++++ b/contrib/win32/mercurial.ini	Fri Apr 24 15:21:28 2009 +0200
+@@ -24,6 +24,8 @@
+ ; provides built-in Python hooks to perform line ending conversions.
+ ; This is normally much faster than running an external program.
+ hgext.win32text =
++; CuteHg is an extension to mercurial which displays graphical dialogs for some hg commands
++hgext.cutehg =
+ 
+ 
+ [encode]

File installer/hg-patches/cutehg-installer-no-locales

+Disables inclusion of locale files in the installer.
+Only a temporary solution until the locales can be built automatically.
+
+diff -r 67e59a9886d5 -r f9f43d991545 contrib/win32/mercurial.iss
+--- a/contrib/win32/mercurial.iss	Thu Mar 26 19:01:06 2009 +0900
++++ b/contrib/win32/mercurial.iss	Fri Apr 24 11:46:29 2009 +0200
+@@ -42,7 +42,7 @@
+ Source: dist\w9xpopen.exe; DestDir: {app}
+ Source: dist\add_path.exe; DestDir: {app}
+ Source: doc\*.html; DestDir: {app}\Docs
+-Source: locale\*.*; DestDir: {app}\locale; Flags: recursesubdirs createallsubdirs
++;Source: locale\*.*; DestDir: {app}\locale; Flags: recursesubdirs createallsubdirs
+ Source: templates\*.*; DestDir: {app}\Templates; Flags: recursesubdirs createallsubdirs
+ Source: CONTRIBUTORS; DestDir: {app}; DestName: Contributors.txt
+ Source: COPYING; DestDir: {app}; DestName: Copying.txt

File installer/hg-patches/cutehg-modify-installer-data

+Modifies the installer data for Inno Setup to contain fields related to CuteHg, also adds extra files and installation items.
+
+diff -r 177ed49630b8 contrib/win32/mercurial.iss
+--- a/contrib/win32/mercurial.iss	Fri Apr 24 15:21:28 2009 +0200
++++ b/contrib/win32/mercurial.iss	Fri Apr 24 21:48:46 2009 +0200
+@@ -1,30 +1,31 @@
+ ; Script generated by the Inno Setup Script Wizard.
+ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
+ [Setup]
+-AppCopyright=Copyright 2005-2009 Matt Mackall and others
+-AppName=Mercurial
+-AppVerName=Mercurial snapshot
++AppCopyright=CuteHg Copyright (C) 2009 Tom Burdick, Mercurial Copyright 2005-2009 Matt Mackall and others
++AppName=CuteHg
++AppVerName=CuteHg-${version}
+ InfoAfterFile=contrib/win32/postinstall.txt
+ LicenseFile=COPYING
+ ShowLanguageDialog=yes
+-AppPublisher=Matt Mackall and others
+-AppPublisherURL=http://www.selenic.com/mercurial
+-AppSupportURL=http://www.selenic.com/mercurial
+-AppUpdatesURL=http://www.selenic.com/mercurial
+-AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3}
+-AppContact=mercurial@selenic.com
+-OutputBaseFilename=Mercurial-snapshot
+-DefaultDirName={pf}\Mercurial
+-SourceDir=..\..
+-VersionInfoDescription=Mercurial distributed SCM
+-VersionInfoCopyright=Copyright 2005-2009 Matt Mackall and others
+-VersionInfoCompany=Matt Mackall and others
++AppPublisher=Tom Burdick and others
++AppPublisherURL=http://bitbucket.org/bfrog/cutehg-stable/wiki/Home
++AppSupportURL=http://bitbucket.org/bfrog/cutehg-stable/wiki/Home
++AppUpdatesURL=http://bitbucket.org/bfrog/cutehg-stable/wiki/Home
++AppID={{52E114B1-5806-4E75-9D7C-24369BDAACAF}
++AppContact=cutehg@googlegroups.com
++OutputBaseFilename=CuteHg-${version}
++DefaultDirName={pf}\CuteHg
++SourceDir=${path}
++VersionInfoDescription=Mercurial distributed SCM and CuteHg GUI
++VersionInfoCopyright=CuteHg Copyright (C) 2009 Tom Burdick, Mercurial Copyright 2005-2009 Matt Mackall and others
++VersionInfoCompany=Tom Burdick and others
+ InternalCompressLevel=max
+ SolidCompression=true
+ SetupIconFile=contrib\win32\mercurial.ico
+ AllowNoIcons=true
+-DefaultGroupName=Mercurial
+-PrivilegesRequired=none
++DefaultGroupName=CuteHg
++PrivilegesRequired=poweruser
++SetupLogging=yes
+ 
+ [Files]
+ Source: contrib\mercurial.el; DestDir: {app}/Contrib
+@@ -49,15 +50,23 @@
+ Source: templates\*.*; DestDir: {app}\Templates; Flags: recursesubdirs createallsubdirs
+ Source: CONTRIBUTORS; DestDir: {app}; DestName: Contributors.txt
+ Source: COPYING; DestDir: {app}; DestName: Copying.txt
++Source: dist\*.exe; DestDir: {app}; Flags: ignoreversion restartreplace uninsrestartdelete
++Source: dist\*.dll; DestDir: {app}; Flags: ignoreversion restartreplace uninsrestartdelete
++Source: dist\*.pyd; DestDir: {app}; Flags: ignoreversion restartreplace uninsrestartdelete
++Source: dist\tortoiseoverlays-win32.msi; DestDir: {app}
++Source: dist\tortoiseoverlays-x64.msi; DestDir: {app}
+ 
+ [INI]
++Filename: {app}\CuteHg.url; Section: InternetShortcut; Key: URL; String: http://bitbucket.org/bfrog/cutehg-stable/wiki/Home
+ Filename: {app}\Mercurial.url; Section: InternetShortcut; Key: URL; String: http://www.selenic.com/mercurial/
+ 
+ [UninstallDelete]
++Type: files; Name: {app}\CuteHg.url
+ Type: files; Name: {app}\Mercurial.url
+ 
+ [Icons]
+-Name: {group}\Uninstall Mercurial; Filename: {uninstallexe}
++Name: {group}\Uninstall CuteHg; Filename: {uninstallexe}
++Name: {group}\CuteHg Web Site; Filename: {app}\CuteHg.url
+ Name: {group}\Mercurial Command Reference; Filename: {app}\Docs\hg.1.html
+ Name: {group}\Mercurial Configuration Files; Filename: {app}\Docs\hgrc.5.html
+ Name: {group}\Mercurial Ignore Files; Filename: {app}\Docs\hgignore.5.html
+@@ -65,12 +74,27 @@
+ 
+ [Run]
+ Filename: "{app}\add_path.exe"; Parameters: "{app}"; Flags: postinstall; Description: "Add the installation path to the search path"
++; Only on 32 bit
++Filename: msiexec.exe; Parameters: "/i ""{app}\tortoiseoverlays-win32.msi"" /qn /norestart ALLUSERS=1"; StatusMsg: Installing TortoiseOverlays.dll ...; Check: Is32BitInstallMode
++Filename: regsvr32.exe; Parameters: "/s ""{app}\cutehg-32.dll"""; StatusMsg: Installing shell extension...; Check: Is32BitInstallMode
++; Only on 64 bit
++Filename: msiexec.exe; Parameters: "/i ""{app}\tortoiseoverlays-x64.msi"" /qn /norestart ALLUSERS=1"; StatusMsg: Installing TortoiseOverlays.dll ...; Check: Is64BitInstallMode
++Filename: regsvr32.exe; Parameters: "/s ""{app}\cutehg-64.dll"""; StatusMsg: Installing shell extension...; Check: Is64BitInstallMode
+ 
+ [UninstallRun]
+ Filename: "{app}\add_path.exe"; Parameters: "/del {app}"
++; Only on 32 bit
++Filename: regsvr32.exe; Parameters: "/s /u ""{app}\cutehg-32.dll"""; Check: Is32BitInstallMode
++; Only on 64 bit
++Filename: regsvr32.exe; Parameters: "/s /u ""{app}\cutehg-64.dll"""; Check: Is64BitInstallMode
+ 
+ [UninstallDelete]
+ Type: files; Name: "{app}\hg.exe.local"
++
++[Registry]
++Root: HKLM; Subkey: Software\CuteHg; Flags: uninsdeletekey; ValueData: {app}
++Root: HKLM; Subkey: Software\Mercurial; Flags: uninsdeletekey; ValueData: {app}\Mercurial.ini
++
+ [Code]
+ var
+   WriteFile: Boolean;
+@@ -101,3 +125,11 @@
+ begin
+   SaveStringToFile(ExpandConstant(fn), '', False);
+ end;
++
++function Is32BitInstallMode(): Boolean;
++begin
++    if Is64BitInstallMode() then
++        Result := False
++    else
++        Result := True;
++end;

File installer/hg-patches/series

 cutehg-setup-fixes
+cutehg-modify-installer-data
+cutehg-installer-no-locales
+cutehg-extension
     bdist_msi = None
     bdist_wininst = None
 
+version = '0.0.3'
+
 def needsupdate(src, targ):
     return not os.path.exists(targ) or os.path.getmtime(src) > os.path.getmtime(targ)
 
 
 msvcpdll = 'msvcp90.dll'
 
+def require_update(target, dependencies):
+    from os.path import join, exists, getmtime
+    if not exists(target):
+        return True
+    mtime = getmtime(target)
+    for dep in dependencies:
+        if not exists(dep):
+            raise IOError("File %s does not exist, cannot check mtime dependencies for %s" % (dep, target))
+        if getmtime(dep) > mtime:
+            return True
+    return False
+
+class AsciiDoc(object):
+    executable = None
+    def __init__(self, executable):
+        self.executable = executable
+
+    def __call__(self, target, backend, cwd=None):
+        cmdline = self.executable + ['-b', backend, target]
+        print('asciidoc: ' + ' '.join(cmdline))
+        call(cmdline, cwd=cwd)
+
+    @staticmethod
+    def find_executable():
+        from os.path import join, exists, expandvars
+        locations = sys.path + [
+                sys.prefix,
+                ]
+        asciidoc = [join(expandvars(p), 'asciidoc.exe') for p in locations] + \
+                   [join(expandvars(p), 'asciidoc.bat') for p in locations] + \
+                   [join(expandvars(p), 'asciidoc.py') for p in locations]
+        env = os.environ.get('ASCIIDOC', None)
+        if env:
+            asciidoc = [env] + asciidoc
+        asciidoc = [p for p in asciidoc if exists(p)]
+        if not asciidoc:
+            raise distutils.errors.DistutilsExecError('Could not find asciidoc executable')
+        asciidoc = asciidoc[0]
+        if asciidoc.endswith('.py'):
+            return [sys.executable, asciidoc]
+        else:
+            return [asciidoc]
+
 # TODO: The build directory should be configurable
 # TODO: See if this command can be built differently, like NSIS
-class CuteHgBuildDist(build):
+class CuteHgPy2Exe(build):
     def run(self):
         try:
             import py2exe
         from os import getcwd
         from shutil import rmtree
 
+        # Find asciidoc executable
+        asciidoc = AsciiDoc(AsciiDoc.find_executable())
+
         # Run sub_commands to build cutehg
         build.run(self)
 
+        dist_path = join('build', 'hg-cutehg')
+
+        # TODO: Only seed to a given tag/rev
         hg('fseed', 'installer/devel.snap')
         hg('fpull', shortopts=['update'], opts={'snapfile': 'installer/devel.snap'})
 
             else:
                 raise distutils.errors.DistutilsExecError('Could not find ' + postdll)
 
-        # Make sure cutehg is enabled by default
-        # TODO: This is not enough, need to install this in the installer or modify any existing file when installing
-        copy_file('installer/mercurial-dist.ini', 'build/hg-cutehg/dist/mercurial.ini')
+        # Prepare HTML documentation
+        doc_path = join(dist_path, 'doc')
+        if require_update(join(doc_path, 'hg.1.gendoc.txt'), [join(dist_path, 'mercurial', name) for name in ('commands.py', 'help.py')]):
+            call([sys.executable, 'gendoc.py'], stdout=open(join(doc_path, 'hg.1.gendoc.txt'), 'w'), cwd=doc_path)
+        for doc in (e for e in os.listdir(doc_path) if e.endswith('.txt')):
+            html = join(doc_path, doc[:-4] + '.html')
+            if require_update(html, (join(doc_path, doc), join(doc_path, 'hg.1.gendoc.txt'))):
+                asciidoc(doc, 'html4', cwd=doc_path)
 
     sub_commands = build.sub_commands
 
-class CuteHgBdistNSIS(Command):
+class CuteHgBdistIntaller(Command):
     description = "create an executable installer for MS Windows using NSIS"
 
     user_options = [('dist-dir=', 'd',
 
     def run(self):
         from os.path import join, exists, expandvars
-        
-        nsis = sys.path + [
-                '%SystemDrive%/Program Files/NSIS/',
-                ]
-    
-        nsis = map(lambda p: join(expandvars(p), 'makensis.exe'), nsis)
-        nsis = [p for p in nsis if exists(p)]
-    
-        if len(nsis) == 0:
-            raise distutils.errors.DistutilsExecError('Could not find NSIS executable makensis.exe')
-
         if not self.skip_build:
-            self.run_command('build_dist')
+            self.run_command('py2exe')
 
         if not exists('build/hg-cutehg'):
             raise distutils.errors.DistutilsFileError('Build directory %s was not found, cutehg has most likely not been built' % 'build/hg-cutehg')
         # Make the installer
         if not exists(self.dist_dir):
             os.makedirs(self.dist_dir)
+
+class CuteHgBdistNSIS(CuteHgBdistIntaller):
+    description = "create an executable installer for MS Windows using NSIS"
+
+    def run(self):
+        from os.path import join, exists, expandvars
+        nsis = sys.path + [
+                '%ProgramFiles%/NSIS',
+                '%SystemDrive%/Program Files/NSIS/',
+                ]
+        nsis = [join(expandvars(p), 'makensis.exe') for p in nsis]
+        nsis = [p for p in nsis if exists(p)]
+    
+        if len(nsis) == 0:
+            raise distutils.errors.DistutilsExecError('Could not find NSIS executable makensis.exe')
+
+        CuteHgBdistIntaller.run(self)
+
         # TODO: Fix location of built installer, should be in dist_dir
         #log.info("creating the installer in %s", self.dist_dir)
         log.info("creating the installer")
         call([nsis[0], '/V4', '/NOCD', 'installer/cutehg.nsi'])
 
+class CuteHgBdistISS(CuteHgBdistIntaller):
+    description = "create an executable installer for MS Windows using Inno Setup"
+
+    def run(self):
+        from os.path import join, exists, expandvars
+        iscc = sys.path + [
+                '%ProgramFiles%/Inno Setup 5',
+                '%SystemDrive%/Program Files/Inno Setup 5',
+                ]
+        iscc = [join(expandvars(p), 'iscc.exe') for p in iscc]
+        iscc = [p for p in iscc if exists(p)]
+        if not iscc:
+            raise distutils.errors.DistutilsExecError('Could not find iscc.exe')
+
+        CuteHgBdistIntaller.run(self)
+
+        build_path = join('build', 'hg-cutehg')
+        dist_path = join(build_path, 'dist')
+
+        # Copy some files required by the installer
+        log.info('copying dlls/exes required by installer')
+        for installer_file in ('mfc71.dll', 'msvcr71.dll', 'add_path.exe'):
+            if exists(installer_file):
+                copy_file(installer_file, join(dist_path, installer_file))
+            else:
+                raise distutils.errors.DistutilsExecError('Could not find ' + installer_file)
+
+        # Creating the .iss file
+        iss_file = join('contrib', 'win32', 'mercurial.iss')
+        iss = join('dist', 'mercurial.iss')
+        log.info("preparing installer: %s" % iss)
+        from string import Template
+        t = Template(open(join(build_path, iss_file), "rb").read())
+        out = t.safe_substitute(version=version, path='..')
+        open(join(build_path, iss), "wb").write(out)
+
+        # Build installer with Inno Setup
+        log.info("creating installer using Inno Setup")
+        cmdline = [iscc[0], iss]
+        log.info(' '.join(cmdline))
+        call(cmdline, cwd=build_path)
+
+        # Copy it to the root
+        log.info("copying installer to current directory")
+        copy_file(join(build_path, 'Output', 'CuteHg-%s.exe' % version), 'CuteHg-%s.exe' % version)
+
 def MakeWinBdist(bdist_base):
     class bdist_win(bdist_base):
         def initialize_options(self):
 cmds = {
         'build' : CuteHgBuild,
         'build_winext' : build_winext,
-        'build_dist' : CuteHgBuildDist,
+        'py2exe' : CuteHgPy2Exe,
        }
 
 if bdist_wininst:
     cmds['bdist_wininst'] = CuteHgWinInst
     cmds['bdist_msi'] = CuteHgWinMsi
     cmds['bdist_nsis'] = CuteHgBdistNSIS
+    cmds['bdist_iss'] = CuteHgBdistISS
 
 
 distutils.core.setup(
     name='cutehg',
-    version='0.0.3',
+    version=version,
     description='Qt4 Dialog extension to Mercurial',
     author="Tom Burdick",
     author_email='thomas.burdick@gmail.com',