Changeset be3dec5 in tol


Ignore:
Timestamp:
Mar 26, 2015, 11:43:38 AM (12 years ago)
Author:
Pedro Gea <pgea@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
bc8a9f9
Parents:
9b614da
Message:

Refs #1821
Se mejora TolPackage a la version 4 que incorpora la gestión de paquetes según la plataforma.
Esta versión aúna TolPackage.2 (para tol.3.1) y TolPackage.3 (para tol.3.2) que fue separada por una incompatibilidad en OIS que luego fue revertida.

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

Location:
tol/stdlib/TolPackage
Files:
1 added
7 edited

Legend:

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

    r9b614da rbe3dec5  
    1515  Set _.autodoc.authors = [["vdebuen@tol-project.org",
    1616    "pgea@bayesforecast.com"]];
    17   // Versión mínima de TOL (a nivel informativo)
    18   Text _.autodoc.minTolVersion = "v3.2";
    19   Real _.autodoc.version.high = 3;
    20   Real _.autodoc.version.low = 2;
     17  // La versión 4 aúna las vesiones 2 y 3 y es válida desde tol.3.1
     18  Text _.autodoc.minTolVersion = "v3.1";
     19  Real _.autodoc.version.high = 4;
     20  Real _.autodoc.version.low = 1;
    2121
    2222  Text _.version = ""<<_.autodoc.version.high<<"."<<_.autodoc.version.low;
    … …  
    3232  #Embed "def_catalog.tol";
    3333  #Embed "TolVersion.tol";
     34  #Embed "TolPlatform.tol";
    3435  #Embed "client.tol";
    3536  #Embed "server.tol";
  • tol/stdlib/TolPackage/TolVersion.tol

    r9b614da rbe3dec5  
    11//////////////////////////////////////////////////////////////////////////////
    22// FILE   : TolVersion.tol
    3 // PURPOSE: TOL version related funcions
     3// PURPOSE: TOL version related functions
    44//////////////////////////////////////////////////////////////////////////////
    55
    66Text _.autodoc.member.TolVersion =
    7   "Módulo de funciones para la gestión de versiones de TOL.";
     7  "Módulo de funciones para la gestión de las versiones de TOL.";
    88//////////////////////////////////////////////////////////////////////////////
    99@LocalBlock TolVersion =
  • tol/stdlib/TolPackage/client.tol

    r9b614da rbe3dec5  
    5858
    5959  ////////////////////////////////////////////////////////////////////////////
    60   Set GetPackageInfo(Text name.version) // GUI
     60  Set GetPackageInfo(Text name.version) // GUI (antes)
    6161  ////////////////////////////////////////////////////////////////////////////
    6262  {
    6363    @Catalog catalog = GetCatalog(?);
    6464    Set record = catalog::GetRecord(name.version);
    65     @Catalog::FormatRecord_Autodoc(record)
     65    If(Card(record), @Catalog::FormatRecord_Autodoc(record), Copy(Empty))
     66  };
     67
     68  ////////////////////////////////////////////////////////////////////////////
     69  Set GetPackageInfo_Compatible(Text name.version) // GUI
     70  ////////////////////////////////////////////////////////////////////////////
     71  {
     72    @Catalog catalog = GetCatalog(?);
     73    Set record = catalog::GetRecord_Compatible(name.version);
     74    If(Card(record), @Catalog::FormatRecord_Autodoc(record), Copy(Empty))
    6675  };
    6776
    … …  
    8392  ////////////////////////////////////////////////////////////////////////////
    8493  {
    85     Real UninstallPackage( package )
     94    Real UninstallPackage(package)
    8695  };
    8796 
    … …  
    9099  //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||//
    91100  {
    92     Real length = TextLength(package);
    93     Text packageWP = If(Text Sub(package, length, length)==".",
    94       Text Sub(package, 1, length-1), package); // Se elimina el punto final
    95     @Catalog catalog = GetCatalog(?);
    96     AvoidErr.NonDecAct(catalog::ObtainLastCompatible(packageWP))
     101    If(TextMatch(package, "*#*"), {
     102      WriteLn("Package pattern '"<<package<<"' not valid.\n"
     103        <<"Please, do require the package without variant.", "E");
     104      ""
     105    }, {
     106      Real length = TextLength(package);
     107      Text packageWP = If(Text Sub(package, length, length)==".",
     108        Text Sub(package, 1, length-1), package); // Se elimina el punto final
     109      @Catalog catalog = GetCatalog(?);
     110      AvoidErr.NonDecAct(catalog::ObtainLastCompatible(packageWP))
     111    })
    97112  };
    98113
    … …  
    234249    "packaging.";
    235250  ////////////////////////////////////////////////////////////////////////////
    236   Real _.DefaultFetch( Real void )
     251  Real _.DefaultFetch(Real void)
    237252  ////////////////////////////////////////////////////////////////////////////
    238253  {
    239254    Text destDir = TolPackage::Client::_.defaultPackageDir;
    240255    WriteLn( "[TolPackage::Client] _.DefaultFetch: " << destDir );
    241     If( !OSDirExist( destDir ), {
    242         Real OSDirMake( destDir )
    243       } );
     256    Real If(!OSDirExist(destDir), OSDirMake(destDir));
    244257    NameBlock catalog = TolPackage::Server::GetCatalog(?);
    245     Set result = EvalSet( _.defaultPackages, Real( Set pkgInfo ) {
    246         Text pkg = pkgInfo[1];
    247         WriteLn( "Downloading last " << pkg <<
    248                  " compatible with " << Version );
    249         Text pkg.id = catalog::ObtainIdentifier( pkg, Version, UnknownDate );
    250         Text zipFile = TolPackage::Server::DownloadPackageAt( pkg.id, destDir );
    251         Real ok = FileExist( zipFile );
    252         Text msgStatus = "   ==> " << pkg << ": " << If( ok, "SUCCESS", "FAIL" );
    253         WriteLn( msgStatus );
    254         ok
    255       } );
    256     Real SetSum( result )
     258    Set result = EvalSet(_.defaultPackages, Real (Set pkgInfo) {
     259      Text pkg = pkgInfo[1];
     260      WriteLn("Downloading last "<<pkg<<" compatible with "<<Version);
     261      Text pkg.id = catalog::ObtainIdentifier(pkg, Platform(?),
     262        Version, UnknownDate);
     263      Text zipFile = TolPackage::Server::DownloadPackageAt(pkg.id, destDir);
     264      Real ok = FileExist(zipFile);
     265      WriteLn("   ==> "<<pkg<<": "<<If(ok, "SUCCESS", "FAIL"));
     266      ok
     267    });
     268    SetSum(result)
    257269  };
    258270
    … …  
    261273  ////////////////////////////////////////////////////////////////////////////
    262274  {
    263     Real tryDefaults = If( ObjectExist("Real", "__NODEFAULTPACKAGES"),
    264                            Not(__NODEFAULTPACKAGES), 1 );
    265     Set toRequire = Select(_.defaultPackages, Real(Set elem)
    266                            { And(tryDefaults, elem[2]) });
    267     Set done = EvalSet( toRequire, Real ( Set elem ) {
    268         NameBlock Require( elem[1] );
    269         Real 1
    270       } );
    271     Real Card( done )
     275    Real tryDefaults = If(ObjectExist("Real", "__NODEFAULTPACKAGES"),
     276      Not(__NODEFAULTPACKAGES), 1);
     277    Set toRequire = Select(_.defaultPackages, Real (Set elem) {
     278      And(tryDefaults, elem[2])
     279    });
     280    Set done = EvalSet(toRequire, Real (Set elem) {
     281      NameBlock Require(elem[1]);
     282    1});
     283    Card(done)
    272284  };
    273285
    … …  
    292304        Text packageName = Replace(GetFileName(filename), ".zip", "");
    293305        If(catalog::FindRecord(packageName), 0, {
    294           WriteLn( "[TolPackage::Client] Installing default package " << packageName );
     306          WriteLn("[TolPackage::Client] Installing default package "
     307           <<packageName);
    295308          InstallZip(_.defaultPackageDir<<filename)
    296309        })
    … …  
    299312      // [C] Se cargan los paquetes por defecto
    300313      _.DefaultRequire(?)
    301      })
     314    })
    302315  }
    303316]];
  • tol/stdlib/TolPackage/common.tol

    r9b614da rbe3dec5  
    33  //  * Text _.autodoc.get.identifier(NameBlock package)
    44  //  * NameBlock Require(Text identifier)
    5   //  * Real AddRepository(Text url)
     5  //  * Text Platform(Real void)
     6  //  * Real AddRepository(Text url)
    67  // [API Client+Server]
    78  //  * Real InstallPackage(Text identifier)
    8   //  * Real InstallCompatible(Text pattern, Text tolVersion, Date date)
     9  //  * Real InstallCompatible(Text pattern, Text tolPlatform,
     10  //      Text tolVersion, Date date)
    911  //  * Real InstallLastCompatible(Text pattern)
    1012  //  * Real UpdateAll(Real void)
    … …  
    2224  ////////////////////////////////////////////////////////////////////////////
    2325  {
    24     package::_.autodoc.name<<"."
     26    Text variant = getOptArg(package, "_.autodoc.variant", "");
     27    package::_.autodoc.name<<If(TextLength(variant), "#"<<variant, "")<<"."
    2528      <<package::_.autodoc.version.high<<"."<<package::_.autodoc.version.low
    2629  };
    … …  
    3437    1}");
    3538    Eval(Tokenizer(identifier, ".")[1])
     39  };
     40
     41  ////////////////////////////////////////////////////////////////////////////
     42  Text _Platform = "";
     43  ////////////////////////////////////////////////////////////////////////////
     44  Text Platform(Real void)
     45  ////////////////////////////////////////////////////////////////////////////
     46  {
     47    Text If(_Platform=="", {
     48      _Platform := Case(ObjectExist("Code", "PlatformInfo"), {
     49        Set platInfo = PlatformInfo(?);
     50        Text ToUpper(platInfo[5])
     51          <<"__"<<FormatReal(platInfo[1]*8, "%.0lf")
     52          <<"__"<<ToUpper(platInfo[3])
     53      }, OSName=="WINDOWS", {
     54        "WINDOWS__32__MSVC"
     55      }, True, {
     56        ToUpper(OSName)<<"__32__GNU"
     57      })
     58    });
     59    _Platform
    3660  };
    3761
    … …  
    7296
    7397  ////////////////////////////////////////////////////////////////////////////
    74   Real InstallCompatible(Text pattern, Text tolVersion, Date date)
     98  Real InstallCompatible(Text pattern, Text tolPlatform,
     99    Text tolVersion, Date date)
    75100  ////////////////////////////////////////////////////////////////////////////
    76101  {
    77102    Real Server::Initialize(?);
    78     Text file = Server::DownloadCompatible(pattern, tolVersion, date);
     103    Text file = Server::DownloadCompatible(pattern, tolPlatform,
     104      tolVersion, date);
    79105    Real If(TextLength(file), {
    80106      Real Client::InstallZip(file);
    … …  
    105131    @Catalog server = Server::GetCatalog(?);
    106132    Code obtainList = Eval("server::Obtain"<<mode<<"List");
    107     Set improveList = obtainList(client, Version, UnknownDate);
     133    Set improveList = obtainList(client, Platform(?), Version, UnknownDate);
    108134    Set selImproveList = Select(improveList, Real (Set record) {
    109135      TextMatch(Name(record), txtPattern)
    … …  
    147173    @Catalog server = Server::GetCatalog(?);
    148174    Code obtainList = Eval("server::Obtain"<<mode<<"List");
    149     Set improveList = obtainList(client, Version, UnknownDate);
     175    Set improveList = obtainList(client, Platform(?), Version, UnknownDate);
    150176    If(Card(improveList), SetSum(EvalSet(improveList, Real (Set record) {
    151177      Real If(mode=="Update", {
    … …  
    236262    @Catalog client = Client::GetCatalog(?);
    237263    @Catalog server = Server::GetCatalog(?);
    238     SetConcat(EvalSet(server::_.records, Set (Set list) {
     264    Set compRecords = server::GetCompatibleRecords(Platform(?), Version,
     265      UnknownDate);
     266    SetConcat(EvalSet(compRecords, Set (Set list) {
    239267      EvalSet(list, Set (Set record) {
    240268        Text dependencies = If(Card(record::freeDependencies), {
    … …  
    245273        }, "");
    246274        Text localIdentifier = client::ObtainIdentifier_Show(record::name,
    247           Version, UnknownDate, 0);
     275          Platform(?), Version, UnknownDate, 0);
    248276        Date localRelease = If(TextLength(localIdentifier), {
    249277          Set localRecord = client::GetRecord(localIdentifier);
    … …  
    263291    @Catalog client = Client::GetCatalog(?);
    264292    @Catalog server = Server::GetCatalog(?);
    265     EvalSet(server::GetCompatibleList(tolVersion, UnknownDate),
    266       Set (Set record) {
     293    Set compList = server::GetCompatibleList(Platform(?), tolVersion,
     294      UnknownDate);
     295    EvalSet(compList, Set (Set record) {
    267296      Text localIdentifier = client::ObtainIdentifier_Show(record::name,
    268         Version, UnknownDate, 0);
     297        Platform(?), tolVersion, UnknownDate, 0);
    269298      Date localRelease = If(TextLength(localIdentifier), {
    270299        Set localRecord = client::GetRecord(localIdentifier);
    … …  
    283312    TolPackage::@Catalog catalog = TolPackage::Server::GetCatalog(?);
    284313    Set deepDs = Unique(SetConcat(EvalSet(patterns, Set (Text pattern) {
    285       [[pattern]]<<catalog::GetDeepDependencies(pattern, Version, UnknownDate)
     314      [[pattern]]<<catalog::GetDeepDependencies(pattern,
     315        Platform(?), Version, UnknownDate)
    286316    })));
    287     Set catalog::IdentifyPackages(deepDs, Version, UnknownDate)
     317    catalog::IdentifyPackages(deepDs, Platform(?), Version, UnknownDate)
    288318  };
    289319
  • tol/stdlib/TolPackage/def_catalog.tol

    r9b614da rbe3dec5  
    44//   Text identifier
    55//   Text name
     6//   Text variant (new)
    67//   Real high
    78//   Real low
    89//   Text repository
    910//   Date release
     11//   Text platform (new)
    1012//   Text minTolVersion
    1113//   Text maxTolVersion
    … …  
    2830  {
    2931    Set parts = Tokenizer(identifier, ".");
    30     Real index = FindIndexByName(_.records, parts[1]);
     32    Text name = Tokenizer(parts[1], "#")[1];
     33    Real index = FindIndexByName(_.records, name);
    3134    If(index, FindIndexByName(_.records[index], identifier), 0)
    3235  };
    … …  
    3740  {
    3841    Set parts = Tokenizer(identifier, ".");
    39     Real index = FindIndexByName(_.records, parts[1]);
     42    Text name = Tokenizer(parts[1], "#")[1];
     43    Real index = FindIndexByName(_.records, name);
    4044    If(index, {
    4145      Real index2 = FindIndexByName(_.records[index], identifier);
    … …  
    4549
    4650  ////////////////////////////////////////////////////////////////////////////
    47   Text ObtainIdentifier(Text pattern, Text tolVersion, Date date)
     51  Set GetRecord_Compatible(Text identifier)
     52  ////////////////////////////////////////////////////////////////////////////
     53  {
     54    Set record = GetRecord(identifier);
     55    If(Card(record),
     56      If(_Record.IsCompatible(record, Platform(?), Version, UnknownDate),
     57        record, Copy(Empty)),
     58      Copy(Empty))
     59  };
     60
     61  ////////////////////////////////////////////////////////////////////////////
     62  Real _Record.IsCompatible(Set record, Text tolPlatform,
     63    Text tolVersion, Date date)
     64  ////////////////////////////////////////////////////////////////////////////
     65  {
     66    // Se comprueba la plataforma de TOL
     67    Real ok = Case(tolPlatform=="", True,
     68      record::platform=="", True,
     69      // no hay limitaciones, fallarían los paquetes que se crearon válidos
     70      // sólo para win32_msvc y unix32_gnu
     71      True, TolPlatform::IsCompatibleWith(tolPlatform, record::platform));
     72    Real If(ok, {
     73      // Se comprueba la versión de TOL
     74      Real ok := If(tolVersion=="any", True, {
     75        TolVersion::CompareVersions(record::minTolVersion, tolVersion)<=0
     76        & TolVersion::CompareVersions(tolVersion, record::maxTolVersion)<=0
     77      })
     78    });
     79    If(ok, {
     80      // Se comprueba que la fecha no es posterior a la indicada
     81      If(""<<date=="Unknown", True, Not(record::release>date))
     82    }, False)
     83  };
     84
     85  ////////////////////////////////////////////////////////////////////////////
     86  Text ObtainIdentifier(Text pattern, Text tolPlatform,
     87    Text tolVersion, Date date)
     88  ////////////////////////////////////////////////////////////////////////////
     89  {
     90    ObtainIdentifier_Show(pattern, tolPlatform, tolVersion, date, 1)
     91  };
     92
     93  ////////////////////////////////////////////////////////////////////////////
     94  Text ObtainLastCompatible(Text pattern)
    4895  ////////////////////////////////////////////////////////////////////////////
    4996  {
    50     ObtainIdentifier_Show(pattern, tolVersion, date, 1)
    51   };
    52 
    53   ////////////////////////////////////////////////////////////////////////////
    54   Text ObtainLastCompatible(Text pattern)
    55   ////////////////////////////////////////////////////////////////////////////
    56   {
    57     ObtainIdentifier(pattern, Version, UnknownDate)
    58   };
    59 
    60   ////////////////////////////////////////////////////////////////////////////
    61   Text ObtainIdentifier_Show(Text pattern, Text tolVersion, Date date,
    62     Real show)
     97    ObtainIdentifier(pattern, Platform(?), Version, UnknownDate)
     98  };
     99
     100  ////////////////////////////////////////////////////////////////////////////
     101  Text ObtainIdentifier_Show(Text pattern, Text tolPlatform, Text tolVersion,
     102    Date date, Real show)
    63103  ////////////////////////////////////////////////////////////////////////////
    64104  {
    65105    // show: 0 none, 1 info, 2 warning, 3 error
    66     Text identifier = _ObtainIdentifier(pattern, tolVersion, date);
     106    Text identifier = _ObtainIdentifier(pattern, tolPlatform,
     107      tolVersion, date);
    67108    If(Text Sub(identifier, 1, 1)=="#", {
    68109      Text wm = Case(show==0, "", show==1, "U", show==2, "W", show==3, "E");
    … …  
    70111        ""
    71112      }, identifier=="#NotCompatible", {
    72         Text msg = If(tolVersion=="any", "", " para la versión de TOL '"
    73           <<tolVersion<<"'");
     113        Text msg = Case(tolPlatform=="" & tolVersion=="any", "",
     114          tolPlatform=="", " para la versión de TOL '"<<tolVersion<<"'",
     115          tolVersion=="any", " para TOL con '"<<tolPlatform<<"'",
     116          True, " para la versión de TOL '"<<tolVersion<<"' con '"
     117            <<tolPlatform<<"'");
    74118        Text msg2 = If(""<<date=="Unknown", If(TextLength(msg), msg, ""), {
    75119          If(TextLength(msg), msg<<" y", " para")<<" la fecha "<<date
    … …  
    88132
    89133  ////////////////////////////////////////////////////////////////////////////
    90   Text _ObtainIdentifier(Text pattern, Text tolVersion, Date date)
     134  Text _ObtainIdentifier(Text pattern, Text tolPlatform,
     135    Text tolVersion, Date date)
    91136  ////////////////////////////////////////////////////////////////////////////
    92137  {
    93138    Set parts = Tokenizer(pattern, ".");
    94     Real index = FindIndexByName(_.records, parts[1]);
     139    Text name = Tokenizer(parts[1], "#")[1];
     140    Real index = FindIndexByName(_.records, name);
    95141    If(index, {
    96142      Set records = _.records[index];
    97143      Set parts := parts << For(1, 3-Card(parts), Text (Real i) { "*" });
    98       Text txtPattern = parts[1]<<"."<<parts[2]<<"."<<parts[3];
     144      Text txtPattern1 = parts[1]<<"."<<parts[2]<<"."<<parts[3];
     145      Text txtPattern2 = parts[1]<<"#*."<<parts[2]<<"."<<parts[3];
    99146      Set options = Select(records, Real (Set record) {
    100         Real ok = TextMatch(record::identifier, txtPattern);
     147        // Se comprueba si encaja con el patrón indicado
     148        Real ok = TextMatch(record::identifier, txtPattern1)
     149          | TextMatch(record::identifier, txtPattern2);
     150        // Se comprueba la plataforma de TOL
     151        Real If(ok, ok := _Record.IsCompatible(record, tolPlatform,
     152          tolVersion, date));
    101153        // Se comprueba la versión de TOL
    102         Real If(ok, {
    103           Real ok := Case(
    104             tolVersion=="any",
    105               True,
    106             TolVersion::CompareVersions(record::minTolVersion, tolVersion)>0,
    107               False,
    108             TolVersion::CompareVersions(tolVersion, record::maxTolVersion)>0,
    109               False
    110           )
    111         });
     154        Real If(ok, ok := Case(tolVersion=="any", True,
     155          TolVersion::CompareVersions(record::minTolVersion, tolVersion)>0,
     156            False,
     157          TolVersion::CompareVersions(tolVersion, record::maxTolVersion)>0,
     158            False,
     159          True, True));
    112160        // Se comprueba que la fecha no es posterior a la indicada
    113         Real If(ok, {
    114           Real ok := Case(""<<date=="Unknown", True,
    115             record::release>date, False)
    116         });
     161        Real If(ok, ok := If(""<<date=="Unknown", True,
     162          record::release<=date));
    117163        ok
    118164      });
    … …  
    122168
    123169  ////////////////////////////////////////////////////////////////////////////
    124   Set GetFreeDependencies(Text pattern, Text tolVersion, Date date)
    125   ////////////////////////////////////////////////////////////////////////////
    126   {
    127     Text identifier = ObtainIdentifier(pattern, tolVersion, date);
     170  Set GetFreeDependencies(Text pattern, Text tolPlatform, Text tolVersion,
     171    Date date)
     172  ////////////////////////////////////////////////////////////////////////////
     173  {
     174    Text identifier = ObtainIdentifier(pattern, tolPlatform, tolVersion, date);
    128175    If(TextLength(identifier), {
    129176      GetRecord(identifier)["freeDependencies"]
    … …  
    135182
    136183  ////////////////////////////////////////////////////////////////////////////
    137   Set GetMainDependencies(Text pattern, Text tolVersion, Date date)
    138   ////////////////////////////////////////////////////////////////////////////
    139   {
    140     Set freeD = GetFreeDependencies(pattern, tolVersion, date);
     184  Set GetMainDependencies(Text pattern, Text tolPlatform, Text tolVersion,
     185    Date date)
     186  ////////////////////////////////////////////////////////////////////////////
     187  {
     188    Set freeD = GetFreeDependencies(pattern, tolPlatform, tolVersion, date);
    141189    Set extraD = Unique(SetConcat(EvalSet(freeD, Set (Text p) {
    142       GetFreeDependencies(p, tolVersion, date)
     190      GetFreeDependencies(p, tolPlatform, tolVersion, date)
    143191    })));
    144192    freeD-extraD
    … …  
    146194
    147195  ////////////////////////////////////////////////////////////////////////////
    148   Anything IdentifyPackages(Anything patterns, Text tolVersion, Date date)
     196  Anything IdentifyPackages(Anything patterns, Text tolPlatform,
     197    Text tolVersion, Date date)
    149198  ////////////////////////////////////////////////////////////////////////////
    150199  {
    151200    Case(Grammar(patterns)=="Set", {
    152201      EvalSet(patterns, Anything (Anything a) {
    153         IdentifyPackages(a, tolVersion, date)
     202        IdentifyPackages(a, tolPlatform, tolVersion, date)
    154203      })
    155204    }, Grammar(patterns)=="Text", {
    156205      If(TextLength(patterns),
    157         ObtainIdentifier(patterns, tolVersion, date), "")
     206        ObtainIdentifier(patterns, tolPlatform, tolVersion, date), "")
    158207    })
    159208  };
    160209
    161210  ////////////////////////////////////////////////////////////////////////////
    162   Set GetDeepDependencies(Text pattern, Text tolVersion, Date date)
    163   ////////////////////////////////////////////////////////////////////////////
    164   {
    165     Set mainDs = GetMainDependencies(pattern, tolVersion, date);
     211  Set GetDeepDependencies(Text pattern, Text tolPlatform,
     212    Text tolVersion, Date date)
     213  ////////////////////////////////////////////////////////////////////////////
     214  {
     215    Set mainDs = GetMainDependencies(pattern, tolPlatform, tolVersion, date);
    166216    If(Card(mainDs), {
    167217      Unique(SetConcat(EvalSet(mainDs, Set (Text mainD) {
    168         Set deepDs = GetDeepDependencies(mainD, tolVersion, date);
     218        Set deepDs = GetDeepDependencies(mainD, tolPlatform, tolVersion, date);
    169219        If(Card(deepDs), {
    170220          Set [[ mainD ]] << deepDs
    … …  
    195245
    196246  ////////////////////////////////////////////////////////////////////////////
    197   Set GetCompatibleRecords(Text tolVersion, Date date)
    198   ////////////////////////////////////////////////////////////////////////////
    199   {
    200     If(tolVersion=="any" & ""<<date=="Unknown", Copy(_.records), {
     247  Set GetCompatibleRecords(Text tolPlatform, Text tolVersion, Date date)
     248  ////////////////////////////////////////////////////////////////////////////
     249  {
     250    If(tolPlatform=="" & tolVersion=="any" & ""<<date=="Unknown",
     251      Copy(_.records), {
    201252      Set records = Select(EvalSet(_.records, Set (Set subrecords) {
    202253        Set selection = Select(subrecords, Real (Set record) {
    203           Real okTolVersion = If(tolVersion=="any", True, {
    204             TolVersion::CompareVersions(record::minTolVersion, tolVersion)<=0
    205             & TolVersion::CompareVersions(tolVersion, record::maxTolVersion)<=0
    206           });
    207           If(okTolVersion, {
    208             If(""<<date=="Unknown", True, Not(record::release>date))
    209           }, False)
     254          _Record.IsCompatible(record, tolPlatform, tolVersion, date)
    210255        });
    211256        Real If(Card(selection), SetIndexByName(selection));
    … …  
    218263
    219264  ////////////////////////////////////////////////////////////////////////////
    220   Set GetCompatibleList(Text tolVersion, Date date)
    221   ////////////////////////////////////////////////////////////////////////////
    222   {
    223     Set compRecords = GetCompatibleRecords(tolVersion, date);
     265  Set GetCompatibleList(Text tolPlatform, Text tolVersion, Date date)
     266  ////////////////////////////////////////////////////////////////////////////
     267  {
     268    Set compRecords = GetCompatibleRecords(tolPlatform, tolVersion, date);
    224269    EvalSet(compRecords, Set (Set subrecords) { subrecords[1] })
    225270  };
    226271
    227272  ////////////////////////////////////////////////////////////////////////////
    228   Set ObtainUpdateList(@Catalog reference, Text tolVersion, Date date)
    229   ////////////////////////////////////////////////////////////////////////////
    230   {
    231     Set records = GetCompatibleRecords(tolVersion, date);
    232     Set refRecords = reference::GetCompatibleRecords(tolVersion, date);
     273  Set ObtainUpdateList(@Catalog reference, Text tolPlatform,
     274    Text tolVersion, Date date)
     275  ////////////////////////////////////////////////////////////////////////////
     276  {
     277    Set records = GetCompatibleRecords(tolPlatform, tolVersion, date);
     278    Set refRecords = reference::GetCompatibleRecords(tolPlatform,
     279      tolVersion, date);
    233280    SetConcat(EvalSet(refRecords, Set (Set refSubrecords) {
    234281      Real index = FindIndexByName(records, Name(refSubrecords));
    … …  
    251298
    252299  ////////////////////////////////////////////////////////////////////////////
    253   Set ObtainUpgradeList(@Catalog reference, Text tolVersion, Date date)
    254   ////////////////////////////////////////////////////////////////////////////
    255   {
    256     Set records = GetCompatibleRecords(tolVersion, date);
    257     Set refRecords = reference::GetCompatibleRecords(tolVersion, date);
     300  Set ObtainUpgradeList(@Catalog reference, Text tolPlatform,
     301    Text tolVersion, Date date)
     302  ////////////////////////////////////////////////////////////////////////////
     303  {
     304    Set records = GetCompatibleRecords(tolPlatform, tolVersion, date);
     305    Set refRecords = reference::GetCompatibleRecords(tolPlatform,
     306      tolVersion, date);
    258307    SetConcat(EvalSet(refRecords, Set (Set refSubrecords) {
    259308      Real index = FindIndexByName(records, Name(refSubrecords));
    … …  
    276325
    277326  ////////////////////////////////////////////////////////////////////////////
    278   Set ObtainLowUpgradeList(@Catalog reference, Text tolVersion, Date date)
    279   ////////////////////////////////////////////////////////////////////////////
    280   {
    281     Set records = RegroupRecords(GetCompatibleRecords(tolVersion, date));
    282     Set refRecords =
    283       RegroupRecords(reference::GetCompatibleRecords(tolVersion, date));
     327  Set ObtainLowUpgradeList(@Catalog reference, Text tolPlatform,
     328    Text tolVersion, Date date)
     329  ////////////////////////////////////////////////////////////////////////////
     330  {
     331    Set records = RegroupRecords(GetCompatibleRecords(tolPlatform,
     332      tolVersion, date));
     333    Set refRecords = RegroupRecords(reference::GetCompatibleRecords(
     334      tolPlatform, tolVersion, date));
    284335    SetConcat(EvalSet(refRecords, Set (Set refSubrecords) {
    285336      Real index = FindIndexByName(records, Name(refSubrecords));
    … …  
    302353
    303354  ////////////////////////////////////////////////////////////////////////////
    304   Set ObtainFullUpgradeList(@Catalog reference, Text tolVersion, Date date)
    305   ////////////////////////////////////////////////////////////////////////////
    306   {
    307     Set fullList = ObtainUpgradeList(reference, tolVersion, date)
    308       << ObtainLowUpgradeList(reference, tolVersion, date);
     355  Set ObtainFullUpgradeList(@Catalog reference, Text tolPlatform,
     356    Text tolVersion, Date date)
     357  ////////////////////////////////////////////////////////////////////////////
     358  {
     359    Set fullList = ObtainUpgradeList(reference, tolPlatform, tolVersion, date)
     360      << ObtainLowUpgradeList(reference, tolPlatform, tolVersion, date);
    309361    EvalSet(Classify(fullList, Real (Set r1, Set r2) {
    310362      Compare(Name(r1), Name(r2))
    … …  
    351403    Set autodocs = Select(EvalSet(GetDir(path)[2], Set (Text package) {
    352404      Text autodocFile = path<<package<<"/info.oza";
    353       If(FileExist(autodocFile), Ois.Load(autodocFile)[1], {
     405      Text autodocFileV = path<<package<<"/infov.oza";
     406      Case(FileExist(autodocFileV), Ois.Load(autodocFileV)[1],
     407        FileExist(autodocFile), Ois.Load(autodocFile)[1],
     408        True, {
    354409        // Si no tiene info se obtiene de la lista A
    355410        Text ozaFile = path<<package<<"/"<<package<<".oza";
    … …  
    384439      Set rows = SetConcat(EvalSet(repositories_, Set (Text repository) {
    385440        Text urlAnswer = GetUrlContents(repository
    386           <<"?tol_package_version=1.1&action=versions");
     441          <<"?tol_package_version="<<_.autodoc.version.high
     442          <<"&action=versions");
    387443        If(Text Sub(urlAnswer, 1, 3)=="Set", IncludeText(urlAnswer), {
    388444          Error("El repositorio '"<<repository
    … …  
    395451        Set freeDeps = Unique(Select(EvalSet(Tokenizer(row[7], ","),
    396452          Text (Text t) { Tokenizer(t, ".")[1] }), TextLength));
     453        Set name_variant = Tokenizer(pkgInfo[1], "#");
     454        Set extra_info = If(TextLength(row[4]), {
     455          SetConcat(EvalSet(Tokenizer(row[4], "\n"), Set (Text line) {
     456            Real pos = TextFind(line, "=");
     457            If(pos, {
     458              Text name = TextSub(line, 1, pos-1);
     459              Text value = TextSub(line, pos+1, -1);
     460              [[PutName(name, value)]]
     461            }, Copy(Empty))
     462          }))
     463        }, Copy(Empty));
    397464        Set pkgRecord =  [[
    398465          Text identifier = row[3];
    399           Text name = pkgInfo[1];
     466          Text name = name_variant[1];
     467          Text variant = If(Card(name_variant)>1, name_variant[1], "");
    400468          Real high = Eval(pkgInfo[2]);
    401469          Real low = Eval(pkgInfo[3]);
    402470          Text repository = row[1];
    403471          Date release = row[8];
     472          Text platform = getOptArg(extra_info, "platform", "");
    404473          Text minTolVersion = row[5];
    405474          Text maxTolVersion = row[6];
    … …  
    416485  ////////////////////////////////////////////////////////////////////////////
    417486  {
     487    Text variant = getOptArg(autodoc, "_.autodoc.variant", "");
    418488    Set pkgRecord = [[
    419       Text identifier = autodoc::_.autodoc.name
     489      Text identifier = autodoc::_.autodoc.name
     490        <<If(TextLength(variant), "#"<<variant, "")
    420491        <<"."<<autodoc::_.autodoc.version.high
    421492        <<"."<<autodoc::_.autodoc.version.low;
    422493      Text name = autodoc::_.autodoc.name;
     494      Text variant;
    423495      Real high = autodoc::_.autodoc.version.high;
    424496      Real low = autodoc::_.autodoc.version.low;
    425497      Text repository = autodoc::_.autodoc.url;
    426498      Date release = autodoc::_.autodoc.releaseDate;
     499      Text platform = getOptArg(autodoc, "_.autodoc.platform", "");
    427500      Text minTolVersion = autodoc::_.autodoc.minTolVersion;
    428501      Text maxTolVersion = If(
    … …  
    441514    Set autodoc = [[
    442515      Text _.autodoc.name = record::name;
     516      Text _.autodoc.variant = record::variant;
    443517      Real _.autodoc.version.high = record::high;
    444518      Real _.autodoc.version.low = record::low;
    445519      Text _.autodoc.url = record::repository;
     520      Text _.autodoc.platform = record::platform;
    446521      Date _.autodoc.releaseDate = record::release;
    447522      Text _.autodoc.minTolVersion = record::minTolVersion;
  • tol/stdlib/TolPackage/packager.tol

    r9b614da rbe3dec5  
    2121    Date releaseGMT = Copy(NowGmt);
    2222    Set package. = IncludeTOL(sourceRoot<<name<<"/"<<name<<".tol", True);
     23    Case(TestAutodoc(package.[1], releaseGMT), {
     24      WriteLn("No pudo generarse el paquete.", "E");
     25      If(False, ?)
     26    }, TestTolVersion(package.[1]), {
     27      WriteLn("No pudo generarse el paquete.", "E");
     28      If(False, ?)
     29    }, True, {
     30      package.
     31    })
     32  };
     33
     34  ////////////////////////////////////////////////////////////////////////////
     35  Set CompilePackage_Variant(Text name, Text variant, Text sourceRoot)
     36  ////////////////////////////////////////////////////////////////////////////
     37  {
     38    Date releaseGMT = Copy(NowGmt);
     39    Set package. = IncludeTOL(sourceRoot<<name<<"/"<<name<<"#"<<variant<<".tol", True);
    2340    Case(TestAutodoc(package.[1], releaseGMT), {
    2441      WriteLn("No pudo generarse el paquete.", "E");
    … …  
    164181
    165182  ////////////////////////////////////////////////////////////////////////////
     183  Text BuildZip_Variant(NameBlock package, Text sourceRoot, Text destination)
     184  ////////////////////////////////////////////////////////////////////////////
     185  {
     186    Text name = package::_.autodoc.name;
     187    Text identifier = _.autodoc.get.identifier(package);
     188    Text source = sourceRoot<<name<<"/";
     189    Text packagePath = destination<<identifier<<"/";
     190    Real OSDirMake(_AsOSDir(packagePath));
     191    Real Ois.Store(Set { [[
     192      PutName(name, package)
     193    ]] }, packagePath<<identifier+".oza");
     194    Real Ois.Store(Copy(Empty), packagePath<<"info.oza");
     195    Real Ois.Store(ObtainAutodoc(package), packagePath<<"infov.oza");
     196    Set EvalSet(package::_.autodoc.nonTolResources, Real (Anything resource) {
     197      ProcessResource(resource, source, packagePath)
     198    });
     199    Real PackArchive::PackFull("ZipArchive", ReplaceSlash(packagePath), True);
     200    _AsOSDir(packagePath)<<".zip"
     201  };
     202
     203  ////////////////////////////////////////////////////////////////////////////
    166204  Set ObtainAutodoc(NameBlock package)   
    167205  ////////////////////////////////////////////////////////////////////////////
  • tol/stdlib/TolPackage/server.tol

    r9b614da rbe3dec5  
    1515  //  * Real UpdateCatalog(Real void)
    1616  //  * Text DownloadPackage(Text identifier)
    17   //  * Text DownloadCompatible(Text pattern, Text tolVersion, Date date)
     17  //  * Text DownloadCompatible(Text pattern, Text tolPlatform, Text tolVersion, Date date)
    1818  //  * Text DownloadLastCompatible(Text pattern)
    1919  //  * Text DownloadPackageAt(Text identifier, Text path)
    … …  
    7777
    7878  ////////////////////////////////////////////////////////////////////////////
    79   Text DownloadCompatible(Text pattern, Text tolVersion, Date date)
     79  Text DownloadCompatible(Text pattern, Text tolPlatform,
     80    Text tolVersion, Date date)
    8081  ////////////////////////////////////////////////////////////////////////////
    8182  {
    8283    @Catalog catalog = GetCatalog(?);
    83     Text compatibleId = catalog::ObtainIdentifier(pattern, tolVersion,
    84       date);
     84    Text compatibleId = catalog::ObtainIdentifier(pattern, tolPlatform,
     85      tolVersion, date);
    8586    If(TextLength(compatibleId), DownloadPackage(compatibleId), "")
    8687  };
    … …  
    9091  ////////////////////////////////////////////////////////////////////////////
    9192  {
    92     DownloadCompatible(pattern, Version, UnknownDate)
     93    DownloadCompatible(pattern, Platform(?), Version, UnknownDate)
    9394  };
    9495
    … …  
    101102    If(Card(record), {
    102103      Text encoded = GetUrlContents(record::repository
    103         <<"?tol_package_version=1.1"
     104        <<"?tol_package_version="<<_.autodoc.version.high
    104105        <<"&action=download&format=base64"
    105         <<"&package="<<identifier);
     106        <<"&package="<<Replace(identifier,"#","%23"));
    106107      Real OSDirMake(_AsOSDir(path));
    107108      Text zipFile = path<<identifier<<".zip";
    … …  
    170171    Text pkg.name = Replace(pkg.name.zip,".zip","");
    171172    Set name.tok = Tokenizer(pkg.name,".");
     173    Text te_identifier = name.tok[1];
     174    Real isVariant = TextMatch(te_identifier, "*#*");
    172175    Real nu_version_high = Eval(name.tok[2]);
    173176    Real nu_version_low = Eval(name.tok[3]);
    174177    Real PackArchive::UnpackFull("ZipArchive",root+pkg.name,False);
    175     Text oza = root+pkg.name+"/info.oza";
     178    Text oza = root+pkg.name+If(isVariant, "/infov.oza", "/info.oza");
    176179    Set pkg = Include(oza);
    177     Text name = pkg::_.autodoc.name;
    178180    Real If(pkg::_.autodoc.version.high!=nu_version_high,
    179181    {
    … …  
    197199      Real id_format = 1;
    198200      Text te_max_tol_version = pkg::_.autodoc.maxTolVersion;
    199       Text te_extra_info = "";
     201      Text te_extra_info = If(isVariant, {
     202        "variant="+pkg::_.autodoc.variant+"\n"+
     203        "platform="+pkg::_.autodoc.platform
     204      }, "");
    200205      Text insert.query = "
    201206        INSERT INTO package_f_contents (
    … …  
    207212        VALUES (
    208213          "<<repId<<",
    209           '"<<pkg::_.autodoc.name<<"',
     214          '"<<te_identifier<<"',
    210215          "<<pkg::_.autodoc.version.high<<",
    211216          "<<pkg::_.autodoc.version.low<<",
Note: See TracChangeset for help on using the changeset viewer.