36
37:- module(check_installation,
38 [ check_installation/0,
39 check_installation/1, 40 check_config_files/0,
41 update_config_files/0,
42 test_installation/0,
43 test_installation/1 44 ]). 45:- autoload(library(apply), [maplist/2, maplist/3, exclude/3]). 46:- autoload(library(archive), [archive_open/3, archive_close/1]). 47:- autoload(library(lists), [append/3, member/2]). 48:- autoload(library(occurs), [sub_term/2]). 49:- autoload(library(option), [option/2, merge_options/3]). 50:- autoload(library(prolog_source), [path_segments_atom/2]). 51:- use_module(library(settings), [setting/2]). 52:- autoload(library(dcg/high_order), [sequence//2, sequence/4]). 53:- autoload(library(error), [must_be/2]). 54:- autoload(library(pce), [get/3, get/4]). 55
56
63
86
88component(tcmalloc,
89 #{ optional:true,
90 test:test_tcmalloc,
91 url:'tcmalloc.html',
92 os:linux
93 }).
94component(gmp,
95 #{ test:current_prolog_flag(bounded, false),
96 url:'gmp.html'
97 }).
99component(library(archive), #{features:archive_features}).
100component(library(cgi), #{}).
101component(library(crypt), #{}).
102component(library(bdb), #{}).
103component(library(double_metaphone), #{}).
104component(library(editline), #{}).
105component(library(filesex), #{}).
106component(library(http/http_stream), #{}).
107component(library(json), #{}).
108component(library(http/jquery), #{features:jquery_file}).
109component(library(graphviz), #{features:graphviz_engines}).
110component(library(isub), #{}).
111component(library(janus), #{features:python_version}).
112component(library(jpl), #{}).
113component(library(memfile), #{}).
114component(library(odbc), #{}).
115component(library(pce),
116 #{pre:use_foreign_library(pce_principal:foreign(pl2xpce)),
117 url:'xpce.html',
118 features:pce_features}).
119component(library(pcre), #{features:pcre_features}).
120component(library(pdt_console), #{}).
121component(library(porter_stem), #{}).
122component(library(process), #{}).
123component(library(protobufs), #{}).
124component(library(readutil), #{}).
125component(library(rlimit), #{os:unix}).
126component(library(semweb/rdf_db), #{}).
127component(library(semweb/rdf_ntriples), #{}).
128component(library(semweb/turtle), #{}).
129component(library(sgml), #{}).
130component(library(sha), #{}).
131component(library(snowball), #{}).
132component(library(socket), #{}).
133component(library(ssl), #{features:ssl_version}).
134component(library(sweep_link), #{features:sweep_emacs_module}).
135component(library(crypto), #{}).
136component(library(syslog), #{os:unix}).
137component(library(table), #{}).
138component(library(time), #{}).
139component(library(tipc/tipc), #{os:linux}).
140component(library(unicode), #{}).
141component(library(uri), #{}).
142component(library(uuid), #{}).
143component(library(yaml), #{}).
144component(library(zlib), #{}).
145
146issue_base('http://www.swi-prolog.org/build/issues/').
147
148:- thread_local
149 issue/1. 150
151:- meta_predicate
152 run_silent(0, +). 153
168
169check_installation :-
170 print_message(informational, installation(checking)),
171 check_installation_(InstallIssues),
172 check_on_path,
173 check_config_files(ConfigIssues),
174 check_autoload,
175 maplist(print_message(warning), ConfigIssues),
176 append(InstallIssues, ConfigIssues, Issues),
177 ( Issues == []
178 -> print_message(informational, installation(perfect))
179 ; length(Issues, Count),
180 print_message(warning, installation(imperfect(Count)))
181 ).
182
190
191check_installation(Issues) :-
192 check_installation_(Issues0),
193 maplist(public_issue, Issues0, Issues).
194
195public_issue(installation(Term), Source-Issue) :-
196 functor(Term, Issue, _),
197 arg(1, Term, Properties),
198 Source = Properties.source.
199
200check_installation_(Issues) :-
201 retractall(issue(_)),
202 forall(component(Source, _Properties),
203 check_component(Source)),
204 findall(I, retract(issue(I)), Issues).
205
206check_component(Source) :-
207 component(Source, Properties),
208 !,
209 check_component(Source, Properties.put(source,Source)).
210
211check_component(_Source, Properties) :-
212 OS = Properties.get(os),
213 \+ current_os(OS),
214 !.
215check_component(Source, Properties) :-
216 compound(Source),
217 !,
218 check_source(Source, Properties).
219check_component(Feature, Properties) :-
220 print_message(informational, installation(checking(Feature))),
221 ( call(Properties.test)
222 -> print_message(informational, installation(ok))
223 ; print_issue(installation(missing(Properties)))
224 ).
225
226check_source(Source, Properties) :-
227 exists_source(Source),
228 !,
229 print_message(informational, installation(loading(Source))),
230 ( run_silent(( ( Pre = Properties.get(pre)
231 -> call(Pre)
232 ; true
233 ),
234 load_files(Source, [silent(true), if(true)])
235 ),
236 Properties.put(action, load))
237 -> test_component(Properties),
238 print_message(informational, installation(ok)),
239 check_features(Properties)
240 ; true
241 ).
242check_source(_Source, Properties) :-
243 Properties.get(optional) == true,
244 !,
245 print_message(silent,
246 installation(optional_not_found(Properties))).
247check_source(_Source, Properties) :-
248 print_issue(installation(not_found(Properties))).
249
250current_os(unix) :- current_prolog_flag(unix, true).
251current_os(windows) :- current_prolog_flag(windows, true).
252current_os(linux) :- current_prolog_flag(arch, Arch),
253 sub_atom(Arch, _, _, _, linux).
254
258
259test_component(Dict) :-
260 Test = Dict.get(test),
261 !,
262 call(Test).
263test_component(_).
264
271
272check_features(Dict) :-
273 Test = Dict.get(features),
274 !,
275 catch(Test, Error,
276 ( print_message(warning, Error),
277 fail)).
278check_features(_).
279
280
285
286run_silent(Goal, Properties) :-
287 run_collect_messages(Goal, Result, Messages),
288 ( Result == true,
289 Messages == []
290 -> true
291 ; print_issue(installation(failed(Properties, Result, Messages))),
292 fail
293 ).
294
304
305:- thread_local
306 got_message/1. 307
308run_collect_messages(Goal, Result, Messages) :-
309 setup_call_cleanup(
310 asserta((user:thread_message_hook(Term,Kind,Lines) :-
311 error_kind(Kind),
312 assertz(got_message(message(Term,Kind,Lines)))), Ref),
313 ( catch(Goal, E, true)
314 -> ( var(E)
315 -> Result0 = true
316 ; Result0 = exception(E)
317 )
318 ; Result0 = false
319 ),
320 erase(Ref)),
321 findall(Msg, retract(got_message(Msg)), Messages),
322 Result = Result0.
323
324error_kind(warning).
325error_kind(error).
326
327
328 331
333
334:- if(current_predicate(malloc_property/1)). 335test_tcmalloc :-
336 malloc_property('generic.current_allocated_bytes'(Bytes)),
337 Bytes > 1 000 000.
338:- else. 339test_tcmalloc :-
340 fail.
341:- endif. 342
346
347archive_features :-
348 tmp_file_stream(utf8, Name, Out),
349 close(Out),
350 findall(F, archive_filter(F, Name), Filters),
351 print_message(informational, installation(archive(filters, Filters))),
352 findall(F, archive_format(F, Name), Formats),
353 print_message(informational, installation(archive(formats, Formats))),
354 delete_file(Name).
355
356archive_filter(F, Name) :-
357 a_filter(F),
358 catch(archive_open(Name, A, [filter(F)]), E, true),
359 ( var(E)
360 -> archive_close(A)
361 ; true
362 ),
363 \+ subsumes_term(error(domain_error(filter, _),_), E).
364
365archive_format(F, Name) :-
366 a_format(F),
367 catch(archive_open(Name, A, [format(F)]), E, true),
368 ( var(E)
369 -> archive_close(A)
370 ; true
371 ),
372 \+ subsumes_term(error(domain_error(format, _),_), E).
373
374a_filter(bzip2).
375a_filter(compress).
376a_filter(gzip).
377a_filter(grzip).
378a_filter(lrzip).
379a_filter(lzip).
380a_filter(lzma).
381a_filter(lzop).
382a_filter(none).
383a_filter(rpm).
384a_filter(uu).
385a_filter(xz).
386
387a_format('7zip').
388a_format(ar).
389a_format(cab).
390a_format(cpio).
391a_format(empty).
392a_format(gnutar).
393a_format(iso9660).
394a_format(lha).
395a_format(mtree).
396a_format(rar).
397a_format(raw).
398a_format(tar).
399a_format(xar).
400a_format(zip).
401
403
404pcre_features :-
405 findall(X, pcre_missing(X), Missing),
406 ( Missing == []
407 -> true
408 ; print_message(warning, installation(pcre_missing(Missing)))
409 ),
410 ( re_config(compiled_widths(Widths)),
411 1 =:= Widths /\ 1
412 -> true
413 ; print_message(warning, installation(pcre_missing('8-bit support')))
414 ).
415
416pcre_missing(X) :-
417 pcre_must_have(X),
418 Term =.. [X,true],
419 \+ catch(re_config(Term), _, fail).
420
421pcre_must_have(unicode).
422
428
429pce_features :-
430 forall(pce_formats(What, Getter),
431 ( pce_formats(Getter, Names)
432 -> print_message(informational,
433 installation(pce_formats(What, Names)))
434 ; true
435 )).
436
437pce_formats(image, image_save_formats).
438pce_formats(sound, sound_file_extensions).
439pce_formats(video, video_decoders).
440pce_formats(video_writer, video_encoders).
441
442pce_formats(Getter, Names) :-
443 catch(get(@(display), Getter, Chain), _, fail),
444 get(Chain, size, N),
445 findall(Name, ( between(1, N, I),
446 get(Chain, nth1, I, Name)
447 ), Names).
448
450
451ssl_version :-
452 current_prolog_flag(ssl_library_version, SSLVersion),
453 print_message(informational, installation(version(SSLVersion))).
454
455
459
460jquery_file :-
461 setting(jquery:version, File),
462 ( absolute_file_name(js(File), Path, [access(read), file_errors(fail)])
463 -> print_message(informational, installation(jquery(found(Path))))
464 ; print_message(warning, installation(jquery(not_found(File))))
465 ).
466
467sweep_emacs_module :-
468 with_output_to(string(S), write_sweep_module_location),
469 split_string(S, "\n", "\n", [VersionInfo|Modules]),
470 must_be(oneof(["V 1"]), VersionInfo),
471 ( maplist(check_sweep_lib, Modules)
472 -> print_message(informational, installation(sweep(found(Modules))))
473 ; print_message(warning, installation(sweep(not_found(Modules))))
474 ).
475
476check_sweep_lib(Line) :-
477 sub_atom(Line, B, _, A, ' '),
478 sub_atom(Line, 0, B, _, Type),
479 must_be(oneof(['L', 'M']), Type),
480 sub_atom(Line, _, A, 0, Lib),
481 exists_file(Lib).
482
483python_version :-
484 py_call(sys:version, Version),
485 print_message(informational, installation(janus(Version))).
486
487
492
493graphviz_engines :-
494 findall(Engine, graphviz:graphviz_engine(Engine), Engines),
495 ( memberchk(dot, Engines)
496 -> print_message(informational, installation(graphviz(Engines)))
497 ; print_message(warning, installation(graphviz(Engines)))
498 ).
499
501
502nop_engine(Engine) :-
503 sub_atom(Engine, 0, _, _, nop).
504
505
511
512check_on_path :-
513 current_prolog_flag(executable, EXEFlag),
514 prolog_to_os_filename(EXE, EXEFlag),
515 file_base_name(EXE, Prog),
516 absolute_file_name(EXE, AbsExe,
517 [ access(execute),
518 file_errors(fail)
519 ]),
520 !,
521 prolog_to_os_filename(AbsExe, OsExe),
522 ( absolute_file_name(path(Prog), OnPath,
523 [ access(execute),
524 file_errors(fail)
525 ])
526 -> ( same_file(EXE, OnPath)
527 -> true
528 ; absolute_file_name(path(Prog), OnPathAny,
529 [ access(execute),
530 file_errors(fail),
531 solutions(all)
532 ]),
533 same_file(EXE, OnPathAny)
534 -> print_message(warning, installation(not_first_on_path(OsExe, OnPath)))
535 ; print_message(warning, installation(not_same_on_path(OsExe, OnPath)))
536 )
537 ; print_message(warning, installation(not_on_path(OsExe, Prog)))
538 ).
539check_on_path.
540
541
542 545
566
567test_installation :-
568 test_installation([]).
569
570test_installation(Options) :-
571 absolute_file_name(swi(test/test),
572 TestFile,
573 [ access(read),
574 file_errors(fail),
575 file_type(prolog)
576 ]),
577 !,
578 test_installation_run(TestFile, Options).
579test_installation(_Options) :-
580 print_message(warning, installation(testing(no_installed_tests))).
581
582test_installation_run(TestFile, Options) :-
583 ( option(package(_), Options)
584 -> merge_options(Options,
585 [ core(false),
586 subdirs(false)
587 ], TestOptions)
588 ; merge_options(Options,
589 [ packages(true)
590 ], TestOptions)
591 ),
592 load_files(user:TestFile),
593 current_prolog_flag(verbose, Old),
594 setup_call_cleanup(
595 set_prolog_flag(verbose, silent),
596 user:test([], TestOptions),
597 set_prolog_flag(verbose, Old)).
598
599
600 603
604:- multifile
605 prolog:message//1. 606
607print_issue(Term) :-
608 assertz(issue(Term)),
609 print_message(warning, Term).
610
611issue_url(Properties, URL) :-
612 Local = Properties.get(url),
613 !,
614 issue_base(Base),
615 atom_concat(Base, Local, URL).
616issue_url(Properties, URL) :-
617 Properties.get(source) = library(Segments),
618 !,
619 path_segments_atom(Segments, Base),
620 file_name_extension(Base, html, URLFile),
621 issue_base(Issues),
622 atom_concat(Issues, URLFile, URL).
623
624prolog:message(installation(Message)) -->
625 message(Message).
626
627message(checking) -->
628 { current_prolog_flag(address_bits, Bits) },
629 { current_prolog_flag(arch, Arch) },
630 { current_prolog_flag(home, Home) },
631 { current_prolog_flag(cpu_count, Cores) },
632 { current_prolog_flag(build_type, BuildType) -> true ; BuildType = "?" },
633 [ 'Checking your SWI-Prolog kit for common issues ...'-[], nl, nl ],
634 [ 'Version: ~`.t~24| '-[] ], '$messages':prolog_message(version), [nl],
635 [ 'CMake Build type: ~`.t~24| ~w'-[BuildType] ], [nl],
636 [ 'Address bits: ~`.t~24| ~d'-[Bits] ], [nl],
637 [ 'Architecture: ~`.t~24| ~w'-[Arch] ], [nl],
638 [ 'Installed at: ~`.t~24| ~w'-[Home] ], [nl],
639 [ 'Cores: ~`.t~24| ~w'-[Cores] ], [nl],
640 [ nl ].
641message(perfect) -->
642 [ nl, 'Congratulations, your kit seems sound and complete!'-[] ].
643message(imperfect(N)) -->
644 [ 'Found ~w issues.'-[N] ].
645message(checking(Feature)) -->
646 [ 'Checking ~w ...'-[Feature], flush ].
647message(missing(Properties)) -->
648 [ at_same_line, '~`.t~48| not present'-[] ],
649 details(Properties).
650message(loading(Source)) -->
651 [ 'Loading ~q ...'-[Source], flush ].
652message(ok) -->
653 [ at_same_line, '~`.t~48| ok'-[] ].
654message(optional_not_found(Properties)) -->
655 [ 'Optional ~q ~`.t~48| not present'-[Properties.source] ].
656message(not_found(Properties)) -->
657 [ '~q ~`.t~48| NOT FOUND'-[Properties.source] ],
658 details(Properties).
659message(failed(Properties, false, [])) -->
660 !,
661 [ at_same_line, '~`.t~48| FAILED'-[] ],
662 details(Properties).
663message(failed(Properties, exception(Ex0), [])) -->
664 !,
665 { strip_stack(Ex0, Ex),
666 message_to_string(Ex, Msg) },
667 [ '~w'-[Msg] ],
668 details(Properties).
669message(failed(Properties, true, Messages)) -->
670 [ at_same_line, '~`.t~48| FAILED'-[] ],
671 explain(Messages),
672 details(Properties).
673message(archive(What, Names)) -->
674 [ ' Supported ~w: '-[What] ],
675 list_names(Names).
676message(pce_formats(image, Formats)) -->
677 [ ' Images can be saved as: '-[] ],
678 list_names(Formats).
679message(pce_formats(sound, [wav])) -->
680 !,
681 [ ' Sound files that can be loaded: wav (no SDL3_sound)'-[] ].
682message(pce_formats(sound, Extensions)) -->
683 [ ' Sound files that can be loaded: '-[] ],
684 list_names(Extensions).
685message(pce_formats(video, [])) -->
686 !,
687 [ ' Videos cannot be played (xpce has no video support)'-[] ].
688message(pce_formats(video, Codecs)) -->
689 [ ' Video codecs that can be played: '-[] ],
690 list_names(Codecs).
691message(pce_formats(video_writer, [])) -->
692 !,
693 [ ' Videos cannot be written (no video encoders)'-[] ].
694message(pce_formats(video_writer, Codecs)) -->
695 [ ' Video codecs that can be written: '-[] ],
696 list_names(Codecs).
697message(pcre_missing(Features)) -->
698 [ 'Missing libpcre features: '-[] ],
699 list_names(Features).
700message(not_first_on_path(EXE, OnPath)) -->
701 { public_executable(EXE, PublicEXE),
702 file_base_name(EXE, Prog)
703 },
704 [ 'The first ~w on '-[Prog] ], 'PATH', [ ' is ~p, while '-[OnPath], nl ],
705 [ 'this version is ~p.'-[PublicEXE] ].
706message(not_same_on_path(EXE, OnPath)) -->
707 { public_executable(EXE, PublicEXE),
708 file_base_name(EXE, Prog)
709 },
710 [ 'The ~w on '-[Prog] ], 'PATH', [ ' is ~p, while '-[OnPath], nl ],
711 [ 'this version is ~p.'-[PublicEXE] ].
712message(not_on_path(EXE, Prog)) -->
713 { public_bin_dir(EXE, Dir),
714 prolog_to_os_filename(Dir, OSDir)
715 },
716 [ 'Could not find ~w on '-[Prog] ], 'PATH', [ '. '-[], nl ],
717 [ 'You may wish to add ~p to '-[OSDir] ], 'PATH', [ '. '-[], nl ].
718message(jquery(found(Path))) -->
719 [ ' jQuery from ~w'-[Path] ].
720message(jquery(not_found(File))) -->
721 [ ' Cannot find jQuery (~w)'-[File] ].
722message(sweep(found(Paths))) -->
723 [ ' GNU-Emacs plugin loads'-[] ],
724 sequence(list_file, Paths).
725message(sweep(not_found(Paths))) -->
726 [ ' Could not find all GNU-Emacs libraries'-[] ],
727 sequence(list_file, Paths).
728message(testing(no_installed_tests)) -->
729 [ ' Runtime testing is not enabled.', nl],
730 [ ' Please recompile the system with INSTALL_TESTS enabled.' ].
731message(janus(Version)) -->
732 [ ' Python version ~w'-[Version] ].
733message(graphviz(Engines)) -->
734 { exclude(nop_engine, Engines, Shown),
735 atomic_list_concat(Shown, ', ', Text)
736 },
737 ( { memberchk(dot, Engines) }
738 -> [ ' Layout engines: ~w'-[Text] ]
739 ; [ ' Layout engines: ~w (dot is missing)'-[Text] ]
740 ).
741message(ambiguous_autoload(PI, Paths)) -->
742 [ 'The predicate ~p can be autoloaded from multiple libraries:'-[PI]],
743 sequence(list_file, Paths).
744message(version(Version)) -->
745 [ ' Using ~w'-[Version] ].
746message(lib_version(What, Version)) -->
747 [ ' Using library ~w version ~w'-[What, Version] ].
748
749public_executable(EXE, PublicProg) :-
750 file_base_name(EXE, Prog),
751 file_directory_name(EXE, ArchDir),
752 file_directory_name(ArchDir, BinDir),
753 file_directory_name(BinDir, Home),
754 file_directory_name(Home, Lib),
755 file_directory_name(Lib, Prefix),
756 atomic_list_concat([Prefix, bin, Prog], /, PublicProg),
757 exists_file(PublicProg),
758 same_file(EXE, PublicProg),
759 !.
760public_executable(EXE, EXE).
761
762public_bin_dir(EXE, Dir) :-
763 public_executable(EXE, PublicEXE),
764 file_directory_name(PublicEXE, Dir).
765
766
767
768'PATH' -->
769 { current_prolog_flag(windows, true) },
770 !,
771 [ '%PATH%'-[] ].
772'PATH' -->
773 [ '$PATH'-[] ].
774
775strip_stack(error(Error, context(prolog_stack(S), Msg)),
776 error(Error, context(_, Msg))) :-
777 nonvar(S).
778strip_stack(Error, Error).
779
780details(Properties) -->
781 { issue_url(Properties, URL), !
782 },
783 [ nl, 'See '-[], url(URL) ].
784details(_) --> [].
785
786explain(Messages) -->
787 { shared_object_error(Messages) },
788 !,
789 [nl],
790 ( { current_prolog_flag(windows, true) }
791 -> [ 'Cannot load required DLL'-[] ]
792 ; [ 'Cannot load required shared library'-[] ]
793 ).
794explain(Messages) -->
795 print_messages(Messages).
796
797shared_object_error(Messages) :-
798 sub_term(Term, Messages),
799 subsumes_term(error(shared_object(open, _Message), _), Term),
800 !.
801
802print_messages([]) --> [].
803print_messages([message(_Term, _Kind, Lines)|T]) -->
804 Lines, [nl],
805 print_messages(T).
806
807list_names([]) --> [].
808list_names([H|T]) -->
809 [ '~w'-[H] ],
810 ( {T==[]}
811 -> []
812 ; [ ', '-[] ],
813 list_names(T)
814 ).
815
816list_file(File) -->
817 [ nl, ' '-[], url(File) ].
818
819
820 823
828
829check_config_files :-
830 check_config_files(Issues),
831 maplist(print_message(warning), Issues).
832
833check_config_files(Issues) :-
834 findall(Issue, check_config_file(Issue), Issues).
835
836check_config_file(config(Id, move(Type, OldFile, NewFile))) :-
837 old_config(Type, Id, OldFile),
838 access_file(OldFile, exist),
839 \+ ( new_config(Type, Id, NewFile),
840 access_file(NewFile, exist)
841 ),
842 once(new_config(Type, Id, NewFile)).
843check_config_file(config(Id, different(Type, OldFile, NewFile))) :-
844 old_config(Type, Id, OldFile),
845 access_file(OldFile, exist),
846 new_config(Type, Id, NewFile),
847 access_file(NewFile, exist),
848 \+ same_file(OldFile, NewFile).
849
854
855update_config_files :-
856 old_config(Type, Id, OldFile),
857 access_file(OldFile, exist),
858 \+ ( new_config(Type, Id, NewFile),
859 access_file(NewFile, exist)
860 ),
861 ( new_config(Type, Id, NewFile),
862 \+ same_file(OldFile, NewFile),
863 create_parent_dir(NewFile)
864 -> catch(rename_file(OldFile, NewFile), E,
865 print_message(warning, E)),
866 print_message(informational, config(Id, moved(Type, OldFile, NewFile)))
867 ),
868 fail.
869update_config_files.
870
871old_config(file, init, File) :-
872 current_prolog_flag(windows, true),
873 win_folder(appdata, Base),
874 atom_concat(Base, '/SWI-Prolog/swipl.ini', File).
875old_config(file, init, File) :-
876 expand_file_name('~/.swiplrc', [File]).
877old_config(directory, lib, Dir) :-
878 expand_file_name('~/lib/prolog', [Dir]).
879old_config(directory, xpce, Dir) :-
880 expand_file_name('~/.xpce', [Dir]).
881old_config(directory, history, Dir) :-
882 expand_file_name('~/.swipl-dir-history', [Dir]).
883old_config(directory, pack, Dir) :-
884 ( catch(expand_file_name('~/lib/swipl/pack', [Dir]), _, fail)
885 ; absolute_file_name(swi(pack), Dir,
886 [ file_type(directory), solutions(all) ])
887 ).
888
889new_config(file, init, File) :-
890 absolute_file_name(user_app_config('init.pl'), File,
891 [ solutions(all) ]).
892new_config(directory, lib, Dir) :-
893 config_dir(user_app_config(lib), Dir).
894new_config(directory, xpce, Dir) :-
895 config_dir(user_app_config(xpce), Dir).
896new_config(directory, history, Dir) :-
897 config_dir(user_app_config('dir-history'), Dir).
898new_config(directory, pack, Dir) :-
899 config_dir([app_data(pack), swi(pack)], Dir).
900
901config_dir(Aliases, Dir) :-
902 is_list(Aliases),
903 !,
904 ( member(Alias, Aliases),
905 absolute_file_name(Alias, Dir,
906 [ file_type(directory), solutions(all) ])
907 *-> true
908 ; member(Alias, Aliases),
909 absolute_file_name(Alias, Dir,
910 [ solutions(all) ])
911 ).
912config_dir(Alias, Dir) :-
913 ( absolute_file_name(Alias, Dir,
914 [ file_type(directory), solutions(all) ])
915 *-> true
916 ; absolute_file_name(Alias, Dir,
917 [ solutions(all) ])
918 ).
919
920create_parent_dir(NewFile) :-
921 file_directory_name(NewFile, Dir),
922 create_parent_dir_(Dir).
923
924create_parent_dir_(Dir) :-
925 exists_directory(Dir),
926 '$my_file'(Dir),
927 !.
928create_parent_dir_(Dir) :-
929 file_directory_name(Dir, Parent),
930 Parent \== Dir,
931 create_parent_dir_(Parent),
932 make_directory(Dir).
933
934prolog:message(config(Id, Issue)) -->
935 [ 'Config: '-[] ],
936 config_description(Id),
937 config_issue(Issue).
938
939config_description(init) -->
940 [ '(user initialization file) '-[], nl ].
941config_description(lib) -->
942 [ '(user library) '-[], nl ].
943config_description(pack) -->
944 [ '(add-ons) '-[], nl ].
945config_description(history) -->
946 [ '(command line history) '-[], nl ].
947config_description(xpce) -->
948 [ '(gui) '-[], nl ].
949
950config_issue(move(Type, Old, New)) -->
951 [ ' found ~w "~w"'-[Type, Old], nl ],
952 [ ' new location is "~w"'-[New] ].
953config_issue(moved(Type, Old, New)) -->
954 [ ' found ~w "~w"'-[Type, Old], nl ],
955 [ ' moved to new location "~w"'-[New] ].
956config_issue(different(Type, Old, New)) -->
957 [ ' found different ~w "~w"'-[Type, Old], nl ],
958 [ ' new location is "~w"'-[New] ].
959
960 963
967
968check_autoload :-
969 findall(Name/Arity, '$in_library'(Name, Arity, _Path), PIs),
970 msort(PIs, Sorted),
971 clumped(Sorted, Clumped),
972 sort(2, >=, Clumped, ClumpedS),
973 ambiguous_autoload(ClumpedS).
974
975ambiguous_autoload([PI-N|T]) :-
976 N > 1,
977 !,
978 warn_ambiguous_autoload(PI),
979 ambiguous_autoload(T).
980ambiguous_autoload(_).
981
982warn_ambiguous_autoload(PI) :-
983 PI = Name/Arity,
984 findall(PlFile,
985 ( '$in_library'(Name, Arity, File),
986 file_name_extension(File, pl, PlFile)
987 ), PlFiles),
988 print_message(warning, installation(ambiguous_autoload(PI, PlFiles)))