Changeset 3b217af in tol


Ignore:
Timestamp:
May 17, 2011, 8:17:58 AM (15 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
3603b6b
Parents:
5408466
Message:

Refs #1206
Refs #1207

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@3552 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/stdlib/general/TolPackage/client.tol

    r5408466 r3b217af  
    2828Text common_php_arguments = "";
    2929
     30Real  trace_max_level = 0;
     31
     32//////////////////////////////////////////////////////////////////////////////
     33Text _.autodoc.member._trace =
     34"Muestra la traza especificada";
     35Real _trace(Text method, Text message, Real level)
     36//////////////////////////////////////////////////////////////////////////////
     37{
     38//WriteLn("[TolPackage::Client::_trace] ("+method+","+message+" "<<level+") trace_max_level="<<trace_max_level);
     39  If(level > trace_max_level, 0,
     40  {
     41    WriteLn("[TolPackage::Client::"+method+"] "+message);
     42    1
     43  })
     44};
     45
    3046//////////////////////////////////////////////////////////////////////////////
    3147Text _.autodoc.member.Initialize =
    … …  
    3450//////////////////////////////////////////////////////////////////////////////
    3551{
     52  Real _trace("Initialize", "Begin", 1);
    3653  Real TolPackage::Initialize(void);
    3754  Text common_php_arguments :=
    … …  
    3956    "&tol_version="+Replace(TolPackage::_.currentTolVersion," ","%20");
    4057  Real OSDirMake(_.localRoot);
     58  Real _trace("Initialize", "End", 1);
    4159  True
    4260};
    … …  
    4967//////////////////////////////////////////////////////////////////////////////
    5068{
    51 //WriteLn("TRACE [TolPackage::Client::Initialize] ");
     69  Real _trace("AddRepository", "Begin", 1);
    5270  Set TolConfigManager::Config::Upgrading::TolPackage::Repositories :=
    5371    Unique(TolConfigManager::Config::Upgrading::TolPackage::Repositories <<
    5472           [[url]]);
    5573  Real TolConfigManager::SaveConfig(TolConfigManager::Config);
     74  Real _trace("AddRepository", "End", 1);
    5675  True
    5776};
    … …  
    7594//////////////////////////////////////////////////////////////////////////////
    7695{
     96  Real _trace("DoRequirements", "Begin", 1);
    7797  Set EvalSet(packages,Real(Text required)
    7898  {
    … …  
    80100    True
    81101  });
     102  Real _trace("DoRequirements", "End", 1);
    82103  True
    83104};
    … …  
    90111//////////////////////////////////////////////////////////////////////////////
    91112{
    92 //WriteLn("TRACE LocalLastCompatible 1 package="<<package);
     113  Real _trace("LocalLastCompatible", "Begin", 1);
    93114  Set pkgLst = GetDir(TolPackage::Client::_.localRoot)[2];
    94115  Text vsi.path = _.localRoot+"/VersSyncInfo.oza";
    … …  
    97118  Set pkgSel = Select(pkgLst,Real(Text pkgNamVer)
    98119  {
    99   //WriteLn("TRACE LocalLastCompatible 2 checking version ="<<pkgNamVer);
     120  //WriteLn("_trace LocalLastCompatible 2 checking version ="<<pkgNamVer);
    100121    Real ok1 = TextBeginWith(pkgNamVer, package);
    101122    If(!ok1, False,
    … …  
    107128         vsi[idx]->te_min_tol_version <= TolPackage::_.currentTolVersion,
    108129         vsi[idx]->te_max_tol_version >= TolPackage::_.currentTolVersion);
    109       //WriteLn("TRACE LocalLastCompatible 3 min="<<vsi[idx]->te_min_tol_version);
    110       //WriteLn("TRACE LocalLastCompatible 4 cur="<<TolPackage::_.currentTolVersion);
    111       //WriteLn("TRACE LocalLastCompatible 5 max="<<vsi[idx]->te_max_tol_version);
    112       //WriteLn("TRACE LocalLastCompatible 6 ok2="<<ok2);
     130      //WriteLn("_trace LocalLastCompatible 3 min="<<vsi[idx]->te_min_tol_version);
     131      //WriteLn("_trace LocalLastCompatible 4 cur="<<TolPackage::_.currentTolVersion);
     132      //WriteLn("_trace LocalLastCompatible 5 max="<<vsi[idx]->te_max_tol_version);
     133      //WriteLn("_trace LocalLastCompatible 6 ok2="<<ok2);
    113134        ok2
    114135      })
    115136    })
    116137  });
    117   Text If(!Card(pkgSel),"",
     138  Text last = If(!Card(pkgSel),"",
    118139  {
    119140    Set pkgSort = Sort(pkgSel, Real(Text a, Text b) {
    120141      Compare.VersionString(b, a) });
    121142    pkgSort[1]
    122   })
     143  });
     144  Real _trace("LocalLastCompatible", "End", 1);
     145  last
    123146};
    124147
    … …  
    161184//////////////////////////////////////////////////////////////////////////////
    162185{
     186  Real _trace("LocalInstallPackage", "Begin", 1);
    163187  Real OSFilCopy(pkg.path.zip, _.localRoot);
    164188  Text pkg.name.zip = GetFileName(pkg.path.zip);
    165189  Text pkg.name = Replace(pkg.name.zip,".zip","");
    166190  Real PackArchive::UnpackFull("ZipArchive",_.localRoot+pkg.name,True);
     191  Real _trace("LocalInstallPackage", "End", 1);
    167192  FileExist(_.localRoot+pkg.name+"/"+pkg.name+".oza")
    168193};
    … …  
    176201//////////////////////////////////////////////////////////////////////////////
    177202{
    178   Real If(TextFind(package,"."),
     203  Real _trace("LocalClean", "Begin", 1);
     204  Real ok = If(TextFind(package,"."),
    179205  {
    180206    Real OSDirRemove(_.localRoot+package)
    … …  
    190216      OSDirRemove(_.localRoot+pkg)
    191217    }))
    192   })
     218  });
     219  Real _trace("LocalClean", "End", 1);
     220  ok
    193221};
    194222
    … …  
    207235//////////////////////////////////////////////////////////////////////////////
    208236{
     237  Real _trace("GetRepositoryInfo", "Begin", 1);
    209238  Text pkgInfo = GetUrlContents(url);
    210239  Real old.show = Show(False,"ALL");
    211240  Set pkgLst = IncludeText(pkgInfo);
    212241  Real Show(old.show,"ALL");
    213 /*
    214   Text If(Card(pkgLst)==0,
    215   {
    216     WriteLn("[TolPackage::Client::GetRepositoryInfo] "
    217     "Cannot connect to \n"+url,"W")
    218   });
    219 */
     242  Real _trace("GetRepositoryInfo", "End", 1);
    220243  pkgLst
    221244};
    … …  
    226249//////////////////////////////////////////////////////////////////////////////
    227250{
    228   If(TolConfigManager::Config::Upgrading::TolPackage::LocalOnly, False,
     251  Real _trace("CheckRepositoryPing", "Begin", 1);
     252  Real ok = If(TolConfigManager::Config::Upgrading::TolPackage::LocalOnly, False,
    229253  {
    230254    Real key = IntRand(111111111,999999999);
    … …  
    235259      Grammar(info[1])!="Real",False,
    236260      1==1, info[1]==key);
    237   //WriteLn("TRACE [CheckRepositoryPing] url="<<url+" info="<<info+" ok="<<ok);
     261  //WriteLn("_trace [CheckRepositoryPing] url="<<url+" info="<<info+" ok="<<ok);
    238262    ok
    239   })
     263  });
     264  Real _trace("CheckRepositoryPing", "End", 1);
     265  ok
    240266};
    241267
    … …  
    254280//////////////////////////////////////////////////////////////////////////////
    255281{
    256 //WriteLn("TRACE [GetMinTolVersionForPackage] 1 package='"<<package+"'");
    257   If(!ChecktolProjectPing(?), "", {
    258 //WriteLn("TRACE [GetMinTolVersionForPackage] 2");
    259   Set repositories =
    260     TolConfigManager::Config::Upgrading::TolPackage::Repositories;
    261   Real K = Card(repositories);
    262   Real k = 1;
    263   Text found = "";
    264 //WriteLn("TRACE [GetMinTolVersionForPackage] 3 K="<<K);
    265   While(And(found=="", k<=K),
    266   {
    267   //WriteLn("TRACE [GetMinTolVersionForPackage] 4 repositories["<<k+"]="<<repositories[k]);
    268     Set pkgLst = GetRepositoryInfo(repositories[k]+"?"+common_php_arguments+
    269       "&action=versions&limit=1&package="+package);
    270   //WriteLn("TRACE [GetMinTolVersionForPackage] 5 pkgInfo="<<pkgInfo);
    271   //WriteLn("TRACE [GetMinTolVersionForPackage] 6 pkgLst="<<pkgLst);
    272   //WriteLn("TRACE [GetMinTolVersionForPackage] 7 Card(pkgLst)="<<Card(pkgLst));
    273     Text If(Card(pkgLst)>0, found := pkgLst[1]->te_min_tol_version);
    274     Real k := k+1
    275   });
     282  Real _trace("GetMinTolVersionForPackage", "Begin", 1);
     283//WriteLn("_trace [GetMinTolVersionForPackage] 1 package='"<<package+"'");
     284  Text found = If(!ChecktolProjectPing(?), "",
     285  {
     286  //WriteLn("_trace [GetMinTolVersionForPackage] 2");
     287    Set repositories =
     288      TolConfigManager::Config::Upgrading::TolPackage::Repositories;
     289    Real K = Card(repositories);
     290    Real k = 1;
     291    Text found = "";
     292  //WriteLn("_trace [GetMinTolVersionForPackage] 3 K="<<K);
     293    While(And(found=="", k<=K),
     294    {
     295    //WriteLn("_trace [GetMinTolVersionForPackage] 4 repositories["<<k+"]="<<repositories[k]);
     296      Set pkgLst = GetRepositoryInfo(repositories[k]+"?"+common_php_arguments+
     297        "&action=versions&limit=1&package="+package);
     298    //WriteLn("_trace [GetMinTolVersionForPackage] 5 pkgInfo="<<pkgInfo);
     299    //WriteLn("_trace [GetMinTolVersionForPackage] 6 pkgLst="<<pkgLst);
     300    //WriteLn("_trace [GetMinTolVersionForPackage] 7 Card(pkgLst)="<<Card(pkgLst));
     301      Text If(Card(pkgLst)>0, found := pkgLst[1]->te_min_tol_version);
     302      Real k := k+1
     303    });
     304    found
     305  });
     306  Real _trace("GetMinTolVersionForPackage", "End", 1);
    276307  found
    277 })};
     308};
    278309
    279310//////////////////////////////////////////////////////////////////////////////
    … …  
    284315//////////////////////////////////////////////////////////////////////////////
    285316{
    286 //WriteLn("TRACE [GetMaxTolVersionForPackage] 1 package='"<<package+"'");
    287   If(!ChecktolProjectPing(?), "", {
    288 //WriteLn("TRACE [GetMaxTolVersionForPackage] 2");
    289   Set repositories =
    290     TolConfigManager::Config::Upgrading::TolPackage::Repositories;
    291   Real K = Card(repositories);
    292   Real k = 1;
    293   Text found = "";
    294 //WriteLn("TRACE [GetMaxTolVersionForPackage] 3 K="<<K);
    295   While(And(found=="", k<=K),
    296   {
    297   //WriteLn("TRACE [GetMaxTolVersionForPackage] 4 repositories["<<k+"]="<<repositories[k]);
    298     Set pkgLst = GetRepositoryInfo(repositories[k]+"?"+common_php_arguments+
    299       "&action=versions&limit=1&package="+package);
    300   //WriteLn("TRACE [GetMaxTolVersionForPackage] 5 pkgInfo="<<pkgInfo);
    301   //WriteLn("TRACE [GetMaxTolVersionForPackage] 6 pkgLst="<<pkgLst);
    302   //WriteLn("TRACE [GetMaxTolVersionForPackage] 7 Card(pkgLst)="<<Card(pkgLst));
    303     Text If(Card(pkgLst)>0, found := pkgLst[1]->te_max_tol_version);
    304     Real k := k+1
    305   });
     317  Real _trace("GetMaxTolVersionForPackage", "Begin", 1);
     318//WriteLn("_trace [GetMaxTolVersionForPackage] 1 package='"<<package+"'");
     319  Text found = If(!ChecktolProjectPing(?), "",
     320  {
     321  //WriteLn("_trace [GetMaxTolVersionForPackage] 2");
     322    Set repositories =
     323      TolConfigManager::Config::Upgrading::TolPackage::Repositories;
     324    Real K = Card(repositories);
     325    Real k = 1;
     326    Text found = "";
     327  //WriteLn("_trace [GetMaxTolVersionForPackage] 3 K="<<K);
     328    While(And(found=="", k<=K),
     329    {
     330    //WriteLn("_trace [GetMaxTolVersionForPackage] 4 repositories["<<k+"]="<<repositories[k]);
     331      Set pkgLst = GetRepositoryInfo(repositories[k]+"?"+common_php_arguments+
     332        "&action=versions&limit=1&package="+package);
     333    //WriteLn("_trace [GetMaxTolVersionForPackage] 5 pkgInfo="<<pkgInfo);
     334    //WriteLn("_trace [GetMaxTolVersionForPackage] 6 pkgLst="<<pkgLst);
     335    //WriteLn("_trace [GetMaxTolVersionForPackage] 7 Card(pkgLst)="<<Card(pkgLst));
     336      Text If(Card(pkgLst)>0, found := pkgLst[1]->te_max_tol_version);
     337      Real k := k+1
     338    });
     339    found
     340  });
     341  Real _trace("GetMaxTolVersionForPackage", "End", 1);
    306342  found
    307 })};
     343};
    308344
    309345
    … …  
    318354//////////////////////////////////////////////////////////////////////////////
    319355{
    320 //WriteLn("TRACE [RemoteFindRepository] 1 package='"<<package+"'");
    321   If(!ChecktolProjectPing(?), "", {
    322 //WriteLn("TRACE [RemoteFindRepository] 2");
    323   Set repositories =
    324     TolConfigManager::Config::Upgrading::TolPackage::Repositories;
    325   Real K = Card(repositories);
    326   Real k = 1;
    327   Text found = "";
    328 //WriteLn("TRACE [RemoteFindRepository] 3 K="<<K);
    329   While(And(found=="", k<=K),
    330   {
    331   //WriteLn("TRACE [RemoteFindRepository] 4 repositories["<<k+"]="<<repositories[k]);
    332     Set pkgLst = GetRepositoryInfo(repositories[k]+"?"+common_php_arguments+
    333       "&action=versions&limit=1&package="+package);
    334   //WriteLn("TRACE [RemoteFindRepository] 6 pkgLst="<<pkgLst);
    335   //WriteLn("TRACE [RemoteFindRepository] 7 Card(pkgLst)="<<Card(pkgLst));
    336     Text If(Card(pkgLst)>0, found := repositories[k]);
    337     Real k := k+1
    338   });
     356  Real _trace("RemoteFindRepository", "Begin", 1);
     357//WriteLn("_trace [RemoteFindRepository] 1 package='"<<package+"'");
     358  Text found = If(!ChecktolProjectPing(?), "",
     359  {
     360  //WriteLn("_trace [RemoteFindRepository] 2");
     361    Set repositories =
     362      TolConfigManager::Config::Upgrading::TolPackage::Repositories;
     363    Real K = Card(repositories);
     364    Real k = 1;
     365    Text found = "";
     366  //WriteLn("_trace [RemoteFindRepository] 3 K="<<K);
     367    While(And(found=="", k<=K),
     368    {
     369    //WriteLn("_trace [RemoteFindRepository] 4 repositories["<<k+"]="<<repositories[k]);
     370      Set pkgLst = GetRepositoryInfo(repositories[k]+"?"+common_php_arguments+
     371        "&action=versions&limit=1&package="+package);
     372    //WriteLn("_trace [RemoteFindRepository] 6 pkgLst="<<pkgLst);
     373    //WriteLn("_trace [RemoteFindRepository] 7 Card(pkgLst)="<<Card(pkgLst));
     374      Text If(Card(pkgLst)>0, found := repositories[k]);
     375      Real k := k+1
     376    });
     377    found
     378  });
     379  Real _trace("RemoteFindRepository", "Begin", 1);
    339380  found
    340 })};
     381};
    341382
    342383//////////////////////////////////////////////////////////////////////////////
    … …  
    351392//////////////////////////////////////////////////////////////////////////////
    352393{
    353   If(!ChecktolProjectPing(?), UnknownDate, {
    354   Text rep = If(repository=="",repository,RemoteFindRepository(package));
    355   If(rep=="", UnknownDate,
    356   {
    357     Set pkgLst = GetRepositoryInfo(rep+"?"+common_php_arguments+
    358       "&action=versions&limit=1&package="+package);
    359     If(!Card(pkgLst), TheEnd,
    360       pkgLst[1]->dh_release_date_remote)
    361   })
    362 })};
     394  Real _trace("RemoteReleaseDate", "Begin", 1);
     395  Date dte =If(!ChecktolProjectPing(?), UnknownDate,
     396  {
     397    Text rep = If(repository=="",repository,RemoteFindRepository(package));
     398    If(rep=="", UnknownDate,
     399    {
     400      Set pkgLst = GetRepositoryInfo(rep+"?"+common_php_arguments+
     401        "&action=versions&limit=1&package="+package);
     402      If(!Card(pkgLst), TheEnd,
     403        pkgLst[1]->dh_release_date_remote)
     404    })
     405  });
     406  Real _trace("RemoteReleaseDate", "End", 1);
     407  dte
     408};
    363409
    364410//////////////////////////////////////////////////////////////////////////////
    … …  
    370416//////////////////////////////////////////////////////////////////////////////
    371417{
    372   If(!ChecktolProjectPing(?), 0, {
    373   Real OSDirMake(localRoot);
    374 //WriteLn("TRACE [DownloadPackage] 1 repository='"<<repository+"'");
    375   Real ok = True;
    376   Text package.orig = package;
    377   Set pkg.tok = Tokenizer(package,".");
    378   Real pkg.tok.num = Card(pkg.tok );
    379   Text package := pkg.tok[1];
    380   Text package.version = Case(
    381     pkg.tok.num==3, pkg.tok[1]+"."+pkg.tok[2]+"."+pkg.tok[3],
    382     pkg.tok.num==2, pkg.tok[1]+"."+pkg.tok[2],
    383     pkg.tok.num==1, pkg.tok[1]);
    384   Set pkgLst = GetRepositoryInfo(repository+"?"+common_php_arguments+
    385     "&action=versions&limit=1&package="+package.version);
    386   Real ok := Card(pkgLst);
    387   Text If(ok,
    388   {
    389     Text package.version := pkgLst[1]->co_name_version
    390   });
    391   If(!ok, 0, {
    392 //WriteLn("TRACE [DownloadPackage] 2.1 package.orig='"<<package.orig+"'");
    393 //WriteLn("TRACE [DownloadPackage] 2.2 package='"<<package+"'");
    394 //WriteLn("TRACE [DownloadPackage] 2.3 package.version='"<<package.version+"'");
    395 
    396   Text pack = package.version+".zip";
    397   Text oza = package.version+"/"+package.version+".oza";
    398   Text localPack = localRoot+"/"+pack;
    399   Text localOza = localRoot+"/"+oza;
    400   Text localDir = localRoot+"/"+package.version;
    401 
    402   Text encoded = GetUrlContents(repository+"?"+common_php_arguments+
    403     "&action=download"+
    404     "&format=base64"+
    405     "&package="+package.version);
    406 //WriteLn("TRACE [DownloadPackage] 3 encoded='"<<encoded+"'");
    407   Real DecodeBase64ToFile(localPack, encoded);
    408   If(!FileExist(localPack), False,
    409   {
    410   //WriteLn("TRACE DownloadPackage 4 UnpackFull("<<localDir+")");
    411     Real PackArchive::UnpackFull("ZipArchive", localDir, True);
    412     True
    413   });
    414   If(!FileExist(localOza), False,
    415   {
    416   //WriteLn("TRACE DownloadPackage 5");
    417     Real RemoteUpdateVersSyncInfo(?);
    418     True
    419   })
    420  })})};
     418  Real _trace("DownloadPackage", "Begin", 1);
     419  Real ok = If(!ChecktolProjectPing(?), 0,
     420  {
     421    Real OSDirMake(localRoot);
     422  //WriteLn("_trace [DownloadPackage] 1 repository='"<<repository+"'");
     423    Real ok = True;
     424    Text package.orig = package;
     425    Set pkg.tok = Tokenizer(package,".");
     426    Real pkg.tok.num = Card(pkg.tok );
     427    Text package := pkg.tok[1];
     428    Text package.version = Case(
     429      pkg.tok.num==3, pkg.tok[1]+"."+pkg.tok[2]+"."+pkg.tok[3],
     430      pkg.tok.num==2, pkg.tok[1]+"."+pkg.tok[2],
     431      pkg.tok.num==1, pkg.tok[1]);
     432    Set pkgLst = GetRepositoryInfo(repository+"?"+common_php_arguments+
     433      "&action=versions&limit=1&package="+package.version);
     434    Real ok := Card(pkgLst);
     435    Text If(ok,
     436    {
     437      Text package.version := pkgLst[1]->co_name_version
     438    });
     439    If(!ok, 0, {
     440  //WriteLn("_trace [DownloadPackage] 2.1 package.orig='"<<package.orig+"'");
     441  //WriteLn("_trace [DownloadPackage] 2.2 package='"<<package+"'");
     442  //WriteLn("_trace [DownloadPackage] 2.3 package.version='"<<package.version+"'");
     443
     444    Text pack = package.version+".zip";
     445    Text oza = package.version+"/"+package.version+".oza";
     446    Text localPack = localRoot+"/"+pack;
     447    Text localOza = localRoot+"/"+oza;
     448    Text localDir = localRoot+"/"+package.version;
     449
     450    Text encoded = GetUrlContents(repository+"?"+common_php_arguments+
     451      "&action=download"+
     452      "&format=base64"+
     453      "&package="+package.version);
     454  //WriteLn("_trace [DownloadPackage] 3 encoded='"<<encoded+"'");
     455    Real DecodeBase64ToFile(localPack, encoded);
     456    If(!FileExist(localPack), False,
     457    {
     458    //WriteLn("_trace DownloadPackage 4 UnpackFull("<<localDir+")");
     459      Real PackArchive::UnpackFull("ZipArchive", localDir, True);
     460      True
     461    });
     462    If(!FileExist(localOza), False,
     463    {
     464    //WriteLn("_trace DownloadPackage 5");
     465      Real RemoteUpdateVersSyncInfo(?);
     466      True
     467    })
     468  })});
     469  Real _trace("DownloadPackage", "End", 1);
     470  ok
     471};
    421472
    422473//////////////////////////////////////////////////////////////////////////////
    … …  
    450501//////////////////////////////////////////////////////////////////////////////
    451502{
    452   If(!ChecktolProjectPing(?), 0, {
    453   Set pkgLst = GetRepositoryInfo(repository+"?"+common_php_arguments+
    454     "&action=versions");
    455   If(!Card(pkgLst), False,
    456   SetMin(EvalSet(pkgLst, Real(Set pkg)
    457   {
    458     RemoteInstallPackage(repository, pkg->co_name_version, showError)
    459   })))
    460 })};
     503  Real _trace("RemoteInstallFullRepository", "Begin", 1);
     504  Real ok = If(!ChecktolProjectPing(?), 0,
     505  {
     506    Set pkgLst = GetRepositoryInfo(repository+"?"+common_php_arguments+
     507      "&action=versions");
     508    If(!Card(pkgLst), False,
     509    SetMin(EvalSet(pkgLst, Real(Set pkg)
     510    {
     511      RemoteInstallPackage(repository, pkg->co_name_version, showError)
     512    })))
     513  });
     514  Real _trace("RemoteInstallFullRepository", "End", 1);
     515  ok
     516};
    461517
    462518//////////////////////////////////////////////////////////////////////////////
    … …  
    482538//////////////////////////////////////////////////////////////////////////////
    483539{
    484 //WriteLn("TRACE [RemoteInstall] 1 repository='"<<repository+"'");
    485 //WriteLn("TRACE [RemoteInstall] 2 package='"<<package+"'");
    486   If(!ChecktolProjectPing(?), 0, {
    487   Case(
    488   And(repository!="",package!=""),
    489   {
    490   //WriteLn("TRACE [RemoteInstall] 3.1");
    491     RemoteInstallPackage(repository, package, showError)
    492   },
    493   And(repository=="",package!=""),
    494   {
    495   //WriteLn("TRACE [RemoteInstall] 3.2");
    496     Text rep = If(repository!="",repository,RemoteFindRepository(package));
    497   //WriteLn("TRACE [RemoteInstall] 3.2.1 rep ="<<rep);
    498     If(rep=="",
    499     {
    500       If(showError,
     540  Real _trace("RemoteInstall", "Begin", 1);
     541//WriteLn("_trace [RemoteInstall] 1 repository='"<<repository+"'");
     542//WriteLn("_trace [RemoteInstall] 2 package='"<<package+"'");
     543  Real ok = If(!ChecktolProjectPing(?), 0,
     544  {
     545    Case(
     546    And(repository!="",package!=""),
     547    {
     548    //WriteLn("_trace [RemoteInstall] 3.1");
     549      RemoteInstallPackage(repository, package, showError)
     550    },
     551    And(repository=="",package!=""),
     552    {
     553    //WriteLn("_trace [RemoteInstall] 3.2");
     554      Text rep = If(repository!="",repository,RemoteFindRepository(package));
     555    //WriteLn("_trace [RemoteInstall] 3.2.1 rep ="<<rep);
     556      If(rep=="",
    501557      {
    502         Text minTolVersion = GetMinTolVersionForPackage(package);
    503         If(minTolVersion=="",
    504         Error(I2(
    505           "Cannot find package "+package+" in any repository for any TOL "
    506           "version.",
    507           "No se encuentra el paquete "+package+" en ningún repositorio "
    508           "para ninguna versión de TOL.")),
    509         Error(I2(
    510           "Cannot find package "+package+" in any repository for current "
    511           "TOL version ",
    512           "No se encuentra el paquete "+package+" en ningún repositorio "
    513           "para la versión de TOL en curso ")+TolPackage::_.currentTolVersion+
    514           ".\n"+I2("You needs to use ", "Es necesario usar ")+minTolVersion))
     558        If(showError,
     559        {
     560          Text minTolVersion = GetMinTolVersionForPackage(package);
     561          If(minTolVersion=="",
     562          Error(I2(
     563            "Cannot find package "+package+" in any repository for any TOL "
     564            "version.",
     565            "No se encuentra el paquete "+package+" en ningún repositorio "
     566            "para ninguna versión de TOL.")),
     567          Error(I2(
     568            "Cannot find package "+package+" in any repository for current "
     569            "TOL version ",
     570            "No se encuentra el paquete "+package+" en ningún repositorio "
     571            "para la versión de TOL en curso ")+TolPackage::_.currentTolVersion+
     572            ".\n"+I2("You needs to use ", "Es necesario usar ")+minTolVersion))
     573        })
     574      },
     575      {
     576      //WriteLn("_trace [RemoteInstall] 3.2.2 ");
     577        RemoteInstallPackage(rep, package, showError)
    515578      })
    516579    },
    517     {
    518     //WriteLn("TRACE [RemoteInstall] 3.2.2 ");
    519       RemoteInstallPackage(rep, package, showError)
     580    And(repository!="",package==""),
     581    {
     582    //WriteLn("_trace [RemoteInstall] 3.3");
     583      RemoteInstallFullRepository(repository, showError)
     584    },
     585    And(repository=="",package==""),
     586    {
     587    //WriteLn("_trace [RemoteInstall] 3.4");
     588      Set repositories =
     589        TolConfigManager::Config::Upgrading::TolPackage::Repositories;
     590      SetMin(EvalSet(repositories, Real(Text rep)
     591      {
     592        RemoteInstallFullRepository(rep, showError)
     593      }))
    520594    })
    521   },
    522   And(repository!="",package==""),
    523   {
    524   //WriteLn("TRACE [RemoteInstall] 3.3");
    525     RemoteInstallFullRepository(repository, showError)
    526   },
    527   And(repository=="",package==""),
    528   {
    529   //WriteLn("TRACE [RemoteInstall] 3.4");
    530     Set repositories =
    531       TolConfigManager::Config::Upgrading::TolPackage::Repositories;
    532     SetMin(EvalSet(repositories, Real(Text rep)
    533     {
    534       RemoteInstallFullRepository(rep, showError)
    535     }))
    536   })
    537 })};
     595  });
     596  Real _trace("RemoteInstall", "End", 1);
     597  ok
     598};
    538599
    539600//////////////////////////////////////////////////////////////////////////////
    … …  
    547608//////////////////////////////////////////////////////////////////////////////
    548609{
    549   If(!ChecktolProjectPing(?), 0, {
    550   Set repositories =
    551     TolConfigManager::Config::Upgrading::TolPackage::Repositories;
    552   Set _.versSyncInfo := SetConcat(EvalSet(repositories,Set(Text rep)
    553   {
    554     GetRepositoryInfo(rep+"?"+common_php_arguments+"&action=versions")
    555   }));
    556   Real SetIndexByName(_.versSyncInfo);
    557   Set pkgLst = GetDir(TolPackage::Client::_.localRoot)[2];
    558   Set EvalSet(pkgLst, Real(Text pkg)
    559   {
    560     Real found = FindIndexByName(_.versSyncInfo, pkg);
    561     Date If(!found, WriteLn("[RemoteUpdateVersSyncInfo] "+I2(
    562       "Cannot find remote image of local package "+pkg+
    563       " in any repository." ,
    564       "No se encuentra la imagen remota del paquete local "+pkg+
    565       " en ningún repositorio"),"W"),
    566     {
    567       Date gmt = Copy(NowGmt);
    568       Date loc = Copy(Now);
    569       Real lag = Round(DateDif(S(0),loc,gmt)/10)*10;
    570       Text oza = TolPackage::Client::_.localRoot+pkg+"/"+pkg+".oza";
    571       Date release.loc = FileTime(oza);
    572       Date release.gmt = Succ(release.loc,S(0),lag);
    573       _.versSyncInfo[found]->dh_release_date_local := release.gmt
    574     });
    575     True
    576   });
    577   Real Ois.Store(_.versSyncInfo,_.localRoot+"/VersSyncInfo.oza");
    578   Card(_.versSyncInfo)
    579 })};
     610  Real _trace("RemoteUpdateVersSyncInfo", "Begin", 1);
     611  Real ok = If(!ChecktolProjectPing(?), 0,
     612  {
     613    Set repositories =
     614      TolConfigManager::Config::Upgrading::TolPackage::Repositories;
     615    Set _.versSyncInfo := SetConcat(EvalSet(repositories,Set(Text rep)
     616    {
     617      GetRepositoryInfo(rep+"?"+common_php_arguments+"&action=versions")
     618    }));
     619    Real SetIndexByName(_.versSyncInfo);
     620    Set pkgLst = GetDir(TolPackage::Client::_.localRoot)[2];
     621    Set EvalSet(pkgLst, Real(Text pkg)
     622    {
     623      Real found = FindIndexByName(_.versSyncInfo, pkg);
     624      Date If(!found, WriteLn("[RemoteUpdateVersSyncInfo] "+I2(
     625        "Cannot find remote image of local package "+pkg+
     626        " in any repository." ,
     627        "No se encuentra la imagen remota del paquete local "+pkg+
     628        " en ningún repositorio"),"W"),
     629      {
     630        Date gmt = Copy(NowGmt);
     631        Date loc = Copy(Now);
     632        Real lag = Round(DateDif(S(0),loc,gmt)/10)*10;
     633        Text oza = TolPackage::Client::_.localRoot+pkg+"/"+pkg+".oza";
     634        Date release.loc = FileTime(oza);
     635        Date release.gmt = Succ(release.loc,S(0),lag);
     636        _.versSyncInfo[found]->dh_release_date_local := release.gmt
     637      });
     638      True
     639    });
     640    Real Ois.Store(_.versSyncInfo,_.localRoot+"/VersSyncInfo.oza");
     641    Card(_.versSyncInfo)
     642  });
     643  Real _trace("RemoteUpdateVersSyncInfo", "End", 1);
     644  ok
     645};
    580646
    581647//////////////////////////////////////////////////////////////////////////////
    … …  
    588654//////////////////////////////////////////////////////////////////////////////
    589655{
    590   Text _MID = "TolPackage::Client::[RemoteUpdatePackSyncInfo] ";
    591   If(!ChecktolProjectPing(?), 0, {
    592   Set repositories =
    593     TolConfigManager::Config::Upgrading::TolPackage::Repositories;
    594   Set _.packSyncInfo := SetConcat(EvalSet(repositories,Set ev.rep(Text rep)
    595   {
    596     GetRepositoryInfo(rep+"?"+common_php_arguments+"&action=packages")
    597   }));
    598   Real SetIndexByName(_.packSyncInfo);
    599   Set verLst = GetDir(TolPackage::Client::_.localRoot)[2];
    600   Set verCls = Classify(verLst,Real ev.class(Text a, Text b)
    601   {
    602     Compare(Tokenizer(a,".")[1], Tokenizer(b,".")[1])
    603   });
    604   Set EvalSet(verCls, Real ev.check(Set cls)
    605   {
    606     Text pkg = Tokenizer(cls[1],".")[1];
    607     Real found = FindIndexByName(_.packSyncInfo, pkg);
    608     Real If(!found,
    609     {
    610       If(showWarnings,
    611         WriteLn(_MID+I2(
    612         "Cannot find remote image of local package "+pkg+
    613         " in any repository." ,
    614         "No se encuentra la imagen remota del paquete local "+pkg+
    615         " en ningún repositorio"),"W"));
    616       False
    617     },
    618     {
    619       Set ord = Sort(cls,Real ev.sort(Text a, Text b) {
    620         Compare.VersionString(b, a) });
    621       Text ver = ord[1];
    622       Date gmt = Copy(NowGmt);
    623       Date loc = Copy(Now);
    624       Real lag = Round(DateDif(S(0),loc,gmt)/10)*10;
    625       Text oza = TolPackage::Client::_.localRoot+ver+"/"+ver+".oza";
    626       Date release.loc = FileTime(oza);
    627       Date release.gmt = Succ(release.loc,S(0),lag);
    628       Date _.packSyncInfo[found]->co_last_version_local := ver;
    629       Date _.packSyncInfo[found]->dh_release_date_local := release.gmt;
     656  Real _trace("RemoteUpdateVersSyncInfo", "Begin", 1);
     657  Text _MID = "[RemoteUpdatePackSyncInfo] ";
     658  Real ok = If(!ChecktolProjectPing(?), 0,
     659  {
     660    Set repositories =
     661      TolConfigManager::Config::Upgrading::TolPackage::Repositories;
     662    Set _.packSyncInfo := SetConcat(EvalSet(repositories,Set ev.rep(Text rep)
     663    {
     664      GetRepositoryInfo(rep+"?"+common_php_arguments+"&action=packages")
     665    }));
     666    Real SetIndexByName(_.packSyncInfo);
     667    Set verLst = GetDir(TolPackage::Client::_.localRoot)[2];
     668    Set verCls = Classify(verLst,Real ev.class(Text a, Text b)
     669    {
     670      Compare(Tokenizer(a,".")[1], Tokenizer(b,".")[1])
     671    });
     672    Set EvalSet(verCls, Real ev.check(Set cls)
     673    {
     674      Text pkg = Tokenizer(cls[1],".")[1];
     675      Real found = FindIndexByName(_.packSyncInfo, pkg);
     676      Real If(!found,
     677      {
     678        If(showWarnings,
     679          WriteLn(_MID+I2(
     680          "Cannot find remote image of local package "+pkg+
     681          " in any repository." ,
     682          "No se encuentra la imagen remota del paquete local "+pkg+
     683          " en ningún repositorio"),"W"));
     684        False
     685      },
     686      {
     687        Set ord = Sort(cls,Real ev.sort(Text a, Text b) {
     688          Compare.VersionString(b, a) });
     689        Text ver = ord[1];
     690        Date gmt = Copy(NowGmt);
     691        Date loc = Copy(Now);
     692        Real lag = Round(DateDif(S(0),loc,gmt)/10)*10;
     693        Text oza = TolPackage::Client::_.localRoot+ver+"/"+ver+".oza";
     694        Date release.loc = FileTime(oza);
     695        Date release.gmt = Succ(release.loc,S(0),lag);
     696        Date _.packSyncInfo[found]->co_last_version_local := ver;
     697        Date _.packSyncInfo[found]->dh_release_date_local := release.gmt;
     698        True
     699      });
    630700      True
    631701    });
    632     True
    633   });
    634   Set _.packForUpdate := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
    635   {
    636     Real need = And(pkg->co_last_version_local != "",
    637         pkg->co_last_version_local == pkg->co_last_version_remote, 
    638         pkg->dh_release_date_local <  pkg->dh_release_date_remote);
    639     If(And(showWarnings,need),
    640     {
    641       WriteLn("  Local package "<<pkg->co_last_version_local+
    642               " created at "<<pkg->dh_release_date_local+
    643               " could be updated to newer remote patch since "<<pkg->dh_release_date_remote)
    644     });
    645     need
    646   });
    647   If(And(showWarnings,Card(_.packForUpdate)),
    648   {
    649     WriteLn(_MID+"There are "<<Card(_.packForUpdate)+" packages that you could update "
    650             "from remote repositories to new patches of the same version.\n"
    651             "You can view them at:\n "
    652             "  Set TolPackage::Client::_.packForUpdate\n"
    653             "You could update all them running this TOL sentence: \n"
    654             "  Real TolPackage::Client::RemoteUpdateAll(0)\n",
    655             "W")
    656   });
    657   Set _.packForUpgrade := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
    658   {
    659     Real need = And(pkg->co_last_version_local != "",
    660         pkg->co_last_version_local < pkg->co_last_version_remote);
    661     If(And(showWarnings,need),
    662     {
    663       WriteLn("  Local package "<<pkg->co_last_version_local+
    664               " could be upgraded to "<<pkg->co_last_version_remote)
    665     });
    666     need
    667   });
    668   If(And(showWarnings,Card(_.packForUpgrade)),
    669   {
    670     WriteLn(_MID+"There are "<<Card(_.packForUpgrade)+" packages that you could upgrade "
    671             "from remote repositories to new versions.\n"
    672             "You can view them at:\n "
    673             "  Set TolPackage::Client::_.packForUpgrade\n"
    674             "You can upgrade all them running this TOL sentence: \n"
    675             "  Real TolPackage::Client::RemoteUpgradeAll(0)\n",
    676             "W")
    677   });
    678   Set _.packForInstall := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
    679   {
    680     pkg->co_last_version_local == "" 
    681   });
    682   Set _.packInstalled := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
    683   {
    684     pkg->co_last_version_local != "" 
    685   });
    686   Real Ois.Store(_.packSyncInfo,_.localRoot+"/PackSyncInfo.oza");
    687   Card(_.packSyncInfo)
    688 })};
     702    Set _.packForUpdate := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
     703    {
     704      Real need = And(pkg->co_last_version_local != "",
     705          pkg->co_last_version_local == pkg->co_last_version_remote, 
     706          pkg->dh_release_date_local <  pkg->dh_release_date_remote);
     707      If(And(showWarnings,need),
     708      {
     709        WriteLn("  Local package "<<pkg->co_last_version_local+
     710                " created at "<<pkg->dh_release_date_local+
     711                " could be updated to newer remote patch since "<<pkg->dh_release_date_remote)
     712      });
     713      need
     714    });
     715    If(And(showWarnings,Card(_.packForUpdate)),
     716    {
     717      WriteLn(_MID+"There are "<<Card(_.packForUpdate)+" packages that you could update "
     718              "from remote repositories to new patches of the same version.\n"
     719              "You can view them at:\n "
     720              "  Set TolPackage::Client::_.packForUpdate\n"
     721              "You could update all them running this TOL sentence: \n"
     722              "  Real TolPackage::Client::RemoteUpdateAll(0)\n",
     723              "W")
     724    });
     725    Set _.packForUpgrade := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
     726    {
     727      Real need = And(pkg->co_last_version_local != "",
     728          Compare.VersionString(pkg->co_last_version_local,pkg->co_last_version_remote)<0);
     729          Compare.VersionString
     730      If(And(showWarnings,need),
     731      {
     732        WriteLn("  Local package "<<pkg->co_last_version_local+
     733                " could be upgraded to "<<pkg->co_last_version_remote)
     734      });
     735      need
     736    });
     737    If(And(showWarnings,Card(_.packForUpgrade)),
     738    {
     739      WriteLn(_MID+"There are "<<Card(_.packForUpgrade)+" packages that you could upgrade "
     740              "from remote repositories to new versions.\n"
     741              "You can view them at:\n "
     742              "  Set TolPackage::Client::_.packForUpgrade\n"
     743              "You can upgrade all them running this TOL sentence: \n"
     744              "  Real TolPackage::Client::RemoteUpgradeAll(0)\n",
     745              "W")
     746    });
     747    Set _.packForInstall := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
     748    {
     749      pkg->co_last_version_local == "" 
     750    });
     751    Set _.packInstalled := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
     752    {
     753      pkg->co_last_version_local != "" 
     754    });
     755    Real Ois.Store(_.packSyncInfo,_.localRoot+"/PackSyncInfo.oza");
     756    Card(_.packSyncInfo)
     757  });
     758  Real _trace("RemoteUpdateVersSyncInfo", "End", 1);
     759  ok
     760};
    689761
    690762
    … …  
    696768//////////////////////////////////////////////////////////////////////////////
    697769{
     770  Real _trace("RemoteUpdateAll", "Begin", 1);
    698771  Real If(Or(updateSyncInfo,!Card(_.packSyncInfo)),
    699772    RemoteUpdatePackSyncInfo(False));
    700   If(!Card(_.packForUpdate), 0,
     773  Real ok = If(!Card(_.packForUpdate), 0,
    701774  SetSum(EvalSet(_.packForUpdate, Real(TolPackage::@PackageSynchro pkg)
    702775  {
    703776    RemoteInstallPackage(pkg->te_url, pkg->co_last_version_remote, True)
    704   })))
     777  })));
     778  Real _trace("RemoteUpdateAll", "End", 1);
     779  ok
    705780};
    706781
    … …  
    712787//////////////////////////////////////////////////////////////////////////////
    713788{
     789  Real _trace("RemoteUpgradeAll", "Begin", 1);
    714790  Real If(Or(updateSyncInfo,!Card(_.packSyncInfo)),
    715791    RemoteUpdatePackSyncInfo(False));
    716   If(!Card(_.packForUpgrade), 0,
     792  Real ok = If(!Card(_.packForUpgrade), 0,
    717793  SetSum(EvalSet(_.packForUpgrade, Real(TolPackage::@PackageSynchro pkg)
    718794  {
    719795    RemoteInstallPackage(pkg->te_url, pkg->co_last_version_remote, True)
    720   })))
     796  })));
     797  Real _trace("RemoteUpgradeAll", "End", 1);
     798  ok
    721799};
    722800
    … …  
    727805////////////////////////////////////////////////////////////////////////////////
    728806{
     807  Real _trace("GetCompatibleVersion.one", "Begin", 1);
    729808  Real If(!Card(_.versSyncInfo),
    730809   TolPackage::Client::RemoteUpdateVersSyncInfo(True));
    … …  
    743822    Compare.VersionString(b->co_name_version,a->co_name_version)
    744823  })[1];
     824  Real _trace("GetCompatibleVersion.one", "End", 1);
    745825  last_compatible->co_name_version
    746826};
    … …  
    765845////////////////////////////////////////////////////////////////////////////////
    766846{
     847  Real _trace("GetDeepDependencies.one", "Begin", 1);
    767848  Real If(!Card(_.versSyncInfo),
    768849   TolPackage::Client::RemoteUpdateVersSyncInfo(True));
    … …  
    771852    reg->co_name_version == package.version
    772853  });
    773   If(!Card(sel), sel,
     854  Set s = If(!Card(sel), sel,
    774855  {
    775856    Text depExpr = sel[1]->te_dependencies;
    … …  
    779860    });
    780861    Unique(SetConcat(EvalSet(dep,GetDeepDependencies.one))<<[[ sel[1]->co_name_version ]])
    781   })
     862  });
     863  Real _trace("GetDeepDependencies.one", "End", 1);
     864  s
    782865};
    783866
    … …  
    797880////////////////////////////////////////////////////////////////////////////////
    798881{
     882  Real _trace("GetVersionInfo", "Begin", 1);
    799883  Real If(!Card(_.versSyncInfo),
    800884   TolPackage::Client::RemoteUpdateVersSyncInfo(True));
    801   EvalSet(package.version.list, TolPackage::@VersionSynchro(Text pv)
     885  Set s = EvalSet(package.version.list, TolPackage::@VersionSynchro(Text pv)
    802886  {
    803887    _.versSyncInfo[pv]
    804   })
     888  });
     889  Real _trace("GetVersionInfo", "End", 1);
     890  s
    805891};
    806892
    … …  
    833919////////////////////////////////////////////////////////////////////////////////
    834920{
     921  Real _trace("DownloadCompatibleDeepDependencies", "Begin", 1);
    835922  Real If(cleanLocalRoot, OSDirRemove(localRoot));
    836923  Set dep = GetCompatibleDeepDependencies(tol_version, package.list);
    837   SetMin(EvalSet(dep, Real(TolPackage::@VersionSynchro vsi)
     924  Real ok = SetMin(EvalSet(dep, Real(TolPackage::@VersionSynchro vsi)
    838925  {
    839926    DownloadPackage(vsi->te_url,vsi->co_name_version,True,localRoot)
    840   }))
     927  }));
     928  Real _trace("DownloadCompatibleDeepDependencies", "End", 1);
     929  ok
    841930};
    842931
Note: See TracChangeset for help on using the changeset viewer.