ExternalApp now makes part of this, instead

of the Grafoscopio Model.
This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-07-05 11:38:57 +00:00
parent 8b29956392
commit 945883ede9

View File

@ -0,0 +1,201 @@
"
I provide support for external helper apps for Grafoscopio, publishing, collaboration
and data management.
"
Class {
#name : #ExternalApp,
#superclass : #Object,
#instVars : [
'name',
'url',
'downloadUrl',
'description',
'sha1',
'md5',
'binaryLocation'
],
#category : #'Grafoscopio-Utils'
}
{ #category : #installation }
ExternalApp class >> compareHashFor: aFileName with: aSHAString [
aSHAString = (SHA1 new hashMessage: aFileName asFileReference binaryReadStream contents) hex
ifFalse: [ ^ false ]
ifTrue: [ ^ true ].
]
{ #category : #configuration }
ExternalApp class >> configureFossil [
"Stablish where is located fossil according to the operative system and/or the input of the user"
| fileStream fossil |
fileStream := UIManager default fileOpen: 'Path to the fossil program binary'.
fileStream isNil ifTrue: [ ^nil ].
fossil := fileStream name asFileReference fullName.
]
{ #category : #configuration }
ExternalApp class >> configurePandoc [
"Stablish where is located pandoc according to the operative system and/or the input of the user"
| fileStream pandoc |
fileStream := UIManager default fileOpen: 'Path to pandoc program binary'.
fileStream isNil ifTrue: [ ^nil ].
pandoc := fileStream name asFileReference fullName.
]
{ #category : #installation }
ExternalApp class >> installSQLite32Bits [
"I dowload the SQLite binary for the hosting platform, uncompress it and made it available as with the name
NBSQLite is wating for"
| packageUrl sha1 localPath packageZipName unzippedFolder |
localPath := FileSystem disk workingDirectory parent / 'bin'.
Smalltalk platform name = 'unix'
ifTrue: [
packageUrl := 'http://sqlite.org/2016/sqlite-tools-linux-x86-3110100.zip'.
sha1 := '21a80cefa91d5de50256996fc55990a027c350fd'].
Smalltalk platform name = 'Win32'
ifTrue: [
packageUrl := 'http://sqlite.org/2016/sqlite-dll-win32-x86-3110100.zip'.
sha1 := 'cfd6f64ba1fb5de1ccf8321e29764c690c25e0a0'].
Smalltalk platform name = 'Mac OS'
ifTrue: [
packageUrl := 'http://sqlite.org/2016/sqlite-tools-osx-x86-3110100.zip'.
sha1 := 'c78b3b92bd37554694d2f73dbecfef1902c15ba7'].
self isSQLite32BitsInstalled
ifTrue: [ self inform: 'SQLite ya está instalado en el sistema' ]
ifFalse: [
GrafoscopioBrowser
downloadingFrom: packageUrl
withMessage: 'Descargando SQLite...'
into: localPath asFileReference.
packageZipName := (packageUrl splitOn: '/') last.
sha1 = (SHA1 new hashMessage: (localPath / packageZipName) asFileReference binaryReadStream contents) hex
ifFalse: [ self inform: 'SQLite: Descarga no exitosa.
Por favor intente el procedimiento de nuevo o manualmente']
ifTrue: [
ZipArchive new
readFrom: (localPath / packageZipName);
extractAllTo: localPath asFileReference.
unzippedFolder := packageZipName copyReplaceAll: '.zip' with: ''.
(localPath / unzippedFolder ) children do:
[:file | file moveTo: (localPath / file basenameWithIndicator)].
(localPath / 'sqlite3') copyTo: (localPath / 'libsqlite3.so').
(localPath / unzippedFolder ) deleteAll.
self inform: 'SQLite instalado existosammente!'
].
"Cleaning leftovers"
(localPath / packageZipName) delete
]
]
{ #category : #configuration }
ExternalApp class >> installSQLite32BitsUI [
"I verify if SQLite for 32 bits is installed in the proper location. If yes, I inform that. If not,
I made the installation"
| install |
install := (UIManager default
confirm: '¿Desea instalar el motor de base de datos (SQLite)?'
label: 'Instalar base de datos?').
install ifTrue: [self installSQLite32Bits]
]
{ #category : #installation }
ExternalApp class >> isSQLite32BitsInstalled [
"I verify if the SQLite binary for the hosting platform is installed"
^ (FileSystem disk workingDirectory parent / 'bin' / 'libsqlite3.so') asFileReference exists
]
{ #category : #configuration }
ExternalApp class >> pandoc [
"I define where the pandoc external app is located"
| app |
app := ExternalApp new
name: 'pandoc';
url: 'http://pandoc.org';
description: 'Pandoc is a free and open-source software document converter, widely used as a writing tool (especially by scholars) and as a basis for publishing workflows. It was originally created by John MacFarlane, a philosophy professor at the University of California, Berkeley. (from https://en.wikipedia.org/wiki/Pandoc)'.
app binaryLocation: '/usr/bin/pandoc' asFileReference.
^ app
]
{ #category : #accessing }
ExternalApp >> binaryLocation [
^ binaryLocation
]
{ #category : #accessing }
ExternalApp >> binaryLocation: anObject [
binaryLocation := anObject
]
{ #category : #accessing }
ExternalApp >> description [
^ description
]
{ #category : #accessing }
ExternalApp >> description: anObject [
description := anObject
]
{ #category : #accessing }
ExternalApp >> downloadUrl [
^ downloadUrl
]
{ #category : #accessing }
ExternalApp >> downloadUrl: anObject [
downloadUrl := anObject
]
{ #category : #accessing }
ExternalApp >> md5 [
^ md5
]
{ #category : #accessing }
ExternalApp >> md5: anObject [
md5 := anObject
]
{ #category : #accessing }
ExternalApp >> name [
^ name
]
{ #category : #accessing }
ExternalApp >> name: anObject [
name := anObject
]
{ #category : #accessing }
ExternalApp >> sha1 [
^ sha1
]
{ #category : #accessing }
ExternalApp >> sha1: anObject [
sha1 := anObject
]
{ #category : #accessing }
ExternalApp >> url [
^ url
]
{ #category : #accessing }
ExternalApp >> url: anObject [
url := anObject
]