diff --git a/utils/fppkg/fppkg.pp b/utils/fppkg/fppkg.pp index 056b76d9ea..867fc62c0c 100644 --- a/utils/fppkg/fppkg.pp +++ b/utils/fppkg/fppkg.pp @@ -275,8 +275,18 @@ begin LoadCompilerDefaults; // 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 - pkghandler.ExecuteAction(nil,'update'); + begin + try + pkghandler.ExecuteAction(nil,'update'); + except + on E: Exception do + Log(vlWarning,E.Message); + end; + end; + LoadLocalMirrors; LoadLocalRepository; LoadFPMakeLocalStatus; // We only need to reload the status when we use a different diff --git a/utils/fppkg/pkgglobals.pp b/utils/fppkg/pkgglobals.pp index 4658eac5a4..198ac8b7d8 100644 --- a/utils/fppkg/pkgglobals.pp +++ b/utils/fppkg/pkgglobals.pp @@ -410,7 +410,9 @@ end; initialization +{$ifndef VER2_2} OnGetVendorName:=@FPPkgGetVendorName; +{$endif} OnGetApplicationName:=@FPPkgGetApplicationName; end. diff --git a/utils/fppkg/pkglnet.pp b/utils/fppkg/pkglnet.pp index d0bd305d91..03acdc0067 100644 --- a/utils/fppkg/pkglnet.pp +++ b/utils/fppkg/pkglnet.pp @@ -6,6 +6,7 @@ interface uses SysUtils, Classes, + uriparser, lnet, lftp, lhttp, pkgdownload,pkgoptions, fprepos; Type @@ -18,6 +19,7 @@ Type FFTP: TLFTPClient; FHTTP: TLHTTPClient; FOutStream: TStream; + URI: TURI; protected // callbacks function OnHttpClientInput(ASocket: TLHTTPClientSocket; ABuffer: pchar; @@ -39,7 +41,6 @@ Type implementation uses - uriparser, pkgglobals, pkgmessages; @@ -95,13 +96,11 @@ procedure TLNetDownloader.OnFTPFailure(aSocket: TLSocket; const aStatus: TLFTPStatus); begin FFTP.Disconnect; - Error(SErrDownloadFailed,['FTP','']); + Error(SErrDownloadFailed,['FTP',EncodeURI(URI),'']); FQuit:=True; end; procedure TLNetDownloader.FTPDownload(const URL: String; Dest: TStream); -var - URI: TURI; begin FOutStream:=Dest; Try @@ -128,8 +127,6 @@ begin end; procedure TLNetDownloader.HTTPDownload(const URL: String; Dest: TStream); -var - URI: TURI; begin FOutStream:=Dest; Try @@ -149,7 +146,7 @@ begin while not FQuit do FHTTP.CallAction; if FHTTP.Response.Status<>HSOK then - Error(SErrDownloadFailed,['HTTP',FHTTP.Response.Reason]); + Error(SErrDownloadFailed,['HTTP',EncodeURI(URI),FHTTP.Response.Reason]); Finally FOutStream:=nil; // to be sure end; diff --git a/utils/fppkg/pkgmessages.pp b/utils/fppkg/pkgmessages.pp index e19d6f1007..f4efef2f08 100644 --- a/utils/fppkg/pkgmessages.pp +++ b/utils/fppkg/pkgmessages.pp @@ -32,7 +32,7 @@ Resourcestring SErrBackupFailed = 'Backup of file "%s" to file "%s" failed.'; SErrUnknownProtocol = 'Unknown download protocol: "%s"'; SErrNoSuchFile = 'File "%s" does not exist.'; - SErrDownloadFailed = '%s Download failed: %s'; + SErrDownloadFailed = '%s Download of "%s" failed: %s'; SErrInvalidLogLevels = 'Invalid verbosity string: "%s"'; SErrInvalidCommand = 'Invalid command: %s'; SErrChangeDirFailed = 'Could not change directory to "%s"'; diff --git a/utils/fppkg/pkgrepos.pp b/utils/fppkg/pkgrepos.pp index 95aec9034b..a9837f5135 100644 --- a/utils/fppkg/pkgrepos.pp +++ b/utils/fppkg/pkgrepos.pp @@ -82,26 +82,30 @@ var M : TFPMirror; begin 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; - 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; if assigned(M) then begin @@ -114,8 +118,6 @@ end; function GetRemoteRepositoryURL(const AFileName:string):string; -var - i : integer; begin if CurrentRemoteRepositoryURL='' then begin diff --git a/utils/fppkg/pkgwget.pp b/utils/fppkg/pkgwget.pp index 8c9e10909c..163348b6d4 100644 --- a/utils/fppkg/pkgwget.pp +++ b/utils/fppkg/pkgwget.pp @@ -53,7 +53,7 @@ begin Dest.WriteBuffer(Buffer,Count); end; If (ExitStatus<>0) then - Error(SErrDownloadFailed,['WGET',Format('exit status %d',[ExitStatus])]); + Error(SErrDownloadFailed,['WGET',URL,Format('exit status %d',[ExitStatus])]); finally Free; end;