wip: fix gitea & postgresql installers
Co-authored-by: omda <mahmmoud.hassanein@gmail.com>
This commit is contained in:
@@ -1,20 +1,117 @@
|
||||
module gitea
|
||||
|
||||
import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.core
|
||||
// import freeflowuniverse.herolib.core.base
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.installers.ulist
|
||||
// import freeflowuniverse.herolib.osal.systemd
|
||||
import freeflowuniverse.herolib.installers.base
|
||||
import freeflowuniverse.herolib.osal.systemd
|
||||
import freeflowuniverse.herolib.osal.zinit
|
||||
import freeflowuniverse.herolib.installers.ulist
|
||||
import freeflowuniverse.herolib.installers.lang.golang
|
||||
import freeflowuniverse.herolib.installers.lang.rust
|
||||
import freeflowuniverse.herolib.installers.lang.python
|
||||
import freeflowuniverse.herolib.installers.db.postgresql as postgresinstaller
|
||||
import os
|
||||
|
||||
// checks if a certain version or above is installed
|
||||
fn installed() !bool {
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
cfg := get()!
|
||||
res := os.execute('/bin/bash -c "gitea --version"')
|
||||
if res.exit_code != 0 {
|
||||
return false
|
||||
}
|
||||
r := res.output.split(' ')
|
||||
if r.len < 3 {
|
||||
return error("couldn't parse gitea version.\n${res.output}")
|
||||
}
|
||||
if texttools.version(cfg.version) > texttools.version(r[2]) {
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
fn install() ! {
|
||||
console.print_header('install gitea')
|
||||
|
||||
if core.platform()! != .ubuntu || core.platform()! != .arch {
|
||||
return error('only support ubuntu and arch for now')
|
||||
}
|
||||
|
||||
if osal.done_exists('gitea_install') {
|
||||
console.print_header('gitea binaraies already installed')
|
||||
return
|
||||
}
|
||||
|
||||
// make sure we install base on the node
|
||||
base.install()!
|
||||
postgresinstaller.install()!
|
||||
|
||||
cfg := get()!
|
||||
version := cfg.version
|
||||
url := 'https://github.com/go-gitea/gitea/releases/download/v${version}/gitea-${version}-linux-amd64.xz'
|
||||
console.print_debug(' download ${url}')
|
||||
mut dest := osal.download(
|
||||
url: url
|
||||
minsize_kb: 40000
|
||||
reset: true
|
||||
expand_file: '/tmp/download/gitea'
|
||||
)!
|
||||
|
||||
binpath := pathlib.get_file(path: dest.path, create: false)!
|
||||
osal.cmd_add(
|
||||
cmdname: 'gitea'
|
||||
source: binpath.path
|
||||
)!
|
||||
|
||||
osal.done_set('gitea_install', 'OK')!
|
||||
|
||||
console.print_header('gitea installed properly.')
|
||||
}
|
||||
|
||||
fn build() ! {
|
||||
install()!
|
||||
}
|
||||
|
||||
fn start_pre() ! {
|
||||
}
|
||||
|
||||
fn start_post() ! {
|
||||
}
|
||||
|
||||
fn stop_pre() ! {
|
||||
}
|
||||
|
||||
fn stop_post() ! {
|
||||
}
|
||||
|
||||
fn destroy() ! {
|
||||
server := get()!
|
||||
server.stop()!
|
||||
|
||||
osal.process_kill_recursive(name: 'gitea')!
|
||||
osal.cmd_delete('gitea')!
|
||||
}
|
||||
|
||||
// get the Upload List of the files
|
||||
fn ulist_get() !ulist.UList {
|
||||
// mut installer := get()!
|
||||
// optionally build a UList which is all paths which are result of building, is then used e.g. in upload
|
||||
return ulist.UList{}
|
||||
}
|
||||
|
||||
// uploads to S3 server if configured
|
||||
fn upload() ! {
|
||||
// mut installer := get()!
|
||||
// installers.upload(
|
||||
// cmdname: 'gitea'
|
||||
// source: '${gitpath}/target/x86_64-unknown-linux-musl/release/gitea'
|
||||
// )!
|
||||
}
|
||||
|
||||
fn startupcmd() ![]zinit.ZProcessNewArgs {
|
||||
mut installer := get()!
|
||||
mut res := []zinit.ZProcessNewArgs{}
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
// res << zinit.ZProcessNewArgs{
|
||||
@@ -28,7 +125,7 @@ fn startupcmd() ![]zinit.ZProcessNewArgs {
|
||||
return res
|
||||
}
|
||||
|
||||
fn running_() !bool {
|
||||
fn running() !bool {
|
||||
mut installer := get()!
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
// this checks health of gitea
|
||||
@@ -49,140 +146,3 @@ fn running_() !bool {
|
||||
// console.print_debug('gitea is answering.')
|
||||
return false
|
||||
}
|
||||
|
||||
fn start_pre() ! {
|
||||
}
|
||||
|
||||
fn start_post() ! {
|
||||
}
|
||||
|
||||
fn stop_pre() ! {
|
||||
}
|
||||
|
||||
fn stop_post() ! {
|
||||
}
|
||||
|
||||
//////////////////// following actions are not specific to instance of the object
|
||||
|
||||
// checks if a certain version or above is installed
|
||||
fn installed_() !bool {
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
// res := os.execute('${osal.profile_path_source_and()!} gitea version')
|
||||
// if res.exit_code != 0 {
|
||||
// return false
|
||||
// }
|
||||
// r := res.output.split_into_lines().filter(it.trim_space().len > 0)
|
||||
// if r.len != 1 {
|
||||
// return error("couldn't parse gitea version.\n${res.output}")
|
||||
// }
|
||||
// if texttools.version(version) == texttools.version(r[0]) {
|
||||
// return true
|
||||
// }
|
||||
return false
|
||||
}
|
||||
|
||||
// get the Upload List of the files
|
||||
fn ulist_get() !ulist.UList {
|
||||
// optionally build a UList which is all paths which are result of building, is then used e.g. in upload
|
||||
return ulist.UList{}
|
||||
}
|
||||
|
||||
// uploads to S3 server if configured
|
||||
fn upload_() ! {
|
||||
// installers.upload(
|
||||
// cmdname: 'gitea'
|
||||
// source: '${gitpath}/target/x86_64-unknown-linux-musl/release/gitea'
|
||||
// )!
|
||||
}
|
||||
|
||||
fn install_() ! {
|
||||
console.print_header('install gitea')
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
// mut url := ''
|
||||
// if core.is_linux_arm()! {
|
||||
// url = 'https://github.com/gitea-dev/gitea/releases/download/v${version}/gitea_${version}_linux_arm64.tar.gz'
|
||||
// } else if core.is_linux_intel()! {
|
||||
// url = 'https://github.com/gitea-dev/gitea/releases/download/v${version}/gitea_${version}_linux_amd64.tar.gz'
|
||||
// } else if core.is_osx_arm()! {
|
||||
// url = 'https://github.com/gitea-dev/gitea/releases/download/v${version}/gitea_${version}_darwin_arm64.tar.gz'
|
||||
// } else if core.is_osx_intel()! {
|
||||
// url = 'https://github.com/gitea-dev/gitea/releases/download/v${version}/gitea_${version}_darwin_amd64.tar.gz'
|
||||
// } else {
|
||||
// return error('unsported platform')
|
||||
// }
|
||||
|
||||
// mut dest := osal.download(
|
||||
// url: url
|
||||
// minsize_kb: 9000
|
||||
// expand_dir: '/tmp/gitea'
|
||||
// )!
|
||||
|
||||
// //dest.moveup_single_subdir()!
|
||||
|
||||
// mut binpath := dest.file_get('gitea')!
|
||||
// osal.cmd_add(
|
||||
// cmdname: 'gitea'
|
||||
// source: binpath.path
|
||||
// )!
|
||||
}
|
||||
|
||||
fn build_() ! {
|
||||
// url := 'https://github.com/threefoldtech/gitea'
|
||||
|
||||
// make sure we install base on the node
|
||||
// if core.platform()!= .ubuntu {
|
||||
// return error('only support ubuntu for now')
|
||||
// }
|
||||
// golang.install()!
|
||||
|
||||
// console.print_header('build gitea')
|
||||
|
||||
// gitpath := gittools.get_repo(coderoot: '/tmp/builder', url: url, reset: true, pull: true)!
|
||||
|
||||
// cmd := '
|
||||
// cd ${gitpath}
|
||||
// source ~/.cargo/env
|
||||
// exit 1 #todo
|
||||
// '
|
||||
// osal.execute_stdout(cmd)!
|
||||
//
|
||||
// //now copy to the default bin path
|
||||
// mut binpath := dest.file_get('...')!
|
||||
// adds it to path
|
||||
// osal.cmd_add(
|
||||
// cmdname: 'griddriver2'
|
||||
// source: binpath.path
|
||||
// )!
|
||||
}
|
||||
|
||||
fn destroy_() ! {
|
||||
// mut systemdfactory := systemd.new()!
|
||||
// systemdfactory.destroy("zinit")!
|
||||
|
||||
// osal.process_kill_recursive(name:'zinit')!
|
||||
// osal.cmd_delete('zinit')!
|
||||
|
||||
// osal.package_remove('
|
||||
// podman
|
||||
// conmon
|
||||
// buildah
|
||||
// skopeo
|
||||
// runc
|
||||
// ')!
|
||||
|
||||
// //will remove all paths where go/bin is found
|
||||
// osal.profile_path_add_remove(paths2delete:"go/bin")!
|
||||
|
||||
// osal.rm("
|
||||
// podman
|
||||
// conmon
|
||||
// buildah
|
||||
// skopeo
|
||||
// runc
|
||||
// /var/lib/containers
|
||||
// /var/lib/podman
|
||||
// /var/lib/buildah
|
||||
// /tmp/podman
|
||||
// /tmp/conmon
|
||||
// ")!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user