1 |
Hello all, |
2 |
|
3 |
Once again, another productive week. This week's work focused mostly on |
4 |
profiles. Uprofile's implementation exceeded my expectations and was |
5 |
much easier than what I thought it would be, the reason: uselect's |
6 |
simple api. |
7 |
|
8 |
What's working on uprofile: |
9 |
|
10 |
* uprofile when called with no arguments, finds current folder profile. |
11 |
If not present, it lists available profiles. |
12 |
|
13 |
** Available profiles are profiles other than './uprofile/folder.json' |
14 |
|
15 |
* Profiles are written in json |
16 |
|
17 |
** Why json and not xml? Well, whoever said that xml is human-readable |
18 |
should reconsider the clause. In need of a markup language, easy bridge |
19 |
between python and markup, easily human-readable, I have chosen json. |
20 |
|
21 |
Example: |
22 |
|
23 |
{"profile": { |
24 |
"description": "Sample Profile", |
25 |
"author": "mephx.x@×××××.com", |
26 |
"version": "0.1", |
27 |
"modules": { |
28 |
"python": { |
29 |
"actions": { |
30 |
"bin": [ |
31 |
"/usr/bin/python2.6", |
32 |
"/usr/bin/python2.6-config" |
33 |
] |
34 |
} |
35 |
} |
36 |
} |
37 |
}} |
38 |
|
39 |
In this profile, uprofile would call module python, action bin with |
40 |
args: python2.6 and python2.6-config. |
41 |
|
42 |
uprofile when called: |
43 |
|
44 |
mephx - profiledfolder $ uprofile |
45 |
Setting Folder Profile... |
46 |
Setting /usr/bin/python2.6 success! |
47 |
Setting /usr/bin/python2.6-config success! |
48 |
Folder Profile Set! |
49 |
|
50 |
* Profiles read modules (from uselect's module dir), actions from |
51 |
modules, and call's Action.do_action() method with the specified args |
52 |
list. |
53 |
** In order to profiles to work properly, arguments cannot be Integers |
54 |
as in uselect/eselect. All modules's actions which feature profiling |
55 |
capabilities, need to accept either indexed values, either absolute |
56 |
string values for specific selection. Why? Example: New python bin |
57 |
appears in /usr/bin, indexes change, profile gets broken. |
58 |
|
59 |
* Decided to keep a bin/ and a env.d/ in each .uprofile directory. These |
60 |
are updated as they normally would via uselect. |
61 |
|
62 |
* Automatic profile changing in bash can be done via a specially crafted |
63 |
PROMPT_COMMAND. I'm using this one now: |
64 |
|
65 |
PROMPT_COMMAND="test -e $HOME/.uselect/env.d/ && |
66 |
PROFILE='$HOME/.uselect' ; test -e .uprofile/env.d/ && |
67 |
PROFILE='./.uprofile' ; source \$PROFILE/env.d/*" |
68 |
|
69 |
** This actually changes the profile quite fast and reflects the changes |
70 |
on $PS1 with the folder name, neat =) |
71 |
|
72 |
mephx - ~/ $ cd profiledfolder |
73 |
[folder] mephx - profiledfolder $ |
74 |
|
75 |
** To generate .uprofile/ directory, uprofile needs to be called by |
76 |
hand. Sourcing env.d/ automatically also updates the user's PATH to that |
77 |
bin DIR (this is still not implemented) therefore not needing to call |
78 |
uprofile every time you wish to activate the profile. |
79 |
|
80 |
|
81 |
Next steps: |
82 |
|
83 |
* Finish implementing env actions. (It's now much funnier to test env |
84 |
actions using profiles) |
85 |
* Implement uprofile module for uselect as suggested. |
86 |
* Implement some more modules. |
87 |
|
88 |
What do you think? |
89 |
|
90 |
* json modules? |
91 |
* profile constraints (this is basically adding if's to profiles if we |
92 |
want profiles to behave differently on certain conditions (hostname, |
93 |
arch, etc...) |
94 |
|
95 |
During the next week, I will deploy a properly packed version for |
96 |
testing. I will also launch a call for modules to every *-eselect dev |
97 |
and *-config dev as I do not have the time to implement most of the |
98 |
modules just for testing purposes. Most modules are very easy to do |
99 |
(symlinking ones) and conversion of eselect to uselect can be done |
100 |
instantly, yet in an ugly way of still using all eselect's libs. |
101 |
|
102 |
Keep tuned for more. And stay in school =) |
103 |
|
104 |
Cheers, |
105 |
Sérgio |
106 |
-- |
107 |
Sérgio Almeida - mephx.x@×××××.com |
108 |
mephx @ freenode |