Skip to content

Commit

Permalink
Issue #4: implement registerTodeSharedDir.solo ... still a bit more t…
Browse files Browse the repository at this point in the history
…ode work to do ... clean up STONES_DATA_HOME definition ... can use customenv to run topaz in stone directory and run solo scripts
  • Loading branch information
dalehenrich committed Jun 2, 2023
1 parent c3853ae commit 3db2a55
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 13 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
```

Expand Down
63 changes: 63 additions & 0 deletions bin/registerTodeSharedDir.solo
Original file line number Diff line number Diff line change
@@ -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=<registry-name> --todeSharedDirectory=<path-to-shared-tode-directory>

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.

%
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
stone creation
createTodeSharedDirectory: stoneSpec
"noop by default ... see GDKhomeStoneDirectorySpec"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
stone destruction
destroyStoneStructure: stoneSpec
"noop"
Original file line number Diff line number Diff line change
Expand Up @@ -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
self stoneDirectorySpec: stoneDirSpec ]
on: Error
do: [ :ex | self rootDir deleteAllChildren ]
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
runtime
defineCustomEnvVars
self stoneDirectorySpec customenv
ifNotNil: [ :customenv |
customenv
keysAndValuesDo: [ :varName :valueStr | System gemEnvironmentVariable: varName put: valueStr ] ]
self stoneDirectorySpec
ifNotNil: [ :dirSpec |
dirSpec customenv
ifNotNil: [ :customenv |
customenv
keysAndValuesDo: [ :varName :valueStr | System gemEnvironmentVariable: varName put: valueStr ] ] ]
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,8 @@ destroyStoneStructure
self rootDir exists
ifTrue: [ self rootDir ensureDeleteAll ].
self registryFile exists
ifTrue: [ self registryFile ensureDelete ]
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 ]

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
todeSharedDirectory
^ self stonesRegistry todeSharedDirectory
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
todeSharedDirectory: object
todeSharedDirectory := object
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
accessing
todeSharedDirectory
^todeSharedDirectory
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"commentStamp" : "",
"instvars" : [
"stones",
"todeSharedDirectory",
"stonesDirectory",
"sessions",
"productDirectory",
Expand Down
Original file line number Diff line number Diff line change
@@ -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' ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
stone destruction
destroyStoneStructure: stoneSpec
| todeDir |
todeDir := stoneSpec todeSharedDirectory asFileReference / stoneSpec stoneName.
todeDir ensureDeleteAll

0 comments on commit 3db2a55

Please sign in to comment.