-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathPatches
1257 lines (1174 loc) · 42.5 KB
/
Patches
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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
*************************************************************************
*** Applied ***
Date: Tue, 18 Apr 2000 07:54:24 +0200
From: "Jeroen Janssen" <[email protected]>
Subject: getting the install source path (cdrom) from within (pre/post)
installation scripts?
Hello,
I'm working on an updated OpenUT setup and I need access to the source path
(of the installation cdrom) in order to apply some xdelta based patches
during the install (xdelta needs the original files from cdrom and applies a
binary diff to it). Since the destination path & symlink path are already
put in the scripts environment I was wondering if it's also possible to add
the install source path to the environment.
I attached a simple patch that *should* do the trick (unfortunately I can't
test it here, so I hope it doesn't break anything), you might want to think
about a different environment variable name & mupltiple/no CDROM support.
Best regards,
Jeroen Janssen
diff -u -r setup-1.2/install.c setup-1.2-jeroenj/install.c
--- setup-1.2/install.c Fri Mar 10 02:20:38 2000
+++ setup-1.2-jeroenj/install.c Tue Apr 18 13:21:06 2000
@@ -814,12 +814,15 @@
"SETUP_PRODUCTVER=\"%s\"\n"
"SETUP_INSTALLPATH=\"%s\"\n"
"SETUP_SYMLINKSPATH=\"%s\"\n"
- "export SETUP_PRODUCTNAME SETUP_PRODUCTVER SETUP_INSTALLPATH SETUP_SYMLINKSPATH\n"
+ "SETUP_CDROMPATH=\"%s\"\n"
+ "export SETUP_PRODUCTNAME SETUP_PRODUCTVER SETUP_INSTALLPATH SETUP_SYMLINKSPATH SETUP_CDROMPATH\n"
"%s\n",
info->name, info->version,
info->install_path,
info->symlinks_path,
- script);
+ cdroms[0], // return first available CDROM (check? do we HAVE a CDROM?)
+ script);
+
fchmod(fileno(fp),0755); /* Turn on executable bit */
fclose(fp);
if ( arg >= 0 ) {
*************************************************************************
*** Applied ***
Date: Mon, 14 Feb 2000 12:24:32 -0700
From: "Troy A. Griffitts" <[email protected]>
Subject: desktops, icons, etc.
I've made the desktop location code a little more intuitive for gnome
and kde.
There is a new destop: REDHAT where info is stored in /etc/Xll/applnk.
Redhat intends for this to work in both the gnome and kde worlds, but
kde is not handled well as of 6.1, so KDE icons are still installed
regardless if a redhat desktop is found.
There are also new options on binary nodes to specify the 'name' on the
icon and to what sub-'menu' the icon will be intalled (created if
necessary). This handles multiple binaries much better.
eg.
<binary arch="any" libc="any" symlink="app1"
menu="Applications/MyProject" name="Application 1" icon="app1icon.xpm">
app1
</binary>
<binary arch="any" libc="any" symlink="app2"
menu="Applications/MyProject" name="Application 2" icon="app2icon.xpm">
app2
</binary>
Everything should still default to 'Games' and such, if none of these
extra options are used.
Again, hope these are useful. I'm not sure if I'm being more of a
burden then a help on this list. Would you like me to continue posting
patches or should we just maintain our own branch and, if you are
interested, you may check our CVS repository? Let me know. I don't
mind either.
-Troy.
Index: copy.c
===================================================================
RCS file: /usr/local/cvsroot/setup/copy.c,v
retrieving revision 1.3
diff -u -r1.3 copy.c
--- copy.c 2000/02/11 18:34:04 1.3
+++ copy.c 2000/02/14 19:07:38
@@ -615,6 +615,8 @@
}
add_bin_entry(info, final, symlink,
xmlGetProp(node, "desc"),
+ xmlGetProp(node, "menu"),
+ xmlGetProp(node, "name"),
xmlGetProp(node, "icon"));
}
}
Index: install.c
===================================================================
RCS file: /usr/local/cvsroot/setup/install.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 install.c
--- install.c 2000/02/06 01:04:01 1.1.1.1
+++ install.c 2000/02/14 19:07:41
@@ -7,12 +7,14 @@
#include <pwd.h>
#include <unistd.h>
#include <signal.h>
+#include <stdio.h>
#include "install.h"
#include "install_log.h"
#include "detect.h"
#include "log.h"
#include "copy.h"
+#include "file.h"
#include "network.h"
extern char *rpm_root;
@@ -214,7 +216,8 @@
/* Add a binary entry to the list of binaries installed */
void add_bin_entry(install_info *info, const char *path,
- const char *symlink, const char *desc, const char *icon)
+ const char *symlink, const char *desc, const char *menu,
+ const char *name, const char *icon)
{
struct bin_elem *elem;
@@ -224,6 +227,8 @@
if ( elem->path ) {
elem->symlink = symlink;
elem->desc = desc;
+ elem->menu = menu;
+ elem->name = name;
elem->icon = icon;
elem->next = info->bin_list;
info->bin_list = elem;
@@ -376,8 +381,10 @@
copy_tree(info, node, info->install_path, update);
if(info->options.install_menuitems){
int i;
- for(i = 0; i<MAX_DESKTOPS; i++)
- install_menuitems(info, i);
+ for(i = 0; i<MAX_DESKTOPS; i++) {
+ if (install_menuitems(info, i))
+ break;
+ }
}
generate_uninstall(info);
return SETUP_COMPLETE;
@@ -570,64 +577,110 @@
return SETUP_EXIT;
}
+static const char* redhat_app_links[] =
+{
+ "/etc/X11/applnk/",
+ 0
+};
+
+
static const char* kde_app_links[] =
{
- "/usr/share/applnk/Games/",
- "/opt/kde/share/applnk/Games/",
+ "/usr/share/applnk/",
+ "/opt/kde/share/applnk/",
"~/.kde/share/applnk/",
0
};
+
static const char* gnome_app_links[] =
{
- "/usr/share/gnome/apps/Games/",
- "/opt/gnome/apps/Games/",
+ "/usr/share/gnome/apps/",
+ "/usr/local/share/gnome/apps/",
+ "/opt/gnome/share/gnome/apps/",
"~/.gnome/apps/",
0
};
/* Install the desktop menu items */
-void install_menuitems(install_info *info, desktop_type desktop)
+char install_menuitems(install_info *info, desktop_type desktop)
{
const char **app_links;
char buf[PATH_MAX];
struct bin_elem *elem;
+ char ret_val = 0;
+ const char *desk_base;
+ char icon_base[PATH_MAX];
+ const char *found_links[3];
+ FILE *fp;
switch (desktop) {
+ case DESKTOP_REDHAT:
+ app_links = redhat_app_links;
+ break;
case DESKTOP_KDE:
- app_links = kde_app_links;
+ desk_base = getenv("KDEDIR");
+ if (desk_base) {
+ sprintf(icon_base, "%s/share/applnk/", desk_base);
+ found_links[0] = icon_base;
+ found_links[1] = "~/.kde/share/applnk/";
+ found_links[2] = 0;
+ app_links = found_links;
+ }
+ else {
+ app_links = kde_app_links;
+ }
break;
case DESKTOP_GNOME:
- app_links = gnome_app_links;
+ fp = popen("gnome-config --prefix", "r");
+ if (fp) {
+ fgets(icon_base, PATH_MAX, fp);
+ icon_base[strlen(icon_base)-1]=0;
+ strcat(icon_base, "/share/gnome/apps/");
+ found_links[0] = icon_base;
+ found_links[1] = "~/.gnome/apps/";
+ found_links[2] = 0;
+ app_links = found_links;
+ }
+ else {
+ app_links = gnome_app_links;
+ }
break;
default:
- return;
+ return ret_val;
}
+
for( ; *app_links; app_links ++){
expand_home(info, *app_links, buf);
+
if ( access(buf, W_OK) < 0 )
continue;
for (elem = info->bin_list; elem; elem = elem->next ) {
FILE *fp;
+ char finalbuf[PATH_MAX];
+
+ sprintf(finalbuf, "%s%s/", buf, (elem->menu) ? elem->menu : "Games");
+ file_create_hierarchy(info, finalbuf);
/* Presumably if there is no icon, no desktop entry */
if ( (elem->icon == NULL) || (elem->symlink == NULL) ) {
continue;
}
- strncat(buf, elem->symlink, PATH_MAX);
+ strncat(finalbuf, elem->symlink, PATH_MAX);
switch(desktop){
case DESKTOP_KDE:
- strncat(buf,".kdelnk", PATH_MAX);
+ strncat(finalbuf,".kdelnk", PATH_MAX);
break;
+ case DESKTOP_REDHAT:
case DESKTOP_GNOME:
- strncat(buf,".desktop", PATH_MAX);
+ strncat(finalbuf,".desktop", PATH_MAX);
break;
default:
break;
}
- fp = fopen(buf, "w");
+ fp = fopen(finalbuf, "w");
if (fp) {
char exec[PATH_MAX], icon[PATH_MAX];
@@ -644,16 +697,22 @@
"Terminal=0\n"
"Type=Application\n",
(desktop==DESKTOP_KDE) ? "KDE " : "",
- info->name, info->desc,
+ elem->name, info->desc,
exec, icon
);
fclose(fp);
- add_file_entry(info, buf);
+ add_file_entry(info, finalbuf);
+
+ // successful REDHAT takes care of KDE/GNOME
+ // tell caller no need to continue others
+ ret_val = (desktop == DESKTOP_REDHAT);
+
} else {
- log_warning(info, "Unable to create desktop file '%s'", buf);
+ log_warning(info, "Unable to create desktop file '%s'", finalbuf);
}
}
}
+ return ret_val;
}
/* Run some shell script commands */
Index: install.h
===================================================================
RCS file: /usr/local/cvsroot/setup/install.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 install.h
--- install.h 2000/02/06 01:04:03 1.1.1.1
+++ install.h 2000/02/14 19:07:42
@@ -33,7 +33,8 @@
/* The types of desktop we support menu items for */
typedef enum {
- DESKTOP_KDE,
+ DESKTOP_KDE, // KDE first because RH6.1 does not yet handle KDE well.
+ DESKTOP_REDHAT,
DESKTOP_GNOME,
MAX_DESKTOPS
/* More to come ? */
@@ -102,6 +103,8 @@
char *path;
const char *symlink;
const char *desc;
+ const char *menu;
+ const char *name;
const char *icon;
struct bin_elem *next;
} *bin_list;
@@ -164,7 +167,8 @@
/* Add a binary entry to the list of binaries installed */
extern void add_bin_entry(install_info *info, const char *path,
- const char *symlink, const char *desc, const char *icon);
+ const char *symlink, const char *desc, const char *menu,
+ const char *name, const char *icon);
/* Expand a path with home directories into the provided buffer */
extern void expand_home(install_info *info, const char *path, char *buffer);
@@ -209,7 +213,7 @@
extern int launch_browser(install_info *info, int (*browser)(const char *url));
/* Install the desktop menu items */
-extern void install_menuitems(install_info *info, desktop_type d);
+extern char 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,
*************************************************************************
*** Applied ***
Date: Fri, 11 Feb 2000 12:07:39 -0700
From: "Troy A. Griffitts" <[email protected]>
Subject: setup patches
Sam,
I've added another feature that we needed that I feel will be useful
to others. We're keeping a copy on our CVS server if you would like to
grab a patched copy. I'm also attaching the patch. It expects the
previous patch that I sent to already be applied.
The new feature allows syntax like the following
...
<files path=${KDEDIR|/usr/local}/share>
kdesharebase.tar.gz
</files>
...
This parses any ${ENVVAR} token and replaces it with the environment
variable value. You may also specify a default value if the environment
variable is not set: ${ENVVAR|default_value}
Hope this is useful.
our anonymous cvs info:
$ export CVSROOT=:pserver:[email protected]:/usr/local/cvsroot
$ cvs login
Password: anonymous
$ cvs checkout setup
Thanks again for a great tool!
-Troy A. Griffitts
http://www.crosswire.org
Index: copy.c
===================================================================
RCS file: /usr/local/cvsroot/setup/copy.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- copy.c 2000/02/06 01:03:56 1.1
+++ copy.c 2000/02/11 18:34:04 1.3
@@ -34,11 +34,29 @@
static char current_option[200];
extern char *rpm_root;
+void getToken(const char *src, const char **end) {
+ *end = 0;
+ while (*++src) {
+ if (*src == '}') {
+ *end = src;
+ break;
+ }
+ }
+}
+
int parse_line(const char **srcpp, char *buf, int maxlen)
{
const char *srcp;
char *dstp;
+ const char *subst = 0;
+ char *tokenval = 0;
+ char *token = 0;
+ const char *end;
+ if (!*srcpp) { // assert
+ *buf = 0;
+ return 0;
+ }
/* Skip leading whitespace */
srcp = *srcpp;
while ( *srcp && isspace(*srcp) ) {
@@ -47,12 +65,33 @@
/* Copy the line */
dstp = buf;
- while ( *srcp && (*srcp != '\r') && (*srcp != '\n') ) {
+ while ( (*srcp || subst) && (*srcp != '\r') && (*srcp != '\n') ) {
if ( (dstp-buf) >= maxlen ) {
break;
}
+ if (!*srcp && subst) { // if we're substituting and done
+ srcp = subst;
+ subst = 0;
+ }
+ if ((!subst) && (*srcp == '$') && (*(srcp+1) == '{')) {
+ getToken(srcp+2, &end);
+ if (end) { // we've got a good token
+ if (token) free(token);
+ token = calloc((end-(srcp+2))+1, 1);
+ memcpy(token, srcp+2, (end-(srcp+2)));
+ strtok(token, "|"); // in case a default val is specified
+ tokenval = getenv(token);
+ if (!tokenval) // if no env set, check for default
+ tokenval = strtok(0, "|");
+ if (tokenval) {
+ subst = end+1; // where to continue after tokenval
+ srcp = tokenval;
+ }
+ }
+ }
*dstp++ = *srcp++;
}
+ if (token) free(token);
/* Trim whitespace */
while ( (dstp > buf) && isspace(*(dstp-1)) ) {
@@ -591,6 +630,7 @@
void (*update)(install_info *info, const char *path, size_t progress, size_t size, const char *current))
{
size_t size, copied;
+ char tmppath[PATH_MAX];
size = 0;
node = node->childs;
@@ -598,6 +638,10 @@
const char *path = xmlGetProp(node, "path");
if (!path)
path = dest;
+ else {
+ parse_line(&path, tmppath, PATH_MAX);
+ path = tmppath;
+ }
/* printf("Checking node element '%s'\n", node->name); */
if ( strcmp(node->name, "files") == 0 ) {
const char *str = xmlNodeListGetString(info->config, (node->parent)->childs, 1);
@@ -643,6 +687,7 @@
void (*update)(install_info *info, const char *path, size_t progress, size_t size, const char *current))
{
size_t size, copied;
+ char tmppath[PATH_MAX];
size = 0;
while ( node ) {
@@ -651,8 +696,13 @@
wanted = xmlGetProp(node, "install");
if ( wanted && (strcmp(wanted, "true") == 0) ) {
const char *deviant_path = xmlGetProp(node, "path");
- copied = copy_node(info, node,
- (deviant_path) ? deviant_path : info->install_path, update);
+ if (!deviant_path)
+ deviant_path = info->install_path;
+ else {
+ parse_line(&deviant_path, tmppath, PATH_MAX);
+ deviant_path = tmppath;
+ }
+ copied = copy_node(info, node, deviant_path, update);
if ( copied > 0 ) {
size += copied;
}
Index: gtk_ui.c
===================================================================
RCS file: /usr/local/cvsroot/setup/gtk_ui.c,v
retrieving revision 1.1
retrieving revision 1.3
diff -u -r1.1 -r1.3
--- gtk_ui.c 2000/02/06 01:03:59 1.1
+++ gtk_ui.c 2000/02/11 18:34:04 1.3
@@ -253,16 +253,19 @@
char check_deviant_paths(xmlNodePtr node)
{
char path_up[PATH_MAX];
+
while ( node ) {
const char *wanted;
- const char *deviant_path;
+ const char *dpath;
+ char deviant_path[PATH_MAX];
wanted = xmlGetProp(node, "install");
if ( wanted && (strcmp(wanted, "true") == 0) ) {
xmlNodePtr elements = node->childs;
while ( elements ) {
- deviant_path = xmlGetProp(elements, "path");
- if ( deviant_path ) {
+ dpath = xmlGetProp(elements, "path");
+ if ( dpath ) {
+ parse_line(&dpath, deviant_path, PATH_MAX);
topmost_valid_path(path_up, deviant_path);
if (access(path_up, W_OK) < 0 )
return 1;
*************************************************************************
*** Applied ***
Date: Sat, 05 Feb 2000 14:41:09 -0700
From: "Troy A. Griffitts" <[email protected]>
Subject: setup patches
Sam and Stephane,
Here are some more patches to the setup util. I haven't had much
time to work on it, but these were quick and should provide some useful
features.
I've added a path="/deviant/path/" option to option components.
This allows an install developer to place components like:
<files path="/usr/lib">
libbase.tar.gz
</files>
<files path="/usr/share">
sharebase.tar.gz
</files>
When all other components still install into the user's selected
directory, these 'deviant' entries will install to the set locations.
The gtk_ui checks write permission for these paths if the option is
selected before enabling install.
diff -Pru setup-1.1.orig/copy.c setup-1.1/copy.c
--- setup-1.1.orig/copy.c Wed Dec 1 16:15:26 1999
+++ setup-1.1/copy.c Fri Feb 4 01:38:17 2000
@@ -595,21 +595,36 @@
size = 0;
node = node->childs;
while ( node ) {
+ const char *path = xmlGetProp(node, "path");
+ if (!path)
+ path = dest;
/* printf("Checking node element '%s'\n", node->name); */
if ( strcmp(node->name, "files") == 0 ) {
const char *str = xmlNodeListGetString(info->config, (node->parent)->childs, 1);
parse_line(&str, current_option, sizeof(current_option));
copied = copy_list(info,
xmlNodeListGetString(info->config, node->childs, 1),
- dest, update);
+ path, update);
if ( copied > 0 ) {
size += copied;
}
}
+ if ( strcmp(node->name, "xfonts") == 0 ) {
+ if (info->copy_xfonts) {
+ const char *str = xmlNodeListGetString(info->config, (node->parent)->childs, 1);
+ parse_line(&str, current_option, sizeof(current_option));
+ copied = (*info->copy_xfonts)(info,
+ xmlNodeListGetString(info->config, node->childs, 1),
+ update);
+ if ( copied > 0 ) {
+ size += copied;
+ }
+ }
+ }
if ( strcmp(node->name, "binary") == 0 ) {
copied = copy_binary(info, node,
xmlNodeListGetString(info->config, node->childs, 1),
- dest, update);
+ path, update);
if ( copied > 0 ) {
size += copied;
}
@@ -617,7 +632,7 @@
if ( strcmp(node->name, "script") == 0 ) {
copy_script(info, node,
xmlNodeListGetString(info->config, node->childs, 1),
- dest);
+ path);
}
node = node->next;
}
@@ -635,7 +650,9 @@
wanted = xmlGetProp(node, "install");
if ( wanted && (strcmp(wanted, "true") == 0) ) {
- copied = copy_node(info, node, info->install_path, update);
+ const char *deviant_path = xmlGetProp(node, "path");
+ copied = copy_node(info, node,
+ (deviant_path) ? deviant_path : info->install_path, update);
if ( copied > 0 ) {
size += copied;
}
diff -Pru setup-1.1.orig/gtk_ui.c setup-1.1/gtk_ui.c
--- setup-1.1.orig/gtk_ui.c Wed Dec 1 16:15:26 1999
+++ setup-1.1/gtk_ui.c Fri Feb 4 01:38:17 2000
@@ -230,26 +231,64 @@
cur_state = SETUP_INSTALL;
}
+
+void topmost_valid_path(char *target, const char *src) {
+ char *cp;
+
+ /* Get the topmost valid path */
+ strcpy(target, src);
+ if ( target[0] == '/' ) {
+ cp = target+strlen(target);
+ while ( access(target, F_OK) < 0 ) {
+ while ( (cp > (target+1)) && (*cp != '/') ) {
+ --cp;
+ }
+ *cp = '\0';
+ }
+ }
+}
+
+
+/* returns true if any deviant paths are not writable */
+char check_deviant_paths(xmlNodePtr node)
+{
+ char path_up[PATH_MAX];
+ while ( node ) {
+ const char *wanted;
+ const char *deviant_path;
+
+ wanted = xmlGetProp(node, "install");
+ if ( wanted && (strcmp(wanted, "true") == 0) ) {
+ xmlNodePtr elements = node->childs;
+ while ( elements ) {
+ deviant_path = xmlGetProp(elements, "path");
+ if ( deviant_path ) {
+ topmost_valid_path(path_up, deviant_path);
+ if (access(path_up, W_OK) < 0 )
+ return 1;
+ }
+ elements = elements->next;
+ }
+ if (check_deviant_paths(node->childs))
+ return 1;
+ }
+ node = node->next;
+ }
+ return 0;
+}
+
+
/* Checks if we can enable the "Begin install" button */
static void check_install_button(void)
{
const char *message;
GtkWidget *options_status;
GtkWidget *button_install;
- char path_up[PATH_MAX], *cp;
+ char path_up[PATH_MAX];
struct stat st;
/* Get the topmost valid path */
- strcpy(path_up, cur_info->install_path);
- if ( path_up[0] == '/' ) {
- cp = path_up+strlen(path_up);
- while ( access(path_up, F_OK) < 0 ) {
- while ( (cp > (path_up+1)) && (*cp != '/') ) {
- --cp;
- }
- *cp = '\0';
- }
- }
+ topmost_valid_path(path_up, cur_info->install_path);
/* See if we can install yet */
message = "";
@@ -265,6 +304,8 @@
message = "Install path is not a directory";
} else if ( access(path_up, W_OK) < 0 ) {
message = "No write permissions on the install directory";
+ } else if ( check_deviant_paths(cur_info->config->root->childs) ) {
+ message = "No write permissions to install a selected package";
} else if ( cur_info->symlinks_path[0] &&
(access(cur_info->symlinks_path, W_OK) < 0) ) {
message = "No write permissions on the binary directory";
@@ -743,7 +787,7 @@
gtk_label_set_text(GTK_LABEL(widget), info->install_path);
widget = glade_xml_get_widget(setup_glade, "play_game_label");
if ( info->installed_symlink ) {
- sprintf(text, "Type '%s' to play the game", info->installed_symlink);
+ sprintf(text, "Type '%s' to start the program", info->installed_symlink);
} else {
strcpy(text, "");
}
**********************************************************************************
****** Applied
Index: README.xml
===================================================================
RCS file: /cvs/setup/README.xml,v
retrieving revision 1.29
diff -u -r1.29 README.xml
--- README.xml 2000/07/31 21:27:08 1.29
+++ README.xml 2000/08/04 03:02:21
@@ -117,6 +117,12 @@
path for binaries. Set this when this installation won't
actually install any binary file.
+ promptbinaries When set to "yes", setup will create a checkbox
+ to allow the user whether or not to create
+ a symbolic link to the binaries.
+
+ This setting has no effect if nobinaries is "yes".
+
meta When this attribute is set to "yes", then setup will act as
a meta-installer, i.e. it will allow the user to select a
product and set-up will respawn itself for the selected
@@ -145,6 +151,29 @@
There is also no need to have the files designated by those tags explicitly
installed in a FILES section, setup will take care of that for you.
+
+
+The INSTALL_DROP_LIST element:
+
+The install_drop_list element makes it possible to override the default
+installation paths supplied in the Installation target drop down box.
+
+Supply a list of drop down paths, space or new line separated.
+An example follows:
+
+ <install_drop_list>
+ /opt /usr/local
+ /var
+ ~
+ </install_drop_list>
+
+If no install_drop_list element is given, it will default to hard coded
+values (see install.c).
+
+Note: Your paths will not be displayed if they are not valid,
+writable paths.
+
+
The OPTION element:
Index: console_ui.c
===================================================================
RCS file: /cvs/setup/console_ui.c,v
retrieving revision 1.36
diff -u -r1.36 console_ui.c
--- console_ui.c 2000/08/02 22:37:47 1.36
+++ console_ui.c 2000/08/04 03:02:21
@@ -37,9 +37,7 @@
char *answer, int maxlen)
{
printf("%s", prompt);
- if ( default_answer && *default_answer ) {
- printf(" [%s] ", default_answer);
- }
+ printf(" [%s] ", default_answer && *default_answer ? default_answer : "");
fflush(stdout);
if ( fgets(answer, maxlen, stdin) ) {
answer[strlen(answer)-1] = '\0';
@@ -287,6 +285,7 @@
char path[PATH_MAX];
xmlNodePtr node;
+
if ( GetProductIsMeta(info) ) {
while ( ! okay ) {
int index = 1, chosen;
@@ -363,15 +362,36 @@
}
}
+ /* Default to empty */
+ path[0] = '\0';
+
/* Find out where to install the binary symlinks, unless the binary path
was provided as a command line argument */
- if ( ! disable_binary_path ) {
- if ( ! GetProductHasNoBinaries(info) ) {
- if ( ! prompt_user(_("Please enter the path for binary installation"),
- info->symlinks_path, path, sizeof(path)) ) {
- return SETUP_ABORT;
- }
- }
+ if ( ! disable_binary_path )
+ {
+ int get_path = 1;
+
+ if (GetProductHasNoBinaries(info))
+ get_path = 0;
+
+ if (get_path)
+ {
+ /*----------------------------------------
+ ** Optionally, ask the user whether
+ ** they want to create a symlink
+ ** to the path or not.
+ **--------------------------------------*/
+ if (GetProductHasPromptBinaries(info))
+ if (console_prompt(_("Do you want to install symbolic links to a directory in your path?"), RESPONSE_YES) != RESPONSE_YES)
+ get_path = 0;
+ }
+
+ if (get_path)
+ if ( ! prompt_user(_("Please enter the path in which to create the symbolic links"),
+ info->symlinks_path, path, sizeof(path)) ) {
+ return SETUP_ABORT;
+ }
+
} else {
printf(_("Binary path set to: %s\n"), info->symlinks_path);
strcpy(path, info->symlinks_path);
@@ -387,14 +407,15 @@
/* Check permissions on the symlinks path, if the path was
provided as a command-line argument and it invalid, then
abort */
- if ( access(info->symlinks_path, W_OK) < 0 ) {
- printf(_("No write permission to %s\n"), info->symlinks_path);
- if (! disable_binary_path) {
- continue;
- } else {
- return SETUP_ABORT;
- }
- }
+ if (strlen(info->symlinks_path) > 0)
+ if ( access(info->symlinks_path, W_OK) < 0 ) {
+ printf(_("No write permission to %s\n"), info->symlinks_path);
+ if (! disable_binary_path) {
+ continue;
+ } else {
+ return SETUP_ABORT;
+ }
+ }
/* Go through the install options */
info->install_size = 0;
Index: gtk_ui.c
===================================================================
RCS file: /cvs/setup/gtk_ui.c,v
retrieving revision 1.44
diff -u -r1.44 gtk_ui.c
--- gtk_ui.c 2000/08/02 22:37:47 1.44
+++ gtk_ui.c 2000/08/04 03:02:22
@@ -109,13 +109,16 @@
/* Globals */
-static char *install_paths[] = {
+static char *default_install_paths[] = {
"/usr/local/games",
"/opt/games",
"/usr/games",
NULL
};
+#define MAX_INSTALL_PATHS 25 /* Use an arbitrary maximum; the lack of
+ flexibility shouldn't be an issue */
+static char *install_paths[MAX_INSTALL_PATHS];
/* Various warning dialogs */
static enum {
@@ -606,6 +609,47 @@
}
}
+/*-----------------------------------------------------------------------------
+** on_use_binary_toggled
+** Signal function to repsond to a toggle state in the
+** 'Use symbolic link' checkbox.
+**---------------------------------------------------------------------------*/
+void on_use_binary_toggled ( GtkWidget* widget, gpointer func_data)
+{
+ GtkWidget *binary_path_widget;
+ GtkWidget *binary_label_widget;
+ GtkWidget *binary_entry;
+ char *string;
+
+ /*-------------------------------------------------------------------------
+ ** Pick up widget handles
+ **-----------------------------------------------------------------------*/
+ binary_path_widget = glade_xml_get_widget(setup_glade, "binary_path");
+ binary_label_widget = glade_xml_get_widget(setup_glade, "binary_label");
+
+ /*-------------------------------------------------------------------------
+ ** Mark the appropriate widgets active or inactive
+ **-----------------------------------------------------------------------*/
+ gtk_widget_set_sensitive(binary_path_widget, GTK_TOGGLE_BUTTON(widget)->active);
+ gtk_widget_set_sensitive(binary_label_widget, GTK_TOGGLE_BUTTON(widget)->active);
+
+ /*-------------------------------------------------------------------------
+ ** Finally, set the symlinks_path. If we've made it active
+ ** again, we have to go get the current binary entry box
+ ** value and restash it into the global symlinkspath.
+ **-----------------------------------------------------------------------*/
+ if (GTK_TOGGLE_BUTTON(widget)->active)
+ {
+ binary_entry = glade_xml_get_widget(setup_glade, "entry5");
+ string = gtk_entry_get_text( GTK_ENTRY(binary_entry) );
+ }
+ else
+ string = NULL;
+
+ set_symlinkspath(cur_info, string ? string : "");
+}
+
+
void setup_checkbox_option_slot( GtkWidget* widget, gpointer func_data)
{
GtkWidget *window;
@@ -740,6 +784,7 @@
GList* list;
int i;
char path[PATH_MAX];
+ xmlNodePtr node;
widget = glade_xml_get_widget(setup_glade, "install_path");
@@ -750,6 +795,67 @@
list = 0;
list = g_list_append( list, cur_info->install_path);
+
+ /*----------------------------------------------------------------------
+ ** Retrieve the list of install paths from the config file, if we can
+ **--------------------------------------------------------------------*/
+ for (i = 0, node = cur_info->config->root->childs; node; node = node->next)
+ {
+ if (strcmp(node->name, "install_drop_list") == 0)
+ {
+ /* Retrieve the value - note that it's up to us to free
+ the memory, which means we can use it without copying it */
+ char *content = xmlNodeGetContent(node);
+ char *p;
+ if (content)
+ {
+ for (p = strtok(content, "\n\t \r\b"); p;
+ p = strtok(NULL,"\n\t \r\b" ))
+ {
+ /*--------------------------------------------------------
+ ** Expand any ~s in the path
+ **------------------------------------------------------*/
+ char *temp_buf;
+ temp_buf = malloc(PATH_MAX);
+ if (! temp_buf)
+ {
+ fprintf(stderr, "Fatal error: out of memory\n");
+ return;
+ }
+ expand_home(cur_info, p, temp_buf);
+
+ if (i > sizeof(install_paths) > sizeof(install_paths[0]))
+ {
+ fprintf(stderr,
+ "Error: maximum of %d install_path entries exceeded\n",
+ sizeof(install_paths) > sizeof(install_paths[0]));
+ return;
+ }
+
+ install_paths[i++] = temp_buf;
+ }
+ }
+ }
+ }
+
+
+ /*----------------------------------------------------------------------
+ ** If no installation paths were specified, use the default
+ ** values that are hard coded in.
+ **--------------------------------------------------------------------*/