* avail,scan commands added

* finished createarchive command, compresses still the whole source
    dir instead of using files from a specified input list

git-svn-id: trunk@7521 -
This commit is contained in:
peter 2007-05-29 20:56:59 +00:00
parent fe1131ae04
commit 88f2a0e53a
14 changed files with 431 additions and 227 deletions

1
.gitattributes vendored
View File

@ -8505,6 +8505,7 @@ utils/fppkg/pkgmessages.pp svneol=native#text/plain
utils/fppkg/pkgmkconv.pp svneol=native#text/plain utils/fppkg/pkgmkconv.pp svneol=native#text/plain
utils/fppkg/pkgocurl.pp svneol=native#text/plain utils/fppkg/pkgocurl.pp svneol=native#text/plain
utils/fppkg/pkgoptions.pp svneol=native#text/plain utils/fppkg/pkgoptions.pp svneol=native#text/plain
utils/fppkg/pkgrepos.pp svneol=native#text/plain
utils/fppkg/pkgsynapse.pp svneol=native#text/plain utils/fppkg/pkgsynapse.pp svneol=native#text/plain
utils/fppkg/pkgwget.pp svneol=native#text/plain utils/fppkg/pkgwget.pp svneol=native#text/plain
utils/fppkg/rep2xml.lpi svneol=native#text/plain utils/fppkg/rep2xml.lpi svneol=native#text/plain

View File

@ -908,12 +908,13 @@ Procedure TZipper.GetFileInfo;
Var Var
Info : TSearchRec; Info : TSearchRec;
I : Word; I : Longint;
NewNode : TZipItem; NewNode : TZipItem;
Begin Begin
For I := 0 to FFiles.Count-1 do For I := 0 to FFiles.Count-1 do
begin
If FindFirst(FFiles[I], STDATTR, Info)=0 then If FindFirst(FFiles[I], STDATTR, Info)=0 then
try try
NewNode:=TZipItem.Create; NewNode:=TZipItem.Create;
@ -925,6 +926,7 @@ Begin
finally finally
FindClose(Info); FindClose(Info);
end; end;
end;
end; end;
Procedure TZipper.OpenOutput; Procedure TZipper.OpenOutput;
@ -972,17 +974,20 @@ Begin
Crc32 := 0; Crc32 := 0;
Compressed_Size := 0; Compressed_Size := 0;
Uncompressed_Size := Item.Size; Uncompressed_Size := Item.Size;
FileName_Length := Length(Item.Name); FileName_Length := 0;
Extra_Field_Length := 0; Extra_Field_Length := 0;
end ; end ;
End; End;
Function TZipper.UpdateZipHeader(Item : TZipItem; FZip : TStream; ACRC : LongWord; AMethod : Word) : Boolean; Function TZipper.UpdateZipHeader(Item : TZipItem; FZip : TStream; ACRC : LongWord; AMethod : Word) : Boolean;
var
ZFileName : ShortString;
Begin Begin
ZFileName:=Item.Path+Item.Name;
With LocalHdr do With LocalHdr do
begin begin
FileName_Length := Length(ZFileName);
Compressed_Size := FZip.Size; Compressed_Size := FZip.Size;
Crc32 := ACRC; Crc32 := ACRC;
Compress_method:=AMethod; Compress_method:=AMethod;
@ -994,7 +999,7 @@ Begin
end; end;
end; end;
FOutFile.WriteBuffer(LocalHdr,SizeOf(LocalHdr)); FOutFile.WriteBuffer(LocalHdr,SizeOf(LocalHdr));
FOutFile.WriteBuffer(Item.Name[1],Length(Item.Name)); FOutFile.WriteBuffer(ZFileName[1],Length(ZFileName));
End; End;
@ -1064,7 +1069,7 @@ end;
Procedure TZipper.ZipOneFile(Item : TZipItem); Procedure TZipper.ZipOneFile(Item : TZipItem);
Var Var
CRC : Integer; CRC : LongWord;
ZMethod : Word; ZMethod : Word;
ZipStream : TStream; ZipStream : TStream;
TmpFileName : String; TmpFileName : String;
@ -1114,21 +1119,29 @@ Procedure TZipper.ZipAllFiles;
Var Var
Item : TZipItem; Item : TZipItem;
I : Integer; I : Integer;
filecnt : integer;
Begin Begin
if FFiles.Count=0 then
exit;
FZipping:=True; FZipping:=True;
Try Try
GetFileInfo; GetFileInfo;
OpenOutput; OpenOutput;
Try Try
filecnt:=0;
For I:=0 to FFiles.Count-1 do For I:=0 to FFiles.Count-1 do
begin begin
Item:=FFiles.Objects[i] as TZipItem; Item:=FFiles.Objects[i] as TZipItem;
ZipOneFile(Item); if assigned(Item) then
begin
ZipOneFile(Item);
inc(filecnt);
end;
end; end;
BuildZipDirectory; if filecnt>0 then
Finally BuildZipDirectory;
CloseOutput; finally
CloseOutput;
end; end;
finally finally
FZipping:=False; FZipping:=False;
@ -1357,7 +1370,9 @@ Begin
For I:=0 to FZipEntries.Count-1 do For I:=0 to FZipEntries.Count-1 do
begin begin
Item:=FZipEntries[i] as TZipItem; Item:=FZipEntries[i] as TZipItem;
UnZipOneFile(Item); if (FFiles=nil) or
(FFiles.IndexOf(Item.Name)<>-1) then
UnZipOneFile(Item);
end; end;
Finally Finally
CloseInput; CloseInput;

View File

