Browse Source

* report URL in download failure
* ignore errors in initial download
* fixed crash with selecting mirror without doing an update

git-svn-id: trunk@10076 -

peter 17 years ago
parent
commit
ef9177ccc4

+ 11 - 1
utils/fppkg/fppkg.pp

@@ -275,8 +275,18 @@ begin
     LoadCompilerDefaults;
     LoadCompilerDefaults;
 
 
     // Load local repository, update first if this is a new installation
     // Load local repository, update first if this is a new installation
+    // errors will only be reported as warning. The user can be bootstrapping
+    // and do an update later
     if not FileExists(GlobalOptions.LocalPackagesFile) then
     if not FileExists(GlobalOptions.LocalPackagesFile) then
-      pkghandler.ExecuteAction(nil,'update');
+      begin
+        try
+          pkghandler.ExecuteAction(nil,'update');
+        except
+          on E: Exception do
+            Log(vlWarning,E.Message);
+        end;
+      end;
+    LoadLocalMirrors;
     LoadLocalRepository;
     LoadLocalRepository;
     LoadFPMakeLocalStatus;
     LoadFPMakeLocalStatus;
     // We only need to reload the status when we use a different
     // We only need to reload the status when we use a different

+ 2 - 0
utils/fppkg/pkgglobals.pp

@@ -410,7 +410,9 @@ end;
 
 
 
 
 initialization
 initialization
+{$ifndef VER2_2}
   OnGetVendorName:=@FPPkgGetVendorName;
   OnGetVendorName:=@FPPkgGetVendorName;
+{$endif}
   OnGetApplicationName:=@FPPkgGetApplicationName;
   OnGetApplicationName:=@FPPkgGetApplicationName;
 
 
 end.
 end.

+ 4 - 7
utils/fppkg/pkglnet.pp

@@ -6,6 +6,7 @@ interface
 
 
 uses
 uses
   SysUtils, Classes,
   SysUtils, Classes,
+  uriparser,
   lnet, lftp, lhttp, pkgdownload,pkgoptions, fprepos;
   lnet, lftp, lhttp, pkgdownload,pkgoptions, fprepos;
 
 
 Type
 Type
@@ -18,6 +19,7 @@ Type
     FFTP: TLFTPClient;
     FFTP: TLFTPClient;
     FHTTP: TLHTTPClient;
     FHTTP: TLHTTPClient;
     FOutStream: TStream;
     FOutStream: TStream;
+    URI: TURI;
    protected
    protected
     // callbacks
     // callbacks
     function OnHttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar;
     function OnHttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar;
@@ -39,7 +41,6 @@ Type
 implementation
 implementation
 
 
 uses
 uses
-  uriparser,
   pkgglobals,
   pkgglobals,
   pkgmessages;
   pkgmessages;
 
 
@@ -95,13 +96,11 @@ procedure TLNetDownloader.OnFTPFailure(aSocket: TLSocket;
   const aStatus: TLFTPStatus);
   const aStatus: TLFTPStatus);
 begin
 begin
   FFTP.Disconnect;
   FFTP.Disconnect;
-  Error(SErrDownloadFailed,['FTP','']);
+  Error(SErrDownloadFailed,['FTP',EncodeURI(URI),'']);
   FQuit:=True;
   FQuit:=True;
 end;
 end;
 
 
 procedure TLNetDownloader.FTPDownload(const URL: String; Dest: TStream);
 procedure TLNetDownloader.FTPDownload(const URL: String; Dest: TStream);
-var
-  URI: TURI;
 begin
 begin
   FOutStream:=Dest;
   FOutStream:=Dest;
   Try
   Try
@@ -128,8 +127,6 @@ begin
 end;
 end;
 
 
 procedure TLNetDownloader.HTTPDownload(const URL: String; Dest: TStream);
 procedure TLNetDownloader.HTTPDownload(const URL: String; Dest: TStream);
-var
-  URI: TURI;
 begin
 begin
   FOutStream:=Dest;
   FOutStream:=Dest;
   Try
   Try
@@ -149,7 +146,7 @@ begin
     while not FQuit do
     while not FQuit do
       FHTTP.CallAction;
       FHTTP.CallAction;
     if FHTTP.Response.Status<>HSOK then
     if FHTTP.Response.Status<>HSOK then
