Changeset 5eeb176 in tol
- Timestamp:
- Jun 24, 2010, 2:00:05 PM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- ef4cac5
- Parents:
- d171685
- Location:
- tol/stdlib/general/TolPackage
- Files:
-
- 5 edited
-
builder.tol (modified) (12 diffs)
-
client.tol (modified) (4 diffs)
-
common.tol (modified) (1 diff)
-
repository.tol (modified) (14 diffs)
-
server.tol (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/general/TolPackage/builder.tol
rd171685 r5eeb176 15 15 Text _.description; //Purpose of repository 16 16 Text _.sourceRoot; //Root directory of package's TOL code 17 Set _.packages;//Set of names of packages17 Set _.packageList; //Set of names of packages 18 18 Text _.root; //Local server-side installing directory 19 Text _.register; //Local server-side register directory 20 Text _.index; //Local server-side index prefix 21 19 22 20 23 ////////////////////////////////////////////////////////////////////////////// … … 25 28 Text description, 26 29 Text sourceRoot, 27 Set package s)30 Set packageList) 28 31 ////////////////////////////////////////////////////////////////////////////// 29 32 { 30 33 Text root = TolPackage::Server::_.localRoot+name+"/"; 31 Real OSDirMake(root+"register/");32 34 @Builder new = [[ 33 35 Text _.url = url; … … 36 38 Text _.description = description; 37 39 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" 40 44 ]]; 45 Real OSDirMake(new::_.root); 46 Real OSDirMake(new::_.register); 41 47 Real new::Build.All(0); 42 48 new … … 50 56 "repository;"+ 51 57 "name;"+ 52 " name.version;"+58 "pkgName;"+ 53 59 "version.high;"+ 54 60 "version.low;"+ … … 58 64 "minTolVersion;"+ 59 65 "releaseDate;"+ 60 "dependencies;\n"; 66 "dependencies;"+ 67 "nonTolResurces;\n"; 61 68 62 69 Text index.tol = … … 73 80 "\n"; 74 81 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); 79 86 True 80 87 }; … … 90 97 91 98 ////////////////////////////////////////////////////////////////////////////// 92 Text FormatSet(Set s) 93 ////////////////////////////////////////////////////////////////////////////// 94 { 95 If(Card(s),Escape(""<<s),"Copy(Empty)") 99 Text _.autodoc.member.FormatSet= 100 "Builds the TOL expression of a Set"; 101 Text 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 " }" 96 130 }; 97 131 … … 102 136 Set aux = IncludeText("NameBlock "+name+";"); 103 137 NameBlock pkg = aux[1]; 104 Text name.version= TolPackage::GetCurrentNameVersion(name,specificVersion);138 Text pkgName = TolPackage::GetCurrentNameVersion(name,specificVersion); 105 139 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 + ";" 108 143 <<name + ";" 109 << name.version+ ";"144 <<pkgName+ ";" 110 145 <<If(!specificVersion,?,pkg::_.autodoc.version.high) + ";" 111 146 <<If(!specificVersion,?,pkg::_.autodoc.version.low) + ";" … … 115 150 <<pkg::_.autodoc.minTolVersion + ";" 116 151 <<Now + ";" 117 <<FormatSet(dependencies)+ "\n"; 152 <<FormatSet(dependencies)+ ";" 153 <<FormatSet(nonTolResurces)+"\n"; 118 154 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"); 122 182 index.csv 123 183 }; … … 131 191 }; 132 192 193 133 194 ////////////////////////////////////////////////////////////////////////////// 134 195 Real Build.All(Real void) 135 196 ////////////////////////////////////////////////////////////////////////////// 136 197 { 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); 147 204 True 148 205 }); 206 149 207 True 150 208 }; … … 154 212 ////////////////////////////////////////////////////////////////////////////// 155 213 { 156 Real new::Initialize(void); 157 Set IncludeText( 158 "Set Include(\""+_.sourceRoot+pkgName+"/"+pkgName+".tol\");" 159 ); 214 Real Initialize(void); 160 215 Text Build.PackageInfo(pkgName); 161 Set pkgLst = Sort(GetDir(_.r oot+"register/")[2], Real(Text a, Text b)216 Set pkgLst = Sort(GetDir(_.register)[2], Real(Text a, Text b) 162 217 { 163 218 Compare(b,a) … … 165 220 Set EvalSet(pkgLst, Real(Text pkgName) 166 221 { 167 Text AppendFile(_. root+"index.csv",ReadFile(_.root+"register/"+pkgName));222 Text AppendFile(_.index+".csv", ReadFile(_.register+pkgName)); 168 223 True 169 224 }); -
tol/stdlib/general/TolPackage/client.tol
rd171685 r5eeb176 8 8 9 9 Text _.localRoot = 10 { 11 Text aux = Replace(TolAppDataPath+"OIS/TolPackage/Client/","\\","/"); 12 Real OSDirMake(aux); 13 aux 14 }; 10 Replace(TolAppDataPath+"TolPackage/Client/","\\","/"); 15 11 16 12 #Embed "repository.tol"; 17 13 #Embed "autoLoadSave.tol"; 18 14 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 19 NameBlock 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 ////////////////////////////////////////////////////////////////////////////// 30 Text _.autodoc.member.LocalPack = 31 "Devuelve el path completo del fichero local correspondiente a un paquete " 32 "comprimido."; 33 Text LocalPack(Text package.version) 34 ////////////////////////////////////////////////////////////////////////////// 35 { 36 TolPackage::Client::_.localRoot+package.version+"/"+package.version+".zip" 37 }; 38 39 ////////////////////////////////////////////////////////////////////////////// 40 Text _.autodoc.member.LocalOza = 41 "Devuelve el path completo del fichero local OIS correspondiente a un " 42 "paquete."; 43 Text LocalOza(Text package.version) 44 ////////////////////////////////////////////////////////////////////////////// 45 { 46 TolPackage::Client::_.localRoot+package.version+"/"+package.version+".zip" 47 }; 48 49 50 ////////////////////////////////////////////////////////////////////////////// 51 Text _.autodoc.member.LocalResourcePath = 52 "Devuelve el path completo del directorio local de un recurso ajeno a TOL " 53 "necesario para el paquete especificado."; 54 Text LocalResourcePath(Text package.version, Text resource) 55 ////////////////////////////////////////////////////////////////////////////// 56 { 57 TolPackage::Client::_.localRoot+package.version+"/"+resource 26 58 }; 27 59 … … 34 66 @Repository r = @Repository::Get(repository, True); 35 67 r::Exist(package.version) 36 };37 38 //////////////////////////////////////////////////////////////////////////////39 //Inicializa el sistema de almacenamiento persistente de la lista de40 //repositorios41 NameBlock Initialize(Real void)42 //////////////////////////////////////////////////////////////////////////////43 {44 TolPackage::Client::@AutoLoadSave _autoLoadSave =45 TolPackage::Client::@AutoLoadSave::Create(0);46 _autoLoadSave47 68 }; 48 69 … … 166 187 167 188 ////////////////////////////////////////////////////////////////////////////// 189 Text _.autodoc.member.Clean = "Elimina un paquete concreto."; 190 Real Clean(Text repository, Text package.version) 191 ////////////////////////////////////////////////////////////////////////////// 192 { 193 @Repository r = @Repository::Get(repository, True); 194 r::Clean(package) 195 }; 196 197 ////////////////////////////////////////////////////////////////////////////// 198 Text _.autodoc.member.Clean.All = 199 "Elimina todos los paquetes disponibles localmente procedentes del " 200 "repositorio."; 201 Real Clean.All(Text repository) 202 ////////////////////////////////////////////////////////////////////////////// 203 { 204 @Repository r = @Repository::Get(repository, True); 205 r::Clean.All(0) 206 }; 207 208 ////////////////////////////////////////////////////////////////////////////// 209 Text _.autodoc.member.Clean.AllInAll = 210 "Elimina todos los paquetes disponibles localmente."; 211 Real Clean.AllInAll(Real void) 212 ////////////////////////////////////////////////////////////////////////////// 213 { 214 @Repository::Clean.AllInAll(void) 215 }; 216 217 ////////////////////////////////////////////////////////////////////////////// 218 Text _.autodoc.member.GetRequirements= 219 "Crea un texto con los #Require para una lista de paquetes"; 220 Text GetRequirements(Set packages) 221 ////////////////////////////////////////////////////////////////////////////// 222 { 223 SetSum(EvalSet(packages,Text(Text required) 224 { 225 "#Require "+required+";\n" 226 })) 227 }; 228 229 ////////////////////////////////////////////////////////////////////////////// 168 230 Text _.autodoc.member.DoRequirements= 169 231 "Llama a #Require para una lista de paquetes"; … … 177 239 }); 178 240 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)215 241 } 216 242 -
tol/stdlib/general/TolPackage/common.tol
rd171685 r5eeb176 20 20 Text minTolVersion, 21 21 Date releaseDate, 22 Set dependencies 22 Set dependencies, 23 Set nonTolResources 23 24 }; 24 25 -
tol/stdlib/general/TolPackage/repository.tol
rd171685 r5eeb176 44 44 Static Set _.allPackages = Copy(Empty); 45 45 46 Static Real _.localOnlyWarningWasShown = False; 47 48 Static Text _.platform = If(OSWin, "Windows-x86_32", "Linux-x86_32"); 49 46 50 ////////////////////////////////////////////////////////////////////////////// 47 51 //Carga la lista de repositorios accesibles … … 72 76 }) 73 77 }); 78 Text bst = TolPackage::Client::_.localRoot+"packages.bst"; 79 Set If(And(FileExist(bst),FileBytes(bst)), 80 @Repository::_.allPackages := IncludeBST(bst)); 74 81 True 75 82 }) … … 86 93 { 87 94 Text file = TolPackage::Client::_.localRoot+"repositories.txt"; 88 WriteLn("[TolPackage::Client::@Repository::SaveInstances]\n"89 "Saving list of available repositories to "+file);90 95 Text WriteFile(file, 91 96 "//////////////////////////////////////////////////////////////////////////////\n" … … 112 117 True 113 118 }); 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); 114 125 True 115 126 }) … … 162 173 ////////////////////////////////////////////////////////////////////////////// 163 174 //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); 167 203 If(!_.isRemote, 168 204 { 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. 226 Static 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 174 259 }; 175 260 … … 179 264 ////////////////////////////////////////////////////////////////////////////// 180 265 { 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, 182 285 { 183 286 WriteLn("[TolPackage::Client::@Repository::Connect] " 184 "Trying to con ect to repository "+_.url+" ...");287 "Trying to connect to repository "+_.url+" ..."); 185 288 Real numErr0 = Copy(NError); 186 Set repInf = IncludeText(GetFileContens("index.tol")); 289 //WriteLn("TRACE [Connect] 1"); 290 Set repInf = IncludeText(GetFileContent("index.tol")); 187 291 Text _.name := repInf::name; 292 //WriteLn("TRACE [Connect] 2 _.name='"+_.name+"'"); 188 293 Text _.type := repInf::type; 294 //WriteLn("TRACE [Connect] 3 _.type='"+_.type+"'"); 189 295 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"); 191 299 Set line = Tokenizer(aux,"\n"); 192 300 //WriteLn("TRACE [Connect] 6 Card(line)=\n"<<Card(line)+"\n"); 193 301 Set cells.all = For(2,Card(line), Set(Real k) 194 302 { … … 198 306 fields 199 307 }); 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"); 201 311 Set pckInf = For(1,Card(cells), TolPackage::@PackageInfo(Real k) 202 312 { … … 213 323 Text minTolVersion = fields[9], 214 324 Date releaseDate = Eval(fields[10]), 215 Set dependencies = Eval(fields[11]) 325 Set dependencies = Eval(fields[11]), 326 Set nonTolResources = Eval(fields[12]) 216 327 ) ]] }; 217 328 Set PutName(aux[1]->name.version,aux[1]); … … 225 336 }); 226 337 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); 233 339 Real numErr1 = Copy(NError); 234 340 Real _.connected := And(numErr1==numErr0,Card(_.index)); … … 252 358 253 359 ////////////////////////////////////////////////////////////////////////////// 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 > 0261 };262 263 //////////////////////////////////////////////////////////////////////////////264 360 Text _.autodoc.member.Find = 265 361 "Busca un paquete entre todos los repositorios consultables y, si lo " … … 270 366 { 271 367 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]); 274 370 found 275 371 }; 276 372 277 373 ////////////////////////////////////////////////////////////////////////////// 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 374 Text _.autodoc.member.Exist = 375 "Devuelve cierto si existe el paquete especificado"; 376 Real Exist(Text package.version) 377 ////////////////////////////////////////////////////////////////////////////// 378 { 379 Real pos = FindIndexByName(_.index,package); 380 pos > 0 381 }; 300 382 301 383 ////////////////////////////////////////////////////////////////////////////// … … 327 409 //WriteLn("TRACE Client::Install"); 328 410 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, 333 413 { 334 414 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 }) 343 437 }; 344 438 … … 427 521 { 428 522 Real Connect(0); 429 Text localFile = TolPackage::Client::Local File(package.version);523 Text localFile = TolPackage::Client::LocalOza(package.version); 430 524 Date localDate = If(!FileExist(localFile), 431 525 y1900, … … 480 574 481 575 ////////////////////////////////////////////////////////////////////////////// 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) 576 Text _.autodoc.member.Clean = "Elimina un paquete concreto."; 577 Real Clean(Text package.version) 578 ////////////////////////////////////////////////////////////////////////////// 579 { 580 Text localFile = TolPackage::Client::LocalOza(package.version); 581 If(!FileExist(localFile), False, OSFilRemove(localFile)) 582 }; 583 584 ////////////////////////////////////////////////////////////////////////////// 585 Text _.autodoc.member.Clean.All = 586 "Elimina todos los paquetes disponibles localmente procedentes del " 587 "repositorio."; 588 Real Clean.All(Real void) 492 589 ////////////////////////////////////////////////////////////////////////////// 493 590 { 494 591 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 ////////////////////////////////////////////////////////////////////////////// 604 Text _.autodoc.member.Clean.AllInAll = 605 "Elimina todos los paquetes disponibles localmente."; 606 Static 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 })) 500 614 } 501 615 -
tol/stdlib/general/TolPackage/server.tol
rd171685 r5eeb176 11 11 12 12 Text _.localRoot = 13 Replace(TolAppDataPath+"TolPackage/Server/","\\","/"); 14 15 Set _.supportedPlatforms = 16 [[ 17 "Windows-x86_32", 18 "Linux-x86_32" 19 ]]; 20 21 ////////////////////////////////////////////////////////////////////////////// 22 //Inicializa el servidor 23 Real Initialize(Real void) 24 ////////////////////////////////////////////////////////////////////////////// 13 25 { 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 17 32 }; 18 33
Note: See TracChangeset
for help on using the changeset viewer.