@ -32,15 +32,15 @@
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<Units Count="36"> <Units Count="37">
<Unit0> <Unit0>
<Filename Value="fppkg.pp"/> <Filename Value="fppkg.pp"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="fppkg"/> <UnitName Value="fppkg"/>
<CursorPos X="41" Y="147"/> <CursorPos X="131" Y="33"/>
<TopLine Value="171"/> <TopLine Value="18"/>
<EditorIndex Value="0"/> <EditorIndex Value="0"/>
<UsageCount Value="73"/> <UsageCount Value="82"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit0> </Unit0>
<Unit1> <Unit1>
@ -49,61 +49,56 @@
<UnitName Value="pkgoptions"/> <UnitName Value="pkgoptions"/>
<CursorPos X="41" Y="18"/> <CursorPos X="41" Y="18"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="73"/> <UsageCount Value="82"/>
</Unit1> </Unit1>
<Unit2> <Unit2>
<Filename Value="fpmkcnst.inc"/> <Filename Value="fpmkcnst.inc"/>
<IsPartOfProject Value="True"/>
<CursorPos X="64" Y="8"/> <CursorPos X="64" Y="8"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="73"/> <UsageCount Value="72"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
<Filename Value="fpmktype.pp"/> <Filename Value="fpmktype.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="fpmktype"/> <UnitName Value="fpmktype"/>
<CursorPos X="3" Y="41"/> <CursorPos X="3" Y="41"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="6"/> <UsageCount Value="72"/>
<UsageCount Value="73"/>
<Loaded Value="True"/>
</Unit3> </Unit3>
<Unit4> <Unit4>
<Filename Value="fpmkunit.pp"/> <Filename Value="fpmkunit.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="fpmkunit"/> <UnitName Value="fpmkunit"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="73"/> <UsageCount Value="72"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="fprepos.pp"/> <Filename Value="fprepos.pp"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="fprepos"/> <UnitName Value="fprepos"/>
<CursorPos X="21" Y="368"/> <CursorPos X="1" Y="187"/>
<TopLine Value="356"/> <TopLine Value="165"/>
<EditorIndex Value="8"/> <EditorIndex Value="9"/>
<UsageCount Value="73"/> <UsageCount Value="82"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
<Filename Value="fpxmlrep.pp"/> <Filename Value="fpxmlrep.pp"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="fpxmlrep"/> <UnitName Value="fpxmlrep"/>
<CursorPos X="33" Y="259"/> <CursorPos X="1" Y="43"/>
<TopLine Value="245"/> <TopLine Value="43"/>
<EditorIndex Value="9"/> <EditorIndex Value="10"/>
<UsageCount Value="73"/> <UsageCount Value="82"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="pkghandler.pp"/> <Filename Value="pkghandler.pp"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="pkghandler"/> <UnitName Value="pkghandler"/>
<CursorPos X="10" Y="167"/> <CursorPos X="56" Y="170"/>
<TopLine Value="153"/> <TopLine Value="156"/>
<EditorIndex Value="1"/> <EditorIndex Value="1"/>
<UsageCount Value="73"/> <UsageCount Value="82"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
@ -112,26 +107,26 @@
<UnitName Value="pkgmkconv"/> <UnitName Value="pkgmkconv"/>
<CursorPos X="14" Y="53"/> <CursorPos X="14" Y="53"/>
<TopLine Value="29"/> <TopLine Value="29"/>
<UsageCount Value="73"/> <UsageCount Value="82"/>
</Unit8> </Unit8>
<Unit9> <Unit9>
<Filename Value="pkgdownload.pp"/> <Filename Value="pkgdownload.pp"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="pkgdownload"/> <UnitName Value="pkgdownload"/>
<CursorPos X="18" Y="88"/> <CursorPos X="27" Y="144"/>
<TopLine Value="71"/> <TopLine Value="129"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<UsageCount Value="73"/> <UsageCount Value="82"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit9> </Unit9>
<Unit10> <Unit10>
<Filename Value="pkgmessages.pp"/> <Filename Value="pkgmessages.pp"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="pkgmessages"/> <UnitName Value="pkgmessages"/>
<CursorPos X="1" Y="29"/> <CursorPos X="34" Y="45"/>
<TopLine Value="27"/> <TopLine Value="25"/>
<EditorIndex Value="5"/> <EditorIndex Value="6"/>
<UsageCount Value="73"/> <UsageCount Value="82"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
@ -139,48 +134,48 @@
<UnitName Value="streamcoll"/> <UnitName Value="streamcoll"/>
<CursorPos X="66" Y="88"/> <CursorPos X="66" Y="88"/>
<TopLine Value="65"/> <TopLine Value="65"/>
<UsageCount Value="5"/> <UsageCount Value="4"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
<Filename Value="streamcoll20.pp"/> <Filename Value="streamcoll20.pp"/>
<UnitName Value="streamcoll"/> <UnitName Value="streamcoll"/>
<CursorPos X="3" Y="15"/> <CursorPos X="3" Y="15"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="5"/> <UsageCount Value="4"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="../../../fpc20/rtl/objpas/classes/classesh.inc"/> <Filename Value="../../../fpc20/rtl/objpas/classes/classesh.inc"/>
<CursorPos X="14" Y="599"/> <CursorPos X="14" Y="599"/>
<TopLine Value="580"/> <TopLine Value="580"/>
<UsageCount Value="33"/> <UsageCount Value="32"/>
</Unit13> </Unit13>
<Unit14> <Unit14>
<Filename Value="../../../fpc20/rtl/inc/objpash.inc"/> <Filename Value="../../../fpc20/rtl/inc/objpash.inc"/>
<CursorPos X="38" Y="277"/> <CursorPos X="38" Y="277"/>
<TopLine Value="269"/> <TopLine Value="269"/>
<UsageCount Value="31"/> <UsageCount Value="30"/>
</Unit14> </Unit14>
<Unit15> <Unit15>
<Filename Value="../../../fpc20/fcl/inc/contnrs.pp"/> <Filename Value="../../../fpc20/fcl/inc/contnrs.pp"/>
<UnitName Value="contnrs"/> <UnitName Value="contnrs"/>
<CursorPos X="1" Y="19"/> <CursorPos X="1" Y="19"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="5"/> <UsageCount Value="4"/>
</Unit15> </Unit15>
<Unit16> <Unit16>
<Filename Value="contnrs20.pp"/> <Filename Value="contnrs20.pp"/>
<UnitName Value="contnrs20"/> <UnitName Value="contnrs20"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="25"/> <UsageCount Value="24"/>
</Unit16> </Unit16>
<Unit17> <Unit17>
<Filename Value="pkgcommands.pp"/> <Filename Value="pkgcommands.pp"/>
<UnitName Value="pkgcommands"/> <UnitName Value="pkgcommands"/>
<CursorPos X="1" Y="73"/> <CursorPos X="3" Y="73"/>
<TopLine Value="54"/> <TopLine Value="59"/>
<EditorIndex Value="4"/> <EditorIndex Value="5"/>
<UsageCount Value="35"/> <UsageCount Value="39"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit17> </Unit17>
<Unit18> <Unit18>
@ -188,36 +183,36 @@
<UnitName Value="pkgwget"/> <UnitName Value="pkgwget"/>
<CursorPos X="18" Y="25"/> <CursorPos X="18" Y="25"/>
<TopLine Value="15"/> <TopLine Value="15"/>
<UsageCount Value="29"/> <UsageCount Value="28"/>
</Unit18> </Unit18>
<Unit19> <Unit19>
<Filename Value="pkglnet.pas"/> <Filename Value="pkglnet.pas"/>
<UnitName Value="pkglnet"/> <UnitName Value="pkglnet"/>
<CursorPos X="36" Y="19"/> <CursorPos X="36" Y="19"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit19> </Unit19>
<Unit20> <Unit20>
<Filename Value="reptest.pp"/> <Filename Value="reptest.pp"/>
<UnitName Value="reptest"/> <UnitName Value="reptest"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="22"/> <UsageCount Value="21"/>
</Unit20> </Unit20>
<Unit21> <Unit21>
<Filename Value="rep2xml.lpr"/> <Filename Value="rep2xml.lpr"/>
<UnitName Value="rep2xml"/> <UnitName Value="rep2xml"/>
<CursorPos X="40" Y="228"/> <CursorPos X="40" Y="228"/>
<TopLine Value="217"/> <TopLine Value="217"/>
<UsageCount Value="22"/> <UsageCount Value="21"/>
</Unit21> </Unit21>
<Unit22> <Unit22>
<Filename Value="pkgarchive.pp"/> <Filename Value="pkgrepos.pp"/>
<UnitName Value="pkgarchive"/> <UnitName Value="pkgrepos"/>
<CursorPos X="1" Y="70"/> <CursorPos X="30" Y="60"/>
<TopLine Value="56"/> <TopLine Value="42"/>
<EditorIndex Value="3"/> <EditorIndex Value="8"/>
<UsageCount Value="26"/> <UsageCount Value="30"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit22> </Unit22>
<Unit23> <Unit23>
@ -225,86 +220,88 @@
<UnitName Value="pkgoCurl"/> <UnitName Value="pkgoCurl"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit23> </Unit23>
<Unit24> <Unit24>
<Filename Value="pkglibcurl.pp"/> <Filename Value="pkglibcurl.pp"/>
<UnitName Value="pkglibcurl"/> <UnitName Value="pkglibcurl"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit24> </Unit24>
<Unit25> <Unit25>
<Filename Value="zipper.pp"/> <Filename Value="zipper.pp"/>
<UnitName Value="zipper"/> <UnitName Value="zipper"/>
<CursorPos X="21" Y="1324"/> <CursorPos X="21" Y="1324"/>
<TopLine Value="1303"/> <TopLine Value="1303"/>
<UsageCount Value="15"/> <UsageCount Value="14"/>
</Unit25> </Unit25>
<Unit26> <Unit26>
<Filename Value="../../../fpc20/rtl/objpas/sysutils/filutilh.inc"/> <Filename Value="../../../fpc20/rtl/objpas/sysutils/filutilh.inc"/>
<CursorPos X="12" Y="53"/> <CursorPos X="12" Y="53"/>
<TopLine Value="40"/> <TopLine Value="40"/>
<UsageCount Value="13"/> <UsageCount Value="12"/>
</Unit26> </Unit26>
<Unit27> <Unit27>
<Filename Value="../../../fpc20/rtl/inc/systemh.inc"/> <Filename Value="../../../fpc20/rtl/inc/systemh.inc"/>
<CursorPos X="3" Y="214"/> <CursorPos X="3" Y="214"/>
<TopLine Value="313"/> <TopLine Value="313"/>
<UsageCount Value="13"/> <UsageCount Value="12"/>
</Unit27> </Unit27>
<Unit28> <Unit28>
<Filename Value="../../../fpc20/rtl/objpas/sysutils/datih.inc"/> <Filename Value="../../../fpc20/rtl/objpas/sysutils/datih.inc"/>
<CursorPos X="16" Y="93"/> <CursorPos X="16" Y="93"/>
<TopLine Value="86"/> <TopLine Value="86"/>
<UsageCount Value="13"/> <UsageCount Value="12"/>
</Unit28> </Unit28>
<Unit29> <Unit29>
<Filename Value="zstream.pp"/> <Filename Value="zstream.pp"/>
<UnitName Value="zstream"/> <UnitName Value="zstream"/>
<CursorPos X="38" Y="348"/> <CursorPos X="38" Y="348"/>
<TopLine Value="330"/> <TopLine Value="330"/>
<UsageCount Value="11"/> <UsageCount Value="10"/>
</Unit29> </Unit29>
<Unit30> <Unit30>
<Filename Value="../../../fpc20/packages/base/paszlib/paszlib.pas"/> <Filename Value="../../../fpc20/packages/base/paszlib/paszlib.pas"/>
<UnitName Value="paszlib"/> <UnitName Value="paszlib"/>
<CursorPos X="34" Y="139"/> <CursorPos X="34" Y="139"/>
<TopLine Value="118"/> <TopLine Value="118"/>
<UsageCount Value="11"/> <UsageCount Value="10"/>
</Unit30> </Unit30>
<Unit31> <Unit31>
<Filename Value="pkgfpmake.pp"/> <Filename Value="pkgfpmake.pp"/>
<UnitName Value="pkgfpmake"/> <UnitName Value="pkgfpmake"/>
<CursorPos X="48" Y="58"/> <CursorPos X="25" Y="100"/>
<TopLine Value="47"/> <TopLine Value="88"/>
<UsageCount Value="14"/> <EditorIndex Value="4"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit31> </Unit31>
<Unit32> <Unit32>
<Filename Value="pkglnet.pp"/> <Filename Value="pkglnet.pp"/>
<UnitName Value="pkglnet"/> <UnitName Value="pkglnet"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<EditorIndex Value="11"/> <EditorIndex Value="12"/>
<UsageCount Value="13"/> <UsageCount Value="17"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit32> </Unit32>
<Unit33> <Unit33>
<Filename Value="pkgoptions.pp"/> <Filename Value="pkgoptions.pp"/>
<UnitName Value="pkgoptions"/> <UnitName Value="pkgoptions"/>
<CursorPos X="2" Y="193"/> <CursorPos X="53" Y="84"/>
<TopLine Value="187"/> <TopLine Value="59"/>
<EditorIndex Value="7"/> <EditorIndex Value="7"/>
<UsageCount Value="13"/> <UsageCount Value="17"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit33> </Unit33>
<Unit34> <Unit34>
<Filename Value="pkgglobals.pp"/> <Filename Value="pkgglobals.pp"/>
<UnitName Value="pkgglobals"/> <UnitName Value="pkgglobals"/>
<CursorPos X="1" Y="87"/> <CursorPos X="1" Y="29"/>
<TopLine Value="73"/> <TopLine Value="29"/>
<EditorIndex Value="10"/> <EditorIndex Value="11"/>
<UsageCount Value="13"/> <UsageCount Value="17"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit34> </Unit34>
<Unit35> <Unit35>
@ -312,129 +309,138 @@
<UnitName Value="URIParser"/> <UnitName Value="URIParser"/>
<CursorPos X="1" Y="193"/> <CursorPos X="1" Y="193"/>
<TopLine Value="189"/> <TopLine Value="189"/>
<UsageCount Value="10"/> <UsageCount Value="9"/>
</Unit35> </Unit35>
<Unit36>
<Filename Value="pkgarchive.pp"/>
<UnitName Value="pkgarchive"/>
<CursorPos X="1" Y="74"/>
<TopLine Value="69"/>
<EditorIndex Value="3"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
</Unit36>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="pkghandler.pp"/> <Filename Value="fppkg.pp"/>
<Caret Line="163" Column="5" TopLine="126"/> <Caret Line="1" Column="1" TopLine="1"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="pkgdownload.pp"/> <Filename Value="fppkg.pp"/>
<Caret Line="130" Column="16" TopLine="116"/> <Caret Line="80" Column="13" TopLine="74"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="pkgarchive.pp"/> <Filename Value="pkgoptions.pp"/>
<Caret Line="27" Column="14" TopLine="46"/> <Caret Line="181" Column="1" TopLine="169"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="pkgcommands.pp"/> <Filename Value="pkgoptions.pp"/>
<Caret Line="60" Column="36" TopLine="50"/> <Caret Line="38" Column="27" TopLine="15"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="pkgcommands.pp"/> <Filename Value="pkgoptions.pp"/>
<Caret Line="58" Column="1" TopLine="44"/> <Caret Line="76" Column="35" TopLine="62"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="pkgoptions.pp"/> <Filename Value="pkgoptions.pp"/>
<Caret Line="64" Column="22" TopLine="41"/> <Caret Line="185" Column="14" TopLine="158"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="pkgoptions.pp"/> <Filename Value="pkgoptions.pp"/>
<Caret Line="110" Column="27" TopLine="96"/> <Caret Line="256" Column="49" TopLine="242"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="pkgoptions.pp"/> <Filename Value="fppkg.pp"/>
<Caret Line="137" Column="39" TopLine="123"/> <Caret Line="23" Column="22" TopLine="15"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="pkgoptions.pp"/> <Filename Value="fppkg.pp"/>
<Caret Line="159" Column="31" TopLine="145"/> <Caret Line="91" Column="1" TopLine="78"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="pkgoptions.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="232" Column="25" TopLine="218"/> <Caret Line="46" Column="42" TopLine="32"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="pkgoptions.pp"/> <Filename Value="pkgoptions.pp"/>
<Caret Line="96" Column="16" TopLine="90"/> <Caret Line="306" Column="58" TopLine="293"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="pkgoptions.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="45" Column="41" TopLine="44"/> <Caret Line="46" Column="42" TopLine="32"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="pkgcommands.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="53" Column="72" TopLine="50"/> <Caret Line="58" Column="35" TopLine="40"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="pkgcommands.pp"/> <Filename Value="fprepos.pp"/>
<Caret Line="47" Column="15" TopLine="39"/> <Caret Line="295" Column="46" TopLine="275"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="pkgcommands.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="59" Column="33" TopLine="45"/> <Caret Line="58" Column="27" TopLine="40"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="fppkg.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="85" Column="1" TopLine="58"/> <Caret Line="61" Column="52" TopLine="40"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="fppkg.pp"/> <Filename Value="pkgcommands.pp"/>
<Caret Line="149" Column="20" TopLine="135"/> <Caret Line="55" Column="11" TopLine="45"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="pkgmessages.pp"/> <Filename Value="pkgcommands.pp"/>
<Caret Line="41" Column="18" TopLine="26"/> <Caret Line="22" Column="16" TopLine="8"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="pkgdownload.pp"/> <Filename Value="pkgcommands.pp"/>
<Caret Line="91" Column="13" TopLine="78"/> <Caret Line="114" Column="43" TopLine="90"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="pkgdownload.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="86" Column="1" TopLine="78"/> <Caret Line="12" Column="1" TopLine="4"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="pkghandler.pp"/> <Filename Value="fppkg.pp"/>
<Caret Line="106" Column="21" TopLine="93"/> <Caret Line="67" Column="1" TopLine="56"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="pkgarchive.pp"/> <Filename Value="fppkg.pp"/>
<Caret Line="62" Column="1" TopLine="48"/> <Caret Line="113" Column="49" TopLine="99"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="pkgarchive.pp"/> <Filename Value="fppkg.pp"/>
<Caret Line="73" Column="67" TopLine="50"/> <Caret Line="211" Column="25" TopLine="197"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="pkgarchive.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="67" Column="30" TopLine="54"/> <Caret Line="55" Column="1" TopLine="27"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="pkgglobals.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="87" Column="1" TopLine="73"/> <Caret Line="9" Column="11" TopLine="1"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="pkgarchive.pp"/> <Filename Value="pkgrepos.pp"/>
<Caret Line="62" Column="1" TopLine="48"/> <Caret Line="32" Column="16" TopLine="18"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="pkgarchive.pp"/> <Filename Value="fppkg.pp"/>
<Caret Line="64" Column="1" TopLine="50"/> <Caret Line="254" Column="1" TopLine="240"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="pkgarchive.pp"/> <Filename Value="fppkg.pp"/>
<Caret Line="67" Column="1" TopLine="53"/> <Caret Line="13" Column="49" TopLine="1"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="pkgarchive.pp"/> <Filename Value="pkgarchive.pp"/>
<Caret Line="68" Column="1" TopLine="54"/> <Caret Line="170" Column="26" TopLine="153"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="pkgarchive.pp"/> <Filename Value="pkgarchive.pp"/>
<Caret Line="69" Column="1" TopLine="55"/> <Caret Line="91" Column="33" TopLine="72"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
@ -469,12 +475,6 @@
</Other> </Other>
</CompilerOptions> </CompilerOptions>
<Debugging> <Debugging>
<BreakPoints Count="1">
<Item1>
<Source Value="pkgarchive.pp"/>
<Line Value="62"/>
</Item1>
</BreakPoints>
<Watches Count="1"> <Watches Count="1">
<Item1> <Item1>
<Expression Value="builddir"/> <Expression Value="builddir"/>