-      Error(SErrDownloadFailed,['HTTP',FHTTP.Response.Reason]);
+      Error(SErrDownloadFailed,['HTTP',EncodeURI(URI),FHTTP.Response.Reason]);
   Finally
   Finally
     FOutStream:=nil; // to be sure
     FOutStream:=nil; // to be sure
   end;
   end;

+ 1 - 1
utils/fppkg/pkgmessages.pp

@@ -32,7 +32,7 @@ Resourcestring
   SErrBackupFailed           = 'Backup of file "%s" to file "%s" failed.';
   SErrBackupFailed           = 'Backup of file "%s" to file "%s" failed.';
   SErrUnknownProtocol        = 'Unknown download protocol: "%s"';
   SErrUnknownProtocol        = 'Unknown download protocol: "%s"';
   SErrNoSuchFile             = 'File "%s" does not exist.';
   SErrNoSuchFile             = 'File "%s" does not exist.';
-  SErrDownloadFailed         = '%s Download failed: %s';
+  SErrDownloadFailed         = '%s Download of "%s" failed: %s';
   SErrInvalidLogLevels       = 'Invalid verbosity string: "%s"';
   SErrInvalidLogLevels       = 'Invalid verbosity string: "%s"';
   SErrInvalidCommand         = 'Invalid command: %s';
   SErrInvalidCommand         = 'Invalid command: %s';
   SErrChangeDirFailed        = 'Could not change directory to "%s"';
   SErrChangeDirFailed        = 'Could not change directory to "%s"';

+ 23 - 21
utils/fppkg/pkgrepos.pp

@@ -82,26 +82,30 @@ var
   M : TFPMirror;
   M : TFPMirror;
 begin
 begin
   Result:='';
   Result:='';
-  // Create array for selection
-  BucketCnt:=0;
-  for i:=0 to CurrentMirrors.Count-1 do
-    inc(BucketCnt,CurrentMirrors[i].Weight);
-  // Select random entry
-  Bucket:=Random(BucketCnt);
   M:=nil;
   M:=nil;
-  for i:=0 to CurrentMirrors.Count-1 do
-    begin
-      for j:=0 to CurrentMirrors[i].Weight-1 do
-        begin
-          if Bucket=0 then
-            begin
-              M:=CurrentMirrors[i];
-              break;
-            end;
-          Dec(Bucket);
-        end;
-      if assigned(M) then
-        break;
+  if assigned(CurrentMirrors) then
+   begin
+     // Create array for selection
+     BucketCnt:=0;
+     for i:=0 to CurrentMirrors.Count-1 do
+       inc(BucketCnt,CurrentMirrors[i].Weight);
+     // Select random entry
+     Bucket:=Random(BucketCnt);
+     M:=nil;
+     for i:=0 to CurrentMirrors.Count-1 do
+       begin
+         for j:=0 to CurrentMirrors[i].Weight-1 do
+           begin
+             if Bucket=0 then
+               begin
+                 M:=CurrentMirrors[i];
+                 break;
+               end;
+             Dec(Bucket);
+           end;
+         if assigned(M) then
+           break;
+       end;
     end;
     end;
   if assigned(M) then
   if assigned(M) then
     begin
     begin
@@ -114,8 +118,6 @@ end;
 
 
 
 
 function GetRemoteRepositoryURL(const AFileName:string):string;
 function GetRemoteRepositoryURL(const AFileName:string):string;
-var
-  i : integer;
 begin
 begin
   if CurrentRemoteRepositoryURL='' then
   if CurrentRemoteRepositoryURL='' then
     begin
     begin

+ 1 - 1
utils/fppkg/pkgwget.pp

@@ -53,7 +53,7 @@ begin
           Dest.WriteBuffer(Buffer,Count);
           Dest.WriteBuffer(Buffer,Count);
         end;
         end;
       If (ExitStatus<>0) then
       If (ExitStatus<>0) then
-        Error(SErrDownloadFailed,['WGET',Format('exit status %d',[ExitStatus])]);
+        Error(SErrDownloadFailed,['WGET',URL,Format('exit status %d',[ExitStatus])]);
     finally
     finally
       Free;
       Free;
     end;
     end;