# # # add_file "win32/modpath.iss" # content [d55bca4b6e07ae144b1c0116e9198285605f618c] # # patch "ChangeLog" # from [003181516027541ad97157861b75c0b964431807] # to [05f119e992054b90f33144ef2d6e784914da5f7c] # # patch "win32/monotone.iss" # from [b7beb799e4fde0a2450b913c19ba45dcd1da5fbe] # to [b92fb67169cf630a02bf0c07d04b7def0b26869f] # ============================================================ --- win32/modpath.iss d55bca4b6e07ae144b1c0116e9198285605f618c +++ win32/modpath.iss d55bca4b6e07ae144b1c0116e9198285605f618c @@ -0,0 +1,138 @@ +// ---------------------------------------------------------------------------- +// +// Inno Setup Ver: 5.1.5 +// Script Version: 1.2.2 +// Author: Jared Breland +// Homepage: http://www.legroom.net/mysoft +// +// Script Function: +// Enable modification of system path directly from Inno Setup packages +// +// Instructions: +// Copy modpath.iss to the same directory as your setup script +// +// Add this statement to your [Setup] section: +// ChangesEnvironment=true +// +// Add the following [Task] (you can change the Description, but the Name must be modifypath) +// Name: modifypath; Description: &Add application directory to your system path; Flags: unchecked +// +// Add the following to the end of your [Code] section +// Result should be set to the path that you want to add +// function ModPathDir(): String; +// begin +// Result := ExpandConstant('{app}'); +// end; +// #include "modpath.iss" +// +// ---------------------------------------------------------------------------- + +procedure ModPath(); +var + oldpath: String; + newpath: String; + pathArr: TArrayOfString; + aExecFile: String; + aExecArr: TArrayOfString; + i: Integer; + pathdir: String; +begin + pathdir := ModPathDir(); + // Modify WinNT path + if UsingWinNT() = true then begin + + // Get current path, split into an array + RegQueryStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', oldpath); + oldpath := oldpath + ';'; + i := 0; + while (Pos(';', oldpath) > 0) do begin + SetArrayLength(pathArr, i+1); + pathArr[i] := Copy(oldpath, 0, Pos(';', oldpath)-1); + oldpath := Copy(oldpath, Pos(';', oldpath)+1, Length(oldpath)); + i := i + 1; + + // Check if current directory matches app dir + if pathdir = pathArr[i-1] then begin + // if uninstalling, remove dir from path + if IsUninstaller() = true then begin + continue; + // if installing, abort because dir was already in path + end else begin + abort; + end; + end; + + // Add current directory to new path + if i = 1 then begin + newpath := pathArr[i-1]; + end else begin + newpath := newpath + ';' + pathArr[i-1]; + end; + end; + + // Append app dir to path if not already included + if IsUninstaller() = false then + newpath := newpath + ';' + pathdir; + + // Write new path + RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', 'Path', newpath); + + // Modify Win9x path + end else begin + + // Convert to shortened dirname + pathdir := GetShortName(pathdir); + + // If autoexec.bat exists, check if app dir already exists in path + aExecFile := 'C:\AUTOEXEC.BAT'; + if FileExists(aExecFile) then begin + LoadStringsFromFile(aExecFile, aExecArr); + for i := 0 to GetArrayLength(aExecArr)-1 do begin + if IsUninstaller() = false then begin + // If app dir already exists while installing, abort add + if (Pos(pathdir, aExecArr[i]) > 0) then + abort; + end else begin + // If app dir exists and = what we originally set, then delete at uninstall + if aExecArr[i] = 'SET PATH=%PATH%;' + pathdir then + aExecArr[i] := ''; + end; + end; + end; + + // If app dir not found, or autoexec.bat didn't exist, then (create and) append to current path + if IsUninstaller() = false then begin + SaveStringToFile(aExecFile, #13#10 + 'SET PATH=%PATH%;' + pathdir, True); + + // If uninstalling, write the full autoexec out + end else begin + SaveStringsToFile(aExecFile, aExecArr, False); + end; + end; + + // Write file to flag modifypath was selected + // Workaround since IsTaskSelected() cannot be called at uninstall and AppName and AppId cannot be "read" in Code section + if IsUninstaller() = false then + SaveStringToFile(ExpandConstant('{app}') + '\uninsTasks.txt', WizardSelectedTasks(False), False); +end; + +procedure CurStepChanged(CurStep: TSetupStep); +begin + if CurStep = ssPostInstall then + if IsTaskSelected('modifypath') then + ModPath(); +end; + +procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep); +var + appdir: String; + selectedTasks: String; +begin + appdir := ExpandConstant('{app}') + if CurUninstallStep = usUninstall then begin + if LoadStringFromFile(appdir + '\uninsTasks.txt', selectedTasks) then + if Pos('modifypath', selectedTasks) > 0 then + ModPath(); + DeleteFile(appdir + '\uninsTasks.txt') + end; +end; ============================================================ --- ChangeLog 003181516027541ad97157861b75c0b964431807 +++ ChangeLog 05f119e992054b90f33144ef2d6e784914da5f7c @@ -1,3 +1,11 @@ +2006-05-28 Matthew Gregan + + * win32/monotone.iss: First pass at rewriting InnoSetup file for + modern versions of IS. + + * win32/modpath.iss: Add Jared Breland's GPL-licensed IS script + for portable %PATH% modification. + 2006-05-27 Matthew Gregan * {unix,win32}/os_strerror.cc, platform.hh: Add OS-specific ============================================================ --- win32/monotone.iss b7beb799e4fde0a2450b913c19ba45dcd1da5fbe +++ win32/monotone.iss b92fb67169cf630a02bf0c07d04b7def0b26869f @@ -1,36 +1,40 @@ [Setup] AppName=monotone +AppVersion=0.26 AppVerName=monotone 0.26 +OutputBaseFileName=monotone-0.26-setup AppCopyright=Copyright © 2002-2006 Graydon Hoare et al. +AppPublisher=venge.net +AppPublisherURL=http://venge.net/monotone DefaultDirName={pf}\monotone DefaultGroupName=monotone MinVersion=4.0,4.0 OutputDir=. -OutputBaseFileName=monotone-setup AllowNoIcons=1 -AppPublisher=venge.net -AppPublisherURL=http://venge.net/monotone -AppVersion=0.26 -Compression=lzma/ultra +Compression=lzma/fast SolidCompression=yes LicenseFile="..\COPYING" +ChangesEnvironment=true [Files] -Source: "..\mtn.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "..\html\*.*"; DestDir: "{app}\documentation"; Flags: ignoreversion +Source: "..\..\monotone.release\mtn.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\..\monotone.release\html\*.*"; DestDir: "{app}\documentation"; Flags: ignoreversion Source: "..\COPYING"; DestDir: "{app}"; Flags: ignoreversion +Source: "..\..\monotone.release\figures\*.png"; DestDir: "{app}\documentation\figures"; Flags: ignoreversion Source: "\mingw\bin\libiconv-2.dll"; DestDir: "{app}" Source: "\mingw\bin\zlib1.dll"; DestDir: "{app}" -Source: "..\figures\*.png"; DestDir: "{app}\documentation\figures"; Flags: ignoreversion [Tasks] Name: initdb; Description: "Initialise a new database"; GroupDescription: "Get up and running"; Check: DBDoesntExist Name: initdb\genkey; Description: "Generate a key for use with monotone"; GroupDescription: "Get up and running"; Check: DBDoesntExist +Name: initdb\createws; Description: "Create an initial workspace"; GroupDescription: "Get up and running"; Check: DBDoesntExist +Name: modifypath; Description: "Add monotone to your path"; GroupDescription: "Get up and running"; Flags: unchecked Name: viewdocs; Description: "View the monotone documentation"; GroupDescription: "Get up and running" [Run] Filename: "{app}\mtn.exe"; Tasks: initdb; StatusMsg: "Initialising database..."; WorkingDir: "{app}"; Parameters: "--db=""{code:ForceDBPath|monotone.mtn}"" db init" Filename: "{app}\mtn.exe"; Tasks: initdb\genkey; StatusMsg: "Generating key..."; Flags: hidewizard; WorkingDir: "{app}"; Parameters: "--db=""{code:ForceDBPath|monotone.mtn}"" genkey {code:GetKeyID}" +Filename: "{app}\mtn.exe"; Tasks: initdb\createws; StatusMsg: "Creating inital workspace..."; WorkingDir: "{app}"; Parameters: "--db=""{code:ForceDBPath|monotone.mtn}"" --branch=""{code:GetBranchName}"" setup ""{code:GetWorkspacePath}""" Filename: "{app}\documentation\index.html"; Tasks: viewdocs; Flags: shellexec nowait; WorkingDir: "{app}\documentation" [Icons] @@ -42,7 +46,8 @@ var DBChecked : Boolean; DBDidntExist : Boolean; - KeyID : String; + KeyIDPage : TInputQueryWizardPage; + BranchWorkspacePage : TInputQueryWizardPage; function InitializeSetup(): Boolean; begin @@ -61,9 +66,19 @@ function GetKeyID(Default: String) : String; begin - Result := KeyID; + Result := KeyIDPage.Values[0]; end; +function GetBranchName(Default: String) : String; +begin + Result := BranchWorkspacePage.Values[0]; +end; + +function GetWorkspacePath(Default: String) : String; +begin + Result := BranchWorkspacePage.Values[1]; +end; + function DBDoesntExist() : Boolean; var path: String; @@ -86,42 +101,34 @@ Result := path + db; end; -function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean; -var - Next: Boolean; +procedure InitializeWizard; begin - if (ShouldProcessEntry('','initdb\genkey') = srYes) and ((not BackClicked and (CurPage = wpSelectTasks)) or (BackClicked and (CurPage = wpReady))) then begin - { Insert a custom wizard page between two non custom pages } - { First open the custom wizard page } - ScriptDlgPageOpen(); - { Set some captions } - ScriptDlgPageSetCaption('Key ID for use with monotone'); - ScriptDlgPageSetSubCaption1('Which e-mail address should your key be generated with?'); - ScriptDlgPageSetSubCaption2('Enter your chosen key ID (this is usually an e-mail address, sometimes a special one for monotone work), then click Next.'); - Next := InputQuery('Key ID / e-mail address:', KeyID); - while Next and (KeyID='') do begin - MsgBox('In order to generate a key, you must enter a Key ID', mbError, MB_OK); - Next := InputQuery('Key ID / e-mail address:', KeyID); - end; - { See NextButtonClick and BackButtonClick: return True if the click should be allowed } - if not BackClicked then - Result := Next - else - Result := not Next; - { Close the wizard page. Do a FullRestore only if the click (see above) is not allowed } - ScriptDlgPageClose(not Result); - end else begin - Result := true; - end; + KeyIDPage := CreateInputQueryPage(wpSelectTasks, 'Key ID', 'Key ID for use with monotone', + 'Which email address should your key be generated with?'); + KeyIDPage.Add('Key ID:', False); + + BranchWorkspacePage := CreateInputQueryPage(KeyIDPage.ID, 'Workspace initialisation', + 'Workspace path and branch name', + 'What branch name and workspace path would you' + + ' like to use for your initial workspace?'); + BranchWorkspacePage.Add('Branch name:', False); + BranchWorkspacePage.Add('Workspace path:', False); end; -function NextButtonClick(CurPage: Integer): Boolean; +function ShouldSkipPage(PageID: Integer): Boolean; begin - Result := ScriptDlgPages(CurPage, False); + if (IsTaskSelected('initdb\genkey') = False) and (PageID = KeyIDPage.ID) then + Result := True + else if (IsTaskSelected('initdb\createws') = False) and (PageID = BranchWorkspacePage.ID) then + Result := True + else + Result := False end; -function BackButtonClick(CurPage: Integer): Boolean; +function ModPathDir(): String; begin - Result := ScriptDlgPages(CurPage, True); + Result := ExpandConstant('{app}'); end; +#include "modpath.iss" +