80 lines
1.3 KiB
Plaintext
Executable File
80 lines
1.3 KiB
Plaintext
Executable File
#!/usr/bin/env ground
|
|
|
|
# dig package manager
|
|
# this is a simple package manager for the Ground programming language
|
|
|
|
extern "request"
|
|
extern "file"
|
|
extern "exec"
|
|
|
|
set &rootURL "https://ground.chookspace.com/pkgs/"
|
|
|
|
getlistsize *args &size
|
|
greater $size 0 &cond
|
|
if $cond %checkArgs
|
|
|
|
stdlnout "Dig package manager"
|
|
stdlnout "Type 'dig install pkgname' to install a package or 'dig help' for more information"
|
|
end 1
|
|
|
|
@checkArgs
|
|
|
|
getlistat *args 0 &instruction
|
|
|
|
equal $instruction "install" &cond
|
|
if $cond %install
|
|
|
|
equal $instruction "help" &cond
|
|
if $cond %help
|
|
|
|
@install
|
|
greater $size 1 &cond
|
|
if $cond %installcontinue
|
|
stdlnout "Usage: dig install pkgname"
|
|
end 1
|
|
|
|
@installcontinue
|
|
|
|
# Download the package
|
|
getlistat *args 1 &pkgname
|
|
stdout "Downloading "
|
|
stdlnout $pkgname
|
|
|
|
add $pkgname ".tar" &pkgfile
|
|
add $rootURL $pkgfile &url
|
|
add "/tmp/" $pkgfile &tmpstorage
|
|
|
|
pusharg $url
|
|
pusharg $tmpstorage
|
|
call !saveContents &status
|
|
|
|
if $status %downloadSuccess
|
|
stdlnout "Download not successful"
|
|
end 1
|
|
|
|
@downloadSuccess
|
|
|
|
# Extract using tar on the system
|
|
stdout "Extrating "
|
|
stdlnout $pkgname
|
|
add "tar -xf " $tmpstorage &cmd
|
|
add $cmd " -C /usr/lib/ground" &cmd
|
|
|
|
pusharg $cmd
|
|
call !exec &status
|
|
equal 0 $status &cond
|
|
|
|
if $cond %extractSuccess
|
|
stdlnout "Extraction not successful"
|
|
end 1
|
|
|
|
@extractSuccess
|
|
|
|
# Report success to the user
|
|
stdlnout "Success!"
|
|
end 0
|
|
|
|
@help
|
|
stdlnout ""
|
|
end 0
|