Merge pull request #176 from weynandkuijpers/development_wk

added fedora for the package install for hero execution
This commit is contained in:
Omdanii
2025-10-12 12:31:39 +03:00
committed by GitHub
4 changed files with 32 additions and 9 deletions

View File

@@ -64,9 +64,9 @@ compile_cmd := if os.user_os() == 'macos' {
}
} else {
if prod_mode {
'v -cg -enable-globals -parallel-cc -w -n hero.v'
'v -cg -enable-globals -parallel-cc -w -n -d use_openssl hero.v'
} else {
'v -cg -enable-globals -w -n hero.v'
'v -cg -enable-globals -w -n -d use_openssl hero.v'
}
}

View File

@@ -64,12 +64,12 @@ os.rm('${os.home_dir()}/.vmodules/freeflowuniverse/herolib') or {}
os.rm('${os.home_dir()}/.vmodules/${org_name}/herolib') or {}
// Create necessary directories
os.mkdir_all('${os.home_dir()}/.vmodules/${org_name}') or {
panic('Failed to create directory ~/.vmodules/${org_name}: ${err}')
os.mkdir_all('${os.home_dir()}/.vmodules/freeflowuniverse') or {
panic('Failed to create directory ~/.vmodules/freeflowuniverse: ${err}')
}
// Create new symlinks
os.symlink('${abs_dir_of_script}/lib', '${os.home_dir()}/.vmodules/${org_name}/herolib') or {
os.symlink('${abs_dir_of_script}/lib', '${os.home_dir()}/.vmodules/freeflowuniverse/herolib') or {
panic('Failed to create herolib symlink: ${err}')
}

View File

@@ -12,6 +12,7 @@ pub enum PlatformType {
alpine
arch
suse
fedora
}
pub fn platform_enum_from_string(platform string) PlatformType {
@@ -20,6 +21,8 @@ pub fn platform_enum_from_string(platform string) PlatformType {
'ubuntu' { .ubuntu }
'alpine' { .alpine }
'arch' { .arch }
'suse' { .suse }
'fedora' { .fedora }
else { .unknown }
}
}
@@ -66,6 +69,8 @@ pub fn platform() !PlatformType {
platform_ = PlatformType.alpine
} else if cmd_exists('pacman') {
platform_ = PlatformType.arch
} else if cmd_exists('dnf') {
platform_ = PlatformType.fedora
} else {
return error('Unknown platform')
}
@@ -126,7 +131,7 @@ pub fn is_ubuntu() !bool {
pub fn is_linux() !bool {
return platform()! == .ubuntu || platform()! == .arch || platform()! == .suse
|| platform()! == .alpine
|| platform()! == .alpine || platform()! == .fedora
}
pub fn is_linux_arm() !bool {

View File

@@ -38,9 +38,15 @@ pub fn package_refresh() ! {
return error('Could not update packages for Arch Linux\nerror:\n${err}')
}
return
} else if platform_ == .fedora {
// Refresh the package list for Fedora
exec(cmd: 'sudo dnf check-update') or {
return error('Could not update packages for Fedora\nerror:\n${err}')
}
return
}
return error("Only ubuntu, alpine, arch, and osx are supported for now. Found \"${platform_}\"")
return error("Only ubuntu, alpine, arch, fedora, and osx are supported for now. Found \"${platform_}\"")
}
// install a package using the right commands per platform
@@ -78,8 +84,12 @@ pub fn package_install(name_ string) ! {
exec(cmd: '${sudo_pre}pacman --noconfirm -Su ${name}') or {
return error('could not install package on Arch: ${name}\nerror:\n${err}')
}
} else if platform_ == .fedora {
exec(cmd: '${sudo_pre}dnf install -y ${name}') or {
return error('could not install package on Fedora: ${name}\nerror:\n${err}')
}
} else {
return error('Only ubuntu, alpine, arch, and osx supported for now')
return error('Only ubuntu, alpine, arch, fedora, and osx supported for now')
}
}
@@ -131,7 +141,15 @@ pub fn package_remove(name_ string) ! {
'pacman --noconfirm -R ${name}'
}
exec(cmd: cmd, ignore_error: true)!
} else if platform_ == .fedora {
// Use sudo if required
cmd := if use_sudo {
'sudo dnf remove -y ${name}'
} else {
'dnf remove -y ${name}'
}
exec(cmd: cmd, ignore_error: true)!
} else {
return error('Only ubuntu, alpine, and osx supported for now')
return error('Only ubuntu, alpine, arch, fedora, and osx supported for now')
}
}