Browse Source

* 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 -

peter 18 years ago
parent
commit
88f2a0e53a

+ 1 - 0
.gitattributes

@@ -8505,6 +8505,7 @@ utils/fppkg/pkgmessages.pp svneol=native#text/plain
 utils/fppkg/pkgmkconv.pp svneol=native#text/plain
 utils/fppkg/pkgocurl.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/pkgwget.pp svneol=native#text/plain
 utils/fppkg/rep2xml.lpi svneol=native#text/plain

+ 27 - 12
utils/fppkg/fcl20/zipper.pp

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

+ 134 - 134
utils/fppkg/fppkg.lpi

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

+ 8 - 37
utils/fppkg/fppkg.pp

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

+ 1 - 1
utils/fppkg/fprepos.pp

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

+ 4 - 2
utils/fppkg/fpxmlrep.pp

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

+ 24 - 36
utils/fppkg/pkgarchive.pp

@@ -38,33 +38,6 @@ uses
   pkgglobals,
   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 }
 
 Procedure TUnzipArchive.UnzipArchive;
@@ -109,15 +82,14 @@ var
   P : TFPPackage;
   PS : TFPPackages;
   X : TFPXMLRepositoryHandler;
-  i : integer;
+  SL : TStringList;
 begin
   if assigned(CurrentPackage) then
     Error(SErrOnlyLocalDir);
   { Generate manifest.xml if it doesn't exists yet }
   if not FileExists(PackageManifestFile) then
     ExecuteAction(CurrentPackage,'fpmakemanifest');
-
-
+  { Load manifest.xml }
   PS:=TFPPackages.Create(TFPPackage);
   X:=TFPXMLRepositoryHandler.Create;
   With X do
@@ -126,13 +98,29 @@ begin
     finally
       Free;
     end;
-
-  for i:=0 to PS.Count-1 do
-    begin
-      P:=PS[i];
-      Writeln(P.Name);
-      Writeln(P.FileName);
+  { Create archive, currently support only 1 file per package, this
+    can be enhanced in the future if needed }
+  if PS.Count<>1 then
+    Error('Only one package supported per manifest');
+  P:=PS[0];
+  { 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;
+  P.Free;
 end;
 
 

+ 33 - 1
utils/fppkg/pkgcommands.pp

@@ -15,6 +15,20 @@ type
     Function Execute(const Args:TActionArgs):boolean;override;
   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 = Class(TPackagehandler)
@@ -51,11 +65,27 @@ uses
   pkgmessages,
   pkgglobals,
   pkgoptions,
-  pkgdownload;
+  pkgdownload,
+  pkgrepos;
 
 function TCommandUpdate.Execute(const Args:TActionArgs):boolean;
 begin
   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;
 
 
@@ -96,6 +126,8 @@ end;
 
 initialization
   RegisterPkgHandler('update',TCommandUpdate);
+  RegisterPkgHandler('avail',TCommandAvail);
+  RegisterPkgHandler('scan',TCommandScanPackages);
   RegisterPkgHandler('download',TCommandDownload);
   RegisterPkgHandler('unzip',TCommandUnzip);
   RegisterPkgHandler('build',TCommandBuild);

+ 0 - 1
utils/fppkg/pkgfpmake.pp

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

+ 48 - 1
utils/fppkg/pkgglobals.pp

@@ -11,8 +11,10 @@ uses
 Const
 {$ifdef unix}
   ExeExt = '';
+  AllFiles='*';
 {$else unix}
   ExeExt = '.exe';
+  AllFiles='*.*';
 {$endif unix}
 
 Type
@@ -20,7 +22,7 @@ Type
   TVerbosities = Set of TVerbosity;
 
   EPackagerError = class(Exception);
-  
+
 // Logging
 Function StringToVerbosity (S : String) : TVerbosity;
 Function VerbosityToString (V : TVerbosity): String;
@@ -32,6 +34,8 @@ Procedure Error(Fmt : String; const Args : array of const);
 // Utils
 function maybequoted(const s:string):string;
 Function FixPath(const S : String) : string;
+Procedure DeleteDir(const ADir:string);
+Procedure SearchFiles(SL:TStringList;const APattern:string);
 
 var
   Verbosity : TVerbosities;
@@ -141,5 +145,48 @@ begin
 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.

+ 1 - 1
utils/fppkg/pkghandler.pp

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

+ 1 - 0
utils/fppkg/pkgmessages.pp

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

+ 9 - 1
utils/fppkg/pkgoptions.pp

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

+ 140 - 0
utils/fppkg/pkgrepos.pp

@@ -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.