Browse Source

Add [ISSigKeys] Group parameter.

Martijn Laan 4 months ago
parent
commit
7840e44c1f

+ 6 - 1
ISHelp/isetup.xml

@@ -2799,10 +2799,15 @@ Name: "MyKey2; \
 <paramlist>
 
 <param name="Name" required="yes">
-<p>The internal name of the key, which you can set to anything you like.</p>
+<p>The internal name of the key.</p>
 <example><pre>Name: "MyKey"</pre></example>
 </param>
 
+<param name="Group">
+<p>A space separated list of internal group names, specifying how to group the key.</p>
+<example><pre>Group: "exesigner docsigner"</pre></example>
+</param>
+
 <param name="KeyID">
 <p>Specifies the ID of the key. If specified, the compiler uses it to double check the values of parameters <tt>KeyFile</tt>, <tt>PublicX</tt>, and <tt>PublicY</tt>.</p>
 <example><pre>KeyID: "def0147c3bbc17ab99bf7b7a9c2de1390283f38972152418d7c2a4a7d7131a38"</pre></example>

+ 3 - 2
Projects/Src/Compiler.Messages.pas

@@ -249,8 +249,9 @@ const
     'It may only include alphanumeric characters, underscores, slashes (/), and/or backslashes (\), may not start with a number and may not start or end with a slash or a backslash. Names ''not'', ''and'' and ''or'' are reserved';
   SCompilerComponentsInvalidLevel = 'Component cannot be more than one level below the preceding component';
   SCompilerTasksInvalidLevel = 'Task cannot be more than one level below the preceding task';
-  SCompilerLanguagesOrISSigKeysBadName = 'Parameter "Name" includes invalid characters.' + SNewLine2 + 'It may only include alphanumeric characters and/or underscores, and may not start with a number. Names ''not'', ''and'' and ''or'' are reserved';
-  SCompilerISSigKeysNameDuplicated = 'Cannot have multiple entries named "%s"';
+  SCompilerLanguagesOrISSigKeysBadName = 'Parameter "%s" includes invalid characters.' + SNewLine2 + 'It may only include alphanumeric characters and/or underscores, and may not start with a number. Names ''not'', ''and'' and ''or'' are reserved';
+  SCompilerLanguagesOrISSigKeysBadGroupName = 'Parameter "%s" includes a name with invalid characters.' + SNewLine2 + 'Names may only include alphanumeric characters and/or underscores, and may not start with a number. Names ''not'', ''and'' and ''or'' are reserved';
+  SCompilerISSigKeysNameExists = 'Name "%s" is already in use"';
   SCompilerISSigKeysKeyNotSpecified = 'Required parameter(s) "KeyFile" or "PublicX"/"PublicY" not specified';
   SCompilerISSigKeysBadKeyID = 'Value of parameter "KeyID" is not valid for given "KeyFile" or "PublicX"/"PublicY" values.';
   SCompilerISSigKeysBadKeyFile = 'Key file is malformed';

+ 48 - 8
Projects/Src/Compiler.SetupCompiler.pas

@@ -314,6 +314,8 @@ type
   PISSigKeyEntryExtraInfo = ^TISSigKeyEntryExtraInfo;
   TISSigKeyEntryExtraInfo = record
     Name: String;
+    GroupNames: array of String;
+    function HasGroupName(const GroupName: String): Boolean;
   end;
 
   TFileLocationSign = (fsNoSetting, fsYes, fsOnce, fsCheck);
@@ -357,6 +359,16 @@ begin
   until (Result <> '') or (S = '');
 end;
 
+{ TISSigKeyEntryExtraInfo }
+
+function TISSigKeyEntryExtraInfo.HasGroupName(const GroupName: String): Boolean;
+begin
+  for var I := 0 to Length(GroupNames)-1 do
+    if SameText(GroupNames[I], GroupName) then
+      Exit(True);
+  Result := False;
+end;
+
 { TSetupCompiler }
 
 constructor TSetupCompiler.Create(AOwner: TComponent);
@@ -4476,16 +4488,30 @@ begin
 end;
 
 procedure TSetupCompiler.EnumISSigKeysProc(const Line: PChar; const Ext: Integer);
+
+  function ISSigKeysNameExists(const Name: String; const CheckGroupNames: Boolean): Boolean;
+  begin
+    for var I := 0 to ISSigKeyEntryExtraInfos.Count-1 do begin
+      var ISSigKeyEntryExtraInfo := PISSigKeyEntryExtraInfo(ISSigKeyEntryExtraInfos[I]);
+      if SameText(ISSigKeyEntryExtraInfo.Name, Name) or
+         (CheckGroupNames and ISSigKeyEntryExtraInfo.HasGroupName(Name)) then
+        Exit(True)
+    end;
+    Result := False;
+  end;
+
 type
-  TParam = (paName, paKeyFile, paKeyID, paPublicX, paPublicY);
+  TParam = (paName, paGroup, paKeyFile, paKeyID, paPublicX, paPublicY);
 const
   ParamISSigKeysName = 'Name';
+  ParamISSigKeysGroup = 'Group';
   ParamISSigKeysKeyFile = 'KeyFile';
   ParamISSigKeysKeyID = 'KeyID';
   ParamISSigKeysPublicX = 'PublicX';
   ParamISSigKeysPublicY = 'PublicY';
   ParamInfo: array[TParam] of TParamInfo = (
     (Name: ParamISSigKeysName; Flags: [piRequired, piNoEmpty]),
+    (Name: ParamISSigKeysGroup; Flags: []),
     (Name: ParamISSigKeysKeyFile; Flags: [piNoEmpty]),
     (Name: ParamISSigKeysKeyID; Flags: [piNoEmpty]),
     (Name: ParamISSigKeysPublicX; Flags: [piNoEmpty]),
@@ -4503,13 +4529,27 @@ begin
     NewISSigKeyEntryExtraInfo := AllocMem(SizeOf(TISSigKeyEntryExtraInfo));
     with NewISSigKeyEntryExtraInfo^ do begin
       { Name }
-      if not IsValidIdentString(Values[paName].Data, False, False) then
-        AbortCompile(SCompilerLanguagesOrISSigKeysBadName);
-      Name := LowerCase(Values[paName].Data);
-      for var I := 0 to ISSigKeyEntryExtraInfos.Count-1 do begin
-        var ISSigKeyEntryExtraInfo := PISSigKeyEntryExtraInfo(ISSigKeyEntryExtraInfos[I]);
-        if SameText(ISSigKeyEntryExtraInfo.Name, Name) then
-          AbortCompileFmt(SCompilerISSigKeysNameDuplicated, [Name]);
+      Name := Values[paName].Data;
+      if not IsValidIdentString(Name, False, False) then
+        AbortCompileFmt(SCompilerLanguagesOrISSigKeysBadName, [ParamISSigKeysName])
+      else if ISSigKeysNameExists(Name, True) then
+        AbortCompileFmt(SCompilerISSigKeysNameExists, [Name]);
+
+      { Group }
+      var S := Values[paGroup].Data;
+      while True do begin
+        const GroupName = ExtractStr(S, ' ');
+        if GroupName = '' then
+          Break;
+        if not IsValidIdentString(GroupName, False, False) then
+          AbortCompileFmt(SCompilerLanguagesOrISSigKeysBadGroupName, [ParamISSigKeysGroup])
+        else if SameText(Name, GroupName) or ISSigKeysNameExists(GroupName, False) then
+          AbortCompileFmt(SCompilerISSigKeysNameExists, [GroupName]);
+        if not HasGroupName(GroupName) then begin
+          const N = Length(GroupNames);
+          SetLength(GroupNames, N+1);
+          GroupNames[N] := GroupName;
+        end;
       end;
     end;
 

+ 1 - 1
Projects/Src/IDE.ScintStylerInnoSetup.pas

@@ -235,7 +235,7 @@ const
   ];
 
   ISSigKeysSectionParameters: array of TScintRawString = [
-    'Name', 'KeyFile', 'KeyID', 'PublicX', 'PublicY'
+    'Name', 'Group', 'KeyFile', 'KeyID', 'PublicX', 'PublicY'
   ];
 
   FilesSectionParameters: array of TScintRawString = [