forked from community-ssu/hildon-application-manager
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME
235 lines (169 loc) · 8.55 KB
/
README
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
This is hildon-application-manager, version 2
=============================================
The Hildon Application Manager is a program to manage add-on software
components for the Hildon Desktop. It uses the Debian package
management tools provided by the maemo platform (namely APT and dpkg)
and presents a 'end user oriented' interface to them.
The Debian package management tools are powerful enough to manage the
whole system, but the Hildon Application Manager does not offer the
full power to the user.
Instead, the Hildon Application Manager is intended to be fully
compatible with existing and future interfaces to the package
management tools. It should be possible to, for example, freely
alternate between apt-get, synaptic and the Hildon Application Manager
and not have anything break. Thus, if you need more power, you can
use Debian package management tools directly, or use one of the more
powerful interfaces.
Documentation
-------------
Technical documentation can be found in the doc/ directory. It mostly
explains how the apt technology is used in the context of maemo and
how it has been extended.
- packaging.txt
For package maintainers; explains things like how to make the
Application installer not hide your package from the user, how to
associate an icon with it, etc.
- repository.txt
For repository maintainers; explains things like how to "certify"
parts of a repository, etc.
- install.txt
For people writing .install files.
- red-pill.txt
For power users.
About the implementation
------------------------
If you want to dive into the code, this is your spring board (aka "The
Design Document"). This section gives a high level overview of the
implementation, highlights general principles and then describes how
the code is divided into files. Further documentation of internal
APIs etc. is contained in the appropriate source code files.
The essential library that provides the actual package management
functionality is libapt-pkg. It is used by the Application installer
in the same way as apt-get, Synaptic and aptitude use it and its use
integrates the Application installer seamlessly into the system-wide
package management.
The Application manager runs as two processes: The first process
implements the GUI and runs as the user who started the Application
Manager. The second process is started in the background and is the
one that actually links to libapt-pkg and does all the package
management work. It runs as "root".
The first process is called the "frontend", the second one is called
the "backend".
The frontend starts the backend by executing an appropriate "sudo"
command (in the Scratchbox environment, fakeroot is used instead).
The two processes communicate via named fifos using an ad-hoc, binary,
private protocol. The frontend also captures stdout and stderr of the
backend and makes it available to the user as the "Log".
No attempt has been made to restrict access to the backend. Every
program, not just the frontend, can start the backend without needig
to provide any credentials such as the root password. Since the
backend can be instructed to execute arbitrary code (via the
maintainer scripts of a package), having the Application installer in
your system is like having a globally known password on the root
account. This is deemed acceptable for the maemo platform since
devices built using that platform are not multi-user devices (yet) and
there is no system administrator. Privilege separation is used only
to contain damage in the case of accidents, not to defend against
attacks.
The backend is command driven: it reads a request, executes it, ships
back a respose, and then loops to reads the next request. It
asynchronously sends status upates. Downloads performed by the
backend are interuptible, but in general commands are not
interruptible.
The frontend is event driven in the usual way. It will send requests
to the backend and then react to it when the result arrives by
executing a registered callback. Somewhat unusually, it will just run
one event loop and no recursive ones for modal dialogs or when waiting
for a reponse from the backend. In effect, the control flow is
implemented in continuation passing style. (The event loop is the
trampoline that gives us the desired tail-call elimination for this.)
The motivation for using continuation passing style was to avoid
spontanous reentry of event callbacks (which are not supported by Gtk+
and are tricky in general) but still have a fully concurrent 'UI
experience'. Thus most of the code does not need to be reentrant,
which makes it easier to reason about its robustness.
Writing in continuation passing style in C is a bit cumbersome, but
worth it, in my opinion.
The backend and most of the frontend is written in C++, but a small
part of the GUI code is plain C to enable easier transportation into
external libraries or reuse. Despite the use of C++, this is not a
object oriented program. No inheritance, run-time types, exceptions
or templates are used.
The backend is contained in the single file "apt-worker.cc".
The protocol that is used between the frontend and the backend is
defined in "apt-worker-proto.h". Support for encoding and decoding it
'for the wire' is contained in "apt-worker-proto.cc". These two files
are used by both the frontend and the backend, but no other source
files are shared.
The frontend uses global variables without prejudice and in a
disciplined way. Being a program (and not a library), the frontend
naturally has a well defined global state and the knowledge about this
is exploited to simplify the internal APIs. For example, the function
'do_current_operation' takes no parameters and will start the
installation/upgrading/removal process of the currently highlighted
package, depending on the currently active view. However, the global
package list and the global section list clearly go to far and need to
be 'unglobalized'.
The frontend implementation is divided into a number of files
according to easily recognizable UI features. Internal APIs are
documented in the header files.
- main.h, main.cc
Contains the main logic, such as all the views and code for
installing/upgrading/removing packages and installing from a file.
The header file defines the main data structure used by the
frontend: package_info.
- menu.h, menu.cc
The main menu and the context menu for package lists.
- details.h, details.cc
The "Details" dialog.
- settings.h, settings.cc
The "Settings" dialog and loading saving of settings and persistent
state.
- search.h, search.cc
The "Search" dialog. The actual searching is implemented in main.cc.
- repo.h, repo.cc
The "Catalogue" dialog.
- log.h, log.cc
The "Log" dialog.
- instr.h, instr.cc
For handling the MIME type application/x-install-instructions.
- util.h, util.cc
A host of general UI and non-UI related utilities such as
confirmation dialogs, scrollable text views, progress indicators,
etc.
These files also contain the implementation of the package list and
section list functionality.
- xexp.h, xexp.c
A implementation of a expressive, general purpose data structure,
inspired by S-Expressions but encoded in XML. This data structure
is used for storing the catalogue settings and when scripting the
Application Manager via .install files. Xexps can be exchanged
easily between the frontend and backend.
- confutils.h, confutils.cc
Utilities for handling configuration related tasks. Used in the
frontend, backend, and the hildon-application-manager-config utility
program.
- hildonbreadcrumbtrail.h, hildonbreadcrumbtrail.c
A throw-away implementation of the breadcrumb trail 'widget'. These
files might turn one-day into a real, reuseable widget, but right
now they only implement the bare necessities.
- apt-worker-client.h, apt-worker-client.cc
Support for starting the backend and communicating with it.
- hildon-application-manager-config.cc
A command line utility for managing the configuration data of the
Application Manager.
BUGS
----
- Make reboot decision more flexible. (from maintainer scripts?)
- Reenable apt-transport-https by using nss.
- Take update-notifier menu contents into account for the blinking state.
- Call reset_idle_timer more often
- Add "New Folder" functionality to maemo-select-menu-location.
- Explain non-removable system updates in Details dialog.
- Consider autolaunching.
Cleanup
-------
The code needs a serious cleanup. For example
- the global package and section list needs to be unglobalized.
- likewise localize_file_and_keep_it_open.
- instead of recreating widgets all the time, we should hide/show them.