]> cygwin.com Git - cygwin-apps/setup.git/blob - choose.cc
* Replace everything with a new GUI version
[cygwin-apps/setup.git] / choose.cc
1 /*
2 * Copyright (c) 2000, Red Hat, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by DJ Delorie <dj@cygnus.com>
13 *
14 */
15
16 /* The purpose of this file is to let the user choose which packages
17 to install, and which versions of the package when more than one
18 version is provided. The "trust" level serves as an indication as
19 to which version should be the default choice. At the moment, all
20 we do is compare with previously installed packages to skip any
21 that are already installed (by setting the action to ACTION_SAME).
22 While the "trust" stuff is supported, it's not really implemented
23 yet. We always prefer the "current" option. In the future, this
24 file might have a user dialog added to let the user choose to not
25 install packages, or to install packages that aren't installed by
26 default. */
27
28 #include "win32.h"
29 #include <stdio.h>
30 #include "dialog.h"
31 #include "resource.h"
32 #include "state.h"
33 #include "ini.h"
34 #include "concat.h"
35 #include "msg.h"
36
37 void
38 do_choose (HINSTANCE h)
39 {
40 int trust_prefs[NTRUST];
41 int i, t;
42
43 /* support this later */
44 trust_level = TRUST_CURR;
45
46 t = 0;
47 for (i=trust_level; i>=0; i--)
48 trust_prefs[t++] = i;
49 for (i=trust_level+1; i<NTRUST; i++)
50 trust_prefs[t++] = i;
51
52 for (i=0; i<npackages; i++)
53 {
54 for (t=0; t<NTRUST; t++)
55 if (package[i].info[t].install)
56 {
57 package[i].trust = t;
58 break;
59 }
60 }
61
62 if (root_dir)
63 {
64 char line[1000], pkg[1000], inst[1000], src[1000];
65 int instsz, srcsz;
66 FILE *db = fopen (concat (root_dir, "/etc/setup/installed.db", 0), "rt");
67 if (db)
68 {
69 while (fgets (line, 1000, db))
70 {
71 src[0] = 0;
72 srcsz = 0;
73 sscanf (line, "%s %s %d %s %d", pkg, inst, &instsz, src, &srcsz);
74
75 for (i=0; i<npackages; i++)
76 {
77 if (strcmp (package[i].name, pkg) == 0)
78 {
79 if (strcmp (package[i].info[package[i].trust].install,
80 inst) == 0)
81 package[i].action = ACTION_SAME;
82 else
83 package[i].action = ACTION_UPGRADE;
84 }
85 }
86 }
87 fclose (db);
88 }
89 }
90
91 for (i=0; i<npackages; i++)
92 if (package[i].action == ACTION_UNKNOWN)
93 package[i].action = ACTION_NEW;
94
95 if (source == IDC_SOURCE_CWD)
96 next_dialog = IDD_S_INSTALL;
97 else
98 next_dialog = IDD_S_DOWNLOAD;
99 }
100
This page took 0.039001 seconds and 5 git commands to generate.