Update and upgrade v 0.0001

This commit is contained in:
chersbobers 2026-05-13 12:53:24 +12:00
parent b267ddf8b5
commit 3eb780ae4f
2 changed files with 73 additions and 4 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.exe

74
bur.v
View file

@ -1,3 +1,14 @@
/*
*
*
*
*
*
*
*
* ascii art from: https://patorjk.com/software/taag/ :)
*/
import os import os
import net.http import net.http
@ -5,7 +16,7 @@ fn main() {
args := os.args args := os.args
if args.len < 2 { if args.len < 2 {
println('commands: bur [install|update|remove]') println('commands: bur [install|update|upgrade|remove]')
return return
} }
@ -19,8 +30,15 @@ fn main() {
} }
install_function(args[2]) install_function(args[2])
} }
'upgrade' {
if args.len < 3 {
println('error: please provide a package name')
return
}
upgrade_function(args[2])
}
else { else {
println('unknown command') println('commands: bur [install|update|upgrade|remove]')
} }
} }
} }
@ -29,7 +47,7 @@ fn install_function(name string) {
url := 'needtoadd' + name + '.c' url := 'needtoadd' + name + '.c'
resp := http.get(url) or { resp := http.get(url) or {
println('error couldnt connect to server sorry!!;') println('error couldnt connect to server sorry!!')
return return
} }
@ -56,3 +74,53 @@ fn install_function(name string) {
println(res.output) println(res.output)
} }
} }
fn update_function() {
println('checking mirror for upd's)
manifest_url := 'https://inserthis/manifest.txt'
resp := http.get(manifest_url) or {
println('sorry could not reach the server')
return
}
if resp.status_code != 200 {
println('error failed to fetch the package list')
return
}
os.mkdir_all('/var/db/bur/') or { }
os.write_file('/var/db/bur/manifest.txt', resp.body) or {
println('failed to save manifest :(')
return
}
println('done! packge list refreshed run bur upgrade [name] to see if it needs a upd')
}
fn upgrade_function(name string) {
hash_url := 'https://inserthis/' + name + '.hash'
resp := http.get(hash_url) or {
println('error: could not check remote hash')
return
}
remote_hash := resp.body.trim_space()
hash_path := '/var/db/bur/' + name + '.hash'
if os.exists(hash_path) {
local_hash := os.read_file(hash_path) or { '' }.trim_space()
if local_hash == remote_hash {
println('$name is latest version not upgrading')
return
}
}
println('new version of $name found upgrading now')
install_function(name)
os.mkdir_all('/var/db/bur/') or { }
os.write_file(hash_path, remote_hash) or { }
}
//yello this is the bottom of the file