Changeset e2935d7 in tol
- Timestamp:
- Feb 10, 2011, 5:02:04 PM (16 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 50aaa05
- Parents:
- 1d01289
- File:
-
- 1 edited
-
tol/stdlib/general/TolPackage/client.tol (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/stdlib/general/TolPackage/client.tol
r1d01289 re2935d7 275 275 })}; 276 276 277 ////////////////////////////////////////////////////////////////////////////// 278 Text _.autodoc.member.DownloadPackage = 279 "Descarga desde el repositorio remoto al path indicado, un paquete " 280 "determinado\n"; 281 Real DownloadPackage( 282 Text repository, Text package, Real showError, Text localRoot) 283 ////////////////////////////////////////////////////////////////////////////// 284 { 285 If(TolConfigManager::Config::Upgrading::TolPackage::LocalOnly, 0, { 286 Real OSDirMake(localRoot); 287 //WriteLn("TRACE [RemoteInstallPackage] 1 repository='"<<repository+"'"); 288 Text package.version = package; 289 Text If(TextFind(package,"."), 290 { 291 Text package := Tokenizer(package.version,".")[1] 292 }, 293 { 294 Text pkgInfo = GetUrlContents(repository+"?" 295 "action=versions&limit=1&"+ 296 "package="+package+"&"+ 297 min_tol_version_cond); 298 Set pkgLst = IncludeText(pkgInfo); 299 Text package.version := pkgLst[1]->co_name_version 300 }); 301 302 //WriteLn("TRACE [RemoteInstallPackage] 2 package='"<<package+"'"); 303 //WriteLn("TRACE [RemoteInstallPackage] 3 package.version='"<<package.version+"'"); 304 305 Text pack = package.version+".zip"; 306 Text oza = package.version+"/"+package.version+".oza"; 307 Text localPack = localRoot+"/"+pack; 308 Text localOza = localRoot+"/"+oza; 309 Text localDir = localRoot+"/"+package.version; 310 311 Text encoded = GetUrlContents(repository+"?" 312 "action=download&"+ 313 "format=base64&"+ 314 "package="+package.version); 315 //WriteLn("TRACE [RemoteInstallPackage] 4 encoded='"<<encoded+"'"); 316 Real DecodeBase64ToFile(localPack, encoded); 317 If(!FileExist(localPack), False, 318 { 319 //WriteLn("TRACE DownloadPackage 4 UnpackFull("<<localDir+")"); 320 Real PackArchive::UnpackFull("ZipArchive", localDir); 321 Real OSFilRemove(localPack); 322 True 323 }); 324 //WriteLn("TRACE DownloadPackage 5"); 325 FileExist(localOza) 326 })}; 277 327 278 328 ////////////////////////////////////////////////////////////////////////////// … … 293 343 ////////////////////////////////////////////////////////////////////////////// 294 344 { 295 If(TolConfigManager::Config::Upgrading::TolPackage::LocalOnly, 0, { 296 //WriteLn("TRACE [RemoteInstallPackage] 1 repository='"<<repository+"'"); 297 Text package.version = package; 298 Text If(TextFind(package,"."), 299 { 300 Text package := Tokenizer(package.version,".")[1] 301 }, 302 { 303 Text pkgInfo = GetUrlContents(repository+"?" 304 "action=versions&limit=1&"+ 305 "package="+package+"&"+ 306 min_tol_version_cond); 307 Set pkgLst = IncludeText(pkgInfo); 308 Text package.version := pkgLst[1]->co_name_version 309 }); 310 311 //WriteLn("TRACE [RemoteInstallPackage] 2 package='"<<package+"'"); 312 //WriteLn("TRACE [RemoteInstallPackage] 3 package.version='"<<package.version+"'"); 313 314 Text pack = package.version+".zip"; 315 Text oza = package.version+"/"+package.version+".oza"; 316 Text localPack = TolPackage::Client::_.localRoot+pack; 317 Text localOza = TolPackage::Client::_.localRoot+oza; 318 Text localDir = TolPackage::Client::_.localRoot+package.version; 319 320 Text encoded = GetUrlContents(repository+"?" 321 "action=download&"+ 322 "format=base64&"+ 323 "package="+package.version); 324 //WriteLn("TRACE [RemoteInstallPackage] 4 encoded='"<<encoded+"'"); 325 Real DecodeBase64ToFile(localPack, encoded); 326 If(!FileExist(localPack), False, 327 { 328 //WriteLn("TRACE DownloadPackage 4 UnpackFull("<<localDir+")"); 329 Real PackArchive::UnpackFull("ZipArchive", localDir); 330 Real OSFilRemove(localPack); 331 True 332 }); 333 //WriteLn("TRACE DownloadPackage 5"); 334 FileExist(localOza) 335 })}; 345 DownloadPackage( 346 repository, package, showError, 347 TolPackage::Client::_.localRoot) 348 }; 336 349 337 350 ////////////////////////////////////////////////////////////////////////////// … … 593 606 ////////////////////////////////////////////////////////////////////////////// 594 607 { 595 Real If(Or(updateSyncInfo, Card(_.packSyncInfo)),608 Real If(Or(updateSyncInfo,!Card(_.packSyncInfo)), 596 609 RemoteUpdatePackSyncInfo(False)); 597 610 If(!Card(_.packForUpdate), 0, … … 609 622 ////////////////////////////////////////////////////////////////////////////// 610 623 { 611 Real If(Or(updateSyncInfo, Card(_.packSyncInfo)),624 Real If(Or(updateSyncInfo,!Card(_.packSyncInfo)), 612 625 RemoteUpdatePackSyncInfo(False)); 613 626 If(!Card(_.packForUpgrade), 0, … … 616 629 RemoteInstallPackage(pkg->te_url, pkg->co_last_version_remote, True) 617 630 }))) 631 }; 632 633 //////////////////////////////////////////////////////////////////////////////// 634 Text _.autodoc.member.GetCompatibleVersion.one = 635 "Gets the latest version of a package that is compatible with a tol version."; 636 Text GetCompatibleVersion.one(Text tol_version, Text package) 637 //////////////////////////////////////////////////////////////////////////////// 638 { 639 Real If(!Card(_.versSyncInfo), 640 TolPackage::Client::RemoteUpdateVersSyncInfo(True)); 641 642 Set sel_compatible = Select(_.versSyncInfo, Real(TolPackage::@VersionSynchro reg) 643 { 644 And(reg->co_name==package, tol_version>=reg->te_min_tol_version) 645 }); 646 647 Set last_compatible = Sort(sel_compatible, Real(TolPackage::@VersionSynchro a, TolPackage::@VersionSynchro b) 648 { 649 Compare(b->co_name_version,a->co_name_version) 650 })[1]; 651 last_compatible->co_name_version 652 }; 653 654 //////////////////////////////////////////////////////////////////////////////// 655 Text _.autodoc.member.GetCompatibleVersion.all = 656 "Gets the latest versions of a set of packages that are compatible with a tol " 657 "version."; 658 Set GetCompatibleVersion.all(Text tol_version, Set package.list) 659 //////////////////////////////////////////////////////////////////////////////// 660 { 661 EvalSet(package.list, Text (Text pv) 662 { 663 GetCompatibleVersion.one(tol_version, pv) 664 }) 665 }; 666 667 //////////////////////////////////////////////////////////////////////////////// 668 Text _.autodoc.member.GetDeepDependencies.one = 669 "Gets the list of deep depencies of a given version of a package"; 670 Set GetDeepDependencies.one(Text package.version) 671 //////////////////////////////////////////////////////////////////////////////// 672 { 673 Real If(!Card(_.versSyncInfo), 674 TolPackage::Client::RemoteUpdateVersSyncInfo(True)); 675 Set sel = Select(_.versSyncInfo, Real(TolPackage::@VersionSynchro reg) 676 { 677 reg->co_name_version == package.version 678 }); 679 If(!Card(sel), sel, 680 { 681 Text depExpr = sel[1]->te_dependencies; 682 Set dep = If(depExpr=="",Copy(Empty), 683 { 684 Tokenizer(depExpr,",") 685 }); 686 Unique(SetConcat(EvalSet(dep,GetDeepDependencies.one))<<[[ sel[1]->co_name_version ]]) 687 }) 688 }; 689 690 //////////////////////////////////////////////////////////////////////////////// 691 Text _.autodoc.member.GetDeepDependencies.all = 692 "Gets the list of deep depencies of a list of versions of packages"; 693 Set GetDeepDependencies.all(Set package.version.list) 694 //////////////////////////////////////////////////////////////////////////////// 695 { 696 Unique(SetConcat(EvalSet(package.version.list, GetDeepDependencies.one))) 697 }; 698 699 //////////////////////////////////////////////////////////////////////////////// 700 Text _.autodoc.member.GetVersionInfo = 701 "Gets the TolPackage::@VersionSynchro related to a version of a package"; 702 Set GetVersionInfo(Set package.version.list) 703 //////////////////////////////////////////////////////////////////////////////// 704 { 705 Real If(!Card(_.versSyncInfo), 706 TolPackage::Client::RemoteUpdateVersSyncInfo(True)); 707 EvalSet(package.version.list, TolPackage::@VersionSynchro(Text pv) 708 { 709 _.versSyncInfo[pv] 710 }) 711 }; 712 713 //////////////////////////////////////////////////////////////////////////////// 714 Text _.autodoc.member.GetCompatibleDeepDependencies = 715 "Gets the TolPackage::@VersionSynchro related to all deep dependencies of a " 716 "list of packages for the last version that is compatible with a tol version"; 717 Set GetCompatibleDeepDependencies(Text tol_version, Set package.list) 718 //////////////////////////////////////////////////////////////////////////////// 719 { 720 Set package.version.list = GetCompatibleVersion.all(tol_version, package.list); 721 GetVersionInfo(GetDeepDependencies.all(package.version.list)) 722 }; 723 724 //////////////////////////////////////////////////////////////////////////////// 725 Text _.autodoc.member.DownloadCompatibleDeepDependencies = 726 "Downloads to a local directory all deep dependencies of a list of packages " 727 "for the last version that is compatible with a tol version"; 728 Real DownloadCompatibleDeepDependencies( 729 Text localRoot, 730 Text tol_version, 731 Set package.list) 732 //////////////////////////////////////////////////////////////////////////////// 733 { 734 Set dep = GetCompatibleDeepDependencies(tol_version, package.list); 735 SetMin(EvalSet(dep, Real(TolPackage::@VersionSynchro vsi) 736 { 737 DownloadPackage(vsi->te_url,vsi->co_name_version,True,localRoot) 738 })) 618 739 } 619 740
Note: See TracChangeset
for help on using the changeset viewer.