View File

@ -10,7 +10,7 @@ uses
Classes, SysUtils, TypInfo, custapp, Classes, SysUtils, TypInfo, custapp,
// Repository handler objects // Repository handler objects
fprepos, fpxmlrep, fprepos, fpxmlrep,
pkgmessages, pkgglobals, pkgoptions, pkgmessages, pkgglobals, pkgoptions, pkgrepos,
// Package Handler components // Package Handler components
pkghandler,pkgmkconv, pkgdownload, pkghandler,pkgmkconv, pkgdownload,
pkgarchive, pkgfpmake, pkgcommands pkgarchive, pkgfpmake, pkgcommands
@ -28,10 +28,7 @@ Type
ActionStack : TActionStack; ActionStack : TActionStack;
ParaAction : string; ParaAction : string;
ParaPackages : TStringList; ParaPackages : TStringList;
FRepository : TFPRepository;
FCompilerConfig : String;
procedure GenerateParaActions; procedure GenerateParaActions;
procedure LoadRepository;
procedure MaybeCreateLocalDirs; procedure MaybeCreateLocalDirs;
procedure ShowUsage; procedure ShowUsage;
Public Public
@ -91,7 +88,7 @@ begin
for i:=0 to SL.Count-1 do for i:=0 to SL.Count-1 do
Include(Verbosity,StringToVerbosity(SL[i])); Include(Verbosity,StringToVerbosity(SL[i]));
SL.Free; SL.Free;
FCompilerConfig:=Defaults.DefaultCompilerConfig; Defaults.CurrentCompilerConfig:=Defaults.DefaultCompilerConfig;
// Tracing of what we've done above, need to be done after the verbosity is set // Tracing of what we've done above, need to be done after the verbosity is set
if GeneratedConfig then if GeneratedConfig then
Log(vDebug,SLogGeneratingGlobalConfig,[cfgfile]) Log(vDebug,SLogGeneratingGlobalConfig,[cfgfile])
@ -112,7 +109,7 @@ procedure TMakeTool.LoadCompilerDefaults;
var var
S : String; S : String;
begin begin
S:=Defaults.CompilerConfigDir+FCompilerConfig; S:=Defaults.CompilerConfigDir+Defaults.CurrentCompilerConfig;
if FileExists(S) then if FileExists(S) then
begin begin
Log(vDebug,SLogLoadingCompilerConfig,[S]); Log(vDebug,SLogLoadingCompilerConfig,[S]);
@ -127,32 +124,6 @@ begin
end; end;
procedure TMakeTool.LoadRepository;
var
S : String;
X : TFPXMLRepositoryHandler;
begin
FRepository:=TFPRepository.Create(Nil);
// Repository
Log(vDebug,SLogLoadingPackagesFile,[Defaults.LocalPackagesFile]);
if FileExists(Defaults.LocalPackagesFile) then
begin
X:=TFPXMLRepositoryHandler.Create;
With X do
try
LoadFromXml(FRepository,Defaults.LocalPackagesFile);
finally
Free;
end;
end;
// Versions
S:=Defaults.LocalVersionsFile(FCompilerConfig);
Log(vDebug,SLogLoadingVersionsFile,[S]);
if FileExists(S) then
FRepository.LoadStatusFromFile(S);
end;
procedure TMakeTool.ShowUsage; procedure TMakeTool.ShowUsage;
begin begin
Writeln('Usage: ',Paramstr(0),' [options] <action> <package>'); Writeln('Usage: ',Paramstr(0),' [options] <action> <package>');
@ -161,8 +132,8 @@ begin
Writeln(' -h --help This help'); Writeln(' -h --help This help');
Writeln(' -v --verbose Set verbosity'); Writeln(' -v --verbose Set verbosity');
Writeln('Actions:'); Writeln('Actions:');
Writeln(' update Update available packages'); Writeln(' update Update packages list');
Writeln(' listpackages List available packages'); Writeln(' avail List available packages');
Writeln(' build Build package'); Writeln(' build Build package');
Writeln(' install Install package'); Writeln(' install Install package');
Writeln(' download Download package'); Writeln(' download Download package');
@ -236,7 +207,7 @@ begin
Inc(I); Inc(I);
// Check options. // Check options.
if CheckOption(I,'c','config') then if CheckOption(I,'c','config') then
FCompilerConfig:=OptionArg(I) Defaults.CurrentCompilerConfig:=OptionArg(I)
else if CheckOption(I,'v','verbose') then else if CheckOption(I,'v','verbose') then
Include(Verbosity,StringToVerbosity(OptionArg(I))) Include(Verbosity,StringToVerbosity(OptionArg(I)))
else if CheckOption(I,'h','help') then else if CheckOption(I,'h','help') then
@ -279,7 +250,7 @@ begin
begin begin
for i:=0 to ParaPackages.Count-1 do for i:=0 to ParaPackages.Count-1 do
begin begin
ActionPackage:=FRepository.PackageByName(ParaPackages[i]); ActionPackage:=CurrentRepository.PackageByName(ParaPackages[i]);
Log(vDebug,SLogCommandLineAction,['['+ActionPackage.Name+']',ParaAction]); Log(vDebug,SLogCommandLineAction,['['+ActionPackage.Name+']',ParaAction]);
ActionStack.Push(ActionPackage,ParaAction,[]); ActionStack.Push(ActionPackage,ParaAction,[]);
end; end;
@ -303,7 +274,7 @@ begin
ProcessCommandLine; ProcessCommandLine;
MaybeCreateLocalDirs; MaybeCreateLocalDirs;
LoadCompilerDefaults; LoadCompilerDefaults;
LoadRepository; LoadLocalRepository;
GenerateParaActions; GenerateParaActions;
repeat repeat

