-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.h
451 lines (349 loc) · 15.9 KB
/
install.h
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
#ifndef _install_h
#define _install_h
#include "config.h"
#include "setupdb.h"
#include "detect.h"
#include "arch.h"
#include "setup-locale.h"
#include <limits.h>
#include "setup-xml.h"
/* Conversion macro for bytes to megabytes */
#define BYTES2MB(bytes) ((bytes/(1024*1024))+1)
/* The default permissions mask for creating files */
#define DEFAULT_UMASK 022
/* The default location of the product */
#if defined(darwin)
#define DEFAULT_PATH "/Applications"
#else
#define DEFAULT_PATH "/usr/local/games"
#endif
/* The default location of the symlinks */
#define DEFAULT_SYMLINKS "/usr/local/bin"
/* The different setup states */
typedef enum {
SETUP_ABORT = -1,
SETUP_INIT,
SETUP_CLASS,
SETUP_LICENSE,
SETUP_README,
SETUP_OPTIONS,
SETUP_CDKEY,
SETUP_INSTALL,
SETUP_WEBSITE,
SETUP_COMPLETE,
SETUP_PLAY,
SETUP_EXIT
} install_state;
/* The types of desktop we support menu items for */
typedef enum {
DESKTOP_MENUDEBIAN,
DESKTOP_REDHAT,
DESKTOP_GNOME,
DESKTOP_KDE, /* KDE first because RH6.1 does not yet handle KDE well. */
DESKTOP_CDE, /* Common Desktop Environment */
DESKTOP_IRIX, /* IRIX ToolChest */
MAX_DESKTOPS
/* More to come ? */
} desktop_type;
/* Forward declaration (used by UI) */
struct UI_data;
/* Forward declaration */
typedef struct _URLlookup URLlookup;
/* Forward declaration */
typedef struct _install_log install_log;
/* The main installation information structure */
typedef struct _install_info {
/* The product name and description */
const char *name;
const char *desc;
const char *version;
/* The category for menu items */
const char *category;
/* The update URL for the product */
const char *update_url;
/* The product install destination */
char install_path[PATH_MAX];
/* The product symlinks destination */
char symlinks_path[PATH_MAX];
const char *installed_symlink;
/* The root of the manpage directory structure to install to */
char man_path[PATH_MAX];
/* The path to the binary for the 'Play' button */
char play_binary[PATH_MAX];
/* The path from which setup is run */
char setup_path[PATH_MAX];
/* The optional path prefix for the product */
char prefix[PATH_MAX];
/* The XML installation config */
xmlDocPtr config;
/* Autodetected environment */
const char *arch;
const char *libc;
distribution distro;
int distro_maj, distro_min; /* Version numbers for the detected distribution */
/* Bitfields of install options */
struct {
unsigned install_menuitems: 1;
unsigned reinstalling: 1;
unsigned unused:30;
} options;
/* The CDROM descriptions */
struct cdrom_elem {
char *id;
char *name;
char *file;
char *mounted;
struct cdrom_elem *next;
} *cdroms_list;
/* The amount installed so far, in bytes */
unsigned long long installed_bytes;
/* The total install size, in bytes */
unsigned long long install_size;
/* Flag indicating if the installation was completed */
int install_complete;
struct component_elem {
char *name;
char *version;
int is_default;
struct option_elem {
char *name;
char *tag; /* Optional, can be NULL */
/* List of installed files and symlinks */
struct file_elem {
char *path;
const char *option;
unsigned char md5sum[16];
char *symlink; /* If file is a symlink, what it points to */
char *desktop; /* If file is a desktop item, what binary it is associated with */
unsigned mutable : 1;
struct file_elem *next;
} *file_list;
/* List of installed directories */
struct dir_elem {
char *path;
const char *option;
struct dir_elem *next;
} *dir_list;
/* List of installed binaries */
struct bin_elem {
struct file_elem *file; /* Holds the file information */
const char *symlink;
const char *desc;
const char *menu;
const char *name;
const char *icon;
const char *args;
struct bin_elem *next;
} *bin_list;
/* List of installed man pages */
struct man_elem {
struct file_elem *file;
const char *section;
struct man_elem *next;
} *man_list;
/* List of post-uninstall scripts to run (from RPM files) */
struct script_elem {
char *script;
struct script_elem *next;
} *pre_script_list, *post_script_list;
/* List of RPMs installed in the process */
struct rpm_elem {
char *name;
char *version;
int release;
int autoremove;
struct rpm_elem *next;
} *rpm_list;
struct option_elem *next;
} *options_list;
struct envvar_elem {
char *name;
struct envvar_elem *next;
} *envvars_list;
char *postun, *preun; /* Optional per-component uninstall scripts */
char *message; /* Optional message */
struct component_elem *next;
} *components_list;
/* Product-global env vars */
struct envvar_elem *envvars_list;
/* Product and component DB information */
product_t *product;
product_component_t *component;
/* Arguments to the game when launching it */
const char *args;
/* URL lookup handle */
URLlookup *lookup;
/* Unspecified UI data */
struct UI_data *uidata;
} install_info;
/** callback for progress bar updates in the UI */
typedef int (*UIUpdateFunc)(install_info *info, const char *path, size_t progress, size_t size, const char *current);
/* Functions to retrieve attribution information from the XML tree */
extern const char *GetProductName(install_info *info);
extern const char *GetProductDesc(install_info *info);
extern const char *GetProductComponent(install_info *info);
extern const char *GetProductUninstall(install_info *info);
extern const char *GetProductVersion(install_info *info);
extern int GetProductCDROMRequired(install_info *info);
extern int GetProductCDROMDescriptions(install_info *info);
extern int GetProductIsMeta(install_info *info);
extern int GetProductHasNoBinaries(install_info *info);
extern int GetProductHasPromptBinaries(install_info *info);
extern const char *GetProductSplash(install_info *info);
extern const char *GetProductCDROMFile(install_info *info);
extern const char *GetProductEULANode(install_info *info, xmlNodePtr node, int *keepdirs);
extern const char *GetProductEULA(install_info *info, int *keepdirs);
extern const char *GetProductREADME(install_info *info, int *keepdirs);
extern const char *GetWebsiteText(install_info *info);
extern const char *GetProductURL(install_info *info);
extern const char *GetProductUpdateURL(install_info *info);
extern const char *GetLocalURL(install_info *info);
extern const char *GetAutoLaunchURL(install_info *info);
extern const char *GetPreInstall(install_info *info);
extern const char *GetPostInstall(install_info *info);
extern const char *GetRuntimeArgs(install_info *info);
extern const char *GetInstallOption(install_info *info, const char *option);
extern const char *GetPreUnInstall(install_info *info);
extern const char *GetPostUnInstall(install_info *info);
extern const char *GetProductDefaultBinaryPath(install_info *info);
extern int GetProductNumComponents(install_info *info);
extern int GetProductRequireRoot(install_info *info);
extern int GetProductAllowsExpress(install_info *info);
extern int GetProductInstallOnce(install_info *info);
extern int GetProductReinstall(install_info *info);
extern int GetProductReinstallNoWarning(install_info *info);
extern int GetReinstallNode(install_info *info, xmlNodePtr node);
extern int GetProductIsAppBundle(install_info *info);
extern int GetProductSplashPosition(install_info *info);
extern int GetProductHasManPages(install_info *info);
extern int GetProductUseFork(install_info *info);
extern const char *GetProductCDKey(install_info *info);
extern const char *GetProductPostInstallMsg(install_info *info);
/** whether the user should be prompted when files already exist */
extern int GetProductPromptOverwrite(install_info *info);
/** whether the product should reinstall with _zero_ user interaction. */
int GetProductReinstallFast(install_info *info);
/** whether the product should not installe Gnome/KDE/etc menu items */
int GetProductInstallMenuItems(install_info *info);
/** check if product can be installed. Returns NULL if product can be
* installed, otherwise reason why not. */
extern const char *IsReadyToInstall(install_info *info);
/** same as IsReadyToInstall but may additionally return a more verbose
* explanation of what went wrong in the variable explanation. This string must
* be freed manually if set.
*/
extern const char *IsReadyToInstall_explain(install_info *info, char** explanation);
extern int CheckRequirements(install_info *info);
/* Parse the XML file for <bool> definitions */
extern int GetProductBooleans(install_info *info);
/* Create the initial installation information */
extern install_info *create_install(const char *configfile,
const char *install_path,
const char *binary_path,
const char *product_prefix);
/* Create a new CDROM description entry */
struct cdrom_elem *add_cdrom_entry(install_info *info, const char *id, const char *name,
const char *file);
/* Change the detected mount point for a CDROM */
void set_cdrom_mounted(struct cdrom_elem *cd, const char *path);
/* Create a new component entry */
struct component_elem *add_component_entry(install_info *info, const char *name, const char *version, int def,
const char *preun, const char *postun);
/* Create a new option entry */
struct option_elem *add_option_entry(struct component_elem *comp, const char *name, const char *tag);
/* Create a new environment variable entry, either global or component-specific */
struct envvar_elem *add_envvar_entry(install_info *info, struct component_elem *comp, const char *name);
/* Add a file entry to the list of files installed */
extern struct file_elem *add_file_entry(install_info *info, struct option_elem *opt, const char *path,
const char *symlink, int mutable);
/* Add a script entry for uninstallation of manually installed RPMs */
extern void add_script_entry(install_info *info, struct option_elem *opt, const char *script, int post);
/* Add a RPM entry to the list of RPMs installed */
extern void add_rpm_entry(install_info *info, struct option_elem *opt, const char *name,
const char *version, int release,
const int autoremove);
/* Add a directory entry to the list of directories installed */
extern void add_dir_entry(install_info *info, struct option_elem *opt, const char *path);
/* Add a binary entry to the list of binaries installed */
extern void add_bin_entry(install_info *info, struct option_elem *opt, struct file_elem *file,
const char *symlink, const char *desc, const char *menu,
const char *name, const char *icon, const char *args, const char *play);
/* Add a man page entry */
extern void add_man_entry(install_info *info, struct option_elem *comp, struct file_elem *file,
const char *section);
/* Expand a path with home directories into the provided buffer */
extern void expand_home(install_info *info, const char *path, char *buffer);
/* Function to set the install path string, expanding home directories */
extern void set_installpath(install_info *info, const char *path, int append_slash);
/* Function to set the symlink path string, expanding home directories */
extern void set_symlinkspath(install_info *info, const char *path);
/* Function to set the man path string, expanding home directories */
extern void set_manpath(install_info *info, const char *path);
/* Mark/unmark an option node for install, optionally recursing */
extern void mark_option(install_info *info, xmlNodePtr node,
const char *value, int recurse);
/* Enable an option recursively, given its name */
extern int enable_option(install_info *info, const char *option);
/* Get the name of an option node */
extern char *get_option_name(install_info *info, xmlNodePtr node, char *name, int len);
/* Get the optional help of an option node, with localization support */
const char *get_option_help(install_info *info, xmlNodePtr node);
/* Get the optional selection warning of an option node, with localization support */
const char *get_option_warn(install_info *info, xmlNodePtr node);
/* Determine if an option should be displayed */
int get_option_displayed(install_info *info, xmlNodePtr node);
/* Free the install information structure */
extern void delete_install(install_info *info);
/* This only affects the CDROM and filesystem components, and is called from delete_install() */
extern void delete_cdrom_install(install_info *info);
/* Actually install the selected filesets */
extern install_state install(install_info *info, UIUpdateFunc update);
/* Abort a running installation (to be called from the update function) */
extern void abort_install(void);
/* Remove a partially installed product */
extern void uninstall(install_info *info);
/* Generate an uninstall shell script */
extern void generate_uninstall(install_info *info);
/* Remove the root directory part from a path */
extern const char *remove_root(install_info *info, const char *path);
/* Updates the 'uninstall' binary in ~/.loki/installed/bin and creates a shell script */
extern int update_uninstall(install_info *info, product_t *product);
/* Run pre/post install scripts */
extern int install_preinstall(install_info *info);
extern int install_postinstall(install_info *info);
/* Recursively look for options with install="command" and run the commands to determine the actual status */
void mark_cmd_options(install_info *info, xmlNodePtr parent, int exclusive);
/* Launch the game using the information in the install info */
extern install_state launch_game(install_info *info);
/* Launch a web browser with the URL specified in the XML file */
extern int launch_browser(install_info *info, int (*browser)(const char *url));
/* Install the desktop menu items */
extern int install_menuitems(install_info *info, desktop_type d);
/* Run shell script commands from a string
If 'arg' is >= 0, it is passed to the script as a numeric argument,
otherwise the install path is passed as a command line argument.
'include_tags' indicates if the SETUP_OPTIONTAGS should be set in the script header.
*/
extern int run_script(install_info *info, const char *script, int arg, int include_tags);
/* Convenience functions to quickly change back and forth between current directories */
extern void push_curdir(const char *path);
extern void pop_curdir(void);
/* Run a program in the background */
int run_command(install_info *info, const char *cmd, const char *arg1, const char *arg2, int warn);
int run_command3(install_info *info, const char *cmd, const char *arg1, const char *arg2, const char *arg3, int warn);
/* Manage the list of corrupt files if we're restoring */
extern void add_corrupt_file(const product_t *prod, const char *path, const char *option);
extern void free_corrupt_files(void);
extern int file_is_corrupt(const product_t *prod, const char *path);
extern int restoring_corrupt(void);
extern void select_corrupt_options(install_info *info);
int xmlNodePropIsTrue(xmlNodePtr node, const char* prop);
int xmlNodePropIsFalse(xmlNodePtr node, const char* prop);
/*** Global variables ****/
extern int disable_install_path;
extern int disable_binary_path;
extern int express_setup;
#ifdef __linux
extern int have_selinux;
#endif
#endif /* _install_h */