| [5b6b63c] | 1 | package require Toltcl |
|---|
| 2 | |
|---|
| 3 | if { ![ llength [ info commands Tol_HciWriter ] ] } { |
|---|
| 4 | tol::initkernel |
|---|
| 5 | |
|---|
| 6 | proc Tol_HciWriter { msg } { |
|---|
| 7 | puts [ string trim $msg ] |
|---|
| 8 | } |
|---|
| 9 | |
|---|
| 10 | tol::initlibrary 1 |
|---|
| 11 | } |
|---|
| 12 | |
|---|
| 13 | namespace eval ::TolPkg { |
|---|
| 14 | variable cwd [ file normalize [ file dir [ info script ] ] ] |
|---|
| 15 | } |
|---|
| 16 | |
|---|
| 17 | proc ::TolPkg::UpdateRepositoryInfo { } { |
|---|
| 18 | tol::console eval { |
|---|
| 19 | Real TolPackage::Client::RemoteUpdatePackSyncInfo(False); |
|---|
| 20 | Real TolPackage::Client::RemoteUpdateVersSyncInfo(False); |
|---|
| 21 | } |
|---|
| 22 | return |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | if { 0 } { |
|---|
| 26 | 0 -- http://packages.localbayes.es/BayesPrivateTolPackages/repository.php |
|---|
| 27 | 1 -- SSCC_P18_Maps |
|---|
| 28 | 2 -- Maps for the sscc in Granada province. |
|---|
| 29 | 3 -- |
|---|
| 30 | 4 -- v2.0.1 b.1 |
|---|
| 31 | 5 -- v999999999999999999 |
|---|
| 32 | 6 -- SSCC_P18_Maps.1.0 |
|---|
| 33 | 7 -- SSCC_P18_Maps.1.0 |
|---|
| 34 | 8 -- y2011m11d26h15i11s00.000 |
|---|
| 35 | 9 -- y2011m11d26h15i11s00.000 |
|---|
| 36 | 10 -- 1154572 |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | proc ::TolPkg::GetPkgSyncInfo { } { |
|---|
| 40 | set localRoot [ file normalize \ |
|---|
| 41 | [ toltcl::eval { Text TolPackage::_.localRoot } ] ] |
|---|
| [e83ccac] | 42 | set oza [ file join $localRoot "Client/PackSyncInfo.oza" ] |
|---|
| 43 | if { ![ file exists $oza ] || ![ file readable $oza ] } { |
|---|
| 44 | return {} |
|---|
| 45 | } |
|---|
| 46 | set tolScript [ string map [ list "%O" $oza ] { |
|---|
| [5b6b63c] | 47 | Set { Ois.Load( "%O" )[1] } |
|---|
| 48 | } ] |
|---|
| 49 | # return a dictionary |
|---|
| 50 | set dict {} |
|---|
| 51 | foreach p [ lindex [ toltcl::eval $tolScript ] 0 ] { |
|---|
| 52 | set url [ lindex $p 0 ] |
|---|
| 53 | set name [ lindex $p 1 ] |
|---|
| 54 | set brief [ lindex $p 2 ] |
|---|
| 55 | set mintol [ lindex $p 4 ] |
|---|
| 56 | set maxtol [ lindex $p 5 ] |
|---|
| 57 | set lastremote [ lindex $p 6 ] |
|---|
| 58 | set lastlocal [ lindex $p 7] |
|---|
| 59 | lappend dict [ list $name \ |
|---|
| 60 | [ list url $url brief $brief mintol $mintol \ |
|---|
| 61 | maxtol $maxtol lastremote $lastremote \ |
|---|
| 62 | lastlocal $lastlocal ] ] |
|---|
| 63 | } |
|---|
| 64 | return $dict |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | if { 0 } { |
|---|
| 68 | 0 -- http://packages.localbayes.es/BayesPrivateTolPackages/repository.php |
|---|
| 69 | 1 -- MMS |
|---|
| 70 | 2 -- MMS.0.6040 |
|---|
| 71 | 3 -- |
|---|
| 72 | 4 -- v2.0.1 b.4 |
|---|
| 73 | 5 -- v999999999999999999 |
|---|
| 74 | 6 -- GuiTools.3.2,BysMcmc.4.8,TolIpopt.2.1,IpoptCore.3.9,QltvRespModel.4.1,GrzLinModel.3.1,MatQuery.3.2,NonLinGloOpt.5.1,TolCint.2.1,BysPrior.2.1,MatAlg.1.1,BysInfDiag.2.1,BysSampler.4.1,BabelTool.1.4,ExtLib.1.5,RandVar.2.104,DecoTools.1.6 |
|---|
| 75 | 7 -- y2011m11d07h10i45s00.000 |
|---|
| 76 | 8 -- y2011m11d07h10i45s00.000 |
|---|
| 77 | 9 -- 1474442 |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | proc ::TolPkg::GetVersSyncInfo { } { |
|---|
| 81 | set localRoot [ file normalize \ |
|---|
| 82 | [ toltcl::eval { Text TolPackage::_.localRoot } ] ] |
|---|
| [e83ccac] | 83 | set oza [ file join $localRoot "Client/VersSyncInfo.oza" ] |
|---|
| 84 | if { ![ file exists $oza ] || ![ file readable $oza ] } { |
|---|
| 85 | return {} |
|---|
| 86 | } |
|---|
| 87 | set tolScript [ string map [ list "%O" $oza ] { |
|---|
| [5b6b63c] | 88 | Set { Ois.Load( "%O" )[1] } |
|---|
| 89 | } ] |
|---|
| 90 | # return a dictionary |
|---|
| 91 | set dict {} |
|---|
| 92 | foreach p [ lindex [ toltcl::eval $tolScript ] 0 ] { |
|---|
| 93 | set url [ lindex $p 0 ] |
|---|
| 94 | set name [ lindex $p 1 ] |
|---|
| 95 | set version [ lindex $p 2 ] |
|---|
| 96 | set mintol [ lindex $p 4 ] |
|---|
| 97 | set maxtol [ lindex $p 5 ] |
|---|
| 98 | set dependencies [ split [ lindex $p 6 ] "," ] |
|---|
| 99 | set dateremote [ lindex $p 7 ] |
|---|
| 100 | set datelocal [ lindex $p 8 ] |
|---|
| 101 | lappend dict [ list $version \ |
|---|
| 102 | [ list url $url name $name mintol $mintol \ |
|---|
| 103 | maxtol $maxtol dateremote $dateremote \ |
|---|
| 104 | datelocal $datelocal \ |
|---|
| 105 | dependencies $dependencies ] ] |
|---|
| 106 | } |
|---|
| 107 | return $dict |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | proc ::TolPkg::GetLocalPackages { } { |
|---|
| 111 | set localRoot [ file normalize \ |
|---|
| 112 | [ toltcl::eval { Text TolPackage::_.localRoot } ] ] |
|---|
| 113 | set clientRoot [ file join $localRoot Client ] |
|---|
| 114 | set dirs [ glob -tail -dir $clientRoot -types {d r} * ] |
|---|
| 115 | set pkgsInfo {} |
|---|
| 116 | foreach d $dirs { |
|---|
| [e83ccac] | 117 | lappend pkgsInfo [ list $d [ GetLocalPackageInfo $d ] ] |
|---|
| [5b6b63c] | 118 | } |
|---|
| 119 | return $pkgsInfo |
|---|
| 120 | } |
|---|
| 121 | |
|---|
| [e83ccac] | 122 | proc ::TolPkg::GetLocalPackageInfo { p } { |
|---|
| 123 | set tolScript [ string map [ list %p $p ] { |
|---|
| 124 | Set TolPackage::Client::LocalInfo( "%p" ); |
|---|
| 125 | } ] |
|---|
| 126 | return [ lindex [ toltcl::eval $tolScript -named 1 ] 1 ] |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| [5b6b63c] | 129 | proc ::TolPkg::GetPackageInfoFromOZA { oza } { |
|---|
| 130 | puts "::TolPkg::GetPackageInfoFromOZA $oza" |
|---|
| 131 | set tolScript [ string map [ list "%O" $oza ] { |
|---|
| 132 | Set { |
|---|
| 133 | Set oza = Include( "%O" ); |
|---|
| 134 | WriteLn( "%O" ); |
|---|
| 135 | Set If( Grammar( oza[1] ) == "NameBlock", { |
|---|
| 136 | NameBlock pkg = oza[ 1 ]; |
|---|
| 137 | Set If( And( ObjectExist( "Text", "pkg::_.autodoc.name" ), |
|---|
| 138 | ObjectExist( "Text", "pkg::_.autodoc.brief" ), |
|---|
| 139 | ObjectExist( "Text", "pkg::_.autodoc.description" ), |
|---|
| 140 | ObjectExist( "Text", "pkg::_.autodoc.url" ), |
|---|
| 141 | ObjectExist( "Real", "pkg::_.autodoc.version.high" ), |
|---|
| 142 | ObjectExist( "Real", "pkg::_.autodoc.version.low"), |
|---|
| 143 | ObjectExist( "Set", "pkg::_.autodoc.authors" ), |
|---|
| 144 | ObjectExist( "Text", "pkg::_.autodoc.minTolVersion" ) ), { |
|---|
| 145 | Set aux = [[ Text name = pkg::_.autodoc.name, |
|---|
| 146 | Text brief = pkg::_.autodoc.brief, |
|---|
| 147 | Text description = pkg::_.autodoc.description, |
|---|
| 148 | Text url = pkg::_.autodoc.url, |
|---|
| 149 | Real version.high = pkg::_.autodoc.version.high, |
|---|
| 150 | Real version.low = pkg::_.autodoc.version.low, |
|---|
| 151 | Set dependencies = pkg::_.autodoc.dependencies, |
|---|
| 152 | Set authors = pkg::_.autodoc.authors, |
|---|
| 153 | Text versionControl = If( ObjectExist( "Text", "pkg::_.autodoc.versionControl" ), |
|---|
| 154 | pkg::_.autodoc.versionControl, "" ); |
|---|
| 155 | Text minTolVersion = pkg::_.autodoc.minTolVersion, |
|---|
| 156 | Text maxTolVersion = If( ObjectExist( "Text", "pkg::_.autodoc.maxTolVersion" ), |
|---|
| 157 | pkg::_.autodoc.axTolVersion, "" ) ]]; |
|---|
| 158 | Text pkgName = pkg::_.autodoc.name << "." << pkg::_.autodoc.version.high |
|---|
| 159 | << "." << pkg::_.autodoc.version.low ; |
|---|
| 160 | Set PutName( pkgName, aux ) |
|---|
| 161 | }, { WriteLn( "Empty 2" ), Copy( Empty )} ) }, { WriteLn( "Empty 1" ); Copy( Empty )} ) |
|---|
| 162 | }; |
|---|
| 163 | } ] |
|---|
| 164 | #puts $tolScript |
|---|
| 165 | set result [ toltcl::eval $tolScript -named 1 ] |
|---|
| 166 | puts "::TolPkg::GetPackageInfoFromOZA END $oza" |
|---|
| 167 | return $result |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | |
|---|
| 171 | proc ::TolPkg::GetRepositoryInfo { repo } { |
|---|
| 172 | set ask "${repo}?action=general_information" |
|---|
| 173 | set result [ toltcl::eval [ string map [ list %A $ask ] { |
|---|
| 174 | Set TolPackage::Client::GetRepositoryInfo( "%A" ) |
|---|
| 175 | } ] ] |
|---|
| 176 | return [ lindex $result 0 ] |
|---|
| 177 | } |
|---|
| 178 | |
|---|
| 179 | proc ::TolPkg::GetKnownRepositories { } { |
|---|
| 180 | return [ lindex [ toltcl::eval \ |
|---|
| 181 | {Set TolConfigManager::Config::Upgrading::TolPackage::Repositories} ] 0 ] |
|---|
| 182 | } |
|---|
| 183 | |
|---|
| 184 | proc ::TolPkg::GetPackagesInfo { } { |
|---|
| 185 | return [ lindex [ toltcl::eval { Set TolPackage::Client::_.packSyncInfo } ] 0 ] |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | proc ::TolPkg::test_00 { } { |
|---|
| 189 | GetRepositoryInfo http://packages.tol-project.org/OfficialTolArchiveNetwork/repository.php |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | proc ::TolPkg::test_01 { } { |
|---|
| 193 | set oza /home/jsperez/.tol/TolPackage/1.1/Client/DecoTools.1.8/DecoTools.1.8.oza |
|---|
| 194 | ::TolPkg::GetPackageInfoFromOZA $oza |
|---|
| 195 | } |
|---|
| 196 | |
|---|
| 197 | proc ::TolPkg::test_02 { } { |
|---|
| 198 | return [ llength [ ::TolPkg::GetLocalPackages ] ] |
|---|
| 199 | } |
|---|