* Merging revisions r44285 from trunk:

------------------------------------------------------------------------
    r44285 | michael | 2020-03-08 14:45:41 +0100 (Sun, 08 Mar 2020) | 1 line
    
    * Add category, support tags for package
    ------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@46577 -
This commit is contained in:
michael 2020-08-23 09:09:43 +00:00
parent d0e3fb0eb2
commit fe716c890b
3 changed files with 32 additions and 23 deletions

View File

@ -122,6 +122,8 @@ Const
SNodeDescription = 'description';
SNodeDependencies = 'dependencies';
SNodeDependency = 'dependency';
SNodeCategory = 'category';
SNodeSupport = 'support';
SNodeOSes = 'oses';
SNodeCPUS = 'cpus';
SNodeOS = 'os';
@ -153,9 +155,9 @@ ResourceString
function TFPXMLHandler.AddTextNode(Const NodeName,NodeContent : String; XML : TXMLDocument; Parent : TDomNode_WithChildren) : TDomElement;
begin
Result:=XML.CreateElement(NodeName);
Result:=XML.CreateElement(UTF8Decode(NodeName));
Try
Result.AppendChild(XML.CreateTextNode(NodeContent));
Result.AppendChild(XML.CreateTextNode(UTF8Decode(NodeContent)));
If Assigned(Parent) then
Parent.AppendChild(Result);
Except
@ -179,14 +181,14 @@ end;
function TFPXMLHandler.FindNextElement(Start: TDomNode; NodeName: String): TDomElement;
begin
Result:=GetNextElement(Start);
While (Result<>Nil) and (Result.NodeName<>NodeName) do
While (Result<>Nil) and (Result.NodeName<>UTF8Decode(NodeName)) do
Result:=GetNextElement(Result.NextSibling);
end;
procedure TFPXMLHandler.CheckNodeType(E : TDomElement; NodeName : String);
begin
If (E.NodeName<>NodeName) then
If (E.NodeName<>UTF8Decode(NodeName)) then
Raise EXMLPackage.CreateFmt(SErrInvalidXMLDocument,[NodeName,E.NodeName]);
end;
@ -199,7 +201,7 @@ begin
While (N<>Nil) and (N.NodeType<>TEXT_NODE) do
N:=N.NextSibling;
If (N<>Nil) then
Result:=N.NodeValue
Result:=UTF8Encode(N.NodeValue)
else
Result:='';
end;
@ -217,13 +219,13 @@ begin
Parent:=XML;
Parent.AppendChild(Result);
if V.Major > -1 then
Result[SAttrMajor]:=IntToStr(V.Major);
Result[SAttrMajor]:=UTF8Decode(IntToStr(V.Major));
if V.Minor > -1 then
Result[SAttrMinor]:=IntToStr(V.Minor);
Result[SAttrMinor]:=UTF8Decode(IntToStr(V.Minor));
if V.Micro > -1 then
Result[SAttrMicro]:=IntToStr(V.Micro);
Result[SAttrMicro]:=UTF8Decode(IntToStr(V.Micro));
if V.Build > -1 then
Result[SAttrBuild]:=IntToStr(V.Build);
Result[SAttrBuild]:=UTF8Decode(IntToStr(V.Build));
except
Parent.RemoveChild(Result);
Result.Free;
@ -242,7 +244,7 @@ begin
Parent:=XML;
Parent.AppendChild(Result);
E:=XML.CreateElement(SNodePackage);
E[SAttrPackageName]:=D.PackageName;
E[SAttrPackageName]:=UTF8Decode(D.PackageName);
Result.AppendChild(E);
if not D.MinVersion.Empty then
VersionToXML(D.MinVersion,XML,Result);
@ -291,7 +293,7 @@ begin
If (O in OSes) then
begin
ES:=XML.CreateElement(SNodeOS);
ES[SAttrName]:=GetEnumName(TypeInfo(TOS),Ord(O));
ES[SAttrName]:=UTF8Decode(GetEnumName(TypeInfo(TOS),Ord(O)));
Result.AppendChild(ES);
end;
end;
@ -308,7 +310,7 @@ begin
If (C in CPUs) then
begin
ES:=XML.CreateElement(SNodeCPU);
ES[SAttrName]:=GetEnumName(TypeInfo(TCPU),Ord(C));
ES[SAttrName]:=UTF8Decode(GetEnumName(TypeInfo(TCPU),Ord(C)));
Result.AppendChild(ES);
end;
end;
@ -321,7 +323,7 @@ begin
If Not Assigned(Parent) then
Parent:=XMl;
Parent.AppendChild(Result);
Result[SAttrName]:=P.Name;
Result[SAttrName]:=UTF8Decode(P.Name);
// Version
VersionToXML(P.Version,XML,Result);
AddTextNode(SNodeAuthor,P.Author,XML,Result);
@ -331,6 +333,8 @@ begin
AddTextNode(SNodeEmail,P.Email,XML,Result);
AddTextNode(SNodeDescription,P.Description,XML,Result);
AddTextNode(SNodeLicense,P.License,XML,Result);
AddTextNode(SNodeCategory,P.Category,XML,Result);
AddTextNode(SNodeSupport,P.Support,XML,Result);
if P.OSes<>AllOSes then
OSesToXML(P.OSes,XML,Result);
if P.CPUs<>AllCPUs then
@ -543,7 +547,7 @@ procedure TFPXMLRepositoryHandler.DoXMLToVersion(E: TDomElement; V: TFPVersion);
var
i: Longint;
begin
if TryStrToInt(E[AttrName], i) then
if TryStrToInt(UTF8Encode(E[UTF8Decode(AttrName)]), i) then
Result := Abs(i)
else
Result := -1;
@ -572,7 +576,7 @@ begin
While (N<>Nil) do
begin
if (N.NodeName=sNodePackage) then
D.PackageName:=N[SAttrPackageName]
D.PackageName:=UTF8Encode(N[SAttrPackageName])
else if (N.NodeName=sNodeVersion) then
DoXMlToVersion(N,D.MinVersion)
else if (N.NodeName=sNodeOSes) then
@ -629,7 +633,7 @@ begin
E:=FindNextElement(N.FirstChild,SNodeOS);
While (E<>Nil) do
begin
J:=GetEnumValue(TypeInfo(TOS),E[SAttrName]);
J:=GetEnumValue(TypeInfo(TOS),UTF8Encode(E[SAttrName]));
If (J<>-1) then
Include(Result,TOS(J));
E:=FindNextElement(E.NextSibling,SNodeOS);
@ -646,7 +650,7 @@ begin
E:=FindNextElement(N.FirstChild,SNodeCPU);
While (E<>Nil) do
begin
J:=GetEnumValue(TypeInfo(TCPU),E[SAttrName]);
J:=GetEnumValue(TypeInfo(TCPU),UTF8Encode(E[SAttrName]));
If (J<>-1) then
Include(Result,TCPU(J));
E:=FindNextElement(E.NextSibling,SNodeCPU);
@ -658,7 +662,7 @@ procedure TFPXMLRepositoryHandler.DoXMLToPackage(E: TDomElement; P: TFPPackage);
Var
N : TDomElement;
begin
P.Name:=E[sAttrName];
P.Name:=UTF8Encode(E[sAttrName]);
N:=GetNextElement(E.FirstChild);
While (N<>Nil) do
begin
@ -682,8 +686,12 @@ begin
P.OSes:=DoXMLToOSes(N)
else if (N.NodeName=sNodeCPUS) then
P.CPUs:=DoXMLToCPUs(N)
else if (N.NodeName=sNodeSupport) then
P.Support:=NodeText(N)
else if (N.NodeName=sNodeDependencies) then
DoXMlToDependencies(N,P.Dependencies)
else if (N.NodeName=sNodeCategory) then
P.Category:=NodeText(N)
else if Not IgnoreUnknownNodes then
Raise EXMLPackage.CreateFmt(SErrUnknownNode,[N.NodeName,sNodePackage,P.Name]);
N:=GetNextElement(N.NextSibling);
@ -887,7 +895,7 @@ procedure TFPXMLMirrorHandler.DoXMLToMirror(E: TDomElement; P: TFPMirror);
Var
N : TDomElement;
begin
P.Name:=E[sAttrName];
P.Name:=UTF8Encode(E[sAttrName]);
N:=GetNextElement(E.FirstChild);
While (N<>Nil) do
begin

