summaryrefslogtreecommitdiff
blob: fdd9d1a0ef591f1fd5befe719495deaf82fb325b (plain)
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<?xml version="1.0" encoding="UTF-8"?>
<guide>
  <title>Universal Select Tool</title>
  <author title="Author">
    <mail link="mephx.x@gmail.com">Sérgio Almeida</mail>
  </author>
  <author title="Editor">
    <mail link="bicatali@gentoo.org">Sébastien Fabbro</mail>
  </author>
  <abstract>
    This document is a complete reference guide for the end user of the 
    Universal Select Tool. 
  </abstract>
  <chapter>
    <title>Introduction</title>
    <body>
      <p>
        The Universal Select Tool is an administration, configuration 
        and profiling tool for Gentoo systems. It's similar to the 
        already existing eselect tool but besides beeing written in 
        python it supports both user and system environment 
        capabilities. Besides beeing a lot faster than it's previous 
        bash implementation, python also makes it a lot easier to expand
        it's code base with already implemented general action types.
      </p>
      <p>
        The Universal Select Tool consists of two tools, the 
		selection tool 'uselect' and the profiling tool 'uprofile'.
      </p>
    </body>
  </chapter>
  <chapter>
    <title>Selection Tool - uselect</title>

    <section>
      <title>Overview</title>
      <body>
        <p>
          The Selection Tool can be used to change system configuration 
          according to specially crafted Modules. This tool consists of 
          3 components:
        </p>
	    <ul>
          <li>uselect tool</li>
          <li>uselect modules</li>
          <li>uselect module's actions</li>
	    </ul>
	  </body>
	</section>
    <section>
      <title>Uselect Tool</title>
      <body>
        <p>
          The uselect tool is a command line interface to use the uselect modules. 
          It features a very similar interface to the eselect's current interface.
          It's quite faster to use because (of course) it's written in python and
          because list and set arguments were thrown away. We will see more as 
          explained in Usage below.
        </p>
      </body>
      <section>
        <title>Usage</title>
        <body>
          <p>The uselect tool should be called with the below usage:</p>
          <pre>
 Options:
    -v  		(*) Verbose Mode
    -nc 		(*) No Colors
    -version    	(*) Version Information

 Modules:
    python      	(*) Python Version Switcher
    bash		(*) Bash Environment Utility
    gcc 		(*) Python GCC Version Switcher
          </pre>
        </body>
      </section>
      <section>
        <title>Wideness</title>
        <body>
          <p>
            When running uselect as a regular user only the user's 
            settings will be changed. The Selection Tool makes use of a 
            new environment folder called '.uselect' localted in the 
            user's $HOME. The '.uselect/' folder structure is 
            automatically created, setup and maintained by uselect.
          </p>
          <p>'~/.uselect' sample folder structure:</p>
          <pre>
.uselect/
  etc/
    completion.d/
    env.d/
  usr/
    bin/
      python -> /usr/bin/python2.6
      gcc -> /usr/bin/gcc-4.3
  bin/
          </pre>
          <p>When running uselect as root the -global option will show up.</p>
          <pre>
 Options:
    -v  		(*) Verbose Mode
    -nc 		(*) No Colors
    -version    	(*) Version Information
    -global     	(*) Set Globally
          </pre>
          <p>
            When this option is specified, changes done by actions are 
            set globally instead of changing root user's profile.
          </p>
        </body>
      </section>
    </section>
    <section>
      <title>Uselect Modules</title>
      <body>
        <p>
          Modules are nothing more than groups of actions that help 
          change the system/user environment. When a module is specified
          to uselect but no action is specified, an action list for the 
          specified module is shown as below:
        </p>
        <pre>
 Module python:
    Author: mephx.x@gmail.com Version: 0.1

 Actions:
    bin 		Change Python's Version
    test		Test Python Environment
    env 		Some env test
        </pre>
        <p>
          At this point Modules are still written in python. The goal is
          to give module developers the ability to create modules in a 
          very easy way without knowing any specific language. When 
          'enough' Action diversity is created, modules can be written 
          by using a markup language like XML or JSON.
        </p>
      </body>
    </section>
    <section>
      <title>Uselect Actions</title>
      <body>
        <p>
          When both a module and an action are specified, the action 
          lists it's available targets/option and it's usage.
        </p>
          <pre>

    Change Python's Version

      0 - /usr/bin/python2.6 - (>) (*)
          1 - /usr/bin/python2.6-config - (>) (*)
          2 - /usr/bin/python2.5-config - (!)
      3 - /usr/bin/python2.5 - (!)
          4 - /usr/bin/python2.6-config - (>) (*)
          5 - /usr/bin/python2.5-config - (!)

          </pre>
        <p>
          Legend:
        
          <ul>
            <li>(>) System's currently selected option</li>
            <li>(*) User's currently selected option</li>
            <li>(!) Unset Option</li>
          </ul>
        </p>
        <p>  
          As you can notice, this python module's action has levels in 
          it's available targets. When you choose a nested target, 
          uselect automatically activates all superior levels of the 
          tree.
        </p>
        <p> 
		  Example:
		</p>
          <pre>
$ uselect python bin 

    Change Python's Version

      0 - /usr/bin/python2.6 - (>) (*)
          1 - /usr/bin/python2.6-config - (>) (*)
          2 - /usr/bin/python2.5-config - (!)

