Mirror list setup via a list but all are deadlinks so I need to make them.,

This commit is contained in:
chersbobers 2026-05-13 13:21:18 +12:00
parent f0634e0b8d
commit 8cc6b4d580

112
bur.v
View file

@ -12,6 +12,12 @@
import os import os
import net.http import net.http
const mirrors = [
'https://githubone/',
//'https://bur.curds.dev/mirrors/',
//'https://os.boreddev.nl/mirrors/'
]
fn main() { fn main() {
args := os.args args := os.args
@ -40,6 +46,13 @@ fn main() {
} }
upgrade_function(args[2]) upgrade_function(args[2])
} }
'remove' {
if args.len < 3 {
println('error: please provide a package name')
return
}
remove_function(args[2])
}
else { else {
println('commands: bur [install|update|upgrade|remove]') println('commands: bur [install|update|upgrade|remove]')
} }
@ -47,20 +60,33 @@ fn main() {
} }
fn install_function(name string) { fn install_function(name string) {
url := 'needtoadd' + name + '.c' mut success := false
resp := http.get(url) or { for mirror in mirrors {
println('error couldnt connect to server sorry!!') url := mirror + name + '.c'
return println('trying mirror: $mirror')
resp := http.get(url) or {
println('mirror down skipping...')
continue
}
if resp.status_code != 200 {
println('not found on this mirror skipping...')
continue
}
os.write_file('/tmp/$name.c', resp.body) or {
println('error failed writing to tmp ')
return
}
success = true
break
} }
if resp.status_code != 200 { if !success {
println('error package $name not found! 404') println('error: $name not found on any mirrors!')
return
}
os.write_file('/tmp/$name.c', resp.body) or {
println('error failed writing to tmp ')
return return
} }
@ -80,33 +106,48 @@ fn install_function(name string) {
fn update_function() { fn update_function() {
println('checking mirror for upds') println('checking mirror for upds')
mut success := false
manifest_url := 'https://inserthis/manifest.txt' for mirror in mirrors {
resp := http.get(manifest_url) or { manifest_url := mirror + 'manifest.txt'
println('sorry could not reach the server') resp := http.get(manifest_url) or { continue }
return
} if resp.status_code != 200 { continue }
if resp.status_code != 200 { os.mkdir_all('/var/db/bur/') or { }
println('error failed to fetch the package list') os.write_file('/var/db/bur/manifest.txt', resp.body) or {
return println('failed to save manifest :(')
return
}
success = true
break
} }
os.mkdir_all('/var/db/bur/') or { } if success {
os.write_file('/var/db/bur/manifest.txt', resp.body) or { println('done! packge list refreshed run bur upgrade [name] to see if it needs a upd')
println('failed to save manifest :(') } else {
return println('error: could not update from any mirrors')
} }
println('done! packge list refreshed run bur upgrade [name] to see if it needs a upd')
} }
fn upgrade_function(name string) { fn upgrade_function(name string) {
hash_url := 'https://inserthis/' + name + '.hash' mut remote_hash := ''
resp := http.get(hash_url) or { mut success := false
println('error: could not check remote hash')
return for mirror in mirrors {
hash_url := mirror + name + '.hash'
resp := http.get(hash_url) or { continue }
if resp.status_code != 200 { continue }
remote_hash = resp.body.trim_space()
success = true
break
}
if !success {
println('error: could not check remote hash on any mirror')
return
} }
remote_hash := resp.body.trim_space()
hash_path := '/var/db/bur/' + name + '.hash' hash_path := '/var/db/bur/' + name + '.hash'
if os.exists(hash_path) { if os.exists(hash_path) {
@ -126,14 +167,9 @@ fn upgrade_function(name string) {
} }
fn remove_function(name string) { fn remove_function(name string) {
if name == '' {
println('hey say a package to remove!')
return
}
println('removing $name play the bugle ;_;') println('removing $name play the bugle ;_;')
executable_path:= '/bin/$name.elf' executable_path := '/bin/$name.elf'
if os.exists(executable_path) { if os.exists(executable_path) {
os.rm(executable_path) or { os.rm(executable_path) or {
println('oh crud could not remove the binary') println('oh crud could not remove the binary')
@ -142,7 +178,7 @@ fn remove_function(name string) {
println('HEY $name.elf was not found in /bin/!') println('HEY $name.elf was not found in /bin/!')
} }
hash_path := '/var/db/bur' + name + '.hash' hash_path := '/var/db/bur/' + name + '.hash'
if os.exists(hash_path) { if os.exists(hash_path) {
os.rm(hash_path) or { } os.rm(hash_path) or { }
} }
@ -150,4 +186,4 @@ fn remove_function(name string) {
println('rip $name it has been removed') println('rip $name it has been removed')
} }
//yello this is the bottom of the file // yello this is the bottom of the file