QuickWho

Check-in [bc281c51cf]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Cleanup of software update
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:bc281c51cf917a5faf6dbafba0b32cdcc951c483
User & Date: kevin 2016-04-08 04:07:05
Context
2016-04-08
04:10
Minor adjustments of XML file check-in: 9aaae89d46 user: kevin tags: trunk
04:07
Cleanup of software update check-in: bc281c51cf user: kevin tags: trunk
03:08
Fix bug in Mac build script check-in: d84a922071 user: kevin tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to scriptlibs/softwareupdate/softwareupdate.tcl.

    94     94   	    if {![package vsatisfies $hostOS $minOS]} {
    95     95   		tk_messageBox -icon warning -message "Error!" -detail "$appname is not supported on Mac OS X $hostOS. The minimum supported OS version is $minOS." 
    96     96   		return
    97     97   	    }
    98     98   	}
    99     99   	
   100    100   	if {[expr $currentversion < $versionnumber]} {
   101         -	    softwareupdate::updatePitch
          101  +	    switch [tk windowingsystem] {
          102  +		"aqua" {
          103  +		    softwareupdate::updatePitch
          104  +
          105  +		}
          106  +		
          107  +		"win32" {
          108  +		    softwareupdate::winPitch $appname $currentversion $oldversion
          109  +		}
          110  +		
          111  +		"x11" {
          112  +		    
          113  +		}
          114  +	    }
          115  +	    
   102    116   	} else {
   103    117   	    softwareupdate::upToDate
   104    118   	}
   105    119       }
   106    120   
   107         -#define the current version of the software
   108         -proc setVersion {app number} {
   109         -    variable currentversion
   110         -    variable appname
   111         -    set currentversion $number
   112         -    set appname $app
   113         -    
   114         -}
   115         -
   116         -
   117         -#get the current installation path
   118         -proc findCurrentInstallation {} {
   119         -    variable currentinstall
   120         -    variable appname 
   121         -    switch [tk windowingsystem] {
   122         -
   123         -	"aqua" {
   124         -	    set approot [info nameofexecutable]
   125         -	    set apppath [split $approot /]
   126         -	    set currentinstall [join [lrange $apppath 0 [lsearch $apppath "*.app"]] / ]
          121  +    #define the current version of the software
          122  +    proc setVersion {app number} {
          123  +	variable currentversion
          124  +	variable appname
          125  +	set currentversion $number
          126  +	set appname $app
          127  +	
          128  +    }
          129  +
          130  +
          131  +    #get the current installation path
          132  +    proc findCurrentInstallation {} {
          133  +	variable currentinstall
          134  +	variable appname 
          135  +	switch [tk windowingsystem] {
          136  +
          137  +	    "aqua" {
          138  +		set approot [info nameofexecutable]
          139  +		set apppath [split $approot /]
          140  +		set currentinstall [join [lrange $apppath 0 [lsearch $apppath "*.app"]] / ]
          141  +	    }
          142  +	    
          143  +	    "win32" {
          144  +		set currentinstall [file join $::env(APPDATA) ${appname}_App]  
          145  +	    }
          146  +	    
          147  +	    "x11" {
          148  +		return
          149  +	    }
          150  +	}
          151  +	
          152  +	return $currentinstall
          153  +
          154  +    }
          155  +
          156  +    #prompt user to update: for Perl, which chokes on XML parsing from Tcl
          157  +    proc updatePitchPerl {apptitle appnumber currentapp changelog} {
          158  +	variable appname
          159  +	variable icon
          160  +	variable changedata
          161  +	variable currentversion
          162  +	variable versionnumber
          163  +	variable changelist
          164  +
          165  +	catch {destroy .updateprogress}
          166  +
          167  +	catch {destroy .update}
          168  +
          169  +
          170  +	toplevel .update
          171  +	wm title .update "Software Update"
          172  +
          173  +	wm withdraw .update
          174  +
          175  +	frame .update.f -bg gray95
          176  +	pack .update.f -fill both -expand yes
          177  +
          178  +	frame .update.f.top -bg gray95
          179  +	pack .update.f.top -fill both -expand yes
          180  +
          181  +	label .update.f.top.i -image $icon -bg gray95 -relief flat -highlightthickness 0
          182  +	pack .update.f.top.i -side left -fill both -expand yes
          183  +
          184  +	frame .update.f.top.r -bg gray95
          185  +	pack .update.f.top.r -side right -fill both -expand yes
          186  +
          187  +	label .update.f.top.r.title -text "A new version of $apptitle is available!" -font {-weight bold} -bg gray95 -relief flat -highlightthickness 0
          188  +	pack .update.f.top.r.title -fill both -expand yes -side top
          189  +
          190  +	label .update.f.top.r.msg -text "$apptitle $appnumber is available--you have $currentapp. Would you like to download it now?" -bg gray95 -relief flat -highlightthickness 0
          191  +	pack .update.f.top.r.msg -fill both -expand yes -side top
          192  +
          193  +	label .update.f.top.r.release -text "Release Notes:" -font {-weight bold} -relief flat -highlightthickness 0 -bg gray95 
          194  +	pack .update.f.top.r.release -side top -fill both -expand yes
          195  +
          196  +	text .update.f.top.r.text -font TkDefaultFont
          197  +	pack .update.f.top.r.text -side top -fill both -expand yes
          198  +
          199  +	ttk::frame .update.f.top.r.bottom -padding 5
          200  +	pack .update.f.top.r.bottom -side bottom -fill both -expand yes
          201  +
          202  +	ttk::button .update.f.top.r.bottom.skip -text "Skip This Version" -command {destroy .update}
          203  +
          204  +	ttk::button .update.f.top.r.bottom.install -text "Install Update" -default active -command softwareupdate::installUpdate
          205  +	
          206  +	pack .update.f.top.r.bottom.install .update.f.top.r.bottom.skip  -side right  -fill both -expand yes
          207  +
          208  +	set changetext [split $changelog *]
          209  +
          210  +	set changetext [lrange $changetext 1 end]
          211  +
          212  +	foreach item $changetext {
          213  +	    
          214  +	    .update.f.top.r.text insert end "* $item\n"
          215  +
          216  +	}
          217  +
          218  +	.update.f.top.r.text configure -state disabled
          219  +
          220  +	wm resizable .update 0 0
          221  +	wm deiconify .update
          222  +	raise .update
          223  +	wm transient .update .
          224  +
          225  +    }
          226  +
          227  +
          228  +    #prompt user to update
          229  +    proc updatePitch {} {
          230  +	variable appname
          231  +	variable icon
          232  +	variable changedata
          233  +	variable currentversion
          234  +	variable versionnumber
          235  +
          236  +	catch {destroy .updateprogress}
          237  +
          238  +	catch {destroy .update}
          239  +	
          240  +
          241  +	toplevel .update
          242  +	wm title .update "Software Update"
          243  +
          244  +	wm withdraw .update
          245  +
          246  +	frame .update.f -bg gray95
          247  +	pack .update.f -fill both -expand yes
          248  +
          249  +	frame .update.f.top -bg gray95
          250  +	pack .update.f.top -fill both -expand yes
          251  +
          252  +	label .update.f.top.i -image $icon -bg gray95 -relief flat -highlightthickness 0
          253  +	pack .update.f.top.i -side left -fill both -expand yes
          254  +
          255  +	frame .update.f.top.r -bg gray95
          256  +	pack .update.f.top.r -side right -fill both -expand yes
          257  +
          258  +	label .update.f.top.r.title -text "A new version of $appname is available!" -font {-weight bold} -bg gray95 -relief flat -highlightthickness 0
          259  +	pack .update.f.top.r.title -fill both -expand yes -side top
          260  +
          261  +	label .update.f.top.r.msg -text "$appname $versionnumber is available--you have $currentversion. Would you like to download it now?" -font {-size 10} -bg gray95 -relief flat -highlightthickness 0
          262  +	pack .update.f.top.r.msg -fill both -expand yes -side top
          263  +
          264  +	label .update.f.top.r.release -text "Release Notes:" -font {-size 10 -weight bold} -relief flat -highlightthickness 0 -bg gray95 
          265  +	pack .update.f.top.r.release -side top -fill both -expand yes
          266  +
          267  +	text .update.f.top.r.text -font TkDefaultFont
          268  +	pack .update.f.top.r.text -side top -fill both -expand yes
          269  +
          270  +	ttk::frame .update.f.top.r.bottom -padding 5
          271  +	pack .update.f.top.r.bottom -side bottom -fill both -expand yes
          272  +
          273  +	ttk::button .update.f.top.r.bottom.skip -text "Skip This Version" -command {destroy .update}
          274  +
          275  +	ttk::button .update.f.top.r.bottom.install -text "Install Update" -default active -command softwareupdate::installUpdate
          276  +	
          277  +	pack .update.f.top.r.bottom.install .update.f.top.r.bottom.skip  -side right  -fill both -expand yes
          278  +
          279  +	.update.f.top.r.text insert end $changedata
          280  +
          281  +	.update.f.top.r.text configure -state disabled
          282  +
          283  +	wm resizable .update 0 0
          284  +	wm deiconify .update
          285  +	raise .update
          286  +	wm transient .update .
          287  +
          288  +    }
          289  +
          290  +    proc winPitch {name newversion oldversion} {
          291  +	set answer [tk_messageBox  -icon info -title "New Version Available" -message "New Version Available" -detail "$name $newversion is available--you have $oldversion. Would you like to download it now?" -type yesno
          292  +		   ]
          293  +
          294  +	switch -- $answer {
          295  +	    yes {
          296  +
          297  +		xplat::launch http://www.codebykevin.com/$name.html
          298  +	    }
          299  +	    no {
          300  +		return
          301  +	    }
   127    302   	}
          303  +    }
          304  +    #"busy" dialog
          305  +    proc checkingForUpdates {} {
          306  +
          307  +	variable appname
          308  +	variable icon
          309  +
          310  +	catch {destroy .updateprogress}
          311  +
          312  +	toplevel .updateprogress 
          313  +	wm title .updateprogress "Updating $appname"
          314  +
          315  +	wm withdraw .updateprogress
          316  +	update idletasks
          317  +
          318  +	ttk::frame .updateprogress.f -padding 5
          319  +	pack .updateprogress.f -fill both -expand yes
          320  +
          321  +	label .updateprogress.f.l -bg gray95 -image $icon -bd 0 -relief flat -highlightthickness 0 -width [image width $icon] -height [image height $icon]
          322  +	pack .updateprogress.f.l -side left -fill both -expand yes
          323  +
          324  +	frame .updateprogress.f.r -bg gray95 -bd 0 -highlightcolor gray95
          325  +	pack .updateprogress.f.r -side right -fill both -expand yes
          326  +	
          327  +	
          328  +	ttk::label .updateprogress.f.r.t -text "Checking for updates..." -padding 5
          329  +	pack .updateprogress.f.r.t -side top -fill both -expand yes
          330  +
          331  +	ttk::frame .updateprogress.f.r.f -padding 5
          332  +	pack .updateprogress.f.r.f -side top -fill both -expand yes
          333  +	
          334  +	ttk::progressbar .updateprogress.f.r.f.progress -mode indeterminate -orient horizontal
          335  +	pack .updateprogress.f.r.f.progress -fill both -expand yes -side top
          336  +
          337  +	.updateprogress.f.r.f.progress start
          338  +
          339  +	ttk::button .updateprogress.f.r.f.b -text "Cancel" -command {destroy .updateprogress}
          340  +
          341  +	pack .updateprogress.f.r.f.b -side bottom -fill both -expand no
          342  +
          343  +	wm geometry .updateprogress 400x100
          344  +	wm resizable .updateprogress 0 0
          345  +
          346  +	wm deiconify .updateprogress
          347  +	raise .updateprogress
          348  +
          349  +	wm transient .updateprogress .
          350  +
          351  +    }
          352  +
          353  +    #dialog if current version is installed
          354  +    proc upToDate {} {
          355  +	variable appname
          356  +	variable currentversion
          357  +
          358  +	catch {destroy .updateprogress}
          359  +
          360  +	tk_messageBox  -icon info -title "Up to Date" -message "You're up to date!" -detail "$appname $currentversion is the currently the newest version available."
          361  +
          362  +    }
          363  +
          364  +    #show progress of installation
          365  +    proc progressDialog {} {
          366  +
          367  +	variable appname
          368  +	variable status
          369  +	variable icon
          370  +
          371  +	catch {destroy .downloadprogress}
          372  +
          373  +	toplevel .downloadprogress
          374  +	wm title .downloadprogress "Updating $appname"
          375  +
          376  +	wm transient .downloadprogress .
          377  +
          378  +	label .downloadprogress.label -image $icon  -anchor w -bg gray95 -highlightthickness 0
          379  +
          380  +	pack .downloadprogress.label -side left -fill both -expand yes
          381  +
          382  +
          383  +	ttk::frame .downloadprogress.frame -padding 5
          384  +	pack .downloadprogress.frame -side right -fill both -expand yes
          385  +
          386  +	ttk::label .downloadprogress.frame.l -textvariable softwareupdate::status -width 40 -text ""
          387  +	pack .downloadprogress.frame.l -side top -fill both -expand yes
          388  +
          389  +	ttk::progressbar .downloadprogress.frame.bar -mode indeterminate -orient horizontal  -maximum 100
          390  +	pack .downloadprogress.frame.bar -side top -fill both -expand yes
          391  +
          392  +	.downloadprogress.frame.bar start
          393  +	update
          394  +
          395  +	ttk::button .downloadprogress.frame.b -text "Cancel" -command {destroy .updateprogress}
          396  +	pack .downloadprogress.frame.b -side right -fill both -expand no
          397  +
          398  +	wm geometry .downloadprogress 400x100
          399  +	wm resizable .downloadprogress 0 0
          400  +	
          401  +    }
          402  +
          403  +    #download and install the update
          404  +    proc installUpdate {} {
          405  +	variable currentinstall
          406  +	variable status
          407  +	variable appname
          408  +	variable tmpdir
          409  +
          410  +	catch {destroy .update}
          411  +
          412  +	softwareupdate::findCurrentInstallation
          413  +
          414  +	softwareupdate::progressDialog
          415  +	set status "Downloading update for $appname"
   128    416   	
   129         -	"win32" {
   130         -	    set currentinstall [file join $::env(APPDATA) ${appname}_App]  
          417  +	switch [tk windowingsystem] {
          418  +
          419  +	    "aqua" {
          420  +		http::geturl http://www.codebykevin.com/updates/[list $appname].tgz -channel [open $tmpdir/[list $appname].tgz w] 
          421  +		update
          422  +		after 1000
          423  +		cd $tmpdir
          424  +		set status "Unpacking update for $appname"
          425  +		update
          426  +		after 1000
          427  +		catch {exec tar xvfz [list $appname].tgz}
          428  +	    }
          429  +	    
          430  +	    "win32" {
          431  +		
          432  +		http::geturl http://www.codebykevin.com/updates/[list $appname].exe -channel [open $tmpdir/[list $appname].exe w] 
          433  +
          434  +	    }
          435  +	    
          436  +	    "x11" {
          437  +		tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
          438  +		return
          439  +	    }
   131    440   	}
   132    441   	
   133         -	"x11" {
   134         -	    return
   135         -	}
          442  +	
          443  +	set status "Ready to install"
          444  +	.downloadprogress.frame.bar configure -mode determinate
          445  +	.downloadprogress.frame.bar configure -value 100
          446  +	.downloadprogress.frame.bar stop
          447  +	destroy .downloadprogress.frame.b 
          448  +	pack [ttk::button .downloadprogress.frame.b -text "Install and Relaunch" -command softwareupdate::launchUpdate] -side right -fill both -expand no
          449  +	return
   136    450       }
   137         -    
   138         -    return $currentinstall
   139    451   
   140         -}
   141    452   
   142         -#prompt user to update: for Perl, which chokes on XML parsing from Tcl
   143         -proc updatePitchPerl {apptitle appnumber currentapp changelog} {
   144         -    variable appname
   145         -    variable icon
   146         -    variable changedata
   147         -    variable currentversion
   148         -    variable versionnumber
   149         -    variable changelist
          453  +    #launch the update
          454  +    proc launchUpdate {}  {
   150    455   
   151         -    catch {destroy .updateprogress}
   152         -
   153         -    catch {destroy .update}
   154         -
   155         -
   156         -    toplevel .update
   157         -    wm title .update "Software Update"
   158         -
   159         -    wm withdraw .update
   160         -
   161         -    frame .update.f -bg gray95
   162         -    pack .update.f -fill both -expand yes
   163         -
   164         -    frame .update.f.top -bg gray95
   165         -    pack .update.f.top -fill both -expand yes
   166         -
   167         -    label .update.f.top.i -image $icon -bg gray95 -relief flat -highlightthickness 0
   168         -    pack .update.f.top.i -side left -fill both -expand yes
   169         -
   170         -    frame .update.f.top.r -bg gray95
   171         -    pack .update.f.top.r -side right -fill both -expand yes
   172         -
   173         -    label .update.f.top.r.title -text "A new version of $apptitle is available!" -font {-weight bold} -bg gray95 -relief flat -highlightthickness 0
   174         -    pack .update.f.top.r.title -fill both -expand yes -side top
   175         -
   176         -    label .update.f.top.r.msg -text "$apptitle $appnumber is available--you have $currentapp. Would you like to download it now?" -bg gray95 -relief flat -highlightthickness 0
   177         -    pack .update.f.top.r.msg -fill both -expand yes -side top
   178         -
   179         -    label .update.f.top.r.release -text "Release Notes:" -font {-weight bold} -relief flat -highlightthickness 0 -bg gray95 
   180         -    pack .update.f.top.r.release -side top -fill both -expand yes
   181         -
   182         -    text .update.f.top.r.text -font TkDefaultFont
   183         -    pack .update.f.top.r.text -side top -fill both -expand yes
   184         -
   185         -    ttk::frame .update.f.top.r.bottom -padding 5
   186         -    pack .update.f.top.r.bottom -side bottom -fill both -expand yes
   187         -
   188         -    ttk::button .update.f.top.r.bottom.skip -text "Skip This Version" -command {destroy .update}
   189         -
   190         -    ttk::button .update.f.top.r.bottom.install -text "Install Update" -default active -command softwareupdate::installUpdate
   191         -    
   192         -    pack .update.f.top.r.bottom.install .update.f.top.r.bottom.skip  -side right  -fill both -expand yes
   193         -
   194         -    set changetext [split $changelog *]
   195         -
   196         -    set changetext [lrange $changetext 1 end]
   197         -
   198         -    foreach item $changetext {
          456  +	variable currentinstall
          457  +	variable appname
          458  +	variable tmpdir
   199    459   	
   200         -	.update.f.top.r.text insert end "* $item\n"
          460  +	switch [tk windowingsystem] {
          461  +
          462  +	    "aqua" {
          463  +		if {[catch {exec codesign -v $tmpdir/$appname.app} msg]} {
          464  +		    bgerror $msg
          465  +		    tk_messageBox -icon warning -message "Error!" -detail "An error occurred in the installation of $appname. Please try again later."
          466  +		    return
          467  +		} else {
          468  +
          469  +		    file rename -force $currentinstall [file join /Users [exec whoami] .Trash [file tail $currentinstall]]
          470  +
          471  +		    file rename -force $tmpdir/$appname.app $currentinstall
          472  +
          473  +		    exec $currentinstall/Contents/MacOS/$appname &
          474  +
          475  +		    exit
          476  +		}
          477  +	    }
          478  +	    
          479  +	    "win32" {
          480  +		
          481  +	    }
          482  +	    
          483  +	}
          484  +
          485  +	catch {destroy .downloadprogress}
          486  +
          487  +	
   201    488   
   202    489       }
   203    490   
   204         -    .update.f.top.r.text configure -state disabled
   205    491   
   206         -    wm resizable .update 0 0
   207         -    wm deiconify .update
   208         -    raise .update
   209         -    wm transient .update .
   210         -
   211         -}
   212         -
   213         -
   214         -#prompt user to update
   215         -proc updatePitch {} {
   216         -    variable appname
   217         -    variable icon
   218         -    variable changedata
   219         -    variable currentversion
   220         -    variable versionnumber
   221         -
   222         -    catch {destroy .updateprogress}
   223         -
   224         -    catch {destroy .update}
   225         -    
   226         -
   227         -    toplevel .update
   228         -    wm title .update "Software Update"
   229         -
   230         -    wm withdraw .update
   231         -
   232         -    frame .update.f -bg gray95
   233         -    pack .update.f -fill both -expand yes
   234         -
   235         -    frame .update.f.top -bg gray95
   236         -    pack .update.f.top -fill both -expand yes
   237         -
   238         -    label .update.f.top.i -image $icon -bg gray95 -relief flat -highlightthickness 0
   239         -    pack .update.f.top.i -side left -fill both -expand yes
   240         -
   241         -    frame .update.f.top.r -bg gray95
   242         -    pack .update.f.top.r -side right -fill both -expand yes
   243         -
   244         -    label .update.f.top.r.title -text "A new version of $appname is available!" -font {-weight bold} -bg gray95 -relief flat -highlightthickness 0
   245         -    pack .update.f.top.r.title -fill both -expand yes -side top
   246         -
   247         -    label .update.f.top.r.msg -text "$appname $versionnumber is available--you have $currentversion. Would you like to download it now?" -font {-size 10} -bg gray95 -relief flat -highlightthickness 0
   248         -    pack .update.f.top.r.msg -fill both -expand yes -side top
   249         -
   250         -    label .update.f.top.r.release -text "Release Notes:" -font {-size 10 -weight bold} -relief flat -highlightthickness 0 -bg gray95 
   251         -    pack .update.f.top.r.release -side top -fill both -expand yes
   252         -
   253         -    text .update.f.top.r.text -font TkDefaultFont
   254         -    pack .update.f.top.r.text -side top -fill both -expand yes
   255         -
   256         -    ttk::frame .update.f.top.r.bottom -padding 5
   257         -    pack .update.f.top.r.bottom -side bottom -fill both -expand yes
   258         -
   259         -    ttk::button .update.f.top.r.bottom.skip -text "Skip This Version" -command {destroy .update}
   260         -
   261         -    ttk::button .update.f.top.r.bottom.install -text "Install Update" -default active -command softwareupdate::installUpdate
   262         -    
   263         -    pack .update.f.top.r.bottom.install .update.f.top.r.bottom.skip  -side right  -fill both -expand yes
   264         -
   265         -    .update.f.top.r.text insert end $changedata
   266         -
   267         -    .update.f.top.r.text configure -state disabled
   268         -
   269         -    wm resizable .update 0 0
   270         -    wm deiconify .update
   271         -    raise .update
   272         -    wm transient .update .
   273         -
   274         -}
   275         -
   276         -proc winPitch {name newversion oldversion} {
   277         -    set answer [tk_messageBox  -icon info -title "New Version Available" -message "New Version Available" -detail "$name $newversion is available--you have $oldversion. Would you like to download it now?" -type yesno
   278         -	       ]
   279         -
   280         -    switch -- $answer {
   281         -	yes {
   282         -
   283         -	    xplat::launch http://www.codebykevin.com/$name.html
   284         -	}
   285         -	no {
   286         -	    return
   287         -	}
   288         -    }
   289         -}
   290         -#"busy" dialog
   291         -proc checkingForUpdates {} {
   292         -
   293         -    variable appname
   294         -    variable icon
   295         -
   296         -    catch {destroy .updateprogress}
   297         -
   298         -    toplevel .updateprogress 
   299         -    wm title .updateprogress "Updating $appname"
   300         -
   301         -    wm withdraw .updateprogress
   302         -    update idletasks
   303         -
   304         -    ttk::frame .updateprogress.f -padding 5
   305         -    pack .updateprogress.f -fill both -expand yes
   306         -
   307         -    label .updateprogress.f.l -bg gray95 -image $icon -bd 0 -relief flat -highlightthickness 0 -width [image width $icon] -height [image height $icon]
   308         -    pack .updateprogress.f.l -side left -fill both -expand yes
   309         -
   310         -    frame .updateprogress.f.r -bg gray95 -bd 0 -highlightcolor gray95
   311         -    pack .updateprogress.f.r -side right -fill both -expand yes
   312         -    
   313         -    
   314         -    ttk::label .updateprogress.f.r.t -text "Checking for updates..." -padding 5
   315         -    pack .updateprogress.f.r.t -side top -fill both -expand yes
   316         -
   317         -    ttk::frame .updateprogress.f.r.f -padding 5
   318         -    pack .updateprogress.f.r.f -side top -fill both -expand yes
   319         -    
   320         -    ttk::progressbar .updateprogress.f.r.f.progress -mode indeterminate -orient horizontal
   321         -    pack .updateprogress.f.r.f.progress -fill both -expand yes -side top
   322         -
   323         -    .updateprogress.f.r.f.progress start
   324         -
   325         -    ttk::button .updateprogress.f.r.f.b -text "Cancel" -command {destroy .updateprogress}
   326         -
   327         -    pack .updateprogress.f.r.f.b -side bottom -fill both -expand no
   328         -
   329         -    wm geometry .updateprogress 400x100
   330         -    wm resizable .updateprogress 0 0
   331         -
   332         -    wm deiconify .updateprogress
   333         -    raise .updateprogress
   334         -
   335         -    wm transient .updateprogress .
   336         -
   337         -}
   338         -
   339         -#dialog if current version is installed
   340         -proc upToDate {} {
   341         -    variable appname
   342         -    variable currentversion
   343         -
   344         -    catch {destroy .updateprogress}
   345         -
   346         -    tk_messageBox  -icon info -title "Up to Date" -message "You're up to date!" -detail "$appname $currentversion is the currently the newest version available."
   347         -
   348         -}
   349         -
   350         -#show progress of installation
   351         -proc progressDialog {} {
   352         -
   353         -    variable appname
   354         -    variable status
   355         -    variable icon
   356         -
   357         -    catch {destroy .downloadprogress}
   358         -
   359         -    toplevel .downloadprogress
   360         -    wm title .downloadprogress "Updating $appname"
   361         -
   362         -    wm transient .downloadprogress .
   363         -
   364         -    label .downloadprogress.label -image $icon  -anchor w -bg gray95 -highlightthickness 0
   365         -
   366         -    pack .downloadprogress.label -side left -fill both -expand yes
   367         -
   368         -
   369         -    ttk::frame .downloadprogress.frame -padding 5
   370         -    pack .downloadprogress.frame -side right -fill both -expand yes
   371         -
   372         -    ttk::label .downloadprogress.frame.l -textvariable softwareupdate::status -width 40 -text ""
   373         -    pack .downloadprogress.frame.l -side top -fill both -expand yes
   374         -
   375         -    ttk::progressbar .downloadprogress.frame.bar -mode indeterminate -orient horizontal  -maximum 100
   376         -    pack .downloadprogress.frame.bar -side top -fill both -expand yes
   377         -
   378         -    .downloadprogress.frame.bar start
   379         -    update
   380         -
   381         -    ttk::button .downloadprogress.frame.b -text "Cancel" -command {destroy .updateprogress}
   382         -    pack .downloadprogress.frame.b -side right -fill both -expand no
   383         -
   384         -    wm geometry .downloadprogress 400x100
   385         -    wm resizable .downloadprogress 0 0
   386         -    
   387         -}
   388         -
   389         -#download and install the update
   390         -proc installUpdate {} {
   391         -    variable currentinstall
   392         -    variable status
   393         -    variable appname
   394         -    variable tmpdir
   395         -
   396         -    catch {destroy .update}
   397         -
   398         -    softwareupdate::findCurrentInstallation
   399         -
   400         -    softwareupdate::progressDialog
   401         -    set status "Downloading update for $appname"
   402         -    
   403         -    switch [tk windowingsystem] {
   404         -
   405         -	"aqua" {
   406         -	    http::geturl http://www.codebykevin.com/updates/[list $appname].tgz -channel [open $tmpdir/[list $appname].tgz w] 
   407         -	    update
   408         -	    after 1000
   409         -	    cd $tmpdir
   410         -	    set status "Unpacking update for $appname"
   411         -	    update
   412         -	    after 1000
   413         -	    catch {exec tar xvfz [list $appname].tgz}
   414         -	}
   415         -	
   416         -	"win32" {
   417         -	    
   418         -	    http::geturl http://www.codebykevin.com/updates/[list $appname].exe -channel [open $tmpdir/[list $appname].exe w] 
   419         -
   420         -	}
   421         -	
   422         -	"x11" {
   423         -	    tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
   424         -	    return
   425         -	}
   426         -    }
   427         -    
   428         -    
   429         -    set status "Ready to install"
   430         -    .downloadprogress.frame.bar configure -mode determinate
   431         -    .downloadprogress.frame.bar configure -value 100
   432         -    .downloadprogress.frame.bar stop
   433         -    destroy .downloadprogress.frame.b 
   434         -    pack [ttk::button .downloadprogress.frame.b -text "Install and Relaunch" -command softwareupdate::launchUpdate] -side right -fill both -expand no
   435         -    return
   436         -}
   437         -
   438         -
   439         -#launch the update
   440         -proc launchUpdate {}  {
   441         -
   442         -    variable currentinstall
   443         -    variable appname
   444         -    variable tmpdir
   445         -    
   446         -    switch [tk windowingsystem] {
   447         -
   448         -	"aqua" {
   449         -	    if {[catch {exec codesign -v $tmpdir/$appname.app} msg]} {
   450         -		bgerror $msg
   451         -		tk_messageBox -icon warning -message "Error!" -detail "An error occurred in the installation of $appname. Please try again later."
   452         -		return
   453         -	    } else {
   454         -
   455         -		file rename -force $currentinstall [file join /Users [exec whoami] .Trash [file tail $currentinstall]]
   456         -
   457         -		file rename -force /tmp/$appname.app $currentinstall
   458         -
   459         -		exec $currentinstall/Contents/MacOS/$appname &
   460         -
   461         -		exit
   462         -	    }
   463         -	}
   464         -	
   465         -	"win32" {
   466         -	    
   467         -	    softwareupdate::writeBatch $appname
   468         -	    eval exec [auto_execok start]  /b "" cmd /c [file join $tmpdir deleteapp.bat] &
   469         -	}
   470         -	
   471         -	"x11" {
   472         -	    tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
   473         -	    return
   474         -	}
   475         -    }
   476         -
   477         -    catch {destroy .downloadprogress}
   478         -
   479         -    
   480         -
   481         -}
   482         -
   483         -
   484         -proc writeBatch {appname} {
   485         -
   486         -    variable tmpdir
   487         -    variable currentinstall
   488         -
   489         -    set script {
   490         -	cd  $currentinstall 
   491         -	taskkill /IM $appname.exe /F
   492         -	rename $appname.exe ${appname}-tmp.exe 
   493         -	cd $tmpdir
   494         -	copy [file nativename [file join $tmpdir $appname.exe]] [file nativename [file join $currentinstall $appname.exe]]
   495         -	cd $currentinstall
   496         -	start $appname.exe
   497         -	del ${appname}-tmp.exe
   498         -	cd $tmpdir
   499         -	::del deleteapp.bat
   500         -    }
   501         -
   502         -    set batchscript [subst $script]
   503         -    set delscript [open [file join $tmpdir deleteapp.bat] w]
   504         -    puts $delscript $batchscript
   505         -    close $delscript
   506         -
   507         -
   508         -}
   509         -
   510         -namespace export *
          492  +    namespace export *
   511    493   
   512    494   }