feat: Add Buildah installer
- Added a Buildah installer to the project. - The installer can install and remove Buildah. - Updated the installer to use the latest Buildah version. Co-authored-by: mahmmoud.hassanein <mahmmoud.hassanein@gmail.com> Co-authored-by: mariobassem <mariobassem12@gmail.com>
This commit is contained in:
11
examples/installers/buildah.vsh
Executable file
11
examples/installers/buildah.vsh
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||||
|
|
||||||
|
import freeflowuniverse.herolib.installers.virt.buildah as buildah_installer
|
||||||
|
|
||||||
|
mut buildah := buildah_installer.get()!
|
||||||
|
|
||||||
|
// To install
|
||||||
|
buildah.install()!
|
||||||
|
|
||||||
|
// To remove
|
||||||
|
buildah.destroy()!
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
!!hero_code.generate_installer
|
!!hero_code.generate_installer
|
||||||
name:'buildah'
|
name:'buildah'
|
||||||
classname:'BuildahInstaller'
|
classname:'BuildahInstaller'
|
||||||
@@ -10,4 +9,4 @@
|
|||||||
reset:0
|
reset:0
|
||||||
startupmanager:0
|
startupmanager:0
|
||||||
hasconfig:0
|
hasconfig:0
|
||||||
build:1
|
build:0
|
||||||
@@ -2,59 +2,26 @@ module buildah
|
|||||||
|
|
||||||
import freeflowuniverse.herolib.osal
|
import freeflowuniverse.herolib.osal
|
||||||
import freeflowuniverse.herolib.ui.console
|
import freeflowuniverse.herolib.ui.console
|
||||||
import freeflowuniverse.herolib.core.texttools
|
|
||||||
import freeflowuniverse.herolib.installers.ulist
|
import freeflowuniverse.herolib.installers.ulist
|
||||||
import freeflowuniverse.herolib.installers.lang.golang
|
import freeflowuniverse.herolib.core
|
||||||
import os
|
|
||||||
|
|
||||||
// checks if a certain version or above is installed
|
// checks if a certain version or above is installed
|
||||||
fn installed_() !bool {
|
fn installed() !bool {
|
||||||
res := os.execute('${osal.profile_path_source_and()!} buildah -v')
|
osal.execute_silent('buildah -v') or { return false }
|
||||||
if res.exit_code != 0 {
|
|
||||||
return false
|
return true
|
||||||
}
|
|
||||||
r := res.output.split_into_lines().filter(it.trim_space().len > 0)
|
|
||||||
if r.len != 1 {
|
|
||||||
return error("couldn't parse herocontainers version, expected 'buildah -v' on 1 row.\n${res.output}")
|
|
||||||
}
|
|
||||||
v := texttools.version(r[0].all_after('version').all_before('(').replace('-dev', ''))
|
|
||||||
if texttools.version(version) == v {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn install_() ! {
|
fn install() ! {
|
||||||
console.print_header('install buildah')
|
console.print_header('install buildah')
|
||||||
build()!
|
if core.platform()! != .ubuntu {
|
||||||
}
|
return error('Only ubuntu is supported for now')
|
||||||
|
}
|
||||||
|
|
||||||
fn build_() ! {
|
cmd := 'sudo apt-get -y update && sudo apt-get -y install buildah'
|
||||||
console.print_header('build buildah')
|
|
||||||
|
|
||||||
osal.package_install('runc,bats,btrfs-progs,git,go-md2man,libapparmor-dev,libglib2.0-dev,libgpgme11-dev,libseccomp-dev,libselinux1-dev,make,skopeo,libbtrfs-dev')!
|
|
||||||
|
|
||||||
mut g := golang.get()!
|
|
||||||
g.install()!
|
|
||||||
|
|
||||||
cmd := '
|
|
||||||
cd /tmp
|
|
||||||
rm -rf buildah
|
|
||||||
git clone https://github.com/containers/buildah
|
|
||||||
cd buildah
|
|
||||||
make SECURITYTAGS="apparmor seccomp"
|
|
||||||
'
|
|
||||||
osal.execute_stdout(cmd)!
|
osal.execute_stdout(cmd)!
|
||||||
|
|
||||||
// now copy to the default bin path
|
console.print_header('Buildah Installed Successfuly')
|
||||||
osal.cmd_add(
|
|
||||||
cmdname: 'buildah'
|
|
||||||
source: '/tmp/buildah/bin/buildah'
|
|
||||||
)!
|
|
||||||
|
|
||||||
osal.rm('
|
|
||||||
/tmp/buildah
|
|
||||||
')!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the Upload List of the files
|
// get the Upload List of the files
|
||||||
@@ -64,17 +31,6 @@ fn ulist_get() !ulist.UList {
|
|||||||
return ulist.UList{}
|
return ulist.UList{}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn destroy_() ! {
|
fn destroy() ! {
|
||||||
osal.package_remove('
|
osal.execute_stdout('sudo apt remove --purge -y buildah')!
|
||||||
buildah
|
|
||||||
')!
|
|
||||||
|
|
||||||
// will remove all paths where go/bin is found
|
|
||||||
osal.profile_path_add_remove(paths2delete: 'go/bin')!
|
|
||||||
|
|
||||||
osal.rm('
|
|
||||||
buildah
|
|
||||||
/var/lib/buildah
|
|
||||||
/tmp/buildah
|
|
||||||
')!
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,29 +14,61 @@ __global (
|
|||||||
|
|
||||||
/////////FACTORY
|
/////////FACTORY
|
||||||
|
|
||||||
|
@[params]
|
||||||
|
pub struct ArgsGet {
|
||||||
|
pub mut:
|
||||||
|
name string
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get(args_ ArgsGet) !&BuildahInstaller {
|
||||||
|
return &BuildahInstaller{}
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
|
//////////////////////////# LIVE CYCLE MANAGEMENT FOR INSTALLERS ///////////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
fn startupmanager_get(cat zinit.StartupManagerType) !startupmanager.StartupManager {
|
||||||
|
// unknown
|
||||||
|
// screen
|
||||||
|
// zinit
|
||||||
|
// tmux
|
||||||
|
// systemd
|
||||||
|
match cat {
|
||||||
|
.zinit {
|
||||||
|
console.print_debug('startupmanager: zinit')
|
||||||
|
return startupmanager.get(cat: .zinit)!
|
||||||
|
}
|
||||||
|
.systemd {
|
||||||
|
console.print_debug('startupmanager: systemd')
|
||||||
|
return startupmanager.get(cat: .systemd)!
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.print_debug('startupmanager: auto')
|
||||||
|
return startupmanager.get()!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@[params]
|
@[params]
|
||||||
pub struct InstallArgs {
|
pub struct InstallArgs {
|
||||||
pub mut:
|
pub mut:
|
||||||
reset bool
|
reset bool
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn install(args InstallArgs) ! {
|
pub fn (mut self BuildahInstaller) install(args InstallArgs) ! {
|
||||||
if args.reset {
|
switch(self.name)
|
||||||
destroy()!
|
if args.reset || (!installed()!) {
|
||||||
}
|
install()!
|
||||||
if !(installed_()!) {
|
|
||||||
install_()!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn destroy() ! {
|
pub fn (mut self BuildahInstaller) destroy() ! {
|
||||||
destroy_()!
|
switch(self.name)
|
||||||
|
destroy()!
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build() ! {
|
// switch instance to be used for buildah
|
||||||
build_()!
|
pub fn switch(name string) {
|
||||||
|
buildah_default = name
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
module buildah
|
module buildah
|
||||||
|
|
||||||
pub const version = '1.38.0'
|
|
||||||
const singleton = true
|
const singleton = true
|
||||||
const default = true
|
const default = true
|
||||||
|
|
||||||
|
// THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED
|
||||||
|
@[heap]
|
||||||
pub struct BuildahInstaller {
|
pub struct BuildahInstaller {
|
||||||
pub mut:
|
pub mut:
|
||||||
name string = 'default'
|
name string = 'default'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn obj_init(obj_ BuildahInstaller) !BuildahInstaller {
|
fn obj_init(obj_ BuildahInstaller) !BuildahInstaller {
|
||||||
|
// never call get here, only thing we can do here is work on object itself
|
||||||
mut obj := obj_
|
mut obj := obj_
|
||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// called before start if done
|
||||||
fn configure() ! {
|
fn configure() ! {
|
||||||
|
// mut installer := get()!
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user