@@ -1725,5 +1725,96 @@ ClassMethod GetSourceControlInclude() As %String
17251725 1 : " " )
17261726}
17271727
1728+ ClassMethod BuildCEInstallationPackage (ByRef destination As %String ) As %Status
1729+ {
1730+ #define sourcedir $System .Util .InstallDirectory ()_" devuser/studio/templates/gitsourcecontrol/"
1731+ #define sourcedirstr ##Quote ($$$sourcedir )
1732+ #define exportGBLString " GitSourceControlProjectExport"
1733+ #define exportGBLDoc $$$exportGBLString _" .GBL"
1734+ #define exportGBL ##Expression (" ^||" _$$$exportGBLString )
1735+ #define exportGBLName $Name ($$$exportGBL )
1736+ #define exportGBLNameQ ##Quote (" ^||" _$$$exportGBLString )
1737+
1738+ new %sourcedirstr
1739+ set sc = $$$OK
1740+ try {
1741+ set projectName = " GitSourceControl_CE"
1742+
1743+ // Main project
1744+ set destination = $Get (destination ,##class (%Library.File ).NormalizeFilename (projectName _" .xml" ))
1745+ if ##class (%Studio.Project ).%ExistsId (projectName ) {
1746+ $$$ThrowOnError(##class (%Studio.Project ).%DeleteId (projectName ))
1747+ }
1748+ set project = ##class (%Studio.Project ).%New ()
1749+ set project .Name = projectName
1750+ $$$ThrowOnError($System .OBJ .GetPackageList (.classes ," SourceControl.Git" ))
1751+ set key = " "
1752+ for {
1753+ set key = $Order (classes (key ))
1754+ quit :key =" "
1755+ $$$ThrowOnError(project .AddItem (key _" .CLS" ))
1756+ }
1757+ $$$ThrowOnError(project .AddItem (" SourceControl.Git.INC" ))
1758+ $$$ThrowOnError(project .AddItem (" %ZPM.PackageManager.Core.Singleton.CLS" ))
1759+
1760+ // /isc/studio/usertemplates project
1761+ set sourcedir = ##class (%Library.File ).NormalizeDirectory ($$$sourcedir)
1762+ set archive = ##class (%ZPM.PackageManager.Core.XDataArchive ).%New (sourcedir )
1763+ do archive .AddToProject (project )
1764+
1765+ kill $$$exportGBL
1766+ $$$ThrowOnError(project .ExportToStream (" /exportversion=2016.2/diffexport" ,0 ))
1767+ Set gblStream = ##class (%Stream.GlobalCharacter ).%New ($$$exportGBLName)
1768+ $$$ThrowOnError(gblStream .CopyFromAndSave (project .Stream ))
1769+
1770+ // Installer automation
1771+ set code ($i (code )) = " #include %occInclude"
1772+ set code ($i (code )) = " Set stream = ##class(%Stream.GlobalCharacter).%Open($ListBuild(1," " " " ," _$$$exportGBLNameQ_" ),,.sc)"
1773+ set code ($i (code )) = " $$$ThrowOnError(sc)"
1774+ set code ($i (code )) = " $$$ThrowOnError($System.OBJ.LoadStream(stream," " ck" " ))"
1775+ do archive .GenerateInstallerCode ($$$sourcedirstr,.code )
1776+ set code ($i (code )) = " Do ##class(SourceControl.Git.Utils).Localize()"
1777+ set code ($i (code )) = " Write !!"
1778+ set code ($i (code )) = " Do ##class(SourceControl.Git.Utils).OutputConfigureMessage()"
1779+
1780+ // Wrapper project
1781+ if ##class (%Studio.Project ).%ExistsId (projectName _" Wrapper" ) {
1782+ $$$ThrowOnError(##class (%Studio.Project ).%DeleteId (projectName _" Wrapper" ))
1783+ }
1784+ set wrapper = ##class (%Studio.Project ).%New ()
1785+ set wrapper .Name = projectName _" Wrapper"
1786+
1787+ // Export of main project
1788+ do wrapper .AddItem ($$$exportGBLDoc)
1789+
1790+ // Installer routine
1791+ if ##class (%Library.Routine ).Exists (" INSTALL.MAC" ) {
1792+ $$$ThrowOnError(##class (%Library.Routine ).Delete (" INSTALL.MAC" ))
1793+ }
1794+ set routine = ##class (%Routine ).%New (" INSTALL.MAC" )
1795+ for i =1 :1 :code {
1796+ do routine .WriteLine (" " _code (i ))
1797+ }
1798+ $$$ThrowOnError(routine .Save ())
1799+ $$$ThrowOnError(routine .Compile (" -d" ))
1800+ do wrapper .AddItem (" INSTALL.MAC" )
1801+
1802+ // Deploy to a file
1803+ $$$ThrowOnError(wrapper .%Save ())
1804+ kill ^||%pkg
1805+ set minVersion = " 2016.2"
1806+ set spec = " /keepsource/exportversion=" _minVersion _" /diffexport"
1807+ $$$ThrowOnError(wrapper .Deploy (" " ,spec ,,," ^||%pkg" ,0 ))
1808+ set ^||%pkg (" VERSION" ) = minVersion
1809+ $$$ThrowOnError($$ExportXMLList ^%apiOBJ (" ^||%pkg.gbl" ,destination ,spec ))
1810+ } catch e {
1811+ set sc = e .AsStatus ()
1812+ }
1813+ if $$$ISERR(sc ) && '$quit {
1814+ write !,$System .Status .GetErrorText (sc )
1815+ }
1816+ quit sc
1817+ }
1818+
17281819}
17291820
0 commit comments