View File

@ -156,7 +156,6 @@ Type
function GetPackage(Index : Integer): TFPPackage; function GetPackage(Index : Integer): TFPPackage;
function GetPackageCount: Integer; function GetPackageCount: Integer;
Protected Protected
Property PackageCollection : TFPPackages Read FPackages;
procedure CreatePackages; virtual; procedure CreatePackages; virtual;
Procedure BackupFile(AFileName : String); virtual; Procedure BackupFile(AFileName : String); virtual;
Procedure DoGetPackageDependencies(PackageName : String; List : TStringList; Level : Integer); virtual; Procedure DoGetPackageDependencies(PackageName : String; List : TStringList; Level : Integer); virtual;
@ -189,6 +188,7 @@ Type
Property PackageCount : Integer Read GetPackageCount; Property PackageCount : Integer Read GetPackageCount;
Property BackupFiles : Boolean Read FBackUpFiles Write FBackupFiles; Property BackupFiles : Boolean Read FBackUpFiles Write FBackupFiles;
Property MaxDependencyLevel : Integer Read FMaxDependencyLevel Write FMaxDependencyLevel; Property MaxDependencyLevel : Integer Read FMaxDependencyLevel Write FMaxDependencyLevel;
Property PackageCollection : TFPPackages Read FPackages;
end; end;
EPackage = Class(Exception); EPackage = Class(Exception);

