ggolang install ok

This commit is contained in:
2025-01-01 15:25:58 +01:00
parent 914e1f5073
commit b927fc5b5d
6 changed files with 36 additions and 15 deletions

View File

@@ -39,4 +39,4 @@ core.interactive_set()! //make sure the sudo works so we can do things even if i
// rust.install(reset:false)! // rust.install(reset:false)!
// python.install(reset:false)! // python.install(reset:false)!
// nodejs.install(reset:false)! // nodejs.install(reset:false)!
golang.install(reset:true)! golang.install(reset:false)!

View File

@@ -73,6 +73,7 @@ value := core.memdb_get('key')
``` ```
### Sudo Operations ### Sudo Operations
```v ```v
// Check sudo requirements // Check sudo requirements
if core.sudo_required()! { if core.sudo_required()! {

View File

@@ -24,8 +24,6 @@ fn installed_() !bool {
vstring = vstring.all_after_first('version').all_after_first('go').all_before(' ').trim_space() vstring = vstring.all_after_first('version').all_after_first('go').all_before(' ').trim_space()
v := texttools.version(vstring) v := texttools.version(vstring)
println(vstring)
println(v)
if v >= texttools.version(version) { if v >= texttools.version(version) {
return true return true
} }
@@ -59,11 +57,8 @@ fn install_() ! {
minsize_kb: 40000 minsize_kb: 40000
expand_dir: expand_dir expand_dir: expand_dir
)! )!
println(dest)
if true{exit(0)}
go_dest := '${osal.usr_local_path()!}/go' go_dest := '${osal.usr_local_path()!}/go'
println(go_dest)
os.mv('${expand_dir}/go', go_dest)! os.mv('${expand_dir}/go', go_dest)!
os.rmdir_all(expand_dir)! os.rmdir_all(expand_dir)!
osal.profile_path_add_remove(paths2add: '${go_dest}/bin')! osal.profile_path_add_remove(paths2add: '${go_dest}/bin')!
@@ -90,7 +85,7 @@ fn destroy_() ! {
osal.rm(' osal.rm('
#next will find go as a binary and remove is like cmd delete #next will find go as a binary and remove is like cmd delete
~/hero/bin/go ~/hero/bin/go
#/usr/local/go /usr/local/go
/root/hero/bin/go /root/hero/bin/go
~/.go ~/.go
~/go ~/go

View File

@@ -245,7 +245,16 @@ pub fn cmd_delete(cmd string) ! {
res := cmd_path(cmd2) or { '' } res := cmd_path(cmd2) or { '' }
if res.len > 0 { if res.len > 0 {
if os.exists(res) { if os.exists(res) {
os.rm(res)! if core.sudo_path_ok(res)!{
os.rm(res)!
}else{
if core.interactive()!{
execute_silent("sudo rm -rf ${res}")!
}else{
return error("can't remove ${res} as sudo because non interactive as part of cmd delete.")
}
}
} }
} }
} }

View File

@@ -42,20 +42,37 @@ pub fn rm(todelete_ string) ! {
if item.trim_space() == ''|| item.trim_space().starts_with("#"){ if item.trim_space() == ''|| item.trim_space().starts_with("#"){
continue continue
} }
if item.len <2{
return error("not allowed to remove anything with less than 2 chars. ${item}")
}
item = item.replace('~', os.home_dir()) item = item.replace('~', os.home_dir())
console.print_debug(' - rm: ${item}') console.print_debug(' - rm: ${item}')
if item.starts_with('/') { if item.starts_with('/') {
if os.exists(item) { if os.exists(item) {
if os.is_dir(item) { if os.is_dir(item) {
if core.sudo_path_ok(item)!{
//console.print_debug("rm deletedir: ${item}") //console.print_debug("rm deletedir: ${item}")
os.rmdir_all(core.sudo_path_check(item)!)! os.rmdir_all(item)!
}else{
if core.interactive()!{
execute_silent("sudo rm -rf ${item}")!
}else{
return error("can't remove ${item} as sudo because non interactive")
}
}
} else { } else {
//console.print_debug("rm delete file: ${item}") //console.print_debug("rm delete file: ${item}")
if core.sudo_path_ok(item)!{ if core.sudo_path_ok(item)!{
os.rm(item)! os.rm(item)!
}else{ }else{
if core.interactive()!{
execute_silent("sudo rm -f ${item}")!
}else{
return error("can't remove ${item} as sudo because non interactive")
}
} }
} }

View File

@@ -1,9 +1,8 @@
module docker module docker
import freeflowuniverse.herolib.osal { cputype, exec, platform } import freeflowuniverse.herolib.osal {exec}
import freeflowuniverse.herolib.core.texttools import freeflowuniverse.herolib.core.texttools
import freeflowuniverse.herolib.virt.utils import freeflowuniverse.herolib.virt.utils
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.core import freeflowuniverse.herolib.core
// import freeflowuniverse.herolib.installers.swarm // import freeflowuniverse.herolib.installers.swarm
@@ -38,9 +37,9 @@ pub fn (mut e DockerEngine) init() ! {
exec(cmd: 'mkdir -p ${e.buildpath}', stdout: false)! exec(cmd: 'mkdir -p ${e.buildpath}', stdout: false)!
} }
if e.platform == [] { if e.platform == [] {
if core.platform()! == .ubuntu && cputype()! == .intel { if core.platform()! == .ubuntu && core.cputype()! == .intel {
e.platform = [.linux_amd64] e.platform = [.linux_amd64]
} else if core.platform()! == .osx && cputype()! == .arm { } else if core.platform()! == .osx && core.cputype()! == .arm {
e.platform = [.linux_arm64] e.platform = [.linux_arm64]
} else { } else {
return error('only implemented ubuntu on amd and osx on arm for now for docker engine.') return error('only implemented ubuntu on amd and osx on arm for now for docker engine.')