(60 lines)
1 #!/usr/bin/env nomsu -V7.0.02 ###3 A tool to install third party Nomsu packages5 Usage:6 nomsu -t install /path/to/package7 nomsu -t install github.com/user/repo9 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.zip22 ")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.gz27 ")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 $cmd39 try:40 sh> $cmd41 ..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 147 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 $filename52 ..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 $cmd58 do next $filename60 fail "Not sure what to do with \$filename"