Initial commit
This commit is contained in:
20
README.md
Normal file
20
README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# dig
|
||||
|
||||
Dig is a simple package manager for Ground. At this point in time it is quite basic.
|
||||
|
||||
## Installation
|
||||
|
||||
You'll need to manually install Ground, and the "request", "file", and "exec" libraries yourself. This will be automated in future.
|
||||
|
||||
Once that is done, you can install the dig package manager wherever you need it.
|
||||
|
||||
## Usage
|
||||
|
||||
`digpkg install pkgname`: Installs the package specified to /usr/lib/ground. Requires root permissions.
|
||||
|
||||
`digpkg help`: Shows help.
|
||||
|
||||
## Package list
|
||||
|
||||
Go to https://ground.chookspace.com/pkgs to see the list. If you've made a Ground library and would like it packaged, please send me an email (max at chookspace dot com).
|
||||
|
79
digpkg
Executable file
79
digpkg
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/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
|
Reference in New Issue
Block a user