From 3db2a5509988b0d08f14a621c0333c6e5df695ac Mon Sep 17 00:00:00 2001 From: Dale Henrichs Date: Fri, 2 Jun 2023 11:19:58 -0700 Subject: [PATCH] Issue #4: implement registerTodeSharedDir.solo ... still a bit more tode work to do ... clean up STONES_DATA_HOME definition ... can use customenv to run topaz in stone directory and run solo scripts --- README.md | 11 ++++ bin/registerTodeSharedDir.solo | 63 +++++++++++++++++++ .../class/base_data_home.st | 4 +- .../instance/createStoneStructure..st | 4 +- .../instance/createTodeSharedDirectory..st | 3 + .../instance/destroyStoneStructure..st | 3 + .../instance/createStoneStructureUsing..st | 5 +- .../instance/defineCustomEnvVars.st | 10 +-- .../instance/destroyStoneStructure.st | 6 +- .../GDKStoneSpec.class/instance/registry.st | 5 -- .../instance/todeSharedDirectory.st | 3 + .../instance/todeSharedDirectory..st | 3 + .../instance/todeSharedDirectory.st | 3 + .../GDKStonesRegistry.class/properties.json | 1 + .../instance/createTodeSharedDirectory..st | 12 ++++ .../instance/destroyStoneStructure..st | 5 ++ 16 files changed, 128 insertions(+), 13 deletions(-) create mode 100755 bin/registerTodeSharedDir.solo create mode 100644 src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/createTodeSharedDirectory..st create mode 100644 src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/destroyStoneStructure..st delete mode 100644 src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/registry.st create mode 100644 src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/todeSharedDirectory.st create mode 100644 src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/instance/todeSharedDirectory..st create mode 100644 src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/instance/todeSharedDirectory.st create mode 100644 src/GsDevKit_stones-Core.package/GDKhomeStoneDirectorySpec.class/instance/createTodeSharedDirectory..st create mode 100644 src/GsDevKit_stones-Core.package/GDKhomeStoneDirectorySpec.class/instance/destroyStoneStructure..st diff --git a/README.md b/README.md index 069b79ad..cc116622 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,15 @@ Greatly simplified version of GsDevKit_home After running install add superDoit/bin and GsDevKit_stones/bin to $PATH +## REQUIRED env vars +GsDevKit_stones maintains a registry data structure based on the [XDG Base Directory Specification](https://xdgbasedirectoryspecification.com/). On Linux machines, the default location for application specific data is $HOME/.local/share and $XDG_DATA_HOME can be used to optionally define an alternate location. On Mac machines, the XDG Base Directory Specification is not defined. + +Therefore to simplify the coding and allow for the creation of short-leved registry structures, The environment variable STONES_DATA_HOME is used to define the root directory for GsDevKit_STONES applications. On Linux, STONES_DATA_HOME defaults to $HOME/.local/share. On Mac, STONES_DATA_HOME must be defined. + +I recommend that a users regardless of platform define STONES_DATA_HOME in their environment. All of the file system paths in the registry include $STONES_DATA_HOME so if you want to be able view these files outside of a GsDevKit_stones application, having the env var defined is very convenient +```bash +export STONES_DATA_HOME=$HOME/.local/share +``` ## Setting up the registry structure ```bash registryName="gsdevkit" @@ -32,6 +41,8 @@ registerProduct.solo --registry=$registryName --productPath=/bosch1/users/dhenri # register default stones directory registerStonesDirectory.solo --registry=$registryName --stonesDirectory=/bosch1/users/dhenrich/_issue_4/stones +# register shared tODE directory +registerTodeSharedDir.solo --registry=issue_4 --todeSharedDirectory=/bosch1/users/dhenrich/_issue_4/tode_shared registryReport.solo ``` diff --git a/bin/registerTodeSharedDir.solo b/bin/registerTodeSharedDir.solo new file mode 100755 index 00000000..cc720623 --- /dev/null +++ b/bin/registerTodeSharedDir.solo @@ -0,0 +1,63 @@ +#!/usr/bin/env superdoit_solo +options +{ +SuperDoitRequiredOptionWithRequiredArg long: 'registry'. +SuperDoitRequiredOptionWithRequiredArg long: 'todeSharedDirectory'. +} +% +Usage +----- +USAGE $basename [--help | -h] [--debug | -D] [--debugGem] \ + --registry= --todeSharedDirectory= + +DESCRIPTION + Register a tode shared directory for the named registry. If the directory does not + exist the directory is created. tODE images store information that is shared by all + tODE images in the named registry. Necessary for a fully functional tODE stone. + +OPTIONS + -h, --help display usage message + -D, --debug bring up topaz debugger in the event of a script error + --debugGem If terminal is connected to stdout, bring up debugger. If not, + dump stack to stdout and wait for topaz to attach using topaz + DEBUGGEM command. + +EXAMPLES + $basename --help + $basename -D + $basename --registry=bosch --todeSharedDirectory=/home/dhenrich/gemstone/tode_shared +----- +% +specs +[ +RwLoadSpecificationV2 { + #projectName : 'GsDevKit_stones', + #projectSpecFile : 'rowan/project.ston', + #componentNames : [ + 'Core', + 'Solo' + ], + #platformProperties : { + 'gemstone' : { + 'allusers' : { + #defaultSymbolDictName : 'Globals' + } + } + }, + #comment : '' +} +] +% +doit + | registryClass stonesRegistry todeSharedDir todeSharedDirPath | + self preDoitSpecLoad: [:spec | + spec projectsHome: self dirname asFileReference parent parent]. + registryClass := (self globalNamed: 'GDKRegistry'). + stonesRegistry := registryClass stonesRegistryNamed: self registry. + todeSharedDir := self todeSharedDirectory asFileReference. + todeSharedDir ensureCreateDirectory. + todeSharedDirPath := GsFile serverRealPath: todeSharedDir pathString. + stonesRegistry todeSharedDirectory: todeSharedDirPath. + stonesRegistry export. + +% diff --git a/src/GsDevKit_stones-Core.package/GDKGsDevKit_stonesBase.class/class/base_data_home.st b/src/GsDevKit_stones-Core.package/GDKGsDevKit_stonesBase.class/class/base_data_home.st index 03c61d1a..58b3d032 100644 --- a/src/GsDevKit_stones-Core.package/GDKGsDevKit_stonesBase.class/class/base_data_home.st +++ b/src/GsDevKit_stones-Core.package/GDKGsDevKit_stonesBase.class/class/base_data_home.st @@ -1,5 +1,7 @@ xdgb accessing base_data_home - "use super here, because our implementation of _envName:defaultDir: needs to be used" + "use super here, because our implementation of _envName:defaultDir: needs to be used, + since we want the value of $XDG_DATA_HOME / $STONES_DATA_HOME, which does not include + the application name" ^ super data_home \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/createStoneStructure..st b/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/createStoneStructure..st index 78a675db..6c2c3fa8 100644 --- a/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/createStoneStructure..st +++ b/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/createStoneStructure..st @@ -20,7 +20,7 @@ createStoneStructure: stoneSpec onClient: false. exportDir at: GDKGsDevKit_stonesBase dataHomeEnvVar - put: self class data_home pathString. + put: self class base_data_home pathString. self keysAndValuesDo: [ :key :value | key = #'customenv' @@ -55,6 +55,8 @@ createStoneStructure: stoneSpec socket close ] ]. key = #'stats' ifTrue: [ (stoneRoot / value) ensureCreateDirectory ]. + key = #'tode' + ifTrue: [ self createTodeSharedDirectory: stoneSpec ]. key = #'tranlogs' ifTrue: [ useTranlogDir := '/' , value. diff --git a/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/createTodeSharedDirectory..st b/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/createTodeSharedDirectory..st new file mode 100644 index 00000000..a63a368a --- /dev/null +++ b/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/createTodeSharedDirectory..st @@ -0,0 +1,3 @@ +stone creation +createTodeSharedDirectory: stoneSpec + "noop by default ... see GDKhomeStoneDirectorySpec" \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/destroyStoneStructure..st b/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/destroyStoneStructure..st new file mode 100644 index 00000000..d2adc1d6 --- /dev/null +++ b/src/GsDevKit_stones-Core.package/GDKStoneDirectorySpec.class/instance/destroyStoneStructure..st @@ -0,0 +1,3 @@ +stone destruction +destroyStoneStructure: stoneSpec + "noop" \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/createStoneStructureUsing..st b/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/createStoneStructureUsing..st index 19b01d9e..7a62dc82 100644 --- a/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/createStoneStructureUsing..st +++ b/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/createStoneStructureUsing..st @@ -4,9 +4,12 @@ createStoneStructureUsing: stonesRegistry | stoneDirSpec | self rootDir ensureCreateDirectory. + [ stonesRegistry productNamed: self gemstoneVersionString. stoneDirSpec := GDKAbstractRegistryStore fromPath: (stonesRegistry templateNamed: self stoneDirectorySpecName) ifAbsent: [ ]. stoneDirSpec createStoneStructure: self. "populate directory structure" - self stoneDirectorySpec: stoneDirSpec \ No newline at end of file + self stoneDirectorySpec: stoneDirSpec ] + on: Error + do: [ :ex | self rootDir deleteAllChildren ] \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/defineCustomEnvVars.st b/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/defineCustomEnvVars.st index 02bfd8e2..34c5de5a 100644 --- a/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/defineCustomEnvVars.st +++ b/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/defineCustomEnvVars.st @@ -1,6 +1,8 @@ runtime defineCustomEnvVars - self stoneDirectorySpec customenv - ifNotNil: [ :customenv | - customenv - keysAndValuesDo: [ :varName :valueStr | System gemEnvironmentVariable: varName put: valueStr ] ] \ No newline at end of file + self stoneDirectorySpec + ifNotNil: [ :dirSpec | + dirSpec customenv + ifNotNil: [ :customenv | + customenv + keysAndValuesDo: [ :varName :valueStr | System gemEnvironmentVariable: varName put: valueStr ] ] ] \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/destroyStoneStructure.st b/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/destroyStoneStructure.st index e5abea03..b89751af 100644 --- a/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/destroyStoneStructure.st +++ b/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/destroyStoneStructure.st @@ -14,4 +14,8 @@ destroyStoneStructure self rootDir exists ifTrue: [ self rootDir ensureDeleteAll ]. self registryFile exists - ifTrue: [ self registryFile ensureDelete ] \ No newline at end of file + ifTrue: [ self registryFile ensureDelete ]. + self stoneDirectorySpec + ifNotNil: [ :directorySpec | + "delete the todeShared stone reference AFTER deleting the stone directory (with symbolic link) ... see internal bug 50514" + directorySpec destroyStoneStructure: self ] \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/registry.st b/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/registry.st deleted file mode 100644 index 7d7c57d8..00000000 --- a/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/registry.st +++ /dev/null @@ -1,5 +0,0 @@ -accessing -registry - ^ GDKAbstractRegistryStore - fromPath: self parentRegistryPath - ifAbsent: [ self error: 'Registry not found at ' , self parentRegistryPath printString ] \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/todeSharedDirectory.st b/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/todeSharedDirectory.st new file mode 100644 index 00000000..02c15f32 --- /dev/null +++ b/src/GsDevKit_stones-Core.package/GDKStoneSpec.class/instance/todeSharedDirectory.st @@ -0,0 +1,3 @@ +accessing +todeSharedDirectory + ^ self stonesRegistry todeSharedDirectory \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/instance/todeSharedDirectory..st b/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/instance/todeSharedDirectory..st new file mode 100644 index 00000000..e1ac68a8 --- /dev/null +++ b/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/instance/todeSharedDirectory..st @@ -0,0 +1,3 @@ +accessing +todeSharedDirectory: object + todeSharedDirectory := object \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/instance/todeSharedDirectory.st b/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/instance/todeSharedDirectory.st new file mode 100644 index 00000000..fbe8904e --- /dev/null +++ b/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/instance/todeSharedDirectory.st @@ -0,0 +1,3 @@ +accessing +todeSharedDirectory + ^todeSharedDirectory \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/properties.json b/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/properties.json index 2bf49ad3..69bbe329 100644 --- a/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/properties.json +++ b/src/GsDevKit_stones-Core.package/GDKStonesRegistry.class/properties.json @@ -7,6 +7,7 @@ "commentStamp" : "", "instvars" : [ "stones", + "todeSharedDirectory", "stonesDirectory", "sessions", "productDirectory", diff --git a/src/GsDevKit_stones-Core.package/GDKhomeStoneDirectorySpec.class/instance/createTodeSharedDirectory..st b/src/GsDevKit_stones-Core.package/GDKhomeStoneDirectorySpec.class/instance/createTodeSharedDirectory..st new file mode 100644 index 00000000..27cd370d --- /dev/null +++ b/src/GsDevKit_stones-Core.package/GDKhomeStoneDirectorySpec.class/instance/createTodeSharedDirectory..st @@ -0,0 +1,12 @@ +stone creation +createTodeSharedDirectory: stoneSpec + stoneSpec todeSharedDirectory + ifNil: [ + GsFile stdout + nextPutAll: + 'WARNING: tode shared directory is not defined, use registerTodeSharedDirectory.solo to define' ] + ifNotNil: [ :todeSharedDirectory | + | todeDir | + todeDir := todeSharedDirectory asFileReference / stoneSpec stoneName. + todeDir ensureCreateDirectory. + self class symbolicLink: todeDir linkName: stoneSpec rootDir / 'tode' ] \ No newline at end of file diff --git a/src/GsDevKit_stones-Core.package/GDKhomeStoneDirectorySpec.class/instance/destroyStoneStructure..st b/src/GsDevKit_stones-Core.package/GDKhomeStoneDirectorySpec.class/instance/destroyStoneStructure..st new file mode 100644 index 00000000..9fa9cd2c --- /dev/null +++ b/src/GsDevKit_stones-Core.package/GDKhomeStoneDirectorySpec.class/instance/destroyStoneStructure..st @@ -0,0 +1,5 @@ +stone destruction +destroyStoneStructure: stoneSpec + | todeDir | + todeDir := stoneSpec todeSharedDirectory asFileReference / stoneSpec stoneName. + todeDir ensureDeleteAll \ No newline at end of file