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 Unified Diffs Show Whitespace Changes Patch

Changes to scriptlibs/softwareupdate/softwareupdate.tcl.

94
95
96
97
98
99
100


101












102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
...
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
...
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
...
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
...
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
...
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
...
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
...
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
...
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
	    if {![package vsatisfies $hostOS $minOS]} {
		tk_messageBox -icon warning -message "Error!" -detail "$appname is not supported on Mac OS X $hostOS. The minimum supported OS version is $minOS." 
		return
	    }
	}
	
	if {[expr $currentversion < $versionnumber]} {


	    softwareupdate::updatePitch












	} else {
	    softwareupdate::upToDate
	}
    }

#define the current version of the software
proc setVersion {app number} {
    variable currentversion
    variable appname
    set currentversion $number
    set appname $app
    
}


#get the current installation path
proc findCurrentInstallation {} {
    variable currentinstall
    variable appname 
................................................................................
	    set currentinstall [file join $::env(APPDATA) ${appname}_App]  
	}
	
	"x11" {
	    return
	}
    }
    
    return $currentinstall

}

#prompt user to update: for Perl, which chokes on XML parsing from Tcl
proc updatePitchPerl {apptitle appnumber currentapp changelog} {
    variable appname
................................................................................

    ttk::frame .update.f.top.r.bottom -padding 5
    pack .update.f.top.r.bottom -side bottom -fill both -expand yes

    ttk::button .update.f.top.r.bottom.skip -text "Skip This Version" -command {destroy .update}

    ttk::button .update.f.top.r.bottom.install -text "Install Update" -default active -command softwareupdate::installUpdate
    
    pack .update.f.top.r.bottom.install .update.f.top.r.bottom.skip  -side right  -fill both -expand yes

    set changetext [split $changelog *]

    set changetext [lrange $changetext 1 end]

    foreach item $changetext {
................................................................................
    variable changedata
    variable currentversion
    variable versionnumber

    catch {destroy .updateprogress}

    catch {destroy .update}
    

    toplevel .update
    wm title .update "Software Update"

    wm withdraw .update

    frame .update.f -bg gray95
................................................................................

    ttk::frame .update.f.top.r.bottom -padding 5
    pack .update.f.top.r.bottom -side bottom -fill both -expand yes

    ttk::button .update.f.top.r.bottom.skip -text "Skip This Version" -command {destroy .update}

    ttk::button .update.f.top.r.bottom.install -text "Install Update" -default active -command softwareupdate::installUpdate
    
    pack .update.f.top.r.bottom.install .update.f.top.r.bottom.skip  -side right  -fill both -expand yes

    .update.f.top.r.text insert end $changedata

    .update.f.top.r.text configure -state disabled

    wm resizable .update 0 0
................................................................................
    pack .updateprogress.f -fill both -expand yes

    label .updateprogress.f.l -bg gray95 -image $icon -bd 0 -relief flat -highlightthickness 0 -width [image width $icon] -height [image height $icon]
    pack .updateprogress.f.l -side left -fill both -expand yes

    frame .updateprogress.f.r -bg gray95 -bd 0 -highlightcolor gray95
    pack .updateprogress.f.r -side right -fill both -expand yes
    
    
    ttk::label .updateprogress.f.r.t -text "Checking for updates..." -padding 5
    pack .updateprogress.f.r.t -side top -fill both -expand yes

    ttk::frame .updateprogress.f.r.f -padding 5
    pack .updateprogress.f.r.f -side top -fill both -expand yes
    
    ttk::progressbar .updateprogress.f.r.f.progress -mode indeterminate -orient horizontal
    pack .updateprogress.f.r.f.progress -fill both -expand yes -side top

    .updateprogress.f.r.f.progress start

    ttk::button .updateprogress.f.r.f.b -text "Cancel" -command {destroy .updateprogress}

................................................................................
    update

    ttk::button .downloadprogress.frame.b -text "Cancel" -command {destroy .updateprogress}
    pack .downloadprogress.frame.b -side right -fill both -expand no

    wm geometry .downloadprogress 400x100
    wm resizable .downloadprogress 0 0
    
}

#download and install the update
proc installUpdate {} {
    variable currentinstall
    variable status
    variable appname
................................................................................

    catch {destroy .update}

    softwareupdate::findCurrentInstallation

    softwareupdate::progressDialog
    set status "Downloading update for $appname"
    
    switch [tk windowingsystem] {

	"aqua" {
	    http::geturl http://www.codebykevin.com/updates/[list $appname].tgz -channel [open $tmpdir/[list $appname].tgz w] 
	    update
	    after 1000
	    cd $tmpdir
................................................................................
	}
	
	"x11" {
	    tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
	    return
	}
    }
    
    
    set status "Ready to install"
    .downloadprogress.frame.bar configure -mode determinate
    .downloadprogress.frame.bar configure -value 100
    .downloadprogress.frame.bar stop
    destroy .downloadprogress.frame.b 
    pack [ttk::button .downloadprogress.frame.b -text "Install and Relaunch" -command softwareupdate::launchUpdate] -side right -fill both -expand no
    return
................................................................................

#launch the update
proc launchUpdate {}  {

    variable currentinstall
    variable appname
    variable tmpdir
    
    switch [tk windowingsystem] {

	"aqua" {
	    if {[catch {exec codesign -v $tmpdir/$appname.app} msg]} {
		bgerror $msg
		tk_messageBox -icon warning -message "Error!" -detail "An error occurred in the installation of $appname. Please try again later."
		return
	    } else {

		file rename -force $currentinstall [file join /Users [exec whoami] .Trash [file tail $currentinstall]]

		file rename -force /tmp/$appname.app $currentinstall

		exec $currentinstall/Contents/MacOS/$appname &

		exit
	    }
	}
	
	"win32" {
	    
	    softwareupdate::writeBatch $appname
	    eval exec [auto_execok start]  /b "" cmd /c [file join $tmpdir deleteapp.bat] &
	}
	
	"x11" {
	    tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
	    return
	}
    }

    catch {destroy .downloadprogress}

    

}


proc writeBatch {appname} {

    variable tmpdir
    variable currentinstall

    set script {
	cd  $currentinstall 
	taskkill /IM $appname.exe /F
	rename $appname.exe ${appname}-tmp.exe 
	cd $tmpdir
	copy [file nativename [file join $tmpdir $appname.exe]] [file nativename [file join $currentinstall $appname.exe]]
	cd $currentinstall
	start $appname.exe
	del ${appname}-tmp.exe
	cd $tmpdir
	::del deleteapp.bat
    }

    set batchscript [subst $script]
    set delscript [open [file join $tmpdir deleteapp.bat] w]
    puts $delscript $batchscript
    close $delscript


}

namespace export *

}







>
>
|
>
>
>
>
>
>
>
>
>
>
>
>











|







 







|







 







|







 







|







 







|







 







|
|





|







 







|







 







|







 







|
|







 







|











|









<
<
|
|
<
<
<
<




|




<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|


94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
...
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
...
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
...
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
...
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
...
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
...
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480


481
482




483
484
485
486
487
488
489
490
491


























492
493
494
	    if {![package vsatisfies $hostOS $minOS]} {
		tk_messageBox -icon warning -message "Error!" -detail "$appname is not supported on Mac OS X $hostOS. The minimum supported OS version is $minOS." 
		return
	    }
	}
	
	if {[expr $currentversion < $versionnumber]} {
	    switch [tk windowingsystem] {
		"aqua" {
		    softwareupdate::updatePitch

		}
		
		"win32" {
		    softwareupdate::winPitch $appname $currentversion $oldversion
		}
		
		"x11" {
		    
		}
	    }
	    
	} else {
	    softwareupdate::upToDate
	}
    }

    #define the current version of the software
    proc setVersion {app number} {
	variable currentversion
	variable appname
	set currentversion $number
	set appname $app
	
    }


    #get the current installation path
    proc findCurrentInstallation {} {
	variable currentinstall
	variable appname 
................................................................................
		set currentinstall [file join $::env(APPDATA) ${appname}_App]  
	    }
	    
	    "x11" {
		return
	    }
	}
	
	return $currentinstall

    }

    #prompt user to update: for Perl, which chokes on XML parsing from Tcl
    proc updatePitchPerl {apptitle appnumber currentapp changelog} {
	variable appname
................................................................................

	ttk::frame .update.f.top.r.bottom -padding 5
	pack .update.f.top.r.bottom -side bottom -fill both -expand yes

	ttk::button .update.f.top.r.bottom.skip -text "Skip This Version" -command {destroy .update}

	ttk::button .update.f.top.r.bottom.install -text "Install Update" -default active -command softwareupdate::installUpdate
	
	pack .update.f.top.r.bottom.install .update.f.top.r.bottom.skip  -side right  -fill both -expand yes

	set changetext [split $changelog *]

	set changetext [lrange $changetext 1 end]

	foreach item $changetext {
................................................................................
	variable changedata
	variable currentversion
	variable versionnumber

	catch {destroy .updateprogress}

	catch {destroy .update}
	

	toplevel .update
	wm title .update "Software Update"

	wm withdraw .update

	frame .update.f -bg gray95
................................................................................

	ttk::frame .update.f.top.r.bottom -padding 5
	pack .update.f.top.r.bottom -side bottom -fill both -expand yes

	ttk::button .update.f.top.r.bottom.skip -text "Skip This Version" -command {destroy .update}

	ttk::button .update.f.top.r.bottom.install -text "Install Update" -default active -command softwareupdate::installUpdate
	
	pack .update.f.top.r.bottom.install .update.f.top.r.bottom.skip  -side right  -fill both -expand yes

	.update.f.top.r.text insert end $changedata

	.update.f.top.r.text configure -state disabled

	wm resizable .update 0 0
................................................................................
	pack .updateprogress.f -fill both -expand yes

	label .updateprogress.f.l -bg gray95 -image $icon -bd 0 -relief flat -highlightthickness 0 -width [image width $icon] -height [image height $icon]
	pack .updateprogress.f.l -side left -fill both -expand yes

	frame .updateprogress.f.r -bg gray95 -bd 0 -highlightcolor gray95
	pack .updateprogress.f.r -side right -fill both -expand yes
	
	
	ttk::label .updateprogress.f.r.t -text "Checking for updates..." -padding 5
	pack .updateprogress.f.r.t -side top -fill both -expand yes

	ttk::frame .updateprogress.f.r.f -padding 5
	pack .updateprogress.f.r.f -side top -fill both -expand yes
	
	ttk::progressbar .updateprogress.f.r.f.progress -mode indeterminate -orient horizontal
	pack .updateprogress.f.r.f.progress -fill both -expand yes -side top

	.updateprogress.f.r.f.progress start

	ttk::button .updateprogress.f.r.f.b -text "Cancel" -command {destroy .updateprogress}

................................................................................
	update

	ttk::button .downloadprogress.frame.b -text "Cancel" -command {destroy .updateprogress}
	pack .downloadprogress.frame.b -side right -fill both -expand no

	wm geometry .downloadprogress 400x100
	wm resizable .downloadprogress 0 0
	
    }

    #download and install the update
    proc installUpdate {} {
	variable currentinstall
	variable status
	variable appname
................................................................................

	catch {destroy .update}

	softwareupdate::findCurrentInstallation

	softwareupdate::progressDialog
	set status "Downloading update for $appname"
	
	switch [tk windowingsystem] {

	    "aqua" {
		http::geturl http://www.codebykevin.com/updates/[list $appname].tgz -channel [open $tmpdir/[list $appname].tgz w] 
		update
		after 1000
		cd $tmpdir
................................................................................
	    }
	    
	    "x11" {
		tk_messageBox -icon info -parent . -message "Please ask the maintainer of $appname on your platform to prepare a release of the latest version."
		return
	    }
	}
	
	
	set status "Ready to install"
	.downloadprogress.frame.bar configure -mode determinate
	.downloadprogress.frame.bar configure -value 100
	.downloadprogress.frame.bar stop
	destroy .downloadprogress.frame.b 
	pack [ttk::button .downloadprogress.frame.b -text "Install and Relaunch" -command softwareupdate::launchUpdate] -side right -fill both -expand no
	return
................................................................................

    #launch the update
    proc launchUpdate {}  {

	variable currentinstall
	variable appname
	variable tmpdir
	
	switch [tk windowingsystem] {

	    "aqua" {
		if {[catch {exec codesign -v $tmpdir/$appname.app} msg]} {
		    bgerror $msg
		    tk_messageBox -icon warning -message "Error!" -detail "An error occurred in the installation of $appname. Please try again later."
		    return
		} else {

		    file rename -force $currentinstall [file join /Users [exec whoami] .Trash [file tail $currentinstall]]

		    file rename -force $tmpdir/$appname.app $currentinstall

		    exec $currentinstall/Contents/MacOS/$appname &

		    exit
		}
	    }
	    
	    "win32" {
		


	    }
	    




	}

	catch {destroy .downloadprogress}

	

    }




























    namespace export *

}