Changeset be3dec5 in tol
- Timestamp:
- Mar 26, 2015, 11:43:38 AM (12 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- bc8a9f9
- Parents:
- 9b614da
- Location:
- tol/stdlib/TolPackage
- Files:
-
- 1 added
- 7 edited
-
TolPackage.tol (modified) (2 diffs)
-
TolPlatform.tol (added)
-
TolVersion.tol (modified) (1 diff)
-
client.tol (modified) (7 diffs)
-
common.tol (modified) (10 diffs)
-
def_catalog.tol (modified) (19 diffs)
-
packager.tol (modified) (2 diffs)
-
server.tol (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/TolPackage/TolPackage.tol
r9b614da rbe3dec5 15 15 Set _.autodoc.authors = [["vdebuen@tol-project.org", 16 16 "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; 21 21 22 22 Text _.version = ""<<_.autodoc.version.high<<"."<<_.autodoc.version.low; … … 32 32 #Embed "def_catalog.tol"; 33 33 #Embed "TolVersion.tol"; 34 #Embed "TolPlatform.tol"; 34 35 #Embed "client.tol"; 35 36 #Embed "server.tol"; -
tol/stdlib/TolPackage/TolVersion.tol
r9b614da rbe3dec5 1 1 ////////////////////////////////////////////////////////////////////////////// 2 2 // FILE : TolVersion.tol 3 // PURPOSE: TOL version related func ions3 // PURPOSE: TOL version related functions 4 4 ////////////////////////////////////////////////////////////////////////////// 5 5 6 6 Text _.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."; 8 8 ////////////////////////////////////////////////////////////////////////////// 9 9 @LocalBlock TolVersion = -
tol/stdlib/TolPackage/client.tol
r9b614da rbe3dec5 58 58 59 59 //////////////////////////////////////////////////////////////////////////// 60 Set GetPackageInfo(Text name.version) // GUI 60 Set GetPackageInfo(Text name.version) // GUI (antes) 61 61 //////////////////////////////////////////////////////////////////////////// 62 62 { 63 63 @Catalog catalog = GetCatalog(?); 64 64 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)) 66 75 }; 67 76 … … 83 92 //////////////////////////////////////////////////////////////////////////// 84 93 { 85 Real UninstallPackage( package)94 Real UninstallPackage(package) 86 95 }; 87 96 … … 90 99 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||// 91 100 { 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 }) 97 112 }; 98 113 … … 234 249 "packaging."; 235 250 //////////////////////////////////////////////////////////////////////////// 236 Real _.DefaultFetch( Real void)251 Real _.DefaultFetch(Real void) 237 252 //////////////////////////////////////////////////////////////////////////// 238 253 { 239 254 Text destDir = TolPackage::Client::_.defaultPackageDir; 240 255 WriteLn( "[TolPackage::Client] _.DefaultFetch: " << destDir ); 241 If( !OSDirExist( destDir ), { 242 Real OSDirMake( destDir ) 243 } ); 256 Real If(!OSDirExist(destDir), OSDirMake(destDir)); 244 257 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) 257 269 }; 258 270 … … 261 273 //////////////////////////////////////////////////////////////////////////// 262 274 { 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 1270 });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) 272 284 }; 273 285 … … 292 304 Text packageName = Replace(GetFileName(filename), ".zip", ""); 293 305 If(catalog::FindRecord(packageName), 0, { 294 WriteLn( "[TolPackage::Client] Installing default package " << packageName ); 306 WriteLn("[TolPackage::Client] Installing default package " 307 <<packageName); 295 308 InstallZip(_.defaultPackageDir<<filename) 296 309 }) … … 299 312 // [C] Se cargan los paquetes por defecto 300 313 _.DefaultRequire(?) 301 })314 }) 302 315 } 303 316 ]]; -
tol/stdlib/TolPackage/common.tol
r9b614da rbe3dec5 3 3 // * Text _.autodoc.get.identifier(NameBlock package) 4 4 // * NameBlock Require(Text identifier) 5 // * Real AddRepository(Text url) 5 // * Text Platform(Real void) 6 // * Real AddRepository(Text url) 6 7 // [API Client+Server] 7 8 // * 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) 9 11 // * Real InstallLastCompatible(Text pattern) 10 12 // * Real UpdateAll(Real void) … … 22 24 //////////////////////////////////////////////////////////////////////////// 23 25 { 24 package::_.autodoc.name<<"." 26 Text variant = getOptArg(package, "_.autodoc.variant", ""); 27 package::_.autodoc.name<<If(TextLength(variant), "#"<<variant, "")<<"." 25 28 <<package::_.autodoc.version.high<<"."<<package::_.autodoc.version.low 26 29 }; … … 34 37 1}"); 35 38 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 36 60 }; 37 61 … … 72 96 73 97 //////////////////////////////////////////////////////////////////////////// 74 Real InstallCompatible(Text pattern, Text tolVersion, Date date) 98 Real InstallCompatible(Text pattern, Text tolPlatform, 99 Text tolVersion, Date date) 75 100 //////////////////////////////////////////////////////////////////////////// 76 101 { 77 102 Real Server::Initialize(?); 78 Text file = Server::DownloadCompatible(pattern, tolVersion, date); 103 Text file = Server::DownloadCompatible(pattern, tolPlatform, 104 tolVersion, date); 79 105 Real If(TextLength(file), { 80 106 Real Client::InstallZip(file); … … 105 131 @Catalog server = Server::GetCatalog(?); 106 132 Code obtainList = Eval("server::Obtain"<<mode<<"List"); 107 Set improveList = obtainList(client, Version, UnknownDate);133 Set improveList = obtainList(client, Platform(?), Version, UnknownDate); 108 134 Set selImproveList = Select(improveList, Real (Set record) { 109 135 TextMatch(Name(record), txtPattern) … … 147 173 @Catalog server = Server::GetCatalog(?); 148 174 Code obtainList = Eval("server::Obtain"<<mode<<"List"); 149 Set improveList = obtainList(client, Version, UnknownDate);175 Set improveList = obtainList(client, Platform(?), Version, UnknownDate); 150 176 If(Card(improveList), SetSum(EvalSet(improveList, Real (Set record) { 151 177 Real If(mode=="Update", { … … 236 262 @Catalog client = Client::GetCatalog(?); 237 263 @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) { 239 267 EvalSet(list, Set (Set record) { 240 268 Text dependencies = If(Card(record::freeDependencies), { … … 245 273 }, ""); 246 274 Text localIdentifier = client::ObtainIdentifier_Show(record::name, 247 Version, UnknownDate, 0);275 Platform(?), Version, UnknownDate, 0); 248 276 Date localRelease = If(TextLength(localIdentifier), { 249 277 Set localRecord = client::GetRecord(localIdentifier); … … 263 291 @Catalog client = Client::GetCatalog(?); 264 292 @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) { 267 296 Text localIdentifier = client::ObtainIdentifier_Show(record::name, 268 Version, UnknownDate, 0);297 Platform(?), tolVersion, UnknownDate, 0); 269 298 Date localRelease = If(TextLength(localIdentifier), { 270 299 Set localRecord = client::GetRecord(localIdentifier); … … 283 312 TolPackage::@Catalog catalog = TolPackage::Server::GetCatalog(?); 284 313 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) 286 316 }))); 287 Set catalog::IdentifyPackages(deepDs, Version, UnknownDate)317 catalog::IdentifyPackages(deepDs, Platform(?), Version, UnknownDate) 288 318 }; 289 319 -
tol/stdlib/TolPackage/def_catalog.tol
r9b614da rbe3dec5 4 4 // Text identifier 5 5 // Text name 6 // Text variant (new) 6 7 // Real high 7 8 // Real low 8 9 // Text repository 9 10 // Date release 11 // Text platform (new) 10 12 // Text minTolVersion 11 13 // Text maxTolVersion … … 28 30 { 29 31 Set parts = Tokenizer(identifier, "."); 30 Real index = FindIndexByName(_.records, parts[1]); 32 Text name = Tokenizer(parts[1], "#")[1]; 33 Real index = FindIndexByName(_.records, name); 31 34 If(index, FindIndexByName(_.records[index], identifier), 0) 32 35 }; … … 37 40 { 38 41 Set parts = Tokenizer(identifier, "."); 39 Real index = FindIndexByName(_.records, parts[1]); 42 Text name = Tokenizer(parts[1], "#")[1]; 43 Real index = FindIndexByName(_.records, name); 40 44 If(index, { 41 45 Real index2 = FindIndexByName(_.records[index], identifier); … … 45 49 46 50 //////////////////////////////////////////////////////////////////////////// 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) 48 95 //////////////////////////////////////////////////////////////////////////// 49 96 { 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) 63 103 //////////////////////////////////////////////////////////////////////////// 64 104 { 65 105 // 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); 67 108 If(Text Sub(identifier, 1, 1)=="#", { 68 109 Text wm = Case(show==0, "", show==1, "U", show==2, "W", show==3, "E"); … … 70 111 "" 71 112 }, 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<<"'"); 74 118 Text msg2 = If(""<<date=="Unknown", If(TextLength(msg), msg, ""), { 75 119 If(TextLength(msg), msg<<" y", " para")<<" la fecha "<<date … … 88 132 89 133 //////////////////////////////////////////////////////////////////////////// 90 Text _ObtainIdentifier(Text pattern, Text tolVersion, Date date) 134 Text _ObtainIdentifier(Text pattern, Text tolPlatform, 135 Text tolVersion, Date date) 91 136 //////////////////////////////////////////////////////////////////////////// 92 137 { 93 138 Set parts = Tokenizer(pattern, "."); 94 Real index = FindIndexByName(_.records, parts[1]); 139 Text name = Tokenizer(parts[1], "#")[1]; 140 Real index = FindIndexByName(_.records, name); 95 141 If(index, { 96 142 Set records = _.records[index]; 97 143 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]; 99 146 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)); 101 153 // 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)); 112 160 // 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)); 117 163 ok 118 164 }); … … 122 168 123 169 //////////////////////////////////////////////////////////////////////////// 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); 128 175 If(TextLength(identifier), { 129 176 GetRecord(identifier)["freeDependencies"] … … 135 182 136 183 //////////////////////////////////////////////////////////////////////////// 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); 141 189 Set extraD = Unique(SetConcat(EvalSet(freeD, Set (Text p) { 142 GetFreeDependencies(p, tol Version, date)190 GetFreeDependencies(p, tolPlatform, tolVersion, date) 143 191 }))); 144 192 freeD-extraD … … 146 194 147 195 //////////////////////////////////////////////////////////////////////////// 148 Anything IdentifyPackages(Anything patterns, Text tolVersion, Date date) 196 Anything IdentifyPackages(Anything patterns, Text tolPlatform, 197 Text tolVersion, Date date) 149 198 //////////////////////////////////////////////////////////////////////////// 150 199 { 151 200 Case(Grammar(patterns)=="Set", { 152 201 EvalSet(patterns, Anything (Anything a) { 153 IdentifyPackages(a, tol Version, date)202 IdentifyPackages(a, tolPlatform, tolVersion, date) 154 203 }) 155 204 }, Grammar(patterns)=="Text", { 156 205 If(TextLength(patterns), 157 ObtainIdentifier(patterns, tol Version, date), "")206 ObtainIdentifier(patterns, tolPlatform, tolVersion, date), "") 158 207 }) 159 208 }; 160 209 161 210 //////////////////////////////////////////////////////////////////////////// 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); 166 216 If(Card(mainDs), { 167 217 Unique(SetConcat(EvalSet(mainDs, Set (Text mainD) { 168 Set deepDs = GetDeepDependencies(mainD, tol Version, date);218 Set deepDs = GetDeepDependencies(mainD, tolPlatform, tolVersion, date); 169 219 If(Card(deepDs), { 170 220 Set [[ mainD ]] << deepDs … … 195 245 196 246 //////////////////////////////////////////////////////////////////////////// 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), { 201 252 Set records = Select(EvalSet(_.records, Set (Set subrecords) { 202 253 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) 210 255 }); 211 256 Real If(Card(selection), SetIndexByName(selection)); … … 218 263 219 264 //////////////////////////////////////////////////////////////////////////// 220 Set GetCompatibleList(Text tol Version, Date date)221 //////////////////////////////////////////////////////////////////////////// 222 { 223 Set compRecords = GetCompatibleRecords(tol Version, date);265 Set GetCompatibleList(Text tolPlatform, Text tolVersion, Date date) 266 //////////////////////////////////////////////////////////////////////////// 267 { 268 Set compRecords = GetCompatibleRecords(tolPlatform, tolVersion, date); 224 269 EvalSet(compRecords, Set (Set subrecords) { subrecords[1] }) 225 270 }; 226 271 227 272 //////////////////////////////////////////////////////////////////////////// 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); 233 280 SetConcat(EvalSet(refRecords, Set (Set refSubrecords) { 234 281 Real index = FindIndexByName(records, Name(refSubrecords)); … … 251 298 252 299 //////////////////////////////////////////////////////////////////////////// 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); 258 307 SetConcat(EvalSet(refRecords, Set (Set refSubrecords) { 259 308 Real index = FindIndexByName(records, Name(refSubrecords)); … … 276 325 277 326 //////////////////////////////////////////////////////////////////////////// 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)); 284 335 SetConcat(EvalSet(refRecords, Set (Set refSubrecords) { 285 336 Real index = FindIndexByName(records, Name(refSubrecords)); … … 302 353 303 354 //////////////////////////////////////////////////////////////////////////// 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); 309 361 EvalSet(Classify(fullList, Real (Set r1, Set r2) { 310 362 Compare(Name(r1), Name(r2)) … … 351 403 Set autodocs = Select(EvalSet(GetDir(path)[2], Set (Text package) { 352 404 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, { 354 409 // Si no tiene info se obtiene de la lista A 355 410 Text ozaFile = path<<package<<"/"<<package<<".oza"; … … 384 439 Set rows = SetConcat(EvalSet(repositories_, Set (Text repository) { 385 440 Text urlAnswer = GetUrlContents(repository 386 <<"?tol_package_version=1.1&action=versions"); 441 <<"?tol_package_version="<<_.autodoc.version.high 442 <<"&action=versions"); 387 443 If(Text Sub(urlAnswer, 1, 3)=="Set", IncludeText(urlAnswer), { 388 444 Error("El repositorio '"<<repository … … 395 451 Set freeDeps = Unique(Select(EvalSet(Tokenizer(row[7], ","), 396 452 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)); 397 464 Set pkgRecord = [[ 398 465 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], ""); 400 468 Real high = Eval(pkgInfo[2]); 401 469 Real low = Eval(pkgInfo[3]); 402 470 Text repository = row[1]; 403 471 Date release = row[8]; 472 Text platform = getOptArg(extra_info, "platform", ""); 404 473 Text minTolVersion = row[5]; 405 474 Text maxTolVersion = row[6]; … … 416 485 //////////////////////////////////////////////////////////////////////////// 417 486 { 487 Text variant = getOptArg(autodoc, "_.autodoc.variant", ""); 418 488 Set pkgRecord = [[ 419 Text identifier = autodoc::_.autodoc.name 489 Text identifier = autodoc::_.autodoc.name 490 <<If(TextLength(variant), "#"<<variant, "") 420 491 <<"."<<autodoc::_.autodoc.version.high 421 492 <<"."<<autodoc::_.autodoc.version.low; 422 493 Text name = autodoc::_.autodoc.name; 494 Text variant; 423 495 Real high = autodoc::_.autodoc.version.high; 424 496 Real low = autodoc::_.autodoc.version.low; 425 497 Text repository = autodoc::_.autodoc.url; 426 498 Date release = autodoc::_.autodoc.releaseDate; 499 Text platform = getOptArg(autodoc, "_.autodoc.platform", ""); 427 500 Text minTolVersion = autodoc::_.autodoc.minTolVersion; 428 501 Text maxTolVersion = If( … … 441 514 Set autodoc = [[ 442 515 Text _.autodoc.name = record::name; 516 Text _.autodoc.variant = record::variant; 443 517 Real _.autodoc.version.high = record::high; 444 518 Real _.autodoc.version.low = record::low; 445 519 Text _.autodoc.url = record::repository; 520 Text _.autodoc.platform = record::platform; 446 521 Date _.autodoc.releaseDate = record::release; 447 522 Text _.autodoc.minTolVersion = record::minTolVersion; -
tol/stdlib/TolPackage/packager.tol
r9b614da rbe3dec5 21 21 Date releaseGMT = Copy(NowGmt); 22 22 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); 23 40 Case(TestAutodoc(package.[1], releaseGMT), { 24 41 WriteLn("No pudo generarse el paquete.", "E"); … … 164 181 165 182 //////////////////////////////////////////////////////////////////////////// 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 //////////////////////////////////////////////////////////////////////////// 166 204 Set ObtainAutodoc(NameBlock package) 167 205 //////////////////////////////////////////////////////////////////////////// -
tol/stdlib/TolPackage/server.tol
r9b614da rbe3dec5 15 15 // * Real UpdateCatalog(Real void) 16 16 // * Text DownloadPackage(Text identifier) 17 // * Text DownloadCompatible(Text pattern, Text tol Version, Date date)17 // * Text DownloadCompatible(Text pattern, Text tolPlatform, Text tolVersion, Date date) 18 18 // * Text DownloadLastCompatible(Text pattern) 19 19 // * Text DownloadPackageAt(Text identifier, Text path) … … 77 77 78 78 //////////////////////////////////////////////////////////////////////////// 79 Text DownloadCompatible(Text pattern, Text tolVersion, Date date) 79 Text DownloadCompatible(Text pattern, Text tolPlatform, 80 Text tolVersion, Date date) 80 81 //////////////////////////////////////////////////////////////////////////// 81 82 { 82 83 @Catalog catalog = GetCatalog(?); 83 Text compatibleId = catalog::ObtainIdentifier(pattern, tol Version,84 date);84 Text compatibleId = catalog::ObtainIdentifier(pattern, tolPlatform, 85 tolVersion, date); 85 86 If(TextLength(compatibleId), DownloadPackage(compatibleId), "") 86 87 }; … … 90 91 //////////////////////////////////////////////////////////////////////////// 91 92 { 92 DownloadCompatible(pattern, Version, UnknownDate)93 DownloadCompatible(pattern, Platform(?), Version, UnknownDate) 93 94 }; 94 95 … … 101 102 If(Card(record), { 102 103 Text encoded = GetUrlContents(record::repository 103 <<"?tol_package_version= 1.1"104 <<"?tol_package_version="<<_.autodoc.version.high 104 105 <<"&action=download&format=base64" 105 <<"&package="<< identifier);106 <<"&package="<<Replace(identifier,"#","%23")); 106 107 Real OSDirMake(_AsOSDir(path)); 107 108 Text zipFile = path<<identifier<<".zip"; … … 170 171 Text pkg.name = Replace(pkg.name.zip,".zip",""); 171 172 Set name.tok = Tokenizer(pkg.name,"."); 173 Text te_identifier = name.tok[1]; 174 Real isVariant = TextMatch(te_identifier, "*#*"); 172 175 Real nu_version_high = Eval(name.tok[2]); 173 176 Real nu_version_low = Eval(name.tok[3]); 174 177 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"); 176 179 Set pkg = Include(oza); 177 Text name = pkg::_.autodoc.name;178 180 Real If(pkg::_.autodoc.version.high!=nu_version_high, 179 181 { … … 197 199 Real id_format = 1; 198 200 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 }, ""); 200 205 Text insert.query = " 201 206 INSERT INTO package_f_contents ( … … 207 212 VALUES ( 208 213 "<<repId<<", 209 '"<< pkg::_.autodoc.name<<"',214 '"<<te_identifier<<"', 210 215 "<<pkg::_.autodoc.version.high<<", 211 216 "<<pkg::_.autodoc.version.low<<",
Note: See TracChangeset
for help on using the changeset viewer.
