code / nomsu

Lines6.6K Lua5.1K PEG1.3K make117
2 others 83
Markdown60 Bourne Again Shell23
(60 lines)
1 #!/usr/bin/env nomsu -V7.0.0
2 ###
3 A tool to install third party Nomsu packages
5 Usage:
6 nomsu -t install /path/to/package
7 nomsu -t install github.com/user/repo
9 use "filesystem"
10 use "commandline"
11 use "shell"
13 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 $actions = []
16 (download $patts with $cmd) means:
17 $actions, add {.patterns = $patts, .cmd = $cmd}
18 download ["^.*/([^/]+)%.git$"] with "git clone %0 \$(NOMSU PACKAGEPATH)/%1"
19 download ["^.*/([^/]+)%.zip"] with ("
20 curl %0 > \($(NOMSU PACKAGEPATH))/%1.zip && unzip \($(NOMSU PACKAGEPATH))/%1.zip -d \$(NOMSU PACKAGEPATH) && rm \($(NOMSU PACKAGEPATH))\
21 ../%1.zip
22 ")
24 download ["^.*/([^/]+)%.tar%.gz"] with ("
25 curl %0 > \($(NOMSU PACKAGEPATH))/%1.tar.gz && tar xf \($(NOMSU PACKAGEPATH))/%1.tar.gz --directory \$(NOMSU PACKAGEPATH)\
26 .. && rm \($(NOMSU PACKAGEPATH))/%1.tar.gz
27 ")
29 download ["^https://github%.com/([^/]+)/([^/]+)$", "^github%.com/([^/]+)/([^/]+)$"]
30 ..with "git clone https://github.com/%1/%2.git \$(NOMSU PACKAGEPATH)/%2"
32 download [
33 "^https://bitbucket%.org/([^/]+)/([^/]+)$"
34 "^bitbucket%.org/([^/]+)/([^/]+)$"
35 ] with "git clone git@bitbucket.org:%1.git \$(NOMSU PACKAGEPATH)/%2"
37 (run command $cmd) means:
38 say $cmd
39 try:
40 sh> $cmd
41 ..if it fails:
42 say ("
43 Sorry, the install failed. You may need to re-run as root with `sudo` in front of the command.
44 ")
45 exit 1
47 command line program with $args:
48 for $filename in $args.extras:
49 if ($Files.exists $filename):
50 run command "cp -rv \$filename \$(NOMSU PACKAGEPATH)"
51 do next $filename
52 ..else:
53 for $action in $actions:
54 for $patt in $action.patterns:
55 if ($filename, match $patt):
56 $cmd = ($filename, with $patt -> $action.cmd)
57 run command $cmd
58 do next $filename
60 fail "Not sure what to do with \$filename"