View File

@ -647,8 +647,9 @@ begin
P:=PS.AddPackage(''); P:=PS.AddPackage('');
try try
DoXMLToPackage(PN,P); DoXMLToPackage(PN,P);
finally except
P.Free; P.Free;
Raise;
end; end;
PN:=FindNextElement(PN.NextSibling,SNodePackage); PN:=FindNextElement(PN.NextSibling,SNodePackage);
end; end;
@ -677,8 +678,9 @@ begin
P:=R.AddPackage(''); P:=R.AddPackage('');
try try
DoXMLToPackage(PN,P); DoXMLToPackage(PN,P);
finally except
P.Free; P.Free;
Raise;
end; end;
PN:=FindNextElement(PN.NextSibling,SNodePackage); PN:=FindNextElement(PN.NextSibling,SNodePackage);
end; end;

View File

@ -38,33 +38,6 @@ uses
pkgglobals, pkgglobals,
pkgmessages; pkgmessages;
Procedure DeleteDir(const ADir:string);
const
{$ifdef unix}
AllFiles='*';
{$else}
AllFiles='*.*';
{$endif}
var
Info : TSearchRec;
begin
if FindFirst(ADir+PathDelim+AllFiles,faAnyFile, Info)=0 then
try
repeat
if (Info.Attr and faDirectory)=faDirectory then
begin
if (Info.Name<>'.') and (Info.Name<>'..') then
DeleteDir(ADir+PathDelim+Info.Name)
end
else
DeleteFile(ADir+PathDelim+Info.Name);
until FindNext(Info)<>0;
finally
FindClose(Info);
end;
end;
{ TUnzipArchive } { TUnzipArchive }
Procedure TUnzipArchive.UnzipArchive; Procedure TUnzipArchive.UnzipArchive;
@ -109,15 +82,14 @@ var
P : TFPPackage; P : TFPPackage;
PS : TFPPackages; PS : TFPPackages;
X : TFPXMLRepositoryHandler; X : TFPXMLRepositoryHandler;
i : integer; SL : TStringList;
begin begin
if assigned(CurrentPackage) then if assigned(CurrentPackage) then
Error(SErrOnlyLocalDir); Error(SErrOnlyLocalDir);
{ Generate manifest.xml if it doesn't exists yet } { Generate manifest.xml if it doesn't exists yet }
if not FileExists(PackageManifestFile) then if not FileExists(PackageManifestFile) then
ExecuteAction(CurrentPackage,'fpmakemanifest'); ExecuteAction(CurrentPackage,'fpmakemanifest');
{ Load manifest.xml }
PS:=TFPPackages.Create(TFPPackage); PS:=TFPPackages.Create(TFPPackage);
X:=TFPXMLRepositoryHandler.Create; X:=TFPXMLRepositoryHandler.Create;
With X do With X do
@ -126,13 +98,29 @@ begin
finally finally
Free; Free;
end; end;
{ Create archive, currently support only 1 file per package, this
for i:=0 to PS.Count-1 do can be enhanced in the future if needed }
begin if PS.Count<>1 then
P:=PS[i]; Error('Only one package supported per manifest');
Writeln(P.Name); P:=PS[0];
Writeln(P.FileName); { Unzip Archive }
With TZipper.Create do
try
Log(vCommands,SLogZippping,[P.FileName]);
{$warning TODO replace with files from manifest}
try
SL:=TStringList.Create;
SearchFiles(SL,AllFiles);
if SL.Count=0 then
Error('No files found');
ZipFiles(P.FileName,SL);
finally
SL.Free;
end;
Finally
Free;
end; end;
P.Free;
end; end;

