├── .gitignore ├── .gitmodules ├── CHANGELOG.txt ├── LICENSE ├── README.txt ├── build.sh ├── commit.sh ├── docs └── USERGUIDE.txt ├── inst_config ├── rf.cfg └── startinst.lua ├── logo-notext.png ├── logo.png ├── pull-repos.sh ├── push-repos.sh ├── release.lua ├── setup.sh ├── utils ├── env.sh ├── guimenu.lua ├── manfmt.lua ├── mkman.sh ├── mtar.lua ├── preproc.lua └── proc.lua └── versions ├── bsh ├── cldr ├── corelibs ├── coresvc ├── coreutils ├── cynosure ├── getty ├── gpuproxy ├── installer ├── luaposix ├── manpages ├── netutils ├── norris ├── osgui ├── refinement ├── sudo ├── tle ├── upm ├── usysd └── uwm /.gitignore: -------------------------------------------------------------------------------- 1 | out 2 | webman 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cynosure"] 2 | path = cynosure 3 | url = git@github.com:ocawesome101/oc-cynosure.git 4 | [submodule "refinement"] 5 | path = refinement 6 | url = git@github.com:ocawesome101/oc-refinement.git 7 | [submodule "external"] 8 | path = external 9 | url = git@github.com:ocawesome101/ulos-external 10 | [submodule "tle"] 11 | path = tle 12 | url = git@github.com:ocawesome101/tle.git 13 | -------------------------------------------------------------------------------- /CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | ULOS 21.05-pre1: 2 | * First pre-release. 3 | * Supports booting from managed filesystems. 4 | * Has a relatively straightforward installation process. 5 | * All core functionality should be mostly stable. 6 | 7 | ULOS 21.05-pre2: 8 | * Second pre-release. 9 | * Better-optimized MTAR loader. 10 | 11 | ULOS 21.05-pre3: 12 | * Third pre-release. 13 | * Optimized the MTAR loader slightly further. 14 | * Fixed a typo in 'login'. 15 | * 'passwd' can now remove users. 16 | * New coreutil: 'less' pager. 17 | * New coreutil: 'tfmt' text formatter. 18 | 19 | ULOS 21.06-pre4: 20 | * Fourth pre-release. 21 | * There are now manual pages for all core utilities and libraries. 22 | * A long-standing TTY bug has been fixed - long lines ending at the edge of the screen should now wrap properly. 23 | * There is now a 'text.wrap' function, which wraps text and ignores (but preserves) VT100 escape sequences while doing so. 24 | 25 | ULOS 21.06-pre5: 26 | * Fifth pre-release. 27 | * The Cynosure kernel now features opt-out pre-emptive multitasking, through hijacking load(). 28 | * There is now a MOTD in /etc/motd.txt, which /bin/login will display on logging in. 29 | * LSH supports semicolon-separated commands, though the implementation leaves much to be desired. 30 | * Added a mostly-complete LuaFileSystem compatibility layer. 31 | * LSH's `into' builtin now supports executing programs directly, if passed the '-p' option. 32 | 33 | ULOS 21.06-pre6: 34 | * Sixth pre-release. 35 | * Cynosure's pre-emptive multitasking has been significantly improved. 36 | * Fixed a typo in the 'futil' library's manual page. 37 | 38 | ULOS 21.06-1.0: 39 | * First release. 40 | * The ULOS Package Manager is implemented and working. 41 | * Cynosure now has networking support. Currently, this is only implemented for the internet card, but support for other forms of networking can and will be transparently added in the future. 42 | * Cynosure's buffer implementation now behaves as expected when reading 0 bytes from a file. 43 | * Fixed a small bug with Cynosure's pre-emptive multitasking implementation. 44 | * install: There is now an option to use UPM for installation, rather than copying from the live media. Only available if an internet card is installed. 45 | * mtar: The MiniTel ARchive library now properly unarchives files, and the behavior of the unarchiver function has as a result changed slightly. (Unarchiver code credit: Izaya) 46 | * There are several new manual pages (man, tfmt, upm, and UPM's included libraries config and serializer). 47 | 48 | ULOS 21.06-r1.1: 49 | * Release 1.1. 50 | * There is now a readline() library for improved line editing, and an accompanying manual page. 51 | * The shell and the Lua REPL now both use the new readline() library. 52 | * There have been numerous fixes and additions to UPM: 53 | > The `search` command now indicates whether the specified package is installed. 54 | > There is now a `list` command, which lists all installed packages in no particular order. 55 | > There is now an `upgrade` command, which upgrades all out-of-date packages on the system. 56 | * Fixed a very small bug with the Cynosure VT100 emulator wherein cursor wrapping did not work properly in one very specific case. 57 | * Added the `sv` command for service management, and a corresponding manual page. 58 | * Merged the `coresvc` and `refinement` packages. 59 | * Refinement now sets `__metatable` on the table returned from `sv.list()`. 60 | * Added the `uname` command, identical to `print(_OSVERSION)`. 61 | 62 | ULOS 21.06-r1.2: 63 | * Release 1.2. 64 | * Added category selection ('installed', 'all', and per-repository) to UPM's 'list' command. 65 | * LSH's program exit status filter has been improved slightly; it will no longer print 'exited' or blank exit statuses. 66 | * UPM now has a copyright notice in its help text. 67 | * UPM now automatically resolves package dependencies. 68 | * UPM's package installation process has been refined: it will now resolve dependencies, *then* download packages, *then* install them. Previously it would download and install each package individually. 69 | * A piece of debug code that could cause unexpected behavior has been removed from Cynosure. 70 | * Cynosure's TTY cursor can now be toggled. 71 | * Syntax highlighting is now included in the 'tle' package. 72 | * /etc/motd.txt is now included in the 'coreutils' package. 73 | * The release image now includes an 'installed.list', so that a system installed using the offline method will be upgradeable using UPM. 74 | * A small bug with the readline() library has been fixed. 75 | * Added a basic 'more' pager. 76 | 77 | ULOS 21.07-r1.3: 78 | * Release 1.3. 79 | * There is now an optional `getgpu()` function, for getting the GPU bound to a specific TTY. 80 | * Several breaking bugs in Cynosure's kernel argument parsing code have finally been fixed. 81 | * Cynosure now features proper hostname support in its network API. 82 | * Refinement has gained support for loading and saving the hostname from /etc/hostname during startup and shutdown. 83 | * The /etc/rf/ttys script now sets {stdin,stdout,stderr}.tty to the ID of the attached TTY; for example, 2. Previously it would be set to `true`. 84 | * UPM's `search` functionality now matches on patterns, rather than requiring the full package name; this does not impact installation or removal. 85 | * There is now a `hostname` utility for getting and setting the system hostname. 86 | * There are now manual pages for `more`, the `sysfs`, `getgpu`, the `network` API, and `edit`. 87 | * Manual pages can now be viewed in a web browser at https://oz-craft.pickardayune.com/man/ulos. 88 | * Typos in a few manual pages have been fixed. 89 | * UPM has been split into a library and a command; this is entirely for speed reasons and the library is not intended for use in other programs. 90 | * The `config` and `serializer` libraries are now in the `corelibs` package rather than the `upm` package, as they are now dependencies of Refinement. 91 | * The `config` library's `bracket` type now saves entries in the order they were loaded. This has the downside of making new entries slightly more complicated to create. 92 | * The `termio` library now has a `cursorVisible()` function, for setting cursor visibility. 93 | * `sv.list()` now behaves correctly. 94 | * The `find` command now prints usage to the standard error if no arguments are specified. 95 | 96 | ULOS 21.07-r1.4: 97 | * Release 1.4. 98 | * UPM now displays progress bars while downloading packages, as well as the total download size before package installation. 99 | * Fixed a bug with the Cynosure `sysfs`'s TTY handler not properly flushing the TTY stream. 100 | * Cynosure's `sysfs` now exports handle templates' `flush` functions where it previously did not. 101 | * `rm` no longer chokes under certain situations. 102 | * The Cynosure Loader's default kernel flags now reduce kernel output during boot. 103 | * Cynosure's terminal emulator now does not act on ctrl-D while raw mode is enabled. The old behavior was considered a bug. 104 | * The `sv` command can now add, remove, and control autostart of services. 105 | > The `sv` API has functions for this accordingly. 106 | * The `package.protect` function has been fixed to that `pairs` and `ipairs` behave properly on the protected table. 107 | * The `config` library's `bracket` preset now saves `nil` values. 108 | * UPM will now remove files that a package stops owning after an upgrade. 109 | * The Cynosure TTY's maximum buffer size is now 2048 bytes. This may change or become configurable in the future. 110 | 111 | ULOS 21.08-r1.5: 112 | * Release 1.5. 113 | * Cynosure's `os.exit()` function now behaves properly. 114 | * `readline` now accepts the `noexit` option to not exit when ctrl-D is pressed. 115 | * `readline` now accepts a `complete` function, which is given the current text buffer and a session ID and expected to make something of it. 116 | * The default task time limit is now 0.1s, down from 0.5s. This does not have a noticeable impact on performance and improves responsiveness while programs loop. 117 | * A few improvements have been made to the Lua REPL. 118 | * Cynosure now has a `sound` API. 119 | * Fixed a bug with Cynosure's `load()` wrapper pre-emption scheme causing `coroutine.yield()` to misbehave. 120 | * There is a new kernel option, `no_wrap_coroutine`, which disables Cynosure's `coroutine` wrapper for userspace only. 121 | * `\27[0m` now properly resets the TTY's foreground and background colors. 122 | * `io.popen` now sometimes works, but should not be relied upon. 123 | * `/usr/lib` is now in the default package path. 124 | * There is a new installer, `installer`, and the old one has been moved to `minstall`. 125 | * Both installers now assist in the adding of users, creation of home directories, and hostname setup. 126 | * There are two new commands, `mkpasswd` and `hnsetup`, which should only be used during system installation. 127 | * Cynosure now provides a `tty` interface for using the kernel's TTY driver on userspace-provided GPU objects. 128 | * Cynosure's terminal emulator supports an "xoff" mode, where all input is suspended. Use with caution. 129 | * The `getgpu` function has been moved into the `tty` API. Programs will need to be updated to reflect this. 130 | * Cynosure's terminal emulator now supports `\27[0;X;Y;W;Hg` to clear only specific areas of the screen. More GPU functions may be added in the future. 131 | * The `gpuproxy` API is now its own package. 132 | * There is now an option for the release image to autostart the installer. Download `release_noautostart.lua` if you do not want the installer to autostart; it can still be autostarted by running `installer` from the command line. 133 | * The default Message Of The Day has been changed. 134 | 135 | ULOS 21.08-r1.6: 136 | * Release 1.6. 137 | * The ULOS Web Site is now live at https://ocawesome101.github.io/ulos. 138 | * The ULOS Window Manager, `uwm`, is now available as a package in the `extra` repository. 139 | * The Open System's GUI has been mostly ported as the `osgui` package. 140 | * A bug with the Cynosure terminal where signals would still be sent even if `XOFF` was set has been fixed. 141 | * Programs can now detect if they're running with a `gpuproxy`-created proxy, with the `isProxy` field. 142 | * The Cynosure Loader now calls loaded files with `xpcall()` for traceback support. 143 | * A few bugs with `gpuproxy`'s `buffer` wrapper have been fixed. 144 | * Cynosure's `loadfile()` now behaves properly when given an environment. 145 | * The `extra` repository is now included in UPM's default configuration. 146 | * Cynosure's `process.kill` function now behaves correctly. 147 | * There is finally a `mv` command. 148 | * Fixed a bug with Cynosure's `load()` wrapper wherein signals would sometimes be either duplicated or not sent. 149 | * The Cynosure TTY implementation now behaves as expected when given `\27[nnG`. 150 | * Refinement's `sv.list()` now returns more data. 151 | * Updated `sv` to reflect this. 152 | * The `require()` function has been moved from Refinement into Cynosure. This enables running any userspace software as init with the `init=PATH` kernel argument. 153 | * Some scheduler weirdness with process environments has been sorted. 154 | * The IO stream passed to `init` now has the `tty` field set. 155 | * Cynosure's TTY now supports negative numbers as arguments. 156 | * Added `\27[1;XX;YY;WW;HH;RX;RYg` as an interface to `gpu.copy`. 157 | * Cynosure now supports displaying a boot splash on startup. 158 | * Refinement's logger has been updated to look slightly nicer with Cynosure's bootsplash enabled - the standard logger will be used if the bootsplash is not enabled. 159 | * The kernel command line is now accessible through `/sys/cmdline`. 160 | * Cynosure's `users.usermod` function now behaves correctly. 161 | * The `passwd` command will only prompt for a password if the user being modified is not the current user OR if no arguments have been passed, but not, for example, if changing the shell. 162 | * Cynosure's TTY now has 24-bit color support through the `\27[{3,4}8;2;RRR;GGG;BBBm` extension. 163 | * `login` now prints the value of `_OSVERSION` and the TTY ID rather than just `Welcome to ULOS.` since the first line of the MOTD is `Welcome to ULOS!`. 164 | * Fixed a bug with the Cynosure TTY's output line buffer where it would sometimes not flush properly. 165 | * Cynosure's TTY should now mostly support UTF-8 input and output. 166 | * USysD has replaced Refinement as the default init system. 167 | * Cynosure's `io.lines()` function now behaves as expected. 168 | * The Cynosure TTY's "XOFF" mode now disables output as well as input. 169 | * Cynosure's `users.exec_as` function now returns the PID of the process it spawned if the `wait` argument is not specified. It also now supports a sixth argument, `stdio`, which sets *all* input and output streams of the spawned process to the provided stream. Finally, a password is now required only if the user calling the function is not `root`. 170 | * Cynosure's `io` library now canonicalizes paths. This is an improvement over the previous system that required a userspace hack. 171 | * There is now a `quit` signal in `process.signals`. 172 | * There is now a file `/etc/os-release` containing a set of key-value pairs describing the OS. This is in a similar format to the standard Linux file of the same name. 173 | * There is now an official ULOS logo. 174 | * There is now an official Cynosure logo. 175 | * There is now a standalone ULOS installer for OpenOS using a badly ported version of UPM, as well as a script to download and boot the latest release image. 176 | 177 | ULOS 21.09-r1.7: 178 | * Release 1.7. 179 | * Cynosure's TTY now properly supports 24-bit color. 180 | * The `ANSI_COLOR` field in `/etc/os-release` has been updated to `38;2;102;182;255`; it was previously `96`. 181 | * A bug with Cynosure's `load()` wrapper where a `for` specifier would sometimes not be recognized has been fixed. 182 | * Writing to a broken pipe now sends the `SIGPIPE` signal to the offending process. 183 | * The TTY's signal sending logic has been fixed. 184 | * There is a new shell available, `bsh`. Its design is similar to the Bourne shell. 185 | * The `sh` script now points to whatever the user's shell is. 186 | * The old `sh` bourne-like shell has been removed. 187 | * Cynosure's managed filesystem driver no longer errors when passed an empty file path. 188 | * The `HOSTNAME` and `PWD` environment variables are now set by default. 189 | * The default shell has changed to `/bin/sh`. 190 | * Added `/bin/echo`, which behaves exactly as it should. 191 | * The ULOS Package Manager now checks for conflicting packages during installation. 192 | * `io.popen` should behave as expected now. 193 | * `network:read()` should work properly now. 194 | * `FILE*` streams are now unbuffered if the buffer mode is set to `pipe` as well as if it is set to `none`. 195 | * All of a process's I/O streams are now properly closed when a process exits, unless they point to a TTY. 196 | * `/sys/dev/null` now exists as an empty file into which all that is written disappears. 197 | * `/bin/login` now passes `--login` to the shells it executes. 198 | * `readline()` now accepts an `exit` option to set the function it calls when Control-D is pressed. 199 | * `ls` now exits with a status of 1 if a file or directory is not found, rather than ignoring it. 200 | * Cynosure's TTY colors now use the full 16 palette colors available for exact color matching. 201 | * Cynosure now supports color profiles and custom colors for the TTY. This allows switching between terminal palettes with a kernel argument. These themes are: The default (1), the Breeze theme from Konsole (2), Gruvbox (3), Gruvbox Light (4), PaperColor light (5), and Pale Night (6). 202 | * Cynosure's `loadfile()` now supports shebangs. This eliminates the need for the shell to support them. 203 | * Cynosure now adds support to `checkArg` for the first `n` argument to be a string. This is useful for functions where arguments are provided in a table. 204 | * The coreutils' `lua` REPL now parses arguments exactly as does the PUC-Rio interpreter. 205 | * The official UPM repositories have moved to http://ulos.pickardayune.com. 206 | * The `text` library's `wrap` function now word-wraps. It will also preserve the indentation of a line across wraps, such that manual pages now look significantly better. 207 | * There are now manual pages for `tle`. 208 | * `argutil` now has a `getopt` function, with the manual page updated accordingly. 209 | * Fixed a small bug in `less` when jumping down a page. 210 | * `less` now supports searching for a pattern within its buffer. 211 | * Cynosure now (at least in theory) supports the Minitel networking stack. 212 | * Fixed a bug in `cp` when copying a single file into a directory. 213 | * There is now a `lshw` command. It doubles as a `components` implementation when given the `-o` or `--openos` options. 214 | * `mount` now prints a more easily readable form of the output from `/sys/mounts` when invoked with no arguments. 215 | * `passwd` has a new flag, `--clear-acls`, to clear all ACLs before processing `--enable` or `--disable`. 216 | * Fixed a small bug with `df`. 217 | * UWM now checks whether the GPU supports VRAM buffers before launching. 218 | * Cynosure now caches `loadfile()` results for 60 seconds after the final time they are used, or until the system runs low on memory. This provides a moderate performance boost in the shell and other apps, while still allowing the system to run on 384KB of RAM. 219 | * File reads now support pre-emption. 220 | * The `sysfs`'s `filesystem` component handler now strips trailing newlines when setting filesystem labels. 221 | * Cynosure's `checkArg` now supports being given a string as the first argument, and will show the function name in the error 222 | * Fixed a few small bugs with `tle`. 223 | 224 | ULOS 21.10: 225 | * Release 21.10. Releases will now be roughly month-aligned. 226 | * Fixed an issue with `edit` where the bottom bar would sometimes scroll up. 227 | * UPM now uses semantic versions, and has been updated accordingly to version 2.0.0. **Upgrade to this release with `upm upgrade -f` or the upgrade will fail.** 228 | * The `upm` package now contains a semantic versioning library, `semver`. 229 | * `less`'s scrolling has been greatly optimized and is now much faster and smoother. 230 | * Fixed a minor bug with the Cynosure TTY's `\27[S` function. 231 | * Fixed pipes in `bsh` misbehaving when a process uses `os.execute`. 232 | * There is now a `getty` package available, providing a service that automatically starts a login prompt on any TTY that does not already have a service assigned to it. 233 | * There are now manual pagees documenting Cynosure's VT100 support, as well as a brief history of the ANSI specification. 234 | * `bsh` now sets the process working directory to the user's home directory on login. 235 | * Added `--help` and `--version` options to `bsh`. 236 | * Fixed a bug with Cynosure's filesystem API. 237 | * Added a `finish_after_arg` option to `argutil.getopt`. 238 | * USysD's service management API now uses a request queue internally, so that services are always spawned from the `init` process. 239 | * The `sudo` utility is now its own package, and requires the `sudo` service to be running in order to function. However, its policies are now different, and user credentials are "remembered" for 5 minutes after each `sudo` invocation. 240 | * Switched `bsh` to use `argutil.getopt` over `argutil.parse`. 241 | * The `sh` script now passes all arguments recieved to the shell it executes. 242 | * Fixed the `minstall` installer not fully working when running from the same medium that is its target. 243 | * Cynosure will now panic if `init`'s exit status is nonzero. 244 | * Cynosure's `FILE*` implementation now returns itself from `:write()`. This was an oversight and has been fixed. 245 | * There is now a `netutils` package available, containing a `wget` utility. 246 | * The installer's online mode finally no longer clobbers `/init.lua` (by installing CLDR) except as the last step. 247 | 248 | ULOS 22.2: 249 | * Release 22.2. 250 | * Fixed a bug with starting services in USysD. 251 | * Added a new function, `message()`, to Cynosure's `process` API. 252 | * Fixed an issue with Cynosure's pre-emption wrapper sometimes ignoring multiline strings. 253 | * Cynosure now has configurable behavior for `computer.pullSignal` with a kernel argument. 254 | * There is now a `sysfs` handler for the `eeprom` component. 255 | * Replaced the preprocessor with a slightly improved version, making the kernel ~30KB smaller. It might now load on 192K of memory (though ULOS won't work). 256 | * Completely rewrote Cynosure's code wrapper. It now behaves as expected when quote types are mixed. 257 | * `os.execute` now behaves properly when `$PATH` is not set. 258 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | // DSL: the Developer's Software License, v2 2 | 3 | / Terminology: 4 | / the Creator = the creator of this software 5 | / the User = anyone who isn't the Creator 6 | 7 | The User may do anything with this software, 8 | unless the Creator tells them to stop doing it. 9 | 10 | This software comes with no warranty, implied or 11 | otherwise. It is free, open source, and made 12 | available to anyone and everyone. Technical 13 | support is not guaranteed. 14 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | // ULOS // 2 | 3 | A Unix-Like OS for OpenComputers. I need to stop writing these. 4 | 5 | Structured similarly to Apotheosis, but hopefully with a slightly better architecture. 6 | 7 | The ULOS Web Site is live now at https://ocawesome101.github.io/ulos ! 8 | 9 | // INSTALLATION + USER GUIDE 10 | 11 | Run `pastebin run L7iWx5j7` in an OpenOS shell to begin the installation process. The installer should be fairly self-explanatory. 12 | 13 | An outdated user guide + installation guide is available at `docs/USERGUIDE.txt`. 14 | 15 | // BUILDING 16 | 17 | *** IMPORTANT *** 18 | Building ULOS is only necessary if you wish to make significant changes to the system; if you just want to install it on a computer, follow the instructions pointed to above. 19 | 20 | To build ULOS, you'll need a working install of Lua 5.3, a *nix-like system supporting `io.popen`, `mkdir`, and `cd`, as well as `cmd1; cmd2` in the shell (when in doubt, the Bourne shell will more than suffice). You'll also need LuaFileSystem. 21 | 22 | Make sure to clone with `--recursive`, since the repository has submodules. 23 | 24 | To build, just run `./build` from the repository root. Output will be placed in `out`. 25 | 26 | To develop ULOS, clone the repository, then run `./setup.sh` from the repository root. 27 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # i finally have switched to a shell-script-based build :/ 3 | 4 | source utils/env.sh 5 | 6 | ogdir=$PWD 7 | external="cldr/ corelibs/ coreutils/ manpages/ upm/ uwm/ gpuproxy/ bsh/ norris/ getty/ sudo/ netutils/ installer/" 8 | tobuild="cynosure external/usysd" 9 | 10 | build() { 11 | printf ":: building $1\n" 12 | cd $1; ./build.sh; cd $ogdir 13 | } 14 | 15 | rm -rf out && mkdir -p out/{r,b}oot 16 | for b in $tobuild; do 17 | build $b 18 | done 19 | 20 | for ext in $external; do 21 | cp -r external/${ext}* out/ 22 | done 23 | 24 | cd tle; ./standalone.lua; cd .. 25 | cp tle/tle out/bin/tle.lua 26 | mkdir -p out/usr/share 27 | cp -r tle/syntax out/usr/share/VLE 28 | 29 | cp cynosure/kernel.lua out/boot/cynosure.lua 30 | cp -rv external/usysd/out/* out/ 31 | printf "VERSION=\"$ULOSVERSION\"\nBUILD_ID=\"$DATE\"\nVERSION_ID=\"$ULOSREL\"\n" | cat external/os-release - > out/etc/os-release 32 | printf "ulos\n" > out/etc/hostname 33 | -------------------------------------------------------------------------------- /commit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | commit () { 4 | cd $1 5 | git add . 6 | git commit 7 | cd .. 8 | } 9 | 10 | commit cynosure 11 | commit refinement 12 | commit external 13 | commit tle 14 | 15 | git add . 16 | if [ "$#" -lt 0 ] ; then 17 | git commit "$@" 18 | else 19 | git commit -m 'updates' 20 | fi 21 | -------------------------------------------------------------------------------- /docs/USERGUIDE.txt: -------------------------------------------------------------------------------- 1 | //// ULOS User Guide //// 2 | 3 | This is the official user guide for the Unix-Like Operating System (ULOS). Any errors should be reported on the issues page of this repository. 4 | 5 | /!\ Certain sections of this document are outdated. Look at the README.txt of this project for up-to-date links. /!\ 6 | 7 | /// Contents 8 | 9 | Conventions 10 | System Requirements 11 | Installation 12 | - Prerequisites 13 | - Step 1 14 | - Step 2 15 | - Step 3 16 | General Use 17 | - The Lisp-ish Shell 18 | - Commands 19 | - Filesystem Hierarchy 20 | - Package Management 21 | Troubleshooting 22 | - Installation 23 | 24 | /// Conventions 25 | 26 | All examples are shown indented by four spaces. Words or phrases encased in single-quotes (') should be entered without the quotes. 27 | 28 | /// System Requirements 29 | 30 | ULOS requires at least 384 kilobytes of memory for the live image, or at least 256 kilobytes if running from an installed medium. An internet card is necessary to download the installation files. 31 | 32 | The installed system consumes around 300KB of disk space. 33 | 34 | /// Installation 35 | 36 | This section of the Guide will instruct you in installing ULOS. 37 | 38 | // Prerequisites 39 | 40 | Ensure that your computer meets the system requirements listed above. Ensure that you have booted from a medium containing OpenOS, and that there is at least one writable drive in your computer other than this one. 41 | 42 | // Step 1: Download the live image 43 | 44 | Type 'mount' into the OpenOS shell and press the [enter] key on your keyboard. You should see a list on-screen that looks like something like this: 45 | 46 | a7541fb5 on /tmp (rw) "tmpfs" 47 | c7223813 on /mnt/c72 (rw) "c7223813-1686-48ae-89e4-b86150cc0771" 48 | e48f3373 on / (rw) "OpenOS" 49 | e48f3373 on /mnt/e48 (rw) "OpenOS" 50 | f5501a9b on /dev (rw) "devfs" 51 | 52 | Locate the entry whose address matches that of your writable installation disk. In this case, the matching entry is 'c7223813 on /mnt/c72 (rw) "c7223813-1686-48ae-89e4-b86150cc0771"'. Note the path at which is mounted, '/mnt/c72'. 53 | 54 | In the OpenOS shell, type 'wget https://raw.githubusercontent.com/ocawesome101/oc-ulos/master/release.lua PATH/init.lua', replacing PATH with the path from the last instruction. If the download is successful, you should see the word 'Downloading...' appear on screen, then after awhile 'success. Saved data to PATH/init.lua'. 55 | 56 | 57 | // Step 2. Boot the live image 58 | 59 | Now, shut down your computer. Remove the medium on which OpenOS is installed, and turn on the computer. You should be greeted with a screen bearing the words "Cynosure MTAR-FS Loader" across the top, and some status messages below that, as shown: 60 | 61 | █████████████Cynosure MTAR-FS Loader██████████████ 62 | Seeking to data section.... - 63 | Reading file headers...bin/ls.lua 64 | 65 | 66 | This screen is effectively a progress bar displayed by the live image's boot loader. It will take some time to complete. Once it has finished, the loader will load and execute the kernel. 67 | 68 | If ULOS boots successfully, you will see a login prompt similar to that shown below. 69 | 70 | Welcome to ULOS. 71 | 72 | login: █ 73 | 74 | Log in with the username 'root' and the password 'root'. There will be no visual indication during password entry. You should now see the following: 75 | 76 | login: root 77 | password: 78 | 79 | █ 80 | 81 | You have reached ULOS's read-only live environment. Experiment as much as you wish. 82 | 83 | / Step 3. Install ULOS 84 | 85 | Ensure you have a blank disk drive (whether it is a hard disk or a floppy disk does not matter) in your computer, excluding the installation drive[1]. In the shell, execute 'install'. You should see something similar to the following. If you wish to cancel the installation process, hold down the Control key on your keyboard and, as you do so, press D. Release both keys at once. 86 | 87 | Available filesystems: 88 | 1. c7223813-1686-4a8e-89e4-b86150cc0771 89 | 2. 201496e4-e4ff-4e2c-8015-a114a523c53c 90 | Please input your selection. 91 | > █ 92 | 93 | The installer will continue to prompt you with '>' until you have entered a valid numerical choice. 94 | 95 | > cabbage 96 | > 4 97 | > 15 98 | > FORTY-TWO!!!! 99 | > 2 100 | 101 | If an internet card is installed, the installer will prompt you for whether to download ULOS from the internet using UPM. This is generally a good idea as it will be slightly more up-to-date. 102 | 103 | Perform an online installation? [Y/n]: █ 104 | 105 | If you select 'y', the installer will ask whether to include manual pages and TLE in the installed package. This is generally a good idea. 106 | 107 | Install the full system (manual pages, TLE)? [Y/n]: █ 108 | 109 | Once this process has been completed, the installer will install ULOS to the selected medium. This will take some time. Once the installer has finished, it will print information relating to user creation and exit. 110 | 111 | You may continue to experiment with the live environment, or restart your computer and boot from the writable freshly-installed medium. 112 | 113 | Congratulations! You have successfully installed the Unix-Like Operating System on your computer. 114 | 115 | /// General Use 116 | 117 | // The Lisp-ish Shell 118 | 119 | The default shell for all users in ULOS is the Lisp-ish Shell. Its syntax mirrors a Lisp much more closely than the Bourne shell. 120 | 121 | Perhaps the most important syntactical difference is the method of grabbing the output from a program; where in the Bourne shell one would write 122 | 123 | a $(b -cd) e f 124 | 125 | the Lisp-ish Shell syntax is 126 | 127 | a (b -cd) e f 128 | 129 | to grab the program's output, or 130 | 131 | a [b -cd] e f 132 | 133 | to grab the program's exit status. In any case, the result will be inserted as arguments (if capturing the program's output, then it will be split on every new-line character) to the parent program. 134 | 135 | Building on this syntax, rather than have a separate syntax for getting and setting environment variables, the Lisp-ish shell has two builtins, 'get' and 'set'. Where the equivalent Bourne expression would be 136 | 137 | echo $TERM 138 | set EXAMPLE=abc 139 | FOUR=$EXAMPLE 140 | 141 | the Lisp-ish Shell syntax is 142 | 143 | echo (get TERM) 144 | set EXAMPLE abc 145 | set FOUR (get example) 146 | 147 | When executed with no arguments, the 'get' builtin will print all currently set environment variables and their values in a manner similar to the Bourne shell's 'set'. 148 | 149 | The Lisp-ish Shell eliminates the need for the Bourne shell's third syntax type: prompt shorthand substitution. Where PS1 in the Bourne shell would be 150 | 151 | PS1='<\u@\h: \W> ' 152 | 153 | the Lisp-ish Shell equivalent is 154 | 155 | set PS1 '<(get USER)@(or (get HOSTNAME) localhost): (or (match (get PWD) \"([^/]+)/?$\") /)>' 156 | 157 | This is more complex on the surface, and certainly less concise, but the premise is really very simple: for every value within a set of parentheses '()', the shell is to substitute the result of the evaluated expression instead. Thus, where the Bourne shell's output is 158 | 159 | 160 | 161 | the Lisp-ish Shell's output is exactly the same. 162 | 163 | 164 | 165 | The Lisp-ish Shell names its built-ins differently, and furthermore contains a different set of builtins, than the Bourne shell. The Lisp-ish Shell's built-ins, and a short description of each: 166 | 167 | or A B Print whichever argument evaluates to a truthy value, or nothing 168 | get K Print the value of environment variable K 169 | set K V Set environment variable K to value V 170 | match S P Equivalent to the Lua expression 'string.match(S, P)' 171 | gsub S P R Equivalent to the Lua expression 'string.gsub(S, P, R)' 172 | sub S A B Print substring [A..B] of S 173 | cd D Identical to the Bourne shell builtin of the same name 174 | time P ... Print how long a program took 175 | + A B Add A and B, and print the result 176 | - A B Subtract B from A, and print the result 177 | / A B Divide A/B, and print the result 178 | * A B Multiply A by B, and print the result 179 | = A B If A == B, exit status 0; else, exit status 1 180 | into F ... Concatenate arguments with newlines, and dump the result into F 181 | seq A B Print all numbers from A to B 182 | 183 | // Commands 184 | 185 | A list of currently available commands may be obtained by running 'ls /bin'. 186 | 187 | The included default editor is TLE (https://github.com/ocawesome101/tle). 188 | 189 | Certain ULOS coreutils have different enough functionality from their Linux or UNIX counterparts to be worth mentioning here: 190 | 191 | The 'passwd' command combines 'usermod', 'useradd', and 'userdel' into one command. It can also display user information and, of course, change the password of any user whom the current user has permission to modify. 192 | 193 | There is no 'umount' command; use 'mount -u' instead. 194 | 195 | The 'sudo' command by default sudos to root; this can be changed by setting the first parameter to 'uid=UID', where 'UID' is the desired UID. This is not how the Linux version of 'sudo' operates. 196 | 197 | All commands will accept the '--help' option and, when invoked with it, will display some informational text about the command to the standard error. 198 | 199 | // Filesystem Hierarchy 200 | 201 | The ULOS filesystem hierarchy is as follows: 202 | 203 | /bin/ Executable programs. 204 | /sbin/ Programs necessary to boot; also 'sudo', 'shutdown'. 205 | /lib/ Libraries. 206 | /usr/ Certain user documents. Primarily for compatibility. 207 | |- share/ Shared files (for example, TLE highlighting data). 208 | |- lib/ Certain user libraries. 209 | |- bin/ Certain user binaries. 210 | |- man/ Manual pages. 211 | /etc/ System-wide configuration. 212 | |- rf/ Scripts and services for Refinement. 213 | |- rf.cfg Refinement init's master configuration file. 214 | |- upm/ Data for the ULOS Package Manaager 215 | |- upm.cfg UPM's configuration file. 216 | /sys/ The Cynosure sysfs. 217 | |- mounts File containing filesystem mount information. 218 | |- dev/ Device files (the devfs). For example, TTY streams. 219 | |- components/ Component data. 220 | | |- by-address/ Component data by address. 221 | | |- by-type/ Component data by type. 222 | |- proc/ The Cynosure procfs. Only for process information. 223 | 224 | // Package Management 225 | Packages may be installed and removed with the ULOS Package Manager (UPM). 226 | 227 | UPM's usage is generally similar to Debian's Advanced Packaging Tool (APT), with 'install', 'remove', 'search', and 'update' all being recognized command verbs. 228 | 229 | A fairly detailed help text will be printed if UPM is invoked with the '--help' command line option, or the 'help' command verb. 230 | 231 | See the UPM manual page for more details. 232 | 233 | / Installing packages 234 | 235 | upm install 236 | 237 | / Update the system 238 | 239 | upm update 240 | upm upgrade 241 | 242 | 243 | /// Troubleshooting 244 | 245 | // Installation 246 | 247 | If step 1 fails with "command not found" or similar: Carefully check your spelling. 248 | 249 | If step 1 fails with "unknown host: Name or service not known" or similar: Ensure that the URL you have entered is correct. 250 | 251 | If step 1 fails with "This program requires an internet card to run": Ensure that you have an internet card installed in your computer. 252 | 253 | If step 2 fails with "Not enough memory" or similar: Ensure you have at least 384 KB of memory in your computer. 254 | 255 | If step 2 fails with "No bootable medium found" or similar: Ensure that the file on your installation disk is named 'init.lua'. 256 | 257 | If step 2 fails with a kernel panic, and it is not one of the above errors, please file a bug report on the ULOS GitHub Issues page. 258 | 259 | 260 | /// Footnotes 261 | 262 | 1. ULOS may be able to install over its live image on the same medium, but this is untested and liable to fail. 263 | -------------------------------------------------------------------------------- /inst_config/rf.cfg: -------------------------------------------------------------------------------- 1 | [io] 2 | autostart = true 3 | type = script 4 | file = io.lua 5 | depends = [] 6 | 7 | [start-installer] 8 | autostart = true 9 | type = script 10 | file = startinst.lua 11 | depends = [] 12 | -------------------------------------------------------------------------------- /inst_config/startinst.lua: -------------------------------------------------------------------------------- 1 | -- basic script for starting the installer -- 2 | 3 | local handle = assert(io.open("/sys/dev/tty0")) 4 | handle.tty = 0 5 | handle.buffer_mode = "none" 6 | 7 | local lsh = assert(loadfile("/bin/lsh.lua")) 8 | 9 | require("process").spawn { 10 | name = "lsh", 11 | func = function() 12 | return lsh("--exec=installer") 13 | end, 14 | stdin=handle, 15 | stdout=handle, 16 | stderr=handle, 17 | input=handle, 18 | output=handle 19 | } 20 | -------------------------------------------------------------------------------- /logo-notext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ocawesome101/oc-ulos/44e089d9de250c8f8456d9f778dc4bdfd4af8f90/logo-notext.png -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Ocawesome101/oc-ulos/44e089d9de250c8f8456d9f778dc4bdfd4af8f90/logo.png -------------------------------------------------------------------------------- /pull-repos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pull () { 4 | cd $1 5 | git pull 6 | cd .. 7 | } 8 | 9 | git pull 10 | pull cynosure 11 | pull refinement 12 | pull external 13 | pull tle 14 | -------------------------------------------------------------------------------- /push-repos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | push () { 4 | cd $1 5 | git add . 6 | git commit 7 | git push 8 | cd .. 9 | } 10 | 11 | push cynosure 12 | push refinement 13 | push external 14 | push tle 15 | 16 | git add . 17 | git commit "$@" -m 'updates' 18 | git push 19 | -------------------------------------------------------------------------------- /release.lua: -------------------------------------------------------------------------------- 1 | do 2 | local addr, invoke = computer.getBootAddress(), component.invoke 3 | local function loadfile(file) 4 | local handle = assert(invoke(addr, "open", file)) 5 | local buffer = "" 6 | repeat 7 | local data = invoke(addr, "read", handle, math.huge) 8 | buffer = buffer .. (data or "") 9 | until not data 10 | invoke(addr, "close", handle) 11 | return load(buffer, "=" .. file, "bt", _G) 12 | end 13 | loadfile("/lib/core/boot.lua")(loadfile) 14 | end 15 | 16 | while true do 17 | local result, reason = xpcall(require("shell").getShell(), function(msg) 18 | return tostring(msg).."\n"..debug.traceback() 19 | end) 20 | if not result then 21 | io.stderr:write((reason ~= nil and tostring(reason) or "unknown error") .. "\n") 22 | io.write("Press any key to continue.\n") 23 | os.sleep(0.5) 24 | require("event").pull("key") 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # setup the repos for dev work after a fresh clone when they aren't on a branch 3 | 4 | switch () { 5 | cd $1 6 | git switch "$2" 7 | git checkout "$2" 8 | cd .. 9 | } 10 | 11 | switch cynosure dev 12 | switch refinement master 13 | switch external master 14 | switch tle master 15 | -------------------------------------------------------------------------------- /utils/env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | export OS="ULOS" 3 | export DATE="$(date +%y.%m)" 4 | export ULOSREL="1.7" 5 | export ULOSVERSION="$OS $DATE-$ULOSREL" 6 | export PREPROCESSOR="$PWD/utils/preproc.lua" 7 | -------------------------------------------------------------------------------- /utils/guimenu.lua: -------------------------------------------------------------------------------- 1 | package.path = package.path .. ";external/corelibs/lib/?.lua" 2 | 3 | local termio = require("termio") 4 | 5 | local mstr = (...) 6 | -- example menu: 7 | -- { 8 | -- __ordering = {"main", "extra"} 9 | -- main = { 10 | -- __title = "Main Configuration", 11 | -- __ordering = {"foo", "bar", "baz"}, 12 | -- foo = 14, 13 | -- bar = "", 14 | -- baz = 0, 15 | -- }, 16 | -- extra = { 17 | -- __title = "Extra Configuration", 18 | -- __ordering = {"a", "b", "c"}, 19 | -- a = "", 20 | -- b = "", 21 | -- c = 0 22 | -- } 23 | -- } 24 | 25 | 26 | mstr = mstr or {} 27 | 28 | local colors = { 29 | BASE_BG = "104", 30 | BASE_FG = "97", 31 | MENU_BG = "100", 32 | MENU_FG = "30", 33 | MENU_SEL = "104", 34 | } 35 | 36 | local USAGE = "up/down/left/right: go up/go down/descend/ascend; return: modify" 37 | 38 | local function setcolor(...) 39 | io.write("\27[", table.concat(table.pack(...), ";"), "m") 40 | end 41 | 42 | local function fill(x, y, w, h) 43 | local fst = (" "):rep(w) 44 | for i=1, h, 1 do 45 | termio.setCursor(x, y + i - 1) 46 | io.write(fst) 47 | end 48 | end 49 | 50 | local curmenu = {__ordering={"main"}, main = {}} 51 | 52 | local function drawmenu() 53 | local w, h = termio.getTermSize() 54 | termio.setCursor(1, 1) 55 | setcolor(colors.BASE_BG, colors.BASE_FG) 56 | io.write("\27[2J") 57 | if curmenu.__title then 58 | termio.setCursor(1, 1) 59 | io.write(curmenu.__title) 60 | end 61 | termio.setCursor(1, h) 62 | io.write(USAGE) 63 | setcolor("40") 64 | fill(5, 3, w - 8, h - 4) 65 | setcolor(colors.MENU_BG, colors.MENU_FG) 66 | fill(4, 2, w - 8, h - 4) 67 | for i, item in ipairs(curmenu.__ordering) do 68 | termio.setCursor(6, 3 + i) 69 | if curmenu.__selected == i then 70 | setcolor(colors.MENU_SEL, colors.MENU_FG) 71 | else 72 | setcolor(colors.MENU_BG, colors.MENU_FG) 73 | end 74 | local val = curmenu[item] 75 | io.write(item, " ") 76 | if type(val) == "table" then 77 | else 78 | io.write("(", val, ")") 79 | end 80 | end 81 | end 82 | 83 | drawmenu() 84 | -------------------------------------------------------------------------------- /utils/manfmt.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | -- coreutils: text formatter -- 3 | 4 | local args = {...} 5 | 6 | local patterns = { 7 | {" ", "  "}, 8 | {"<", "<"}, 9 | {">", ">"}, 10 | {"\n", "
"}, 11 | {"%*{(..-)}", "%1"}, 12 | {"%${(..-)}", "%1"}, 13 | {"@{(..-)}", "%1"}, 14 | {"#{(..-)}", "%1"}, 15 | {"red{(..-)}", "%1"}, 16 | {"green{(..-)}", "%1"}, 17 | {"yellow{(..-)}", "%1"}, 18 | {"blue{(..-)}", "%1"}, 19 | {"magenta{(..-)}", "%1"}, 20 | {"cyan{(..-)}", "%1"}, 21 | {"white{(..-)}", "%1"}, 22 | {"gray{(..-)}", "%1"}, 23 | } 24 | 25 | local base = [[ 26 | 27 | 28 | 29 | 30 | 31 | %s 32 | ULOS Manual Pages - %s | Back

