Changeset 837719d in tol


Ignore:
Timestamp:
Dec 19, 2011, 6:07:56 PM (15 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
20da7ad
Parents:
13eebd9
Message:

Refs #1368

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

Location:
tol/stdlib/general/TolPackage
Files:
3 edited

Legend:

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

    r13eebd9 r837719d  
    102102  Real _trace("DoRequirements", "End", 1);
    103103  True
     104};
     105
     106
     107//////////////////////////////////////////////////////////////////////////////
     108Text _.autodoc.member.LocalInfo =
     109"Devuelve la información local disponible acerca de un paquete.";
     110Set LocalInfo(Text name.version)
     111//////////////////////////////////////////////////////////////////////////////
     112{
     113  Text root = TolPackage::Client::_.localRoot+"/"+name.version+"/";
     114  Text info.path=root+"info.oza";
     115  Real If(!OSFilExist(info.path),
     116  {
     117    Set pkgCnt = Ois.Load(root+name.version+".oza")[1];
     118    TolPackage::PackageInfo.Build(pkgCnt[1], root, UnknownDate)
     119  });
     120  Ois.Load(info.path)[1]
    104121};
    105122
    … …  
    126143  Real _trace("LocalLastCompatible", "package='"<<package+"'", 1);
    127144  Set pkgLst = GetDir(TolPackage::Client::_.localRoot)[2];
    128   Text vsi.path = _.localRoot+"/VersSyncInfo.oza";
    129   Real If(!FileExist(vsi.path), RemoteUpdateVersSyncInfo(false));
    130   Set vsi = If(!FileExist(vsi.path), Copy(Empty), { Include(vsi.path) });
    131145  Set pkgSel = Select(pkgLst,Real(Text pkgNamVer)
    132146  {
    133     WriteLn("_trace LocalLastCompatible 2 checking version ="<<pkgNamVer);
     147    Real _trace("LocalLastCompatible", "checking version ="<<pkgNamVer, 5);
    134148    Real ok1 = TextBeginWith(pkgNamVer, package);
    135149    If(!ok1, False,
    136150    {
    137       Real idx = FindIndexByName(vsi, pkgNamVer);
    138       If(idx<=0, True,
    139       {
    140         Real ok2 = And(
    141          Compare.VersionString(vsi[idx]->te_min_tol_version,TolPackage::_.currentTolVersion)<=0,
    142          Compare.VersionString(vsi[idx]->te_max_tol_version,TolPackage::_.currentTolVersion)>=0);
    143       //WriteLn("_trace LocalLastCompatible 3 min="<<vsi[idx]->te_min_tol_version);
    144       //WriteLn("_trace LocalLastCompatible 4 cur="<<TolPackage::_.currentTolVersion);
    145       //WriteLn("_trace LocalLastCompatible 5 max="<<vsi[idx]->te_max_tol_version);
    146       //WriteLn("_trace LocalLastCompatible 6 ok2="<<ok2);
     151      Set info = TolPackage::Client::LocalInfo(pkgNamVer);
     152      Real ok2 = And(
     153       Compare.VersionString(info::_.autodoc.minTolVersion,TolPackage::_.currentTolVersion)<=0,
     154       Compare.VersionString(info::_.autodoc.maxTolVersion,TolPackage::_.currentTolVersion)>=0);
    147155        ok2
    148       })
    149156    })
    150157  });
    … …  
    198205{
    199206  Real _trace("LocalInstallPackage", "Begin", 1);
     207  Real _trace("LocalInstallPackage", "pkg.path.zip='"+pkg.path.zip+"'", 5);
    200208  Real OSFilCopy(pkg.path.zip, _.localRoot);
    201209  Text pkg.name.zip = GetFileName(pkg.path.zip);
     210  Real _trace("LocalInstallPackage", "pkg.name.zip='"+pkg.name.zip+"'", 5);
    202211  Text pkg.name = Replace(pkg.name.zip,".zip","");
     212  Real _trace("LocalInstallPackage", "pkg.name='"+pkg.name+"'", 5);
     213  Real OSDirRemove(_.localRoot+pkg.name);
    203214  Real PackArchive::UnpackFull("ZipArchive",_.localRoot+pkg.name,True);
    204215  Real _trace("LocalInstallPackage", "End", 1);
    … …  
    652663      Date If(found,
    653664      {
    654         Date gmt = Copy(NowGmt);
    655         Date loc = Copy(Now);
    656         Real lag = Round(DateDif(S(0),loc,gmt)/10)*10;
    657         Text oza = TolPackage::Client::_.localRoot+pkg+"/"+pkg+".oza";
    658         Date release.loc = FileTime(oza);
    659         Date release.gmt = Succ(release.loc,S(0),lag);
    660         _.versSyncInfo[found]->dh_release_date_local := release.gmt
     665        Set info = LocalInfo(pkg);
     666        _.versSyncInfo[found]->dh_release_date_local := info::_.autodoc.releaseDate
    661667      });
    662668      True
    … …  
    703709          Compare.VersionString(b, a) });
    704710        Text ver = ord[1];
    705         Date gmt = Copy(NowGmt);
    706         Date loc = Copy(Now);
    707         Real lag = Round(DateDif(S(0),loc,gmt)/10)*10;
    708         Text oza = TolPackage::Client::_.localRoot+ver+"/"+ver+".oza";
    709         Date release.loc = FileTime(oza);
    710         Date release.gmt = Succ(release.loc,S(0),lag);
    711         Date _.packSyncInfo[found]->co_last_version_local := ver;
    712         Date _.packSyncInfo[found]->dh_release_date_local := release.gmt;
     711        Set info = LocalInfo(ver);
     712        Date _.packSyncInfo[found]->co_last_version_local :=
     713          pkg+"."<<info::_.autodoc.version.high+"."<<info::_.autodoc.version.low;
     714        Date _.packSyncInfo[found]->dh_release_date_local := info::_.autodoc.releaseDate;
    713715        True
    714716      });
    … …  
    717719    Set _.packForUpdate := Select(_.packSyncInfo, Real(TolPackage::@PackageSynchro pkg)
    718720    {
    719       Real need = And(pkg->co_last_version_local != "",
    720           pkg->co_last_version_local == pkg->co_last_version_remote, 
    721           pkg->dh_release_date_local <  pkg->dh_release_date_remote);
     721      Real _trace("RemoteUpdateVersSyncInfo", "pkg="<<pkg, 5);
     722      Real need = Case(
     723        pkg->co_last_version_local == "", False,
     724        pkg->co_last_version_local != pkg->co_last_version_remote, False,
     725        pkg->dh_release_date_local == TheBegin, False,
     726        DateDif(S(0),pkg->dh_release_date_remote,pkg->dh_release_date_local) <= 2, False,
     727        1==1, True);
     728      Real _trace("RemoteUpdateVersSyncInfo", "need="<<need, 5);
    722729      If(And(showWarnings,need),
    723730      {
  • tol/stdlib/general/TolPackage/common.tol

    r13eebd9 r837719d  
    120120    Unique(SetConcat(aux))
    121121  })
    122 }
     122};
     123
     124//////////////////////////////////////////////////////////////////////////////
     125Text _.autodoc.member.PackageInfo.Extract =
     126"Extrae la información documental de un paquete.";
     127Set PackageInfo.Extract(NameBlock pkg)
     128//////////////////////////////////////////////////////////////////////////////
     129{
     130  Set info = [[
     131    Text _.autodoc.name            = pkg::_.autodoc.name;
     132    Text _.autodoc.brief           = pkg::_.autodoc.brief;
     133    Text _.autodoc.description     = pkg::_.autodoc.description;
     134    Text _.autodoc.url             = pkg::_.autodoc.url;
     135    Set  _.autodoc.keys            = pkg::_.autodoc.keys;
     136    Set  _.autodoc.authors         = pkg::_.autodoc.authors;
     137    Text _.autodoc.minTolVersion   = pkg::_.autodoc.minTolVersion;
     138    Text _.autodoc.maxTolVersion   = pkg::_.autodoc.maxTolVersion;
     139    Real _.autodoc.version.high    = pkg::_.autodoc.version.high;
     140    Real _.autodoc.version.low     = pkg::_.autodoc.version.low;
     141    Date _.autodoc.releaseDate     = pkg::_.autodoc.releaseDate;
     142    Set  _.autodoc.dependencies    = pkg::_.autodoc.dependencies;
     143    Set  _.autodoc.nonTolResources = pkg::_.autodoc.nonTolResources;
     144    Text _.autodoc.versionControl  = pkg::_.autodoc.versionControl;
     145    Text _.autodoc.extra_info      = pkg::_.autodoc.extra_info
     146  ]];
     147  Real SetIndexByName(info);
     148  info
     149};
     150
     151//////////////////////////////////////////////////////////////////////////////
     152Text _.autodoc.member.PackageInfo.AutoFill =
     153"Rellena automaticamente algunos campos de información documental del "
     154"paquete añadiendo los miembros que falten y cambiando su valor si es "
     155"necesario.";
     156Set PackageInfo.AutoFill(NameBlock pkg, Date releaseDate)
     157//////////////////////////////////////////////////////////////////////////////
     158{
     159  Text name = Name(pkg);
     160  Text name.version = name+"."<<
     161    pkg::_.autodoc.version.high+"."<<pkg::_.autodoc.version.low;
     162  Set dep = TolPackage::GetDeepDependencies(name, True);
     163
     164  Real If(!ObjectExist("Text", "pkg::_.autodoc.name"),
     165  {
     166    AddMember(pkg,{Text _.autodoc.name = name })
     167  },
     168  {
     169    Text pkg::_.autodoc.name := name;
     170    True
     171  });
     172  Real If(!ObjectExist("Set", "pkg::_.autodoc.dependencies"),
     173  {
     174    AddMember(pkg,{Set _.autodoc.dependencies = dep })
     175  },
     176  {
     177    Set pkg::_.autodoc.dependencies := dep;
     178    True
     179  });
     180  Real If(!ObjectExist("Date","pkg::_.autodoc.releaseDate"),
     181  {
     182    Real AddMember(pkg,{Date _.autodoc.releaseDate = releaseDate})
     183  },
     184  {
     185    Date pkg::_.autodoc.releaseDate := releaseDate;
     186    True
     187  });
     188  Real If(!ObjectExist("Set", "pkg::_.autodoc.authors"),
     189  {
     190    AddMember(pkg,{Set _.autodoc.authors = Copy(Empty) })
     191  });
     192  Real If(!ObjectExist("Set", "pkg::_.autodoc.keys"),
     193  {
     194    AddMember(pkg,{Set _.autodoc.keys = Copy(Empty) })
     195  });
     196  Real If(!ObjectExist("Set", "pkg::_.autodoc.nonTolResources"),
     197  {
     198    AddMember(pkg,{Set _.autodoc.nonTolResources = Copy(Empty) })
     199  });
     200  Real If(!ObjectExist("Text", "pkg::_.autodoc.versionControl"),
     201  {
     202    AddMember(pkg,{Text _.autodoc.versionControl = "" })
     203  });
     204  Real If(!ObjectExist("Text", "pkg::_.autodoc.maxTolVersion"),
     205  {
     206    Real AddMember(pkg,{Text _.autodoc.maxTolVersion = "v999999999999999999" })
     207  });
     208  Real If(!ObjectExist("Text", "pkg::_.autodoc.extra_info"),
     209  {
     210    Real AddMember(pkg,{Text _.autodoc.extra_info = "" })
     211  });
     212  PackageInfo.Extract(pkg)
     213};
     214
     215//////////////////////////////////////////////////////////////////////////////
     216Text _.autodoc.member.PackageInfo.Build =
     217"Builds the info.oza file with documental information about a loaded "
     218"package.";
     219Real PackageInfo.Build(NameBlock pkg, Text dirPath, Date releaseDate_)   
     220//////////////////////////////////////////////////////////////////////////////
     221{
     222  Date releaseDate = Date If(""<<releaseDate_!="Unknown",
     223  {
     224    releaseDate_
     225  },
     226  {
     227    Text name = Name(pkg);
     228    Text name.version = name+"."<<
     229     pkg::_.autodoc.version.high+"."<<pkg::_.autodoc.version.low;
     230    Date gmt = Copy(NowGmt);
     231    Date loc = Copy(Now);
     232    Real lag = Round(DateDif(S(0),loc,gmt)/10)*10;
     233    Text oza = dirPath+name.version+".oza";
     234    Date local = FileTime(oza);
     235    Succ(local,S(0),lag)
     236  });
     237  Set info = PackageInfo.AutoFill(pkg,releaseDate);
     238  Real OSDirMake(dirPath);
     239  Real Ois.Store(info,dirPath+"info.oza")
     240};
     241
  • tol/stdlib/general/TolPackage/server.tol

    r13eebd9 r837719d  
    9494  })
    9595};
     96
    9697
    9798
    … …  
    114115//////////////////////////////////////////////////////////////////////////////
    115116{
     117  Date release.gmt = Copy(NowGmt);
    116118  Text _MID = "[BuildPackage] ";
    117119  WriteLn(_MID+sourceRoot+name+" -> "+destination);
    … …  
    119121     sourceRoot+name+"/"+name+".tol\",True)");
    120122  NameBlock pkg = pkgCnt[1];
    121   Text name.version = TolPackage::GetCurrentNameVersion(name,True);
    122   Set dependencies = TolPackage::GetDeepDependencies(name, True);
    123   Set nonTolResources=If(!ObjectExist("Set",name+"::_.autodoc.nonTolResources"),
    124     Copy(Empty),pkg::_.autodoc.nonTolResources);
    125 
     123  Text name.version = name+"."<<
     124    pkg::_.autodoc.version.high+"."<<pkg::_.autodoc.version.low;
    126125  Text ppRoot_ = destination+name.version;
    127126  Text ppRoot = ppRoot_+"/";
     127  Real TolPackage::PackageInfo.Build(pkg,ppRoot,release.gmt);
     128  Set nonTolResources = pkg::_.autodoc.nonTolResources;
     129
     130  Real OSDirMake(ppRoot);
    128131  Real Ois.Store(pkgCnt,ppRoot+name.version+".oza");
    129   Real OSDirMake(ppRoot);
    130132
    131133  Real cleanResource(Text dest)
    … …  
    143145    True
    144146  };
     147
    145148  Real processResourceText(Text resource)
    146149  {
    … …  
    164167    Eval("processResource"+gra+"(res)")
    165168  });
    166   Text ppr = ReplaceSlash(ppRoot_);
    167   Set dep = TolPackage::GetDeepDependencies(name, True);
    168  
     169  Text ppr = ReplaceSlash(ppRoot_);
    169170  Real PackArchive::PackFull("ZipArchive", ppr, removeDir);
    170171  ppRoot_+".zip"
    … …  
    190191  Text oza = root+pkg.name+"/"+pkg.name+".oza";
    191192  Set pkgCnt = Include(oza);
    192   Date gmt = Copy(NowGmt);
    193   Date loc = Copy(Now);
    194   Real lag = Round(DateDif(S(0),loc,gmt)/10)*10;
    195   Date release.loc = FileTime(oza);
    196   Date release.gmt = Succ(release.loc,S(0),lag);
    197  
    198193  NameBlock pkg = pkgCnt[1];
    199194  Text name = Name(pkgCnt[1]);
    … …  
    234229  },
    235230  {
    236     Set dep = TolPackage::GetDeepDependencies(name, True);
    237     Set aut = If(!ObjectExist("Set","pkg::_.autodoc.authors"),
    238       Copy(Empty),
    239       pkg::_.autodoc.authors);
    240     Set key = If(!ObjectExist("Set","pkg::_.autodoc.keys"),
    241       Copy(Empty),
    242       pkg::_.autodoc.keys);
    243     Set res = If(!ObjectExist("Set","pkg::_.autodoc.nonTolResources"),
    244       Copy(Empty),
    245       pkg::_.autodoc.nonTolResources);
    246     Text verCnt = If(!ObjectExist("Text","pkg::_.autodoc.versionControl"),"",
    247       ReplaceTable(pkg::_.autodoc.versionControl,[[
     231    Set dep = pkg::_.autodoc.dependencies;
     232    Set aut = pkg::_.autodoc.authors;
     233    Set key = pkg::_.autodoc.keys;
     234    Set res = pkg::_.autodoc.nonTolResources;
     235    Text verCnt = ReplaceTable(pkg::_.autodoc.versionControl,[[
    248236      [["\n","<BR>"]],
    249237      [["'","\""]] ,
    250       [[";",","]] ]]));
     238      [[";",","]] ]]);
    251239    Text bl_contents = EncodeBase64FromFile(pkg.path.zip);
    252240    Real nu_bytes = FileBytes(pkg.path.zip);
    253241    Real id_format = 1;
    254     Text te_max_tol_version = "v999999999999999999";
     242    Text te_max_tol_version = pkg::_.autodoc.maxTolVersion;
    255243    Text te_extra_info = "";
    256     Text If(ObjectExist("Text", "pkg::_.autodoc.maxTolVersion"),
    257       te_max_tol_version := pkg::_.autodoc.maxTolVersion);
    258244  //Text exist.query =
    259245    Text insert.query = "
    … …  
    274260     "'"<<TolPackage::Server::SqlFormatSetOfText(pkg::_.autodoc.authors)+"', \n"+
    275261     "'"<<pkg::_.autodoc.minTolVersion+"', \n"+
    276      "'"<<FormatDate(release.gmt,"%c%Y-%m-%d %h:%i:%s")+"', \n"+
     262     "'"<<FormatDate(pkg::_.autodoc.releaseDate,"%c%Y-%m-%d %h:%i:%s")+"', \n"+
    277263     "'"<<TolPackage::Server::SqlFormatSetOfText(dep)+"', \n"+
    278264     "'"<<TolPackage::Server::FormatSet(res)+"', \n"+
Note: See TracChangeset for help on using the changeset viewer.