View File

@ -15,6 +15,20 @@ type
Function Execute(const Args:TActionArgs):boolean;override; Function Execute(const Args:TActionArgs):boolean;override;
end; end;
{ TCommandAvail }
TCommandAvail = Class(TPackagehandler)
Public
Function Execute(const Args:TActionArgs):boolean;override;
end;
{ TCommandScanPackages }
TCommandScanPackages = Class(TPackagehandler)
Public
Function Execute(const Args:TActionArgs):boolean;override;
end;
{ TCommandDownload } { TCommandDownload }
TCommandDownload = Class(TPackagehandler) TCommandDownload = Class(TPackagehandler)
@ -51,11 +65,27 @@ uses
pkgmessages, pkgmessages,
pkgglobals, pkgglobals,
pkgoptions, pkgoptions,
pkgdownload; pkgdownload,
pkgrepos;
function TCommandUpdate.Execute(const Args:TActionArgs):boolean; function TCommandUpdate.Execute(const Args:TActionArgs):boolean;
begin begin
DownloadFile(Defaults.RemotePackagesFile,Defaults.LocalPackagesFile); DownloadFile(Defaults.RemotePackagesFile,Defaults.LocalPackagesFile);
LoadLocalRepository;
end;
function TCommandAvail.Execute(const Args:TActionArgs):boolean;
begin
ListRepository;
end;
function TCommandScanPackages.Execute(const Args:TActionArgs):boolean;
begin
RebuildRepository;
ListRepository;
SaveRepository;
end; end;
@ -96,6 +126,8 @@ end;
initialization initialization
RegisterPkgHandler('update',TCommandUpdate); RegisterPkgHandler('update',TCommandUpdate);
RegisterPkgHandler('avail',TCommandAvail);
RegisterPkgHandler('scan',TCommandScanPackages);
RegisterPkgHandler('download',TCommandDownload); RegisterPkgHandler('download',TCommandDownload);
RegisterPkgHandler('unzip',TCommandUnzip); RegisterPkgHandler('unzip',TCommandUnzip);
RegisterPkgHandler('build',TCommandBuild); RegisterPkgHandler('build',TCommandBuild);

