Changeset 5eeb176 in tol


Ignore:
Timestamp:
Jun 24, 2010, 2:00:05 PM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
ef4cac5
Parents:
d171685
Message:

Refs #916
Refs #918
Refs #897

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

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

Legend:

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

    rd171685 r5eeb176  
    1515Text _.description;  //Purpose of repository
    1616Text _.sourceRoot;   //Root directory of package's TOL code
    17 Set _.packages;      //Set of names of packages
     17Set  _.packageList;  //Set of names of packages
    1818Text _.root;         //Local server-side installing directory
     19Text _.register;     //Local server-side register directory
     20Text _.index;        //Local server-side index prefix
     21
    1922
    2023//////////////////////////////////////////////////////////////////////////////
    … …  
    2528  Text description, 
    2629  Text sourceRoot,
    27   Set packages)
     30  Set packageList)
    2831//////////////////////////////////////////////////////////////////////////////
    2932{
    3033  Text root = TolPackage::Server::_.localRoot+name+"/";
    31   Real OSDirMake(root+"register/");
    3234  @Builder new = [[
    3335    Text _.url = url;
    … …  
    3638    Text _.description = description;
    3739    Text _.sourceRoot = sourceRoot;
    38     Set _.packages = packages;
    39     Text _.root = root
     40    Set  _.packageList = packageList;
     41    Text _.root = root;
     42    Text _.register = root+"register/";
     43    Text _.index = root+"index"
    4044  ]];
     45  Real OSDirMake(new::_.root);
     46  Real OSDirMake(new::_.register);
    4147  Real new::Build.All(0);
    4248  new
    … …  
    5056  "repository;"+
    5157  "name;"+
    52   "name.version;"+
     58  "pkgName;"+
    5359  "version.high;"+
    5460  "version.low;"+
    … …  
    5864  "minTolVersion;"+
    5965  "releaseDate;"+
    60   "dependencies;\n";
     66  "dependencies;"+
     67  "nonTolResurces;\n";
    6168
    6269  Text index.tol =
    … …  
    7380  "\n";
    7481   
    75   Text WriteFile(_.root+"index.csv",  index.csv);
    76   Text WriteFile(_.root+"index.tol",  index.tol);
    77 //Text WriteFile(_.root+"index.wiki", index.wiki);
    78 //Text WriteFile(_.root+"index.html", index.html);
     82  Text WriteFile(_.index+".csv",  index.csv);
     83  Text WriteFile(_.index+".tol",  index.tol);
     84//Text WriteFile(_.index+".wiki", index.wiki);
     85//Text WriteFile(_.index+".html", index.html);
    7986  True
    8087};
    … …  
    9097
    9198//////////////////////////////////////////////////////////////////////////////
    92 Text FormatSet(Set s)
    93 //////////////////////////////////////////////////////////////////////////////
    94 {
    95   If(Card(s),Escape(""<<s),"Copy(Empty)")
     99Text _.autodoc.member.FormatSet=
     100"Builds the TOL expression of a Set";
     101Text FormatSet(Set set)
     102//////////////////////////////////////////////////////////////////////////////
     103{
     104  Text bl = " ";
     105  Text name = Name(set);
     106  "Set { "+If(name=="","",Name(set)+" = ")+bl+
     107  If(!Card(set),"Copy(Empty)",
     108  {
     109    "[["+bl+
     110    SetSum(For(1,Card(set),Text(Real k)
     111    {
     112      Text gk = Grammar(set[k]);
     113      Text nk = Name(set[k]);
     114      Text dec = "  "+gk+" { "+If(nk=="","",nk+" = ");
     115      If(k>1,","+bl,"")+
     116      Case(
     117      gk=="Text", dec+"\""+set[k]+"\" } ",
     118      gk=="Real", dec<<set[k]+" } ",
     119      gk=="Date", dec<<set[k]+" } ",
     120      gk=="Set",  FormatSet(set[k]),
     121      1==1,
     122      {
     123        WriteLn("[TolPackage::Server::@Builder::FormatSet] "
     124        " Unexpected object "+If(nk,nk+" ","")+"of invalid type "+gk,"E"),
     125        ""
     126      })
     127    }))+bl+"]]"
     128  })+
     129  " }"
    96130};
    97131
    … …  
    102136  Set aux = IncludeText("NameBlock "+name+";");
    103137  NameBlock pkg = aux[1];
    104   Text name.version = TolPackage::GetCurrentNameVersion(name,specificVersion);
     138  Text pkgName = TolPackage::GetCurrentNameVersion(name,specificVersion);
    105139  Set dependencies = TolPackage::GetDeepDependencies(name, specificVersion);
    106   Text index.csv =
    107     pkg:: _.autodoc.url + ";"
     140  Set nonTolResurces = If(!ObjectExist("Set",name+"::_.autodoc.nonTolResources"),
     141    Copy(Empty),pkg::_.autodoc.nonTolResources);
     142  Text index.csv = pkg::_.autodoc.url + ";"
    108143  <<name + ";"
    109   <<name.version+ ";"
     144  <<pkgName+ ";"
    110145  <<If(!specificVersion,?,pkg::_.autodoc.version.high) + ";"
    111146  <<If(!specificVersion,?,pkg::_.autodoc.version.low) + ";"
    … …  
    115150  <<pkg::_.autodoc.minTolVersion + ";"
    116151  <<Now + ";"
    117   <<FormatSet(dependencies)+ "\n";
     152  <<FormatSet(dependencies)+ ";"
     153  <<FormatSet(nonTolResurces)+"\n";
    118154  WriteLn("[TolPackage::Server::@Builder::Build.PackageInfo.Version] "+
    119     name.version+":\n"+index.csv+"\n");
    120   Text WriteFile(_.root+"register/"+name.version,  index.csv);
    121   Real Ois.Store(aux,_.root+"packages/"+name.version+".oza");
     155    pkgName+":\n"+index.csv+"\n");
     156  Text WriteFile(_.register+pkgName,  index.csv);
     157  Real Ois.Store(aux,_.root+pkgName+".oza");
     158  Set EvalSet(TolPackage::Server::_.supportedPlatforms, Real(Text platform)
     159  {
     160    Text ppRoot_ = _.root+platform+"/"+pkgName;
     161    Text ppRoot = ppRoot_+"/";
     162    Real OSDirMake(ppRoot);
     163    Real OSFilCopy(_.root+pkgName+".oza", ppRoot+pkgName+".oza");
     164    Set selResources = SetConcat(Select(nonTolResurces, Real(Set ptf)
     165    {
     166      Or(ptf==platform,ptf=="CrossPlatform")
     167    }));
     168    Set EvalSet(selResources, Real(Text resource)
     169    {
     170      Text orig = _.sourceRoot+name+"/"+resource;
     171      Text dest = ppRoot+"/"+Name(resource);
     172      WriteLn("TRACE dir copy '"+orig+"' -> '"+dest+"'");
     173      OSDirCopy(orig,dest)
     174    });
     175    Text ppr = If(!TextBeginWith(platform,"Windows"),ppRoot_,
     176     Replace(ppRoot_,"/","\\"));
     177    Real PackArchive::PackFull("ZipArchive", ppr);
     178    Real OSDirRemove(ppRoot);
     179    True
     180  });
     181  Real OSFilRemove(_.root+pkgName+".oza");
    122182  index.csv
    123183};
    … …  
    131191};
    132192
     193
    133194//////////////////////////////////////////////////////////////////////////////
    134195Real Build.All(Real void)
    135196//////////////////////////////////////////////////////////////////////////////
    136197{
    137   Real new::Initialize(void);
    138   Set IncludeText(SetSum(EvalSet(_.packages, Text(Text pkgName)
    139   {
    140     "Set Include(\""+_.sourceRoot+pkgName+"/"+pkgName+".tol\");"
    141   })));
    142   Set EvalSet(_.packages, Real(Text pkgName)
    143   {
    144     Text AppendFile(_.root+"index.csv",  Build.PackageInfo(pkgName));
    145   //Text AppendFile(_.root+"index.wiki", index.wiki);
    146   //Text AppendFile(_.root+"index.html", index.html);
     198  Real Initialize(void);
     199  Set EvalSet(_.packageList, Real(Text pkgName)
     200  {
     201    Text AppendFile(_.index+".csv",  Build.PackageInfo(pkgName));
     202  //Text AppendFile(_.index+".wiki", index.wiki);
     203  //Text AppendFile(_.index+".html", index.html);
    147204    True
    148205  });
     206
    149207  True
    150208};
    … …  
    154212//////////////////////////////////////////////////////////////////////////////
    155213{
    156   Real new::Initialize(void);
    157   Set IncludeText(
    158     "Set Include(\""+_.sourceRoot+pkgName+"/"+pkgName+".tol\");"
    159   );
     214  Real Initialize(void);
    160215  Text Build.PackageInfo(pkgName);
    161   Set pkgLst = Sort(GetDir(_.root+"register/")[2], Real(Text a, Text b)
     216  Set pkgLst = Sort(GetDir(_.register)[2], Real(Text a, Text b)
    162217  {
    163218    Compare(b,a)
    … …  
    165220  Set EvalSet(pkgLst, Real(Text pkgName)
    166221  {
    167     Text AppendFile(_.root+"index.csv",ReadFile(_.root+"register/"+pkgName));
     222    Text AppendFile(_.index+".csv", ReadFile(_.register+pkgName));
    168223    True
    169224  });
  • tol/stdlib/general/TolPackage/client.tol

    rd171685 r5eeb176  
    88
    99Text _.localRoot =
    10 {
    11   Text aux = Replace(TolAppDataPath+"OIS/TolPackage/Client/","\\","/");
    12   Real OSDirMake(aux);
    13   aux
    14 };
     10  Replace(TolAppDataPath+"TolPackage/Client/","\\","/");
    1511
    1612#Embed "repository.tol";
    1713#Embed "autoLoadSave.tol";
    1814
    19 //////////////////////////////////////////////////////////////////////////////
    20 Text _.autodoc.member.LocalFile =
    21 "Devuelve el path completo del fichero local correspondiente a un paquete.";
    22 Text LocalFile(Text package.version)
    23 //////////////////////////////////////////////////////////////////////////////
    24 {
    25   TolPackage::Client::_.localRoot+package.version+".oza"
     15
     16//////////////////////////////////////////////////////////////////////////////
     17//Inicializa el sistema de almacenamiento persistente de la lista de
     18//repositorios
     19NameBlock Initialize(Real void)
     20//////////////////////////////////////////////////////////////////////////////
     21{
     22  Real OSDirMake(_.localRoot);
     23  TolPackage::Client::@AutoLoadSave _autoLoadSave =
     24    TolPackage::Client::@AutoLoadSave::Create(0);
     25  _autoLoadSave
     26};
     27
     28
     29//////////////////////////////////////////////////////////////////////////////
     30Text _.autodoc.member.LocalPack =
     31"Devuelve el path completo del fichero local correspondiente a un paquete "
     32"comprimido.";
     33Text LocalPack(Text package.version)
     34//////////////////////////////////////////////////////////////////////////////
     35{
     36  TolPackage::Client::_.localRoot+package.version+"/"+package.version+".zip"
     37};
     38
     39//////////////////////////////////////////////////////////////////////////////
     40Text _.autodoc.member.LocalOza =
     41"Devuelve el path completo del fichero local OIS correspondiente a un "
     42"paquete.";
     43Text LocalOza(Text package.version)
     44//////////////////////////////////////////////////////////////////////////////
     45{
     46  TolPackage::Client::_.localRoot+package.version+"/"+package.version+".zip"
     47};
     48
     49
     50//////////////////////////////////////////////////////////////////////////////
     51Text _.autodoc.member.LocalResourcePath =
     52"Devuelve el path completo del directorio local de un recurso ajeno a TOL "
     53"necesario para el paquete especificado.";
     54Text LocalResourcePath(Text package.version, Text resource)
     55//////////////////////////////////////////////////////////////////////////////
     56{
     57  TolPackage::Client::_.localRoot+package.version+"/"+resource
    2658};
    2759
    … …  
    3466  @Repository r = @Repository::Get(repository, True);
    3567  r::Exist(package.version)
    36 };
    37 
    38 //////////////////////////////////////////////////////////////////////////////
    39 //Inicializa el sistema de almacenamiento persistente de la lista de
    40 //repositorios
    41 NameBlock Initialize(Real void)
    42 //////////////////////////////////////////////////////////////////////////////
    43 {
    44   TolPackage::Client::@AutoLoadSave _autoLoadSave =
    45     TolPackage::Client::@AutoLoadSave::Create(0);
    46   _autoLoadSave
    4768};
    4869
    … …  
    166187
    167188//////////////////////////////////////////////////////////////////////////////
     189Text _.autodoc.member.Clean = "Elimina un paquete concreto.";
     190Real Clean(Text repository, Text package.version)
     191//////////////////////////////////////////////////////////////////////////////
     192{
     193  @Repository r = @Repository::Get(repository, True);
     194  r::Clean(package)
     195};
     196
     197//////////////////////////////////////////////////////////////////////////////
     198Text _.autodoc.member.Clean.All =
     199"Elimina todos los paquetes disponibles localmente procedentes del "
     200"repositorio.";
     201Real Clean.All(Text repository)
     202//////////////////////////////////////////////////////////////////////////////
     203{
     204  @Repository r = @Repository::Get(repository, True);
     205  r::Clean.All(0)
     206};
     207
     208//////////////////////////////////////////////////////////////////////////////
     209Text _.autodoc.member.Clean.AllInAll =
     210"Elimina todos los paquetes disponibles localmente.";
     211Real Clean.AllInAll(Real void)
     212//////////////////////////////////////////////////////////////////////////////
     213{
     214  @Repository::Clean.AllInAll(void)
     215};
     216
     217//////////////////////////////////////////////////////////////////////////////
     218Text _.autodoc.member.GetRequirements=
     219"Crea un texto con los #Require para una lista de paquetes";
     220Text GetRequirements(Set packages)
     221//////////////////////////////////////////////////////////////////////////////
     222{
     223  SetSum(EvalSet(packages,Text(Text required)
     224  {
     225    "#Require "+required+";\n"
     226  }))
     227};
     228
     229//////////////////////////////////////////////////////////////////////////////
    168230Text _.autodoc.member.DoRequirements=
    169231"Llama a #Require para una lista de paquetes";
    … …  
    177239  });
    178240  True
    179 };
    180 
    181 //////////////////////////////////////////////////////////////////////////////
    182 Text _.autodoc.member.ForceExactRequirements =
    183 "Permite usar una versión de un paquete distinta de la última con #Require "
    184 "asegurando la compatibilidad con el estado exacto de los paquetes de los "
    185 "que depende el requerido y recursivamente los que dependen de ellos. \n"
    186 "Lee en el repositorio remoto la lista de requerimientos para el paquete y "
    187 "hace los requires de las versiones exactas. \n"
    188 "Hay que llamar a este método siempre antes de hacer ningún #Require de "
    189 "cualquiera de los paquetes requeridos directa o indirectamente por lo que "
    190 "lo más aconsejable es hacerlo justo después de cargar la StdLib ";
    191 Real ForceExactRequirements(Text repository, Text package.version)
    192 //////////////////////////////////////////////////////////////////////////////
    193 {
    194   @Repository r = @Repository::Get(repository, True);
    195   r::ForceExactRequirements(package.version)
    196 };
    197 
    198 //////////////////////////////////////////////////////////////////////////////
    199 Text _.autodoc.member.Remove =
    200 "Borra un paquete del directorio local.";
    201 Real Remove(Text package.version)
    202 //////////////////////////////////////////////////////////////////////////////
    203 {
    204   OSFilRemove(_.localRoot+package.version)
    205 };
    206 
    207 //////////////////////////////////////////////////////////////////////////////
    208 Text _.autodoc.member.Remove.All =
    209 "Borra todos los paquetes del directorio local.";
    210 Real Remove.All(Real void)
    211 //////////////////////////////////////////////////////////////////////////////
    212 {
    213   OSDirRemove(_.localRoot);
    214   OSDirMake(_.localRoot)
    215241}
    216242
  • tol/stdlib/general/TolPackage/common.tol

    rd171685 r5eeb176  
    2020  Text minTolVersion,
    2121  Date releaseDate,
    22   Set  dependencies
     22  Set  dependencies,
     23  Set  nonTolResources
    2324};
    2425
  • tol/stdlib/general/TolPackage/repository.tol

    rd171685 r5eeb176  
    4444Static Set _.allPackages = Copy(Empty);
    4545
     46Static Real _.localOnlyWarningWasShown = False;
     47
     48Static Text _.platform = If(OSWin, "Windows-x86_32", "Linux-x86_32");
     49
    4650//////////////////////////////////////////////////////////////////////////////
    4751//Carga la lista de repositorios accesibles
    … …  
    7276        })
    7377      });
     78      Text bst = TolPackage::Client::_.localRoot+"packages.bst";
     79      Set If(And(FileExist(bst),FileBytes(bst)), 
     80        @Repository::_.allPackages := IncludeBST(bst));
    7481      True   
    7582    })
    … …  
    8693  {
    8794    Text file = TolPackage::Client::_.localRoot+"repositories.txt";
    88     WriteLn("[TolPackage::Client::@Repository::SaveInstances]\n"
    89             "Saving list of available repositories to "+file);
    9095    Text WriteFile(file,
    9196    "//////////////////////////////////////////////////////////////////////////////\n"
    … …  
    112117      True   
    113118    });
     119    Set If(Card(@Repository::_.allPackages),
     120      BSTFile(@Repository::_.allPackages,
     121        TolPackage::Client::_.localRoot+"packages.bst"));
     122    WriteLn("[TolPackage::Client::@Repository::SaveInstances]\n"
     123            "List of available repositories and packages have been saved to "
     124            "local store \n  "+TolPackage::Client::_.localRoot);
    114125    True
    115126  })
    … …  
    162173//////////////////////////////////////////////////////////////////////////////
    163174//Devuelve el contenido de un fichero de texto ubicado en el repositorio
    164   Text GetFileContens(Text path)
    165 //////////////////////////////////////////////////////////////////////////////
    166 {
     175  Text GetFileContent(Text path)
     176//////////////////////////////////////////////////////////////////////////////
     177{
     178  Text content = If(!_.isRemote,
     179  {
     180  //WriteLn("TRACE [GetFileContent] 1 _.address+path='"+_.address+path+"'");
     181    ReadFile(_.address+path)
     182  },
     183  {
     184  //WriteLn("TRACE [GetFileContent] 2 _.url+path='"+_.url+path+"'");
     185    StdLib::GetUrlContents(_.url+path)
     186  });
     187//WriteLn("TRACE [GetFileContent] 3 content='"+content+"'");
     188  content
     189};
     190
     191//////////////////////////////////////////////////////////////////////////////
     192//Copia un fichero del repositorio remoto al directorio local de paquetes
     193  Real DownloadPackage(Text packageName)
     194//////////////////////////////////////////////////////////////////////////////
     195{
     196  Text pack = packageName+".zip";
     197  Text oza = packageName+"/"+packageName+".oza";
     198  Text localPack = TolPackage::Client::_.localRoot+pack;
     199  Text localOza = TolPackage::Client::_.localRoot+oza;
     200  Text localDir = TolPackage::Client::_.localRoot+packageName;
     201  If(FileExist(localPack), OSFilRemove(localPack));
     202//WriteLn("TRACE DownloadPackage localPack="<<localPack);
    167203  If(!_.isRemote,
    168204  {
    169     ReadFile(_.address+path)
    170   },
    171   {
    172     StdLib::GetUrlContents(_.url+path)
    173   })
     205  //WriteLn("TRACE DownloadPackage  cp \""+_.address+@Repository::_.platform+"/"+pack+"\" \""+localPack+"\"");
     206    OSFilCopy(_.address+@Repository::_.platform+"/"+pack,localPack)
     207  },
     208  {
     209    Curl::Get([[
     210      Text url  = _.url+@Repository::_.platform+"/"+pack,
     211      Text file = localPack ]])
     212  });
     213  If(!FileExist(localPack), False,
     214  {
     215  //WriteLn("TRACE DownloadPackage UnpackFull("<<localDir+")");
     216    Real PackArchive::UnpackFull("ZipArchive", localDir);
     217    OSFilRemove(localPack);
     218    True
     219  });
     220  FileExist(localOza)
     221};
     222
     223//////////////////////////////////////////////////////////////////////////////
     224//Mezcla un listado de paquetes con la lista actual de los mismos comprobando
     225//si no hay repeticiones y manteniendo los índices y el orden.
     226Static Real MergePackages(Set packages)
     227//////////////////////////////////////////////////////////////////////////////
     228{
     229  Set newPackages = Select(packages, Real(TolPackage::@PackageInfo a)
     230  {
     231    Set ap = @Repository::_.allPackages;
     232    Real pos = FindIndexByName(ap,a->name.version);
     233    Case(
     234    pos<=0,
     235    {
     236      True
     237    },
     238    ap[pos]->repository == a->repository,
     239    {
     240      False
     241    },
     242    1==1,
     243    {
     244      WriteLn("[TolPackage::Client::@Repository::Connect] Package "+
     245      a->name.version+" is duplicated in these repositories: \n"+
     246      "  "+ap[pos]->repository+"\n"+
     247      "  "+a->repository+"\n" ,
     248      "E");
     249      False
     250    })
     251  });
     252  Set Append(@Repository::_.allPackages, newPackages, True);
     253  Set @Repository::_.allPackages := Sort(@Repository::_.allPackages,
     254  Real(TolPackage::@PackageInfo a, TolPackage::@PackageInfo b)
     255  {
     256    Compare(b->name.version, a->name.version)
     257  });
     258  True
    174259};
    175260
    … …  
    179264//////////////////////////////////////////////////////////////////////////////
    180265{
    181   If(Not(IsUnknown(_.connected)), _.connected,
     266  Case(
     267  Not(IsUnknown(_.connected)),
     268  {
     269    _.connected
     270  },
     271  And(_.isRemote,TolConfigManager::Config::Upgrading::TolPackage::LocalOnly),
     272  {
     273    If(Not(@Repository::_.localOnlyWarningWasShown),
     274    {
     275      WriteLn("[TolPackage::Client::@Repository::Connect] "
     276        "Remote connections are disabled by user configuration parameter\n"
     277        "  TolConfigManager::Config::Upgrading::TolPackage::LocalOnly \n"
     278        "Using just local information.");
     279      @Repository::_.localOnlyWarningWasShown := True
     280    });
     281    Real _.connected := False;
     282    _.connected
     283  },
     284  1==1,
    182285  {
    183286    WriteLn("[TolPackage::Client::@Repository::Connect] "
    184       "Trying to conect to repository "+_.url+" ...");
     287      "Trying to connect to repository "+_.url+" ...");
    185288    Real numErr0 = Copy(NError);
    186     Set repInf = IncludeText(GetFileContens("index.tol"));
     289  //WriteLn("TRACE [Connect] 1");
     290    Set repInf = IncludeText(GetFileContent("index.tol"));
    187291    Text _.name := repInf::name;
     292  //WriteLn("TRACE [Connect] 2 _.name='"+_.name+"'");
    188293    Text _.type := repInf::type;
     294  //WriteLn("TRACE [Connect] 3 _.type='"+_.type+"'");
    189295    Text _.description := repInf::description;
    190     Text aux = GetFileContens("index.csv");
     296  //WriteLn("TRACE [Connect] 4 _.description='"+_.description+"'");
     297    Text aux = GetFileContent("index.csv");
     298  //WriteLn("TRACE [Connect] 5 aux=\n"+aux+"\n");
    191299    Set line = Tokenizer(aux,"\n");
    192 
     300  //WriteLn("TRACE [Connect] 6 Card(line)=\n"<<Card(line)+"\n");
    193301    Set cells.all = For(2,Card(line), Set(Real k)
    194302    {
    … …  
    198306      fields
    199307    });
    200     Set cells = Select(cells.all, Real(Set s) { Card(s)==11 });
     308  //WriteLn("TRACE [Connect] 7 Card(cells.all)=\n"<<Card(cells.all)+"\n");
     309    Set cells = Select(cells.all, Real(Set s) { Card(s)==12 });
     310  //WriteLn("TRACE [Connect] 8 Card(cells)=\n"<<Card(cells)+"\n");
    201311    Set pckInf = For(1,Card(cells), TolPackage::@PackageInfo(Real k)
    202312    {
    … …  
    213323        Text minTolVersion = fields[9],
    214324        Date releaseDate = Eval(fields[10]),
    215         Set dependencies = Eval(fields[11])
     325        Set dependencies = Eval(fields[11]),
     326        Set  nonTolResources = Eval(fields[12])
    216327      ) ]] };
    217328      Set PutName(aux[1]->name.version,aux[1]);
    … …  
    225336    });
    226337    Real SetIndexByName(_.index);
    227     Set Append(_.allPackages,_.index, True);
    228     Set _.allPackages := Sort(_.allPackages,
    229     Real(TolPackage::@PackageInfo a, TolPackage::@PackageInfo b)
    230     {
    231       Compare(b->name.version, a->name.version)
    232     });
     338    Real @Repository::MergePackages(_.index);
    233339    Real numErr1 = Copy(NError);
    234340    Real _.connected := And(numErr1==numErr0,Card(_.index));
    … …  
    252358
    253359//////////////////////////////////////////////////////////////////////////////
    254 Text _.autodoc.member.Exist =
    255 "Devuelve cierto si existe el paquete especificado";
    256 Real Exist(Text package.version)
    257 //////////////////////////////////////////////////////////////////////////////
    258 {
    259   Real pos = FindIndexByName(_.index,package);
    260   pos > 0
    261 };
    262 
    263 //////////////////////////////////////////////////////////////////////////////
    264360Text _.autodoc.member.Find =
    265361"Busca un paquete entre todos los repositorios consultables y, si lo "
    … …  
    270366{
    271367  Real @Repository::ForceConnect.All(0);
    272   Real pos = FindIndexByName(_.allPackages,package.version);
    273   Set found = If(pos<=0, Copy(Empty), _.allPackages[pos]);
     368  Real pos = FindIndexByName(@Repository::_.allPackages,package.version);
     369  Set found = If(pos<=0, Copy(Empty), @Repository::_.allPackages[pos]);
    274370  found
    275371};
    276372
    277373//////////////////////////////////////////////////////////////////////////////
    278 //Copia un fichero del repositorio remoto al directorio local de paquetes
    279   Real DownloadPackage(Text packageName)
    280 //////////////////////////////////////////////////////////////////////////////
    281 {
    282   Text localPath = TolPackage::Client::LocalFile(packageName);
    283   If(FileExist(localPath), OSFilRemove(localPath));
    284   If(!_.isRemote,
    285   {
    286     OSFilCopy(_.address+"packages/"+packageName+".oza",localPath)
    287   },
    288   {
    289     //Hay que buscar una forma de copiar remoto sin wget, con el TCL
    290     Text order =
    291       "wget -O\""+localPath+"\" \""+ _.url+"packages/"+packageName+".oza\"";
    292     WriteLn("[TolPackage::Client::@Repository::DownloadPackage] \n"+order);
    293     Real ok = OSCmdWait(order);
    294     Real Sleep(.1);
    295     ok
    296   });
    297   FileExist(localPath)
    298 };
    299 
     374Text _.autodoc.member.Exist =
     375"Devuelve cierto si existe el paquete especificado";
     376Real Exist(Text package.version)
     377//////////////////////////////////////////////////////////////////////////////
     378{
     379  Real pos = FindIndexByName(_.index,package);
     380  pos > 0
     381};
    300382
    301383//////////////////////////////////////////////////////////////////////////////
    … …  
    327409//WriteLn("TRACE Client::Install");
    328410  Real Connect(0);
    329   Real DownloadPackage(package.version);
    330   Real ok = FileExist(LocalFile(package.version));
    331   Case(
    332   ok,
     411  Real pos = FindIndexByName(_.index,package.version);
     412  If(pos<=0,
    333413  {
    334414    WriteLn("[TolPackage::Client::@Repository::Install] "
    335     "Installed package "+package.version)
    336   },
    337   showError,
    338   {
    339     WriteLn("[TolPackage::Client::@Repository::Install] "
    340     "Cannot install package "+package.version,"E")
    341   });
    342   ok
     415    "Package "+package.version+ " not found in repository "+_.url,"E");
     416    False
     417  },
     418  {
     419    Real ok = DownloadPackage(package.version);
     420    Case(
     421    ok,
     422    {
     423    //Text depend = TolPackage::Client::GetRequirements(
     424    //  _.index[pos]->dependencies);
     425    //Text dependFile = TolPackage::Client::LocalDepend(package.version);
     426    //Text WriteFile(dependFile, depend);
     427      WriteLn("[TolPackage::Client::@Repository::Install] "
     428      "Installed package "+package.version)
     429    },
     430    showError,
     431    {
     432      WriteLn("[TolPackage::Client::@Repository::Install] "
     433      "Cannot install package "+package.version,"E")
     434    });     
     435    ok
     436  })
    343437};
    344438
    … …  
    427521{
    428522  Real Connect(0);
    429   Text localFile = TolPackage::Client::LocalFile(package.version);
     523  Text localFile = TolPackage::Client::LocalOza(package.version);
    430524  Date localDate = If(!FileExist(localFile),
    431525    y1900,
    … …  
    480574
    481575//////////////////////////////////////////////////////////////////////////////
    482 Text _.autodoc.member.ForceExactRequirements =
    483 "Permite usar una versión de un paquete distinta de la última con #Require "
    484 "asegurando la compatibilidad con el estado exacto de los paquetes de los "
    485 "que depende el requerido y recursivamente los que dependen de ellos. \n"
    486 "Lee en el repositorio remoto la lista de requerimientos para el paquete y "
    487 "hace los requires de las versiones exactas. \n"
    488 "Hay que llamar a este método siempre antes de hacer ningún #Require de "
    489 "cualquiera de los paquetes requeridos directa o indirectamente por lo que "
    490 "lo más aconsejable es hacerlo justo después de cargar la StdLib ";
    491 Real ForceExactRequirements(Text package.version)
     576Text _.autodoc.member.Clean = "Elimina un paquete concreto.";
     577Real Clean(Text package.version)
     578//////////////////////////////////////////////////////////////////////////////
     579{
     580  Text localFile = TolPackage::Client::LocalOza(package.version);
     581  If(!FileExist(localFile), False, OSFilRemove(localFile))
     582};
     583
     584//////////////////////////////////////////////////////////////////////////////
     585Text _.autodoc.member.Clean.All =
     586"Elimina todos los paquetes disponibles localmente procedentes del "
     587"repositorio.";
     588Real Clean.All(Real void)
    492589//////////////////////////////////////////////////////////////////////////////
    493590{
    494591  Real Connect(0);
    495   Real pos = FindIndexByName(_.index,package.version),
    496   If(!pos, False,
    497   {
    498     TolPackage::DoRequirements(_.index[pos]->dependencies)
    499   })
     592  WriteLn("[TolPackage::Client::@Repository::Clean.All] "
     593  "Removing local packages from repository "+_.url);
     594  Real n = SetSum(EvalSet(_.index, Real(TolPackage::@PackageInfo pi)
     595  {
     596    Clean(pi->name.version)
     597  }));
     598  WriteLn("[TolPackage::Client::@Repository::Clean.All] "<<n+
     599  " packages where removed from repository "+_.url);
     600  n
     601};
     602
     603//////////////////////////////////////////////////////////////////////////////
     604Text _.autodoc.member.Clean.AllInAll =
     605"Elimina todos los paquetes disponibles localmente.";
     606Static Real Clean.AllInAll(Real void)
     607//////////////////////////////////////////////////////////////////////////////
     608{
     609  Real @Repository::ForceConnect.All(0);
     610  SetSum(EvalSet(@Repository::_.instances, Real(@Repository r)
     611  {
     612    r::Clean.All(0)
     613  }))
    500614}
    501615
  • tol/stdlib/general/TolPackage/server.tol

    rd171685 r5eeb176  
    1111
    1212Text _.localRoot =
     13  Replace(TolAppDataPath+"TolPackage/Server/","\\","/");
     14
     15Set _.supportedPlatforms =
     16[[
     17  "Windows-x86_32",
     18  "Linux-x86_32"
     19]];
     20
     21//////////////////////////////////////////////////////////////////////////////
     22//Inicializa el servidor
     23Real Initialize(Real void)
     24//////////////////////////////////////////////////////////////////////////////
    1325{
    14   Text aux = Replace(TolAppDataPath+"OIS/TolPackage/Server/","\\","/");
    15   Real OSDirMake(aux);
    16   aux
     26  Real OSDirMake(_.localRoot);
     27  Set EvalSet(_.supportedPlatforms, Real(Text platform)
     28  {
     29    Real OSDirMake(_.localRoot+platform)
     30  });
     31  True
    1732};
    1833
Note: See TracChangeset for help on using the changeset viewer.