ApplicationDefinition.st
changeset 20589 fd675c8fdfe9
parent 20581 a84d4217a951
child 20596 6c34f0777523
child 20599 c7eebeef73a8
--- a/ApplicationDefinition.st	Tue Oct 11 01:55:46 2016 +0200
+++ b/ApplicationDefinition.st	Tue Oct 11 01:57:23 2016 +0200
@@ -111,7 +111,7 @@
 !
 
 startupClass
-    "the class, but onlz of loaded"
+    "the class, but only if loaded"
 
     |cls|
 
@@ -741,11 +741,14 @@
         at:self rcFilename      put:#'generate_packageName_dot_rc';
         at:self nsiFilename     put:#'generate_packageName_dot_nsi';
         at:self apspecFilename  put:#'generate_autopackage_default_dot_apspec'; "/ for linux
-        at:'osx/Info.plist'  put:#'generate_osx_info_dot_plist';
-        at:'osx/PkgInfo'  put:#'generate_osx_pkginfo';
+        at:'osx/Info.plist'     put:#'generate_osx_info_dot_plist';
+        at:'osx/PkgInfo'        put:#'generate_osx_pkginfo';
         at:'builder/baseline.rbspec'  put:#'generate_builder_baseline_dot_rbspec';
         at:'builder/package.deps.rake' put: #'generate_package_dot_deps_dot_rake'.
 
+"/    self isGUIApplication ifFalse:[    
+"/        dict at:'osx/Distribution'  put:#'generate_osx_distributionScript'.
+"/    ].
     ^ dict.
 
     "Modified: / 21-12-2010 / 11:01:27 / cg"
@@ -1018,55 +1021,6 @@
     RMDir /r "$INSTDIR"'
 !
 