33 | 34 | %s 35 | 36 | 37 | ]] 38 | 39 | for i=1, #args, 1 do 40 | local handle, err = io.open(args[i], "r") 41 | if not handle then 42 | io.stderr:write("tfmt: ", args[i], ": ", err, "\n") 43 | os.exit(1) 44 | end 45 | local data = handle:read("a") 46 | handle:close() 47 | 48 | for i=1, #patterns, 1 do 49 | data = data:gsub(patterns[i][1], patterns[i][2]) 50 | end 51 | 52 | local name = args[i]:match("[^/]+/[^/]+$") 53 | name = name:sub(3) .. "(" .. name:sub(1,1) .. ")" 54 | 55 | print(base:format(name, name, name:sub(-2,-2), data)) 56 | end 57 | -------------------------------------------------------------------------------- /utils/mkman.sh: -------------------------------------------------------------------------------- 1 | paths="manpages coresvc upm uwm gpuproxy bsh" 2 | 3 | rm -rf webman 4 | mkdir -p webman 5 | 6 | htmlbase=" 7 | 8 | 9 | 10 | 11 | 12 | ULOS Manual Pages 13 | 14 | ULOS Manual Pages - Directory listing | Back

15 | In this directory:
16 | " 17 | 18 | htmlend=" 19 |
This page was auto-generated. 20 | 21 | 22 | " 23 | 24 | printf "$htmlbase" > webman/index.html 25 | wget https://raw.githubusercontent.com/ocawesome101/ulos/master/style.css -O webman/style.css 26 | 27 | for category in $(seq 1 9); do 28 | mkdir -p webman/$category 29 | printf "%s  " $category $category >> webman/index.html 30 | printf "$htmlbase" > webman/$category/index.html 31 | done 32 | 33 | for name in $paths; do 34 | path=external/$name/usr/man/ 35 | for category in $(ls $path); do 36 | for file in $(ls $path/$category); do 37 | utils/manfmt.lua $path/$category/$file > webman/$category/$file.html 38 | printf "%s
" $file $file >> webman/$category/index.html 39 | done 40 | done 41 | done 42 | 43 | for category in $(seq 1 9); do 44 | printf "$htmlend" >> webman/$category/index.html 45 | done 46 | 47 | printf "$htmlend" >> webman/index.html 48 | 49 | if [ "$1" = "upload" ]; then 50 | cd webman 51 | tar cf /tmp/man.tar ./* 52 | cd .. 53 | scp /tmp/man.tar meow:ozcraft/man/ulos 54 | ssh meow -tx "cd ozcraft/man/ulos; tar xf man.tar; rm man.tar" 55 | fi 56 | -------------------------------------------------------------------------------- /utils/mtar.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | -- create an mtar v1 file -- 3 | 4 | local function genHeader(name, len) 5 | --io.stderr:write(name, "\n") 6 | return string.pack(">I2I1I2", 0xFFFF, 1, #name) .. name 7 | .. string.pack(">I8", len) 8 | end 9 | 10 | local function packFile(path) 11 | local handle = assert(io.open(path, "r")) 12 | local data = handle:read("a") 13 | handle:close() 14 | return genHeader(path:gsub("^out/", ""), #data) .. data 15 | end 16 | 17 | for file in io.lines() do 18 | io.write(packFile(file)) 19 | end 20 | -------------------------------------------------------------------------------- /utils/preproc.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | --[[ 3 | Barebones Lua preprocessor. 4 | Copyright (C) 2021 Ocawesome101 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | ]]-- 19 | 20 | _G.env = setmetatable({}, {__index = function(t, k) return os.getenv(k) end}) 21 | 22 | local handle 23 | 24 | local included = {} 25 | local dirs 26 | dirs = { 27 | {"%-%-#define ([^ ]+).-([^ ]+)", function(a, b) 28 | dirs[#dirs + 1] = {"[^a-zA-Z0-9_]"..a.."[^a-zA-Z0-9_]", b} 29 | end}, 30 | {"%-%-#undef ([^ }+)", function(a) 31 | local done = false 32 | for i=1, #dirs, 1 do 33 | if dirs[i][1]:sub(13, -13) == a then 34 | table.remove(dirs, i) 35 | done = true 36 | break 37 | end 38 | end 39 | if not done then 40 | error(a .. ": not defined") 41 | end 42 | end}, 43 | {"$%[%{(.+)%}%]", function(ex) 44 | return assert(io.popen(ex, "r"):read("a")):gsub("\n$","") 45 | end}, 46 | {"@%[%{(.+)%}%]", function(ex) 47 | return assert(load("return " .. ex, "=eval", "t", _G))() 48 | end}, 49 | {"(%-%-#include \")(.+)(\" ?)(.-)", function(_, f, _, e) 50 | if (e == "force") or not included[f] then 51 | included[f] = true 52 | return proc(f) 53 | end 54 | end}, 55 | } 56 | 57 | _G.proc = function(f) 58 | io.write("\27[36m *\27[39m processing " .. f .. "\n") 59 | for line in io.lines(f) do 60 | for k, v in ipairs(dirs) do 61 | line = line:gsub(v[1], v[2]) 62 | end 63 | if not line:match("#include") then 64 | handle:write(line .. "\n") 65 | end 66 | end 67 | end 68 | 69 | local args = {...} 70 | 71 | if #args < 2 then 72 | io.stderr:write([[ 73 | usage: proc IN OUT 74 | Preprocesses files in a manner similar to LuaComp. 75 | 76 | Much more primitive than LuaComp. 77 | 78 | Copyright (C) 2021 Ocawesome101 under the GPLv3. 79 | ]]) 80 | os.exit(1) 81 | end 82 | 83 | handle = assert(io.open(args[2], "w")) 84 | 85 | proc(args[1]) 86 | 87 | handle:close() 88 | 89 | if args[3] == "-strip-comments" then 90 | io.write("\27[93m * \27[39mStripping comments\n") 91 | local rhand = assert(io.open(args[2], "r")) 92 | local data = rhand:read("a") 93 | :gsub(" *%-%-%[(=*)%[.-%]%1%]", "") 94 | :gsub(" *%-%-[^\n]*\n", "") 95 | :gsub("\n+", "\n") 96 | :gsub("\n( +)([^/\\_ ])", "\n%2") 97 | rhand:close() 98 | local whand = assert(io.open(args[2], "w")) 99 | whand:write(data) 100 | whand:close() 101 | end 102 | 103 | io.write("\27[95m * \27[39mSuccess!\n") 104 | 105 | _G.env = nil 106 | _G.proc = nil 107 | 108 | os.exit(0) 109 | -------------------------------------------------------------------------------- /utils/proc.lua: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env lua 2 | -- apparently, LuaComp doesn't work under ULOS 3 | -- I'll fix that later, but for now this will do 4 | 5 | _G.env = setmetatable({}, {__index = function(t, k) return os.getenv(k) end}) 6 | 7 | local proc, handle 8 | 9 | local dirs = { 10 | {"@%[%{(.+)%}%]", function(ex) 11 | return assert(load("return " .. ex, "=eval", "t", _G))() 12 | end}, 13 | {"%-%-#include \"(.+)\"", function(f) 14 | return proc(f) 15 | end}, 16 | } 17 | 18 | proc = function(f) 19 | io.write("\27[36m *\27[39m processing " .. f .. "\n") 20 | for line in io.lines(f) do 21 | for k, v in ipairs(dirs) do 22 | line = line:gsub(v[1], v[2]) 23 | end 24 | handle:write(line .. "\n") 25 | end 26 | end 27 | 28 | local args = {...} 29 | 30 | if #args < 2 then 31 | io.stderr:write([[ 32 | usage: proc IN OUT 33 | Preprocesses files in a manner similar to LuaComp. 34 | 35 | Much more primitive than LuaComp. 36 | ]]) 37 | os.exit(1) 38 | end 39 | 40 | handle = assert(io.open(args[2], "w")) 41 | 42 | proc(args[1]) 43 | 44 | handle:close() 45 | 46 | io.write("\27[95m * \27[39mSuccess!\n") 47 | 48 | os.exit(0) 49 | -------------------------------------------------------------------------------- /versions/bsh: -------------------------------------------------------------------------------- 1 | 1.2.4 2 | -------------------------------------------------------------------------------- /versions/cldr: -------------------------------------------------------------------------------- 1 | 1.1.0 2 | -------------------------------------------------------------------------------- /versions/corelibs: -------------------------------------------------------------------------------- 1 | 1.7.0 2 | -------------------------------------------------------------------------------- /versions/coresvc: -------------------------------------------------------------------------------- 1 | n/a 2 | -------------------------------------------------------------------------------- /versions/coreutils: -------------------------------------------------------------------------------- 1 | 1.9.2 2 | -------------------------------------------------------------------------------- /versions/cynosure: -------------------------------------------------------------------------------- 1 | 1.12.2 2 | -------------------------------------------------------------------------------- /versions/getty: -------------------------------------------------------------------------------- 1 | 0.1.0 2 | -------------------------------------------------------------------------------- /versions/gpuproxy: -------------------------------------------------------------------------------- 1 | 1.0.0 2 | -------------------------------------------------------------------------------- /versions/installer: -------------------------------------------------------------------------------- 1 | 1.2.0 2 | -------------------------------------------------------------------------------- /versions/luaposix: -------------------------------------------------------------------------------- 1 | 0.0.0 2 | -------------------------------------------------------------------------------- /versions/manpages: -------------------------------------------------------------------------------- 1 | 1.8.0 2 | -------------------------------------------------------------------------------- /versions/netutils: -------------------------------------------------------------------------------- 1 | 1.0.0 2 | -------------------------------------------------------------------------------- /versions/norris: -------------------------------------------------------------------------------- 1 | 1.0.0 2 | -------------------------------------------------------------------------------- /versions/osgui: -------------------------------------------------------------------------------- 1 | 1.0.0 2 | -------------------------------------------------------------------------------- /versions/refinement: -------------------------------------------------------------------------------- 1 | 1.5.5 2 | -------------------------------------------------------------------------------- /versions/sudo: -------------------------------------------------------------------------------- 1 | 1.0.0 2 | -------------------------------------------------------------------------------- /versions/tle: -------------------------------------------------------------------------------- 1 | 1.4.0 2 | -------------------------------------------------------------------------------- /versions/upm: -------------------------------------------------------------------------------- 1 | 2.1.0 2 | -------------------------------------------------------------------------------- /versions/usysd: -------------------------------------------------------------------------------- 1 | 1.0.9 2 | -------------------------------------------------------------------------------- /versions/uwm: -------------------------------------------------------------------------------- 1 | 1.3.1 2 | --------------------------------------------------------------------------------