$ uselect python bin 1
Setting /usr/bin/python2.6-config success!
Setting /usr/bin/python2.6 success!
          </pre>
        <p>
          Targets can be specified either by it's index or by it's 
          complete name. 
        </p> 
        <p>
          Example:
        </p>
          <pre>
$ uselect python bin 0
Setting /usr/bin/python2.6 success!
$ uselect python bin /usr/bin/python2.6
Setting /usr/bin/python2.6 success!
          </pre>
      </body>
    </section>
  </chapter>
  <chapter>
    <title>Profiling Tool - uprofile</title>
    <section>
      <title>Overview</title>
      <body>
        <p>
          The Profiling tool can be used to create, set and change user 
          profiles. This tool is still in a PoC state and therefore few 
          options are still available.
		</p>
		<p>
		  The Profiling Tool consists of 2 components:
          <ul>
            <li>uprofile Tool</li>
            <li>uprofile Profiles</li>
          </ul>
        </p>
      </body>
    </section>
    <section>
      <title>Uprofile Tool</title>
      <body>
        <p>
          The uprofile tool is a command line interface to manage the 
          current folder's user profile. Uprofile features a similar 
          interface to uselect's one as can be seen in the Usage below.
        </p>
      </body>
      <section>
        <title>Usage</title>
        <body>
          <p>
            <pre>
$ uprofile -help -list
Usage: uprofile [options] [profile] [action]

 Options:
    -v  		(*) Verbose Mode
    -nc 		(*) No Colors
    -help       	(*) See this screen
    -list       	(*) List Profiles
    -version    	(*) Version Information

 Usage Examples:
    uprofile    	(*) Activates Folder Profile. Fallback to user profile.
    uprofile [profile]  (*) See Details on [profile]

 Profiles:
    folder      	(*) Sample Profile.

            </pre>
          </p>
          <p>
            When called with no arguments, uprofile will activate the 
            current's folder profile.
          </p>
          <p>
            When there exist mode than one profile in current folder, 
            uprofile can be used to switch between them.
          </p>
          <pre>
$ uprofile debug
Usage: uprofile [options] debug [action]

 Profile debug:
    Author: mephx Version: 0.1
    Description: Sample Profile

 Actions:
    activate    	Set this profile for this folder.
    default     	Set this profile the default profile.

         </pre>
        </body>
      </section>
      <section>
        <title></title>
        <body>
          <p>
            Profiles are set in a per-folder basis beeing each folder's 
            profile set by a '.uprofile/' directory similar to the 
            previously introduced '~/.uselect/' folder. Child folder's 
            behaviour is yet to be defined. Profile definition is done 
            in JSON. The default folder profile is set by 
            '.uprofile/folder.json'. Every '.json' file inside 
            '.uprofile/' directory is considered a profile.
          </p>
          <p>
            Example Profile:
          </p>
          <pre>
{"profile": {
	"description": "Sample Profile.",
	"author": "mephx",
	"version": "0.1",
	"modules": {
		"python": {
			"actions": {
				"bin": [
					"/usr/bin/python2.6",
					"/usr/bin/python2.6-config"
					]
				}
			}
	}
}}
          </pre>
        </body>
      </section>
    </section>
  </chapter>
  <chapter>
    <title>Module Developing</title>
    <section>
      <title>Modules</title>
      <body>
        <p>This is an example of a simple module with no actions.</p>
        <pre>
from umodule import *

module = Module(name = "python", description = "Empty Module", version = "0.1", author ="foo@bar.com")
        </pre>
      </body>
    </section>
    <section>
      <title>Actions</title>
      <body>
        <p>
          Actions as in modules are created in the same way. Prior to the 
          action instantiation you have to add the Action to the Module 
          by using the "module.add_action(action)" function.
        </p>
        <pre>
action = Action (name = 'action', description = "Example Action", type = "sym")

module.add_action(action)
        </pre>
      </body>
      <section>
        <title>Action Types</title>
        <body>
          <p>
            Actions can have different types. Types are pre-defined and 
            pre-implemented action templates. Up to now only 3 types 
            are implemented. 
          </p>
        </body>
        <section>
          <title>Runnable</title>
          <body>
            <p>
              The Runnable type is a simple API so you can have actions 
              coded in any interpreted language.
            </p>
			<p>
			  add_parameter(String)
			  Add parameter to be displayed in the argument's usage. 
			  <pre> action.add_parameter('[target]')</pre>
		    </p>
		    <p>
		      add_usage(String)
		      Add code to be evaluated when no arguments are specified. 
		      <pre>test.add_usage("""#!/usr/bin/python
print "Usage can be multi-line!"
print 5 * "And can have dynamic options! You Choose!\n"""")
              </pre>
		    </p>
		    <p>
		      add_code(String)
		      Add the action's main code. 
		      <pre> 
test.add_code("""#!/usr/bin/python
print "Test Action In Python!"
""")
              </pre>
		    </p>
            <p>Example Runnable Action:</p>
            <pre>
test = Action (name = 'test', description = 'Runnable Action Test', type = 'runnable')

test.add_parameter('[argument]')

test.add_usage("""#!/usr/bin/python
print "Usage can be multi-line!"
print 5 * "And can have dynamic options! You Choose!\n"
""")

test.add_code("""#!/usr/bin/python
print "Test Action In Python!"
""")
            </pre>
          </body>
        </section>
        <section>
          <title>Sym</title>
        </section>
        <section>
          <title>Env</title>
        </section>
      </section>
    </section>
  </chapter>
  <date>2009-09-03</date>
  <version>1</version>
</guide>