-dmgImageSetupLines
-    "generate (OSX unix) copy commands to generate a directory holding the dmg prototype image directory.
-     This is used to generate a macOS deployable package"
-
-    |genLine product productFile dmgVolume dmgDir appDir contentsDir macOSDir resourcesDir dirsMade|
-
-    product := self productName.
-    productFile := self productFilename.
-
-    dmgVolume := productFile,'.dmg'.
-    dmgDir := productFile,'_dmg'.
-    appDir := dmgDir,'/',productFile,'.app'.
-    contentsDir := appDir,'/Contents'.
-    macOSDir := contentsDir,'/MacOS'.
-    resourcesDir := contentsDir,'/Resources'.
-    dirsMade := Set new.
-
-    genLine :=
-        [:s :d :srcAndDest |
-            |sourcePattern relPath destination|
-
-            sourcePattern := srcAndDest first.
-            relPath := srcAndDest second.
-            (relPath startsWith:'bin') ifTrue:[
-                relPath := '.',(relPath copyFrom:4)
-            ].
-            destination := contentsDir,'/',d,'/',relPath.
-            (dirsMade includes:destination) ifFalse:[
-                s tab; nextPutLine:('@-mkdir "%1"' bindWith:destination).
-                dirsMade add:destination.
-            ].
-            s tab; nextPutLine:('-cp -r %1 "%2"' bindWith:sourcePattern with:destination).
-        ].
-
-    ^ String streamContents:[:s |
-        s tab; nextPutLine:('@-rm -rf "%1"' bindWith:dmgDir).
-        s tab; nextPutLine:('@-mkdir "%1"' bindWith:dmgDir).  dirsMade add:dmgDir.
-        s tab; nextPutLine:('@-mkdir "%1"' bindWith:appDir).  dirsMade add:appDir.
-        s tab; nextPutLine:('@-mkdir "%1"' bindWith:contentsDir).  dirsMade add:contentsDir.
-        s tab; nextPutLine:('@-mkdir "%1"' bindWith:macOSDir).  dirsMade add:macOSDir.
-        s tab; nextPutLine:('cp "',self applicationName,'" "',macOSDir,'/"').
-        s tab; nextPutLine:('@-cp osx/Info.plist "',contentsDir,'/"').
-        s tab; nextPutLine:('@-cp osx/PkgInfo "',contentsDir,'/"').
-        self commonFilesToInstall_unix do:[:eachPair | genLine value:s value:'MacOS' value:eachPair].
-        s tab; nextPutLine:('@-rm "%1/"*WINrc.rc' bindWith:macOSDir).
-        self additionalFilesToInstall_unix do:[:eachPair | genLine value:s value:'MacOS' value:eachPair].
-    ].
-!
-
 fileExtensionDefinitionLines_dot_nsi:bindings
     ^ String streamContents:[:s |
         self documentExtensions do:[:ext |
@@ -1114,7 +1068,9 @@
         at: 'PRODUCT_PUBLISHER' put: (self productPublisher);
         at: 'PRODUCT_WEBSITE' put: (self productWebSite);
         at: 'PRODUCT_INSTALLDIR' put: (self productInstallDir);
-        at: 'DMG_IMAGE_SETUP' put: (self dmgImageSetupLines);
+        at: 'OSX_DMG_SETUP' put: (self osxDmgImageSetupLines);
+        at: 'OSX_PKG_SETUP' put: (self osxPkgImageSetupLines);
+        at: 'PRODUCT_ID' put: (self package copyReplaceAny:':/' with:$.); 
         at: 'BUILD_TARGET' put: (self buildTarget ).
 
     self offerSmalltalkSourceCode ifTrue:[ 
@@ -2394,6 +2350,32 @@
     "Created: / 01-03-2007 / 20:00:20 / cg"
 !
 
+linuxSetupRules
+    "this is sliced into the generated Make.proto file"
+    
+    ^ '
+#
+# for linux, this uses autopackage
+# (SETUP_RULE is set to setup_linux)
+setup_linux:
+        @if test -d autopackage; then \
+            makepackage; \
+        else \
+            echo "Error: missing autopackage directory"; \
+            exit 1; \
+        fi
+        
+# backward compatible fallback
+setup::
+        @if test -d autopackage; then \
+            makepackage; \
+        else \
+            echo "Error: make setup not yet available in this unix"; \
+            exit 1; \
+        fi
+'
+!
+
 make_dot_proto
 
 ^
@@ -2497,37 +2479,8 @@
 #
 # a self installable delivery
 #
-# backward compatible fallback
-setup::
-        @if test -d autopackage; then \
-            makepackage; \
-        else \
-            echo "Error: make setup not yet available in this unix"; \
-            exit 1; \
-        fi
-
-#
-# for linux, this uses autopackage
-#
-setup_linux:
-        @if test -d autopackage; then \
-            makepackage; \
-        else \
-            echo "Error: missing autopackage directory"; \
-            exit 1; \
-        fi
-
-#
-# for mac, a dmg is generated
-#
-setup_macosx:   "%(PRODUCT_FILENAME)_dmg"
-        -rm "%(PRODUCT_FILENAME).dmg"
-        hdiutil create -fs HFSX -layout SPUD "%(PRODUCT_FILENAME).dmg" -srcfolder "%(PRODUCT_FILENAME)_dmg" -format UDZO -volname "%(PRODUCT_NAME)" -quiet
-
-app: "%(PRODUCT_FILENAME)_dmg"
-
-"%(PRODUCT_FILENAME)_dmg": $(SUBPROJECT_LIBS) $(REQUIRED_SUPPORT_DIRS) 
-%(DMG_IMAGE_SETUP)
+',self linuxSetupRules,'
+',self osxSetupRules,'
 
 SOURCEFILES: %(APPLICATION)_SOURCES \
         stx_SOURCES
@@ -2787,6 +2740,182 @@
     "Modified: / 09-11-2010 / 11:57:39 / cg"
 !
 
+osxDmgImageSetupLines
+    "generate (OSX unix) copy commands to generate a directory holding the dmg prototype image directory.
+     This is used to generate a macOS deployable dmg containing an app"
+
+    |genLine product productFile dmgVolume dmgDir appDir contentsDir macOSDir resourcesDir dirsMade|
+
+    product := self productName.
+    productFile := self productFilename.
+
+    dmgVolume := productFile,'.dmg'.
+    dmgDir := productFile,'_dmg'.
+    appDir := dmgDir,'/',productFile,'.app'.
+    contentsDir := appDir,'/Contents'.
+    macOSDir := contentsDir,'/MacOS'.
+    resourcesDir := contentsDir,'/Resources'.
+    dirsMade := Set new.
+
+    genLine :=
+        [:s :d :srcAndDest |
+            |sourcePattern relPath destination|
+
+            sourcePattern := srcAndDest first.
+            relPath := srcAndDest second.
+            (relPath startsWith:'bin') ifTrue:[
+                relPath := '.',(relPath copyFrom:4)
+            ].
+            destination := contentsDir,'/',d,'/',relPath.
+            (dirsMade includes:destination) ifFalse:[
+                s tab; nextPutLine:('@-mkdir "%1"' bindWith:destination).
+                dirsMade add:destination.
+            ].
+            s tab; nextPutLine:('-cp -r %1 "%2"' bindWith:sourcePattern with:destination).
+        ].
+
+    ^ String streamContents:[:s |
+        s tab; nextPutLine:('@-rm -rf "%1"' bindWith:dmgDir).
+        s tab; nextPutLine:('@-mkdir "%1"' bindWith:dmgDir).  dirsMade add:dmgDir.
+        s tab; nextPutLine:('@-mkdir "%1"' bindWith:appDir).  dirsMade add:appDir.
+        s tab; nextPutLine:('@-mkdir "%1"' bindWith:contentsDir).  dirsMade add:contentsDir.
+        s tab; nextPutLine:('@-mkdir "%1"' bindWith:macOSDir).  dirsMade add:macOSDir.
+        s tab; nextPutLine:('cp "',self applicationName,'" "',macOSDir,'/"').
+        s tab; nextPutLine:('@-cp osx/Info.plist "',contentsDir,'/"').
+        s tab; nextPutLine:('@-cp osx/PkgInfo "',contentsDir,'/"').
+        self commonFilesToInstall_unix do:[:eachPair | genLine value:s value:'MacOS' value:eachPair].
+        s tab; nextPutLine:('@-rm "%1/"*WINrc.rc' bindWith:macOSDir).
+        self additionalFilesToInstall_unix do:[:eachPair | genLine value:s value:'MacOS' value:eachPair].
+    ].
+!
+
+osxPkgDistributionScript
+    "unfinished.
+     generate (OSX unix) copy commands to generate a directory holding the pkg prototype image directory.
+     This is used to generate a macOS deployable pkg containing libraries or non-GUI programs"
+
+    |packageID product|
+
+    product := self productName.
+    packageID := self package copyReplaceAny:':/' with:$..
+
+    ^  '
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<installer-gui-script minSpecVersion="1">
+    <title>',product,'</title>
+    <options customize="never"/>
+    <allowed-os-versions>
+        <os-version min="10.5"/>
+    </allowed-os-versions>
+    <installation-check script="InstallationCheck();"/>
+    <script><!![CDATA[
+function InstallationCheck () {
+    if (system.compareVersions(system.version.ProductVersion, "10.5") < 0) {
+        my.result.message = "This package is meant to be installed on Mac OS X 10.5 or newer.";
+        my.result.type = ''Fatal'';
+        return false;
+    }
+    if (system.files.fileExistsAtPath(''/opt/local/bin/',product,''')) {
+        my.result.message = "',product,' is already installed.";
+        my.result.type = ''Warn'';
+        return false;
+    }
+    return true;
+}
+    ]]></script>
+    <readme mime-type="text/html" file="ReadMe.html"/>
+    <welcome mime-type="text/html" file="Welcome.html"/>
+    <choices-outline>
+        <line choice="default">
+            <line choice="',packageID,'"/>
+        </line>
+    </choices-outline>
+    <choice id="default"/>
+    <choice id="',packageID,'" visible="false">
+        <pkg-ref id="',packageID,'"/>
+    </choice>
+    <pkg-ref id="',packageID,'" version="0.2.3.3.0.0.0.0.0" installKBytes="14236">#MacPorts-2.3.3-component.pkg</pkg-ref>
+    <pkg-ref id="',packageID,'">
+        <bundle-version/>
+    </pkg-ref>
+    <product id="',packageID,'"/>
+</installer-gui-script>
+'.
+!
+
+osxPkgImageSetupLines
+    "generate (OSX unix) copy commands to generate a directory holding the pkg prototype image directory.
+     This is used to generate a macOS deployable pkg containing libraries or non-GUI programs"
+
+    |product productFile pkgVolume pkgDir 
+     optDir optLocalDir optLocalBinDir|
+
+    product := self productName.
+    productFile := self productFilename.
+
+    pkgVolume := productFile,'.pkg'.
+    pkgDir := productFile,'_pkg'.
+    optDir := pkgDir,'/opt'.
+    optLocalDir := optDir,'/local'.
+    optLocalBinDir := optLocalDir,'/bin'.
+
+    ^ String streamContents:[:s |
+        s tab; nextPutLine:('-rm -rf "%1"' bindWith:pkgDir).
+        s tab; nextPutLine:('-mkdir "%1"' bindWith:pkgDir).  
+        s tab; nextPutLine:('-mkdir "%1"' bindWith:optDir). 
+        s tab; nextPutLine:('-mkdir "%1"' bindWith:optLocalDir). 
+        s tab; nextPutLine:('-mkdir "%1"' bindWith:optLocalBinDir). 
+        s tab; nextPutLine:('cp "',self applicationName,'" "',optLocalBinDir,'/"').
+    ].
+!
+
+osxSetupRules
+    "this is sliced into the generated Make.proto file"
+
+    self isGUIApplication ifTrue:[
+        ^ self osxSetupRules_forDMG
+    ].
+    ^ self osxSetupRules_forPKG
+!
+
+osxSetupRules_forDMG
+    "this is sliced into the generated Make.proto file"
+
+    ^ '
+#
+# for mac, a dmg is generated
+# (SETUP_RULE is set to setup_macosx)
+#
+setup_macosx:   "%(PRODUCT_FILENAME)_dmg"
+        -rm "%(PRODUCT_FILENAME).dmg"
+        hdiutil create -fs HFSX -layout SPUD "%(PRODUCT_FILENAME).dmg" -srcfolder "%(PRODUCT_FILENAME)_dmg" -format UDZO -volname "%(PRODUCT_NAME)" -quiet
+
+app: "%(PRODUCT_FILENAME)_dmg"
+
+"%(PRODUCT_FILENAME)_dmg": $(SUBPROJECT_LIBS) $(REQUIRED_SUPPORT_DIRS) 
+%(OSX_DMG_SETUP)
+'
+!
+
+osxSetupRules_forPKG
+    "this is sliced into the generated Make.proto file"
+
+    ^ '
+#
+# for mac, a pkg is generated
+# (SETUP_RULE is set to setup_macosx)
+#
+setup_macosx:   "%(PRODUCT_FILENAME)_pkg"
+        -rm "%(PRODUCT_FILENAME).pkg"
+        pkgbuild --identifier "%(PRODUCT_ID)" --version "%(PRODUCT_VERSION)" --root %(PRODUCT_FILENAME)_pkg "%(PRODUCT_FILENAME).pkg"
+
+app: "%(PRODUCT_FILENAME)_pkg"
+
+"%(PRODUCT_FILENAME)_pkg": $(SUBPROJECT_LIBS) $(REQUIRED_SUPPORT_DIRS) 
+%(OSX_PKG_SETUP)
+'
+!
+
 packageName_dot_nsi
     "the template code for the <appname>.nsi file"