View File

@ -120,7 +120,6 @@ end;
Function TFPMakeRunner.RunFPMake(const Command:string) : Integer; Function TFPMakeRunner.RunFPMake(const Command:string) : Integer;
Var Var
I : integer;
FPMakeBin : string; FPMakeBin : string;
begin begin
{ Maybe compile fpmake executable? } { Maybe compile fpmake executable? }

View File

@ -11,8 +11,10 @@ uses
Const Const
{$ifdef unix} {$ifdef unix}
ExeExt = ''; ExeExt = '';
AllFiles='*';
{$else unix} {$else unix}
ExeExt = '.exe'; ExeExt = '.exe';
AllFiles='*.*';
{$endif unix} {$endif unix}
Type Type
@ -20,7 +22,7 @@ Type
TVerbosities = Set of TVerbosity; TVerbosities = Set of TVerbosity;
EPackagerError = class(Exception); EPackagerError = class(Exception);
// Logging // Logging
Function StringToVerbosity (S : String) : TVerbosity; Function StringToVerbosity (S : String) : TVerbosity;
Function VerbosityToString (V : TVerbosity): String; Function VerbosityToString (V : TVerbosity): String;
@ -32,6 +34,8 @@ Procedure Error(Fmt : String; const Args : array of const);
// Utils // Utils
function maybequoted(const s:string):string; function maybequoted(const s:string):string;
Function FixPath(const S : String) : string; Function FixPath(const S : String) : string;
Procedure DeleteDir(const ADir:string);
Procedure SearchFiles(SL:TStringList;const APattern:string);
var var
Verbosity : TVerbosities; Verbosity : TVerbosities;
@ -141,5 +145,48 @@ begin
end; end;
Procedure DeleteDir(const ADir:string);
var
Info : TSearchRec;
begin
if FindFirst(ADir+PathDelim+AllFiles,faAnyFile, Info)=0 then
try
repeat
if (Info.Attr and faDirectory)=faDirectory then
begin
if (Info.Name<>'.') and (Info.Name<>'..') then
DeleteDir(ADir+PathDelim+Info.Name)
end
else
DeleteFile(ADir+PathDelim+Info.Name);
until FindNext(Info)<>0;
finally
FindClose(Info);
end;
end;
Procedure SearchFiles(SL:TStringList;const APattern:string);
var
Info : TSearchRec;
ADir : string;
begin
ADir:=ExtractFilePath(APattern);
if FindFirst(APattern,faAnyFile, Info)=0 then
try
repeat
if (Info.Attr and faDirectory)=faDirectory then
begin
if (Info.Name<>'.') and (Info.Name<>'..') then
SearchFiles(SL,ADir+Info.Name+PathDelim+ExtractFileName(APattern))
end;
SL.Add(ADir+Info.Name);
until FindNext(Info)<>0;
finally
FindClose(Info);
end;
end;
end. end.

View File

@ -173,7 +173,7 @@ end;
function TPackageHandler.PackageManifestFile: String; function TPackageHandler.PackageManifestFile: String;
begin begin
Result:='manifest.xml'; Result:=DefaultManifestFile;
end; end;

View File

@ -42,6 +42,7 @@ Resourcestring
SLogChangeDir = 'CurrentDir: "%s"'; SLogChangeDir = 'CurrentDir: "%s"';
SLogDownloading = 'Downloading "%s" to "%s"'; SLogDownloading = 'Downloading "%s" to "%s"';
SLogUnzippping = 'Unzipping "%s"'; SLogUnzippping = 'Unzipping "%s"';
SLogZippping = 'Zipping "%s"';
SLogLoadingGlobalConfig = 'Loading global configuration from "%s"'; SLogLoadingGlobalConfig = 'Loading global configuration from "%s"';
SLogLoadingCompilerConfig = 'Loading compiler configuration from "%s"'; SLogLoadingCompilerConfig = 'Loading compiler configuration from "%s"';
SLogGeneratingGlobalConfig = 'Generating default global configuration in "%s"'; SLogGeneratingGlobalConfig = 'Generating default global configuration in "%s"';

View File

