Update griddriver to use prebuilt binary

This commit is contained in:
Scott Yeager
2025-03-06 18:26:33 -08:00
parent 30546a34f9
commit 0fa54f1354
4 changed files with 42 additions and 49 deletions

View File

@@ -1,10 +1,10 @@
module griddriver module griddriver
import freeflowuniverse.herolib.osal
import freeflowuniverse.herolib.ui.console import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.installers.ulist import freeflowuniverse.herolib.installers.ulist
import freeflowuniverse.herolib.installers.lang.golang
import freeflowuniverse.herolib.develop.gittools
import os import os
// checks if a certain version or above is installed // checks if a certain version or above is installed
@@ -35,45 +35,36 @@ fn ulist_get() !ulist.UList {
fn upload() ! {} fn upload() ! {}
fn install() ! { fn install() ! {
console.print_header('install griddriver') console.print_header('installing griddriver')
panic("to implement") mut url := ''
console.print_header('install griddriver OK') if core.is_linux_arm()! {
} url = 'https://github.com/threefoldtech/griddriver/releases/download/v${version}/griddriver_${version}_linux_arm64'
} else if core.is_linux_intel()! {
fn build() ! { url = 'https://github.com/threefoldtech/griddriver/releases/download/v${version}/griddriver_${version}_linux_amd64'
console.print_header('build griddriver') } else if core.is_osx_arm()! {
mut installer := golang.get()! url = 'https://github.com/threefoldtech/griddriver/releases/download/v${version}/griddriver_${version}_darwin_arm64'
installer.install()! } else if core.is_osx_intel()! {
url = 'https://github.com/threefoldtech/griddriver/releases/download/v${version}/griddriver_${version}_darwin_amd64'
mut gs := gittools.get()! } else {
url := 'https://github.com/threefoldtech/web3gw/tree/development_integration/griddriver' return error('unsported platform')
mut repo := gs.get_repo(
url: url
reset: true
pull: true
)!
mut path := repo.path()
path = '${path}/griddriver'
cmd := '/bin/bash -c "cd ${path} && . ${path}/build.sh"'
res := os.execute(cmd)
if res.exit_code != 0 {
return error('failed to build: ${res.output}')
} }
console.print_header('build griddriver OK') mut dest := osal.download(
url: url
minsize_kb: 1000
)!
osal.cmd_add(
cmdname: 'griddriver'
source: dest.path
)!
console.print_header('install griddriver OK')
} }
fn destroy() ! { fn destroy() ! {
console.print_header('uninstall griddriver') console.print_header('uninstall griddriver')
mut res := os.execute('sudo rm -rf /usr/local/bin/griddriver') binpath := osal.bin_path()!
if res.exit_code != 0 { mut res := os.execute('sudo rm -rf ${binpath}/griddriver')
return error('failed to uninstall griddriver: ${res.output}')
}
res = os.execute('sudo rm -rf ~/code/github/threefoldtech/web3gw')
if res.exit_code != 0 { if res.exit_code != 0 {
return error('failed to uninstall griddriver: ${res.output}') return error('failed to uninstall griddriver: ${res.output}')
} }

View File

@@ -91,11 +91,6 @@ pub fn (mut self GridDriverInstaller) install(args InstallArgs) ! {
} }
} }
pub fn (mut self GridDriverInstaller) build() ! {
switch(self.name)
build()!
}
pub fn (mut self GridDriverInstaller) destroy() ! { pub fn (mut self GridDriverInstaller) destroy() ! {
switch(self.name) switch(self.name)
destroy()! destroy()!

View File

@@ -2,7 +2,7 @@ module griddriver
import freeflowuniverse.herolib.data.encoderhero import freeflowuniverse.herolib.data.encoderhero
pub const version = '0.1.1' pub const version = '0.1.2'
const singleton = true const singleton = true
const default = true const default = true

View File

@@ -1,18 +1,25 @@
# griddriver # griddriver
To use the installer:
To get started
```vlang ```vlang
import freeflowuniverse.herolib.installers.threefold.griddriver import freeflowuniverse.herolib.installers.threefold.griddriver
mut installer:= griddriver.get()! fn main() {
mut installer := griddriver.get()!
installer.install()!
}
```
installer.start()! ## example heroscript
```hero
!!griddriver.install
homedir: '/home/user/griddriver'
username: 'admin'
password: 'secretpassword'
title: 'Some Title'
host: 'localhost'
port: 8888
``` ```