Diff

Differences From Artifact [aaeb907791]:

To Artifact [0b791688aa]:


     1      1   <?
            2  +	package require sha1
            3  +
            4  +	load_response args
            5  +
     2      6   	set sourcedir "/web/rkeene/devel/kitcreator/all"
            7  +	set queue "/home/rkeene/devel/kitcreator/build/web/queue"
            8  +	set secretfile "/home/rkeene/etc/kitcreator-web-secret"
            9  +
     3     10   	foreach file [glob -tails -nocomplain -directory $sourcedir "kitcreator-*.tar.gz"] {
     4     11   		regexp {^kitcreator-(.*).tar.gz$} $file -> vers
     5     12   		set kitcreator_versions($vers) $vers
     6     13   	}
     7     14   	set kitcreator_version_selected [lindex [lsort -dictionary [array names kitcreator_versions]] end]
     8     15   
     9     16   	set kitcreator_versions(trunk) "Fossil Trunk Tip"
    10     17   
    11         -	set tcl_versions(8.4.19) 8.4.19
    12         -	set tcl_versions(8.5.9) 8.5.9
    13         -	set tcl_versions(cvs_HEAD) "Fossil Trunk Tip"
           18  +	set tcl_versions(8.5.15) 8.5.15
           19  +	set tcl_versions(8.6.1) 8.6.1
           20  +	set tcl_versions(fossil_trunk) "Fossil Trunk Tip"
    14     21   
    15         -	set platforms(linux-x86) "Linux on x86"
    16         -	set platforms(linux-amd64) "Linux on amd64"
    17         -	set platforms(linux-mipsel) "Linux on MIPSEL"
    18         -	set platforms(windows-x86) "Windows on x86"
           22  +	set platforms(android-arm) "Android/ARM"
           23  +	set platforms(freebsd-amd64) "FreeBSD/amd64"
           24  +	set platforms(hpux-hppa64) "HP-UX/PA-RISC 2.0"
           25  +	set platforms(linux-amd64) "Linux/amd64"
           26  +	set platforms(linux-arm) "Linux/ARM"
           27  +	set platforms(linux-i386) "Linux/i386"
           28  +	set platforms(linux-mipsel) "Linux/MIPS"
           29  +	set platforms(netbsd-amd64) "NetBSD/amd64"
           30  +	set platforms(netbsd-i386) "NetBSD/i386"
           31  +	set platforms(solaris-amd64) "Solaris/amd64"
           32  +	set platforms(solaris-i386) "Solaris/i386"
           33  +	set platforms(solaris-sparc) "Solaris/SPARC"
           34  +	set platforms(solaris-sparc64) "Solaris/SPARC64"
           35  +	set platforms(win32) "Windows/i386"
           36  +	set platforms(win64) "Windows/amd64"
           37  +
           38  +	set packages(tk) "Tk"
           39  +	set packages(mk4tcl) "Metakit"
           40  +	set packages(tcc4tcl) "tcc4tcl"
           41  +	set packages(tls) TLS
           42  +	set packages(dbus) D-BUS
           43  +	set packages(tclx) TclX
    19     44   
    20     45   	set disable {
    21         -		platform linux-amd64 tk
    22         -		platform linux-mipsel tk
           46  +		platform linux-mipsel {tk tcc4tcl}
           47  +		platform android-arm tk
           48  +		platform netbsd-amd64 {tk tcc4tcl}
           49  +		platform netbsd-i386 {tk tcc4tcl}
           50  +		platform solaris-sparc tcc4tcl
           51  +		platform solaris-sparc64 tcc4tcl
           52  +		platform hpux-hppa64 tcc4tcl
    23     53   	}
    24     54   
    25     55   	set specific {
    26         -		platform windows-x86 file icon {Kit Icon}
    27         -		platform windows-x86 text description {Description}
           56  +		platform win32 file icon {Kit Icon}
           57  +		platform win32 text description {Description}
           58  +		platform win64 file icon {Kit Icon}
           59  +		platform win64 text description {Description}
    28     60   	}
           61  +
           62  +	if {[info exists args(platform)] && [info exists args(tcl_version)] && [info exist args(kitcreator_version)]} {
           63  +		# Read in arguments
           64  +		## Mandatory arguments
           65  +		set build_platform $args(platform)
           66  +		set build_tcl_version $args(tcl_version)
           67  +		set build_kitcreator_version $args(kitcreator_version)
           68  +
           69  +		## Optional Arguments
           70  +		set build_packages [list]
           71  +		set build_options(threaded) 0
           72  +		set build_options(kitdll) 0
           73  +		foreach arg [array names args] {
           74  +			switch -glob -- $arg {
           75  +				"option_package_*" {
           76  +					set package [join [lrange [split $arg _] 2 end] _]
           77  +
           78  +					lappend build_packages $package
           79  +				}
           80  +				"option_threaded" {
           81  +					set build_options(threaded) 1
           82  +				}
           83  +				"option_kitdll" {
           84  +					set build_options(kitdll) 1
           85  +				}
           86  +			}
           87  +		}
           88  +		set build_packages [lsort -dictionary $build_packages]
           89  +
           90  +		# Validate arguments
           91  +		if {![info exists platforms($build_platform)]} {
           92  +			unset build_platform
           93  +		}
           94  +
           95  +		if {![info exists tcl_versions($build_tcl_version)]} {
           96  +			unset build_tcl_version
           97  +		}
           98  +
           99  +		if {![info exists kitcreator_versions($build_kitcreator_version)]} {
          100  +			unset build_kitcreator_version
          101  +		}
          102  +
          103  +		foreach package $build_packages {
          104  +			if {![info exists packages($package)]} {
          105  +				unset build_packages
          106  +
          107  +				break
          108  +			}
          109  +		}
          110  +
          111  +		# Resolve version numbers to checkin IDs
          112  +		## XXX: TODO
          113  +		set cache_tcl_version $build_tcl_version
          114  +		if {$build_tcl_version == "fossil_trunk"} {
          115  +			set cache_tcl_version [clock seconds]
          116  +		}
          117  +
          118  +		set cache_kitcreator_version $build_kitcreator_version
          119  +		if {$build_kitcreator_version == "trunk"} {
          120  +			set cache_kitcreator_version [clock seconds]
          121  +		}
          122  +
          123  +		# Generate a serialized hash that represents the state of the build
          124  +		## Load a secret so keys cannot be pre-computed (but remain consistent)
          125  +		set secretfd [open $secretfile "r"]
          126  +		set secret [gets $secretfd]
          127  +		close $secretfd
          128  +
          129  +		## Compute basic key	
          130  +		set key [list $secret $build_platform $cache_tcl_version $cache_kitcreator_version $build_packages]
          131  +
          132  +		## Update key with options in deterministic order
          133  +		foreach option [lsort -dictionary [array names build_options]] {
          134  +			lappend key [list "option:$option" $build_options($option)]
          135  +		}
          136  +
          137  +		## Convert key to a user-consumable string via hashing
          138  +		set key [string tolower [sha1::sha1 -hex $key]]
          139  +
          140  +		# Determine filename
          141  +		if {$build_options(kitdll)} {
          142  +			set extension "so"
          143  +			switch -- $build_platform {
          144  +				"win32" - "win64" {
          145  +					set extension "dll"
          146  +				}
          147  +				"hpux-hppa64" {
          148  +					set extension "sl"
          149  +				}
          150  +			}
          151  +
          152  +			## XXX: TODO: The version here needs to match what's in the SONAME
          153  +			set filename "libtclkit[string map [list "." ""] ${cache_tcl_version}].${extension}"
          154  +		} else {
          155  +			set filename "tclkit"
          156  +
          157  +			switch -- $build_platform {
          158  +				"win32" - "win64" {
          159  +					append filename ".exe"
          160  +				}
          161  +			}
          162  +		}
          163  +
          164  +		# Queue build up and wait for it to complete
          165  +		set fd [open $queue a+]
          166  +		puts $fd [list filename $filename key $key platform $build_platform tcl_version $build_tcl_version kitcreator_version $build_kitcreator_version packages $build_packages options [array get build_options]]
          167  +		close $fd
          168  +
          169  +		set url "http://kitcreator.rkeene.org/kits/building/$key/"
          170  +
          171  +		headers redirect $url
          172  +?><html>
          173  +	<head>
          174  +		<title>KitCreator, Web Interface</title>
          175  +	</head>
          176  +	<body>
          177  +		<h1>KitCreator Web Interface</h1>
          178  +		<p>Build in progress, output will be: <a href="<? puts -nonewline $url ?>"><? puts -nonewline $url ?></a></p>
          179  +	</body>
          180  +</html>
          181  +<?
          182  +	} else {
    29    183   ?><html>
    30    184     <head>
    31    185       <title>KitCreator, Web Interface</title>
    32    186       <script>
    33    187   <!--
          188  +	function enablePackage(package) {
          189  +		var obj;
          190  +
          191  +		obj = document.getElementById('option_package_' + package);
          192  +		obj.disabled = false;
          193  +	}
          194  +
          195  +	function disablePackage(package) {
          196  +		var obj;
          197  +
          198  +		obj = document.getElementById('option_package_' + package);
          199  +		obj.checked = false;
          200  +		obj.disabled = true;
          201  +	}
          202  +
    34    203   	function verifyOptions() {
    35    204   		var kitcreator_version;
    36    205   		var tcl_version;
    37    206   		var platform;
    38    207   
    39    208   		kitcreator_version = document.getElementsByName('kitcreator_version')[0].value;
    40    209   		tcl_version = document.getElementsByName('tcl_version')[0].value;
    41    210   		platform = document.getElementsByName('platform')[0].value;
    42    211   
          212  +<?
          213  +		set alldisabledpackages [list]
          214  +		foreach {keyword value disablepackages} $disable {
          215  +			foreach package $disablepackages {
          216  +				if {[lsearch -exact $alldisabledpackages $package] == -1} {
          217  +					lappend alldisabledpackages $package
          218  +				}
          219  +			}
          220  +		}
          221  +
          222  +		foreach package $alldisabledpackages {
          223  +			puts "\t\tenablePackage(\"$package\");"
          224  +		}
          225  +
          226  +		foreach {keyword value disablepackages} $disable {
          227  +			puts "\t\tif ($keyword == \"$value\") \{"
          228  +
          229  +			foreach package $disablepackages {
          230  +				puts "\t\t\tdisablePackage(\"$package\");"
          231  +			}
          232  +
          233  +			puts "\t\t\}"
          234  +		}
          235  +?>
    43    236   	}
    44    237   -->
    45    238       </script>
    46    239     </head>
    47         -  <body>
          240  +  <body onLoad="verifyOptions();">
    48    241       <h1>KitCreator Web Interface</h1>
    49    242       <form method="post" enctype="multipart/form-data">
    50    243         <table>
    51    244           <tr>
    52    245             <td>KitCreator Version:</td>
    53    246             <td>
    54    247               <select name="kitcreator_version" onChange="verifyOptions();">
................................................................................
    93    286   ?>
    94    287               </select>
    95    288             </td>
    96    289           </tr>
    97    290           <tr>
    98    291             <td>Kit Options:</td>
    99    292             <td>
   100         -            <input type="checkbox" name="option_package_tk">Tk<br>
   101         -            <input type="checkbox" name="option_package_itcl">[incr Tcl]<br>
   102         -            <input type="checkbox" name="option_package_mk4tcl">Metakit<br>
   103         -            <input type="checkbox" name="option_threaded">Threaded<br>
   104         -            <input type="checkbox" name="option_kitdll">Build Library (KitDLL)<br>
          293  +<?  foreach package [lsort -dictionary [array names packages]] { ?>
          294  +            <input type="checkbox" name="option_package_<? puts -nonewline $package ?>" id="option_package_<? puts -nonewline $package ?>">Package: <? puts -nonewline $packages($package) ?><br>
          295  +<? } ?>
          296  +            <input type="checkbox" name="option_threaded">Kit: Threaded<br>
          297  +            <input type="checkbox" name="option_kitdll">Kit: Build Library (KitDLL)<br>
   105    298             </td>
   106    299           </tr>
   107    300           <tr>
   108    301             <td>Kit Icon:</td>
   109    302             <td>
   110         -            <input type="file" name="platform-windows-x86-icon">
          303  +            <input type="file" name="option_icon">
   111    304             </td>
   112    305           </tr>
   113    306           <tr>
   114    307             <td>Description:</td>
   115    308             <td>
   116         -            <input type="text" name="platform-windows-x86-desc">
          309  +            <input type="text" name="option_desc">
   117    310             </td>
   118    311           </tr>
   119    312         </table>
   120    313         <input type="submit" name="submit" value="Create">
   121    314       </form>
   122    315     </body>
   123         -</html>
          316  +</html><? } ?>