@ -18,6 +18,9 @@ interface
uses Classes, Sysutils, Inifiles, fpmktype; uses Classes, Sysutils, Inifiles, fpmktype;
Const
DefaultManifestFile = 'manifest.xml';
Type Type
{ TPackagerOptions } { TPackagerOptions }
@ -34,6 +37,7 @@ Type
FPackagesDir, FPackagesDir,
FBuildDir : String; FBuildDir : String;
FDefaultVerbosity, FDefaultVerbosity,
FCurrentCompilerConfig,
FDefaultCompilerConfig : String; FDefaultCompilerConfig : String;
// Compiler specific options // Compiler specific options
FCompiler : String; FCompiler : String;
@ -80,13 +84,14 @@ Type
Property CompilerConfigDir : String Index 13 Read GetOptString Write SetOptString; Property CompilerConfigDir : String Index 13 Read GetOptString Write SetOptString;
Property FPMakeCompiler : String Index 14 Read GetOptString Write SetOptString; Property FPMakeCompiler : String Index 14 Read GetOptString Write SetOptString;
Property FPMakeUnitDir : String Index 15 Read GetOptString Write SetOptString; Property FPMakeUnitDir : String Index 15 Read GetOptString Write SetOptString;
Property CurrentCompilerConfig : String Index 16 Read GetOptString Write SetOptString;
Property CompilerOS : TOS Read FCompilerOS Write SetCompilerOS; Property CompilerOS : TOS Read FCompilerOS Write SetCompilerOS;
Property CompilerCPU : TCPU Read FCompilerCPU Write SetCompilerCPU; Property CompilerCPU : TCPU Read FCompilerCPU Write SetCompilerCPU;
end; end;
var var
Defaults : TPackagerOptions; Defaults : TPackagerOptions;
Implementation Implementation
uses uses
@ -157,6 +162,7 @@ begin
13 : Result:=FCompilerConfigDir; 13 : Result:=FCompilerConfigDir;
14 : Result:=FFPMakeCompiler; 14 : Result:=FFPMakeCompiler;
15 : Result:=FFPMakeUnitDir; 15 : Result:=FFPMakeUnitDir;
16 : Result:=FCurrentCompilerConfig;
end; end;
end; end;
@ -180,6 +186,7 @@ begin
13 : FCompilerConfigDir:=FixPath(AValue); 13 : FCompilerConfigDir:=FixPath(AValue);
14 : FFPMakeCompiler:=AValue; 14 : FFPMakeCompiler:=AValue;
15 : FFPMakeUnitDir:=FixPath(AValue); 15 : FFPMakeUnitDir:=FixPath(AValue);
16 : FCurrentCompilerConfig:=AValue;
end; end;
FDirty:=True; FDirty:=True;
end; end;
@ -250,6 +257,7 @@ begin
FRemoteRepository:=DefaultRemoteRepository; FRemoteRepository:=DefaultRemoteRepository;
// Other config // Other config
FDefaultCompilerConfig:='default'; FDefaultCompilerConfig:='default';
FCurrentCompilerConfig:=FDefaultCompilerConfig;
FDefaultVerbosity:='error,info,debug,commands'; FDefaultVerbosity:='error,info,debug,commands';
end; end;

140
utils/fppkg/pkgrepos.pp Normal file
View File

@ -0,0 +1,140 @@
unit pkgrepos;
{$mode objfpc}{$H+}
interface
uses
Classes,SysUtils,
fprepos;
procedure LoadLocalRepository;
procedure SaveRepository;
procedure ListRepository;
procedure RebuildRepository;
var
CurrentRepository : TFPRepository;
implementation
uses
zipper,
fpxmlrep,
pkgglobals,
pkgoptions,
pkgmessages;
procedure LoadLocalRepository;
var
S : String;
X : TFPXMLRepositoryHandler;
begin
if assigned(CurrentRepository) then
CurrentRepository.Free;
CurrentRepository:=TFPRepository.Create(Nil);
// Repository
Log(vDebug,SLogLoadingPackagesFile,[Defaults.LocalPackagesFile]);
if FileExists(Defaults.LocalPackagesFile) then
begin
X:=TFPXMLRepositoryHandler.Create;
With X do
try
LoadFromXml(CurrentRepository,Defaults.LocalPackagesFile);
finally
Free;
end;
end;
// Versions
S:=Defaults.LocalVersionsFile(Defaults.CurrentCompilerConfig);
Log(vDebug,SLogLoadingVersionsFile,[S]);
if FileExists(S) then
CurrentRepository.LoadStatusFromFile(S);
end;
procedure SaveRepository;
var
X : TFPXMLRepositoryHandler;
begin
// Repository
Writeln('Saving repository in packages.xml');
X:=TFPXMLRepositoryHandler.Create;
With X do
try
SaveToXml(CurrentRepository,'packages.xml');
finally
Free;
end;
end;
procedure ListRepository;
var
P : TFPPackage;
i : integer;
begin
for i:=0 to CurrentRepository.PackageCount-1 do
begin
P:=CurrentRepository.Packages[i];
Writeln(Format('%-20s %-20s',[P.Name,P.FileName]));
end;
end;
procedure RebuildRepository;
var
X : TFPXMLRepositoryHandler;
i : integer;
ArchiveSL : TStringList;
ManifestSL : TStringList;
begin
if assigned(CurrentRepository) then
CurrentRepository.Free;
CurrentRepository:=TFPRepository.Create(Nil);
try
ManifestSL:=TStringList.Create;
ManifestSL.Add(DefaultManifestFile);
{ Find all archives }
ArchiveSL:=TStringList.Create;
SearchFiles(ArchiveSL,'*.zip');
if ArchiveSL.Count=0 then
Error('No archive files found');
{ Process all archives }
for i:=0 to ArchiveSL.Count-1 do
begin
Writeln('Processing ',ArchiveSL[i]);
{ Unzip manifest.xml }
With TUnZipper.Create do
try
Log(vCommands,SLogUnzippping,[ArchiveSL[i]]);
OutputPath:='.';
UnZipFiles(ArchiveSL[i],ManifestSL);
Finally
Free;
end;
{ Load manifest.xml }
if FileExists(DefaultManifestFile) then
begin
X:=TFPXMLRepositoryHandler.Create;
With X do
try
LoadFromXml(CurrentRepository.PackageCollection,DefaultManifestFile);
finally
Free;
end;
DeleteFile(DefaultManifestFile);
end
else
Writeln('No manifest found in archive ',ArchiveSL[i]);
end;
finally
ArchiveSL.Free;
ManifestSL.Free;
end;
end;
initialization
end.