Changeset 3a14843 in tol


Ignore:
Timestamp:
Oct 18, 2010, 3:35:35 PM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
33ff7ee
Parents:
ace5023
Message:

New updating and upgrading methods

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

Location:
tol/stdlib
Files:
3 edited

Legend:

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

    race5023 r3a14843  
    1515  Replace(TolAppDataPath+"TolPackage/Client/","\\","/");
    1616
    17 Set _.syncInfo = Copy(Empty);
     17Set _.versSyncInfo = Copy(Empty);
     18Set _.packSyncInfo = Copy(Empty);
     19Set _.packForUpdate = Copy(Empty);
     20Set _.packForUpgrade = Copy(Empty);
     21Set _.packForInstall = Copy(Empty);
     22Set _.packInstalled = Copy(Empty);
    1823
    1924Text min_tol_version_cond =
    … …  
    283288  If(!FileExist(localPack), False,
    284289  {
    285   //WriteLn("TRACE DownloadPackage UnpackFull("<<localDir+")");
     290  //WriteLn("TRACE DownloadPackage 4 UnpackFull("<<localDir+")");
    286291    Real PackArchive::UnpackFull("ZipArchive", localDir);
    287292    Real OSFilRemove(localPack);
    288293    True
    289294  });
     295//WriteLn("TRACE DownloadPackage 5");
    290296  FileExist(localOza) 
    291297})};
    … …  
    375381
    376382//////////////////////////////////////////////////////////////////////////////
    377 Text _.autodoc.member.RemoteUpdateSyncInfo =
    378 "Actualiza la información necesaria para la sincronización de paquetes "
    379 "locales con el repositorio remoto para aquellos que son compatibles con "
    380 "la versión actual de TOL.\n"
    381 "Devuelve el número de paquetes compatibles disponibles de forma remota.";
    382 Real RemoteUpdateSyncInfo(Real void)
     383Text _.autodoc.member.RemoteUpdateVersSyncInfo =
     384"Actualiza la información necesaria para la sincronización de versiones de "
     385"paquetes locales con el repositorio remoto para aquellos que son "
     386"compatibles con la versión actual de TOL.\n"
     387"Devuelve el número de versiones de paquetes compatibles disponibles de "
     388"forma remota.";
     389Real RemoteUpdateVersSyncInfo(Real void)
    383390//////////////////////////////////////////////////////////////////////////////
    384391{
    … …  
    386393  Set repositories =
    387394    TolConfigManager::Config::Upgrading::TolPackage::Repositories;
    388   Set _.syncInfo := SetConcat(EvalSet(repositories,Set(Text rep)
     395  Set _.versSyncInfo := SetConcat(EvalSet(repositories,Set(Text rep)
    389396  {
    390397    Text pkgInfo = GetUrlContents(rep+"?"
    … …  
    393400    IncludeText(pkgInfo)
    394401  }));
    395   Real SetIndexByName(_.syncInfo);
     402  Real SetIndexByName(_.versSyncInfo);
    396403  Set pkgLst = GetDir(TolPackage::Client::_.localRoot)[2];
    397404  Set EvalSet(pkgLst, Real(Text pkg)
    398405  {
    399     Real found = FindIndexByName(_.syncInfo, pkg);
    400     Date If(!found, WriteLn("[RemoteUpdateSyncInfo] "+I2(
     406    Real found = FindIndexByName(_.versSyncInfo, pkg);
     407    Date If(!found, WriteLn("[RemoteUpdateVersSyncInfo] "+I2(
    401408      "Cannot find remote image of local package "+pkg+
    402409      " in any repository." ,
    … …  
    410417      Date release.loc = FileTime(oza);
    411418      Date release.gmt = Succ(release.loc,S(0),lag);
    412       _.syncInfo[found]->dh_release_date_local := release.gmt
     419      _.versSyncInfo[found]->dh_release_date_local := release.gmt
    413420    });
    414421    True
    415422  });
    416   Card(_.syncInfo)
    417 })};
    418 
     423  Card(_.versSyncInfo)
     424})};
     425
     426//////////////////////////////////////////////////////////////////////////////
     427Text _.autodoc.member.RemoteUpdatePackSyncInfo =
     428"Actualiza la información necesaria para la sincronización de paquetes "
     429"locales con el repositorio remoto para aquellos que son "
     430"compatibles con la versión actual de TOL.\n"
     431"Devuelve el número de paquetes compatibles disponibles de forma remota.";
     432Real RemoteUpdatePackSyncInfo(Real showWarnings)
     433//////////////////////////////////////////////////////////////////////////////
     434{
     435  Text _MID = "TolPackage::Client::[RemoteUpdatePackSyncInfo]\n";
     436  If(TolConfigManager::Config::Upgrading::TolPackage::LocalOnly, 0, {
     437  Set repositories =
     438    TolConfigManager::Config::Upgrading::TolPackage::Repositories;
     439  Set _.packSyncInfo := SetConcat(EvalSet(repositories,Set(Text rep)
     440  {
     441    Text pkgInfo = GetUrlContents(rep+"?"
     442      "action=packages&"+
     443      min_tol_version_cond);
     444    IncludeText(pkgInfo)
     445  }));
     446  Real SetIndexByName(_.packSyncInfo);
     447  Set verLst = GetDir(TolPackage::Client::_.localRoot)[2];
     448  Set verCls = Classify(verLst,Real(Text a, Text b)
     449  {
     450    Compare(Tokenizer(a,".")[1], Tokenizer(b,".")[1])
     451  });
     452  Set EvalSet(verCls, Real(Set cls)
     453  {
     454    Text pkg = Tokenizer(cls[1],".")[1];
     455    Real found = FindIndexByName(_.packSyncInfo, pkg);
     456    Date If(And(!found,showWarnings), WriteLn(_MID+I2(
     457      "Cannot find remote image of local package "+pkg+
     458      " in any repository." ,
     459      "No se encuentra la imagen remota del paquete local "+pkg+
     460      " en ningún repositorio"),"W"),
     461    {
     462      Set ord = Sort(cls,Real(Text a, Text b) { Compare(b, a) });
     463      Text ver = ord[1];
     464      Date gmt = Copy(NowGmt);
     465      Date loc = Copy(Now);
     466      Real lag = Round(DateDif(S(0),loc,gmt)/10)*10;
     467      Text oza = TolPackage::Client::_.localRoot+ver+"/"+ver+".oza";
     468      Date release.loc = FileTime(oza);
     469      Date release.gmt = Succ(release.loc,S(0),lag);
     470      _.packSyncInfo[found]->co_last_version_local := ver;
     471      _.packSyncInfo[found]->dh_release_date_local := release.gmt
     472    });
     473    True
     474  });
     475  Set _.packForUpdate := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
     476  {
     477    And(pkg->co_last_version_local != "",
     478        pkg->co_last_version_local == pkg->co_last_version_remote, 
     479        pkg->dh_release_date_local <  pkg->dh_release_date_remote)   
     480  });
     481  If(And(showWarnings,Card(_.packForUpdate)),
     482  {
     483    WriteLn(_MID+"There are "<<Card(_.packForUpdate)+" packages that you can update "
     484            "from remote repositories to new releases of the same version.\n"
     485            "You can view them at:\n "
     486            "  Set TolPackage::Client::_.packForUpdate\n"
     487            "You can update all them running this TOL sentence: \n"
     488            "  Set TolPackage::Client::RemoteUpdateAll(0)\n",
     489            "W")
     490  });
     491  Set _.packForUpgrade := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
     492  {
     493    And(pkg->co_last_version_local != "",
     494        pkg->co_last_version_local < pkg->co_last_version_remote)   
     495  });
     496  If(And(showWarnings,Card(_.packForUpgrade)),
     497  {
     498    WriteLn(_MID+"There are "<<Card(_.packForUpgrade)+" packages that you can upgrade "
     499            "from remote repositories to new versions.\n"
     500            "You can view them at:\n "
     501            "  Set TolPackage::Client::_.packForUpgrade\n"
     502            "You can upgrade all them running this TOL sentence: \n"
     503            "  Set TolPackage::Client::RemoteUpgradeAll(0)\n",
     504            "W")
     505  });
     506  Set _.packForInstall := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
     507  {
     508    pkg->co_last_version_local == "" 
     509  });
     510  Set _.packInstalled := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
     511  {
     512    pkg->co_last_version_local != "" 
     513  });
     514  Card(_.packSyncInfo)
     515})};
     516
     517
     518//////////////////////////////////////////////////////////////////////////////
     519Text _.autodoc.member.RemoteUpdateAll =
     520"Actualiza automáticamente todos los paquetes disponibles desde los "
     521"repositorios remotos para los que la copia local haya caducado.\n";
     522Real RemoteUpdateAll(Real updateSyncInfo)
     523//////////////////////////////////////////////////////////////////////////////
     524{
     525  Real If(Or(updateSyncInfo,Card(_.packSyncInfo)),
     526    RemoteUpdatePackSyncInfo(False));
     527  If(!Card(_.packForUpdate), 0,
     528  SetSum(EvalSet(_.packForUpdate, Real(TolPackage::@PackageSynchro pkg)
     529  {
     530    RemoteInstallPackage(pkg->te_url, pkg->co_last_version_remote, True)
     531  })))
     532};
    419533
    420534//////////////////////////////////////////////////////////////////////////////
    421535Text _.autodoc.member.RemoteUpgradeAll =
    422 "Actualiza automáticamente todos los paquetes disponibles en los "
    423 "repositorios remotos para los que la copia local haya caducado.\n";
    424 Real RemoteUpgradeAll(Real caducityInMinutes)
    425 //////////////////////////////////////////////////////////////////////////////
    426 {
    427 //Real RemoteUpdateSyncInfo(0);
    428 //Set outOfdate
    429   False
     536"Actualiza automáticamente todos los paquetes disponibles desde los "
     537"repositorios remotos para los que exista una versión más moderna.\n";
     538Real RemoteUpgradeAll(Real updateSyncInfo)
     539//////////////////////////////////////////////////////////////////////////////
     540{
     541  Real If(Or(updateSyncInfo,Card(_.packSyncInfo)),
     542    RemoteUpdatePackSyncInfo(False));
     543  If(!Card(_.packForUpgrade), 0,
     544  SetSum(EvalSet(_.packForUpgrade, Real(TolPackage::@PackageSynchro pkg)
     545  {
     546    RemoteInstallPackage(pkg->te_url, pkg->co_last_version_remote, True)
     547  })))
    430548}
    431549
  • tol/stdlib/general/TolPackage/common.tol

    race5023 r3a14843  
    99//Información de un paquete que es relevante para la sincronización de las
    1010//copias locales con el repositorio remoto.
    11   Struct @PackageSynchro {
     11  Struct @VersionSynchro {
    1212//////////////////////////////////////////////////////////////////////////////
    1313  Text te_url,                  //URL of repository
    … …  
    1616  Text te_min_tol_version,      //Required TOL version
    1717  Text te_dependencies,         //Required packages
     18  Date dh_release_date_remote,  //Publication date in remote repository
     19  Date dh_release_date_local    //Local installing date
     20};
     21
     22//////////////////////////////////////////////////////////////////////////////
     23//Información de un paquete que es relevante para la sincronización de las
     24//copias locales con el repositorio remoto.
     25  Struct @PackageSynchro {
     26//////////////////////////////////////////////////////////////////////////////
     27  Text te_url,                  //URL of repository
     28  Text co_name,                 //Generic name of package
     29  Text te_brief,                //Brief description of package
     30  Text te_min_tol_version,      //Required TOL version
     31  Text co_last_version_remote,  //Name of last remote version
     32  Text co_last_version_local,   //Name of last local version
    1833  Date dh_release_date_remote,  //Publication date in remote repository
    1934  Date dh_release_date_local    //Local installing date
    … …  
    7388    Unique(SetConcat(aux))
    7489  })
    75 };
     90}
  • tol/stdlib/gui/tcl/_tclutils.tol

    race5023 r3a14843  
    391391      },
    392392      {
    393         TolPackage::Client::RemoteUpgradeAll(
    394           TolConfigManager::Config::Upgrading::TolPackage::CaducityInMinutes)
     393        TolPackage::Client::RemoteUpdatePackSyncInfo(True)
    395394      });
    396395      WriteLn(I2("Checking if TOL is updated.",
Note: See TracChangeset for help on using the changeset viewer.