'From Pharo0.1 of 16 May 2008 [Latest update: #10373] on 3 November 2009 at 8:37:25 pm'! Object subclass: #GatorLoader instanceVariableNames: 'packageCache homeGrownPackages' classVariableNames: '' poolDictionaries: '' category: 'GatorLoader'! !GatorLoader commentStamp: 'BillSchwab 11/3/2009 20:35' prior: 0! Another gratuitous loader. CONFIGURE ========= Configure it using #homeGrownPackageNames and #me to tell it which packages are intended to hold your work, and how to identify you from the (misnomer!!!!!!) #timeStamp aspects of the compiled methods you produce. SAVE YOUR WORK ============== Use #suspectMethodsReport to produce a listing of class>>selector names that might be in danger of being orphaned in your current image. Use #homeGrownPackgesSaveWithMessage: to save all of the identified home grown packages in the next version and with the common text message. BUILD A NEW IMAGE ================= Load GatorLoader into a new image. It wants underscore_madness.cs, and loads SIXX and other packages of interest to me; you can edit as needed to remove what you do not want to load. Put your packages in the cache directory for the new image. Yes, it is fussy about these things, but the idea is to find errors early rather than being stopped after a long wait. Likewise, if you do not like what #setPreferences does, edit it. W.K. Schwab, Ph.D. This is released under standard Pharo licensing with no warranty of any kind. ! !GatorLoader methodsFor: 'build image' stamp: 'BillSchwab 11/3/2009 19:48'! loadPackages "10-09 - build an image. I have no idea what's up with installer/gofer, etc., and now can't reliably copy text between images. MC seems to work, so create class to do all of this." self checkHomeGrownPackagesForLoad. self setPreferences. self preLoad. self basicLoadPackages. ! ! !GatorLoader methodsFor: 'check for endangered work' stamp: 'BillSchwab 11/3/2009 20:08'! suspectMethodsReport | methods out ws | methods := self suspectMethods. out := String writeStream. out nextPutAll:'Below is a list of methods attributable to '; nextPutAll:self me; nextPutAll:' but not packaged in on the the #homeGrownPackageNames.'; cr; nextPutAll:'They might be at risk of being orphaned as you build a new image.'; cr; cr. methods do:[ :each | out nextPutAll:each methodClass name; nextPutAll:'>>'; nextPutAll:each selector. ] separatedBy:[ out cr. ]. ws := Workspace new contents:out contents. ws openLabel:'Suspect Methods'. " GatorLoader new suspectMethodsReport. " ! ! !GatorLoader methodsFor: 'configuration' stamp: 'BillSchwab 11/3/2009 01:32'! homeGrownPackageNames ^#( 'Dolphincompatibility' 'OpenSSL' 'Apacheat' 'AuthenticationForSeaside' 'BibTeX' ). ! ! !GatorLoader methodsFor: 'configuration' stamp: 'BillSchwab 11/3/2009 16:44'! me "Answer a string to be found in the (yuk!!!!) #timeStamp of methods that represent work to be saved in packages." ^'Schwab' ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 11/3/2009 19:48'! basicLoadPackages "10-09 - load lots of code, some from the local cache, some from elsewhere." | wks | wks := packageCache. "ScriptLoader loadLatestPackage:'' from:'ftp://swikis.ddo.jp/SIXX/squeak/SIXX20091024.sar'." SARInstaller installSAR:'SIXX20091024.sar'. ScriptLoader loadFFI. "Command shell requires proceeding past warnings and THEN commenting out/proceedingpast the last line in #initize - aka it's broke. ScriptLoader loadLatestPackage:'OSProcess' fromSqueaksource:'OSProcess'; loadLatestPackage:'Tests-OSProcess' fromSqueaksource:'OSProcess'; loadLatestPackage:'CommandShell' fromSqueaksource:'CommandShell'. 11-09 - I've had it; save something locally to try to avoid the MVC hassles." ScriptLoader loadLatestPackage:'OSProcess' fromRepository:wks; loadLatestPackage:'CommandShell' fromRepository:wks. "ODBC: http://www.squeaksource.com/ODBC/ODBC-rjl.10.mcz" ScriptLoader loadLatestPackage:'ODBC' fromSqueaksource:'ODBC'; loadLatestPackage:'LDAP' fromSqueaksource:'LDAPlayer'. ScriptLoader loadLatestPackage:'SIF-Support' fromRepository:wks; loadLatestPackage:'SIF-Squeak' fromRepository:wks; "Rio is broken on Windows (kinda fitting, actually). Go to #newForWin32 and add #new." loadLatestPackage:'Rio-Kernel' fromSqueaksource:'Rio'; loadLatestPackage:'Rio-Grande' fromSqueaksource:'Rio'. "10-09 - note the trick of looking for CZLoader by name to avoid a dependency on as-yet not loaded code." Installer ss project: 'Citezen'; install: 'Citezen-Loader'. ( Smalltalk at:#CZLoader ) load. "11-09 - factor out the names that should contain methods that are *not* in danger of being lost for want of packaging." self homeGrownPackages allButFirstDo:[ :each | ScriptLoader loadLatestPackage:each packageName fromRepository:wks. ]. ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 11/3/2009 20:12'! checkHomeGrownPackagesForLoad "11-09 - look for existing versions of all named packages - in short, don't blow up over stupid stuff _after_ installing a bunch of code." self homeGrownPackages. self homeGrownPackages allButFirstDo:[ :each | self assert:[ ( packageCache versionsAvailableForPackage:( PackageInfo named:each packageName ) ) notEmpty ]. ]. " GatorLoader new checkHomeGrownPackagesForLoad. GatorLoader new checkHomeGrownPackagesForSave. " ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 11/3/2009 20:11'! checkHomeGrownPackagesForSave "11-09 - a breif sanity check on the packages; at least see if they contain some methods. A method-less class won't like this, but I'm losing way too much time to avoidable non-sense for want of a real package system; this should slow the bleeding." self homeGrownPackages. self homeGrownPackages do:[ :each | self assert:[ each methods notEmpty ]. ]. " GatorLoader new checkHomeGrownPackagesForLoad. GatorLoader new checkHomeGrownPackagesForSave. " ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 11/3/2009 00:52'! homeGrownPackageFor:method ifNone:ifNone "11-09 - starting to understand why OB is so slow; there appears to be no direct path from method to package." | selector aClass | selector := method selector. aClass := method methodClass. "11-09 - try to luck out and early out method methodClass methods includes:method." ^homeGrownPackages detect:[ :aPackage | aPackage includesMethod:selector ofClass:aClass. "method category. method methodClass." ] ifNone:ifNone. " GatorLoader new homeGrownPackageFor:IrisObjectAdapter methods first. IrisObjectAdapter package methods includes:IrisObjectAdapter methods first. IrisObjectAdapter package methods includes:IrisObjectAdapter methods first selector. IrisObjectAdapter methods first methodClass. IrisObjectAdapter package includesMethod:#allConnections ofClass:IrisObjectAdapter. " ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 11/3/2009 20:16'! homeGrownPackages "11-09 - answer a collection of packages allegedly representing the work of the programmer identified by #me. Add the GatorLoader package as the first in the collection; it is skipped using #allButFirstDo: in various places." homeGrownPackages notNil ifTrue:[ ^homeGrownPackages. ]. homeGrownPackages := ( self homeGrownPackageNames collect:[ :each | "11-09 - can't do this here; sometimes we care about whole packages in the images, and sometimes about extant versions in the cache. See #checkHomeGrownPackagesFor*. self assert:[ PackageInfo existPackageNamed:each. ]." PackageInfo named:each. ] ) asOrderedCollection. "11-09 - lots of bogus complaints over GatorLoader members, so add it to the collection of packages." homeGrownPackages addFirst:self class package. ^homeGrownPackages. " GatorLoader new homeGrownPackages. " ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 11/3/2009 19:50'! initialize super initialize. packageCache := MCCacheRepository default. self homeGrownPackages. " GatorLoader new suspectMethodsReport. GatorLoader new homeGrownPackagesSaveWithMessage:'Automated save'. GatorLoader new loadPackages. " ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 11/2/2009 23:12'! isHomeGrown:method ^( method timeStamp indexOfSubCollection:self me ) ~= 0 ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 10/22/2009 15:01'! preLoad "10-09 - trying to clean up Dolphin dependencies, but SIF didn't want to load things w/o a few tricks. Stragglers appear herein (redacted for release)." "10-09 - load underscore madness." FileStream fileIn:SmalltalkImage current imagePath,'/underscore_madness.cs'. ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 11/3/2009 19:26'! savePackageNamed:packageName message:aString "11-09 - Saving packages one-off using MC is error prone, not to mention just plain pointless. Save the next version of each of the home grown packages using a common message." | wc version | wc := ( MCPackage named:packageName ) workingCopy. version := wc newVersionWithName:wc uniqueVersionName message:aString. packageCache storeVersion:version. ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 10/2/2009 18:25'! setPreferences "Set toolset, fonts, theme; turn off ecompletion." | tinyFont codeFont baseFont boldFont | ToolSet default:StandardToolSet. SystemBrowser default:Browser. UIThemeW2K beCurrent. "Select Fonts - Shamelessly stolen from Lukas" tinyFont := LogicalFont familyName:'DejaVu Sans' fallbackFamilyNames:nil pointSize:8 stretchValue:0 weightValue:400 slantValue:0. codeFont := LogicalFont familyName:'DejaVu Sans Mono' fallbackFamilyNames:nil pointSize:9 stretchValue:0 weightValue:400 slantValue:0. baseFont := LogicalFont familyName:'DejaVu Sans' fallbackFamilyNames:nil pointSize:10 stretchValue:0 weightValue:400 slantValue:0. boldFont := LogicalFont familyName:'DejaVu Sans' fallbackFamilyNames:nil pointSize:11 stretchValue:0 weightValue:600 slantValue:0. Preferences setBalloonHelpFontTo:tinyFont. Preferences setButtonFontTo:baseFont. Preferences setCodeFontTo:codeFont. Preferences setHaloLabelFontTo:baseFont. Preferences setListFontTo:baseFont. Preferences setMenuFontTo:baseFont. Preferences setSystemFontTo:baseFont. Preferences setWindowTitleFontTo:boldFont. Preferences disable:#ecompletionEnabled; disable:#autoFocusForColumns; enable:#fastDragWindowForMorphic; setPreference:#browserWindowColor toValue:( Color r:0.533 g:0.753 b:0.976 ). ! ! !GatorLoader methodsFor: 'helpers' stamp: 'BillSchwab 11/2/2009 23:43'! suspectMethods "11-09 - answer a collection of methods authored (per #timeStamp - misnamed!!!!) by 'me' and not in one of the #homeGrownPackages. Look for them now, or look for them later." | out | out := Array writeStream. self homeGrownPackages. ProtoObject allSubclasses do:[ :aClass | aClass methods do:[ :method | ( self isHomeGrown:method ) ifTrue:[ "11-09 - written here. Is it packaged in kind?" self homeGrownPackageFor:method ifNone:[ out nextPut:method. ]. ]. ]. ] displayingProgress:'Looking for unpackaged code'. ^out contents. " GatorLoader new suspectMethods. " ! ! !GatorLoader methodsFor: 'save packages' stamp: 'BillSchwab 11/3/2009 19:46'! homeGrownPackagesSaveWithMessage:aString "11-09 - Save the 'next version' of each of the home-grown packages." "11-09 - undone work is the most common cause of hassle here, so do some type of check on the integrity of the packages. Is having methods enough?" self checkHomeGrownPackagesForSave. self homeGrownPackages allButFirstDo:[ :each | self savePackageNamed:each packageName message:aString. ]. " GatorLoader new homeGrownPackagesSaveWithMessage:'Automate this'. " ! !