mor

Cross platform dependency manager

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
mor
===
    .--.
   /    \
  ==( )-( )
  (    ._)
   |(-=) |

mor(pheus) is tool that simplifies dependency management the right way.
Some might even say it is a red-pill way of dependency management.

mor searches for requirements.ini file in the current folder, and uses it's
content to download files.

Goals
-----
* Should work standalone
* Cross-platform
* Tiny - mor.cmd for windows, mor.sh for *NIX

Note
----
- Read the FAQ section
- Check the Windows section below if you're using mor.cmd

Config File
------------
mor uses .ini files as config files and can be given to mor with -c flag.
When no flags are given, it searches for requirements.ini in the current
working directory.

In a mor config file, the [sections] represent a directory or target.
The key=value pair under the [section] are the files to download in that
current directory.

[$] is a special section that is discussed in 'Variables' below.

	; requirements.ini
	[$]
	/=out

	[precompiled]
	libfoo-2.7=https://example.com/awavauatush/libfoo.zip
	libbar-3.5=https://example.com/awavauatush/libbar.zip
	...

	$ mor precompiled
	$ tree out/
	precompile
	|--libbar-3.5.zip
	|--libbar-3.5/
	|--libfoo-2.7.zip
	|--libfoo-2.7/

Targets
-------

Not all sections create sub-directoies mind you!

Sections that have a '@' or '#' as the starting letter are treated as target(@)
and target query(#).

Previously we have created [precompiled] section and invoked the mor command to
download it. Real life is seldom this simple.

Usually we are in a situation where the pre-compiled binaries are different for
different architectures and platforms.

	; packages.ini
	[precompiled-macos]
	libfoo-2.7=https://example.com/macos/precompiled.zip

	[precompiled-linux]
	libfoo-2.7=https://example.com/linux/precompiled.zip

In that case we can define a target query with '#',

	; packages.ini
	[#lib]
	match=k-v
	paths=precompiled-$platform download

	; requirements.ini
	[@lib]
	libfoo=2.7

The $platform in the above can be passed to mor as,

	mor -Dplatform=linux @lib

Variables
---------

mor treats any word that starts with '$' as variable and tries to expand it.

Variables in mor has a specific rule and follows the following regex,

	([a-z][A-z])*[0-9][a-z]

	[$]
	; the output folder
	/=outfolder
	; arbitrary variables
	git=https://git.example.com

Status Messages
---------------
Mor uses the following symbols to denote the status to the user,

v - Download
| - Archive Extraction
g - Git
> - Info
! - Error

Example
-------
	; requirements.ini
	[$]
	>[]=packages.ini
	@[]=@lib @build

	[@lib]
	libfoo=2.7

	# when using apple-darwin, use @lib
	[@lib:x86_64-apple-darwin]
	libfoo-git=2.7

	; packages.ini
	[$]
	git=https://git.example.com
	match=k-v
	/=out/.sysroot

	[folder/]
	libfoo-2.7=$git/releases/libfoo/releases/v26.1/foo-26.1-osx-universal.zip
	libfoo-git-2.7=$github/foo/libfoo.git@master

Windows
-------
- curl is the preferred downloader for windows, but if it is missing, mor
defaults to bitsadmin.exe which is available in older versions of Windows.

If you face extreme slowness in downloads when using bitsadmin, it's probably
because some other application is using it to download
something (like Windows Update).If you are on a hurry, you can do

	C:\Users\Admin> bitsadmin /reset

to clear all downloads and try running mor again.

Bugs
----
- Currently it is not possible to null a variable with -D in Windows.

	mor -Dvar= download

The above will silently assign 'download' to $var.
This is a bug with how the cmd process arguments. Use -Dvar="" instead.

- It is currently not possible to use a '$something' directly in a URL if a
variable named 'something' is defined in '$' section

- The varable expansion is not really ([a-z][A-z])*[0-9][a-z].

FAQ
---
> Why the weird symbols ($/, $<, $>) instead of simple clean $root, $include,
etc in [$]?
I wanted mor to be as language agnostic as possible and I wanted the core
variables to be ASCII clean. This is also the reason why the status messages
are mostly made up of symbols.

> Why no 'clean' command?
To keep things simple.
Just do `rm -rf 'directory` or `rmdir /s/q directory` if using cmd

> Where are the damn CHANGELOGs?
For the complete changelog,
        git notes show v0.2~1..

For a specific version,
        git notes show v0.2

Credits
-------
The graphics is a derivative of "butler" by jgs.