View File

@ -173,11 +173,11 @@ begin
else
begin
// Now try if a local config-file exists
cfgfile:=GetFppkgConfigFile(False,False);
cfgfile:=GetFppkgConfigFile(Options.PreferGlobal,False);
if not FileExists(cfgfile) then
begin
// If not, try to find a global configuration file
cfgfile:=GetFppkgConfigFile(True,False);
cfgfile:=GetFppkgConfigFile(not Options.PreferGlobal,False);
if not FileExists(cfgfile) then
begin
// Create a new configuration file

View File

@ -196,6 +196,7 @@ Type
TFppkgOptions = class(TPersistent)
private
FOptionParser: TTemplateParser;
FPreferGlobal: Boolean;
FSectionList: TFppkgOptionSectionList;
function GetCommandLineSection: TFppkgCommandLineOptionSection;
function GetGlobalSection: TFppkgGLobalOptionSection;
@ -213,7 +214,7 @@ Type
procedure AddRepositoriesForCompilerSettings(ACompilerOptions: TCompilerOptions);
function AddRepositoryOptionSection(ASectionClass: TFppkgRepositoryOptionSectionClass): TFppkgRepositoryOptionSection;
function AddIncludeFilesOptionSection(AFileMask: string): TFppkgIncludeFilesOptionSection;
property PreferGlobal : Boolean Read FPreferGlobal Write FPreferGLobal;
property SectionList: TFppkgOptionSectionList read GetSectionList;
property GlobalSection: TFppkgGLobalOptionSection read GetGlobalSection;
property CommandLineSection: TFppkgCommandLineOptionSection read GetCommandLineSection;
@ -806,7 +807,7 @@ begin
end;
end;
constructor TFppkgOptions.Create;
constructor TFppkgOptions.Create();
begin
FOptionParser := TTemplateParser.Create;
FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);