-
Notifications
You must be signed in to change notification settings - Fork 65
/
VirtPackage.pm
1906 lines (1580 loc) · 57.4 KB
/
VirtPackage.pm
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
# -*- mode: Perl; tab-width: 4; -*-'
#
# Fink::VirtPackage class
#
# Fink - a package manager that downloads source and installs it
# Copyright (c) 2001 Christoph Pfisterer
# Copyright (c) 2001-2012 The Fink Package Manager Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA.
#
=head1 NAME
Fink::VirtPackage - Provide "virtual" packages for Fink and related tools
=head1 SYNOPSIS
Fink::VirtPackage is generally not used directly, but is instead used by
the fink-virtual-pkgs tool.
=head1 DESCRIPTION
Fink::VirtPackage is used to inject "fake" package data into the fink
database, as well as to generate a list of dpkg- and apt-get-compatible
packages to satisfy dependencies outside of Fink.
=cut
package Fink::VirtPackage;
our $VERSION = 1.00;
# Programmers' note: Please be *very* careful if you alter this file.
# It is used by dpkg via popen(), so (among other things) that means
# you must not print to STDOUT.
use Fink::Config qw($config $basepath $distribution);
use POSIX qw(uname tmpnam);
use Fink::Status;
use File::Basename;
use Fink::FinkVersion;
use constant STATUS_PRESENT => "install ok installed";
use constant STATUS_ABSENT => "purge ok not-installed";
use vars qw(
%options
);
use strict;
use warnings;
BEGIN {
use Exporter ();
our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = qw();
@EXPORT_OK = qw(); # eg: qw($Var1 %Hashit &func3);
%EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
}
our @EXPORT_OK;
my $pkgconfig_virtual_prefix = 'system-pkgconfig-';
my @xservers = ('XDarwin', 'Xquartz', 'XDarwinQuartz');
my $the_instance = undef;
END { } # module clean-up code here (global destructor)
### constructor
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless($self, $class);
$self->initialize();
$the_instance = $self;
return $self;
}
=head1 TESTS
=over
=cut
### self-initialization
sub initialize {
my $self = shift;
my ($hash);
my ($cctools_version, $cctools_single_module, $growl_version);
=item "kernel"
This test checks for the kernel name and version by running the system
uname(1) call. This should *always* exist.
=cut
# create dummy object for kernel version
$hash = {};
$hash->{package} = lc((uname())[0]);
$hash->{provides} = "kernel";
$hash->{status} = STATUS_PRESENT;
$hash->{version} = Fink::Services::get_kernel_vers_long() . "-1";
$hash->{description} = "[virtual package representing the kernel]";
$hash->{descdetail} = <<END;
This package represents the kernel (XNU (Darwin) on Mac OS X),
which is a core part of the operating system.
END
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{compilescript} = &gen_compile_script($hash);
$self->{$hash->{package}} = $hash;
=item "macosx"
This test checks for the Mac OS X version by running the sw_vers(1)
command and parsing the output. It should exist on all Mac OS X
installations (but not pure Darwin systems).
=cut
# create dummy object for system version, if this is OS X at all
print STDERR "- checking OSX version... " if ($options{debug});
$hash = {};
$hash->{package} = "macosx";
$hash->{description} = "[virtual package representing the system]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
if (Fink::Services::get_osx_vers_long() ne 0) {
$hash->{status} = STATUS_PRESENT;
$hash->{version} = Fink::Services::get_osx_vers_long()."-1";
print STDERR $hash->{version}, "\n" if ($options{debug});
} else {
$hash->{status} = STATUS_ABSENT;
$hash->{version} = '0-0';
print STDERR "unknown\n" if ($options{debug});
}
$hash->{descdetail} = <<END;
This package represents the Mac OS X software release.
It will not show as installed on pure Darwin systems.
END
$hash->{compilescript} = &gen_compile_script($hash);
$self->{$hash->{package}} = $hash;
=item "64bit-cpu"
The package is present when the CPU is 64bit-capable.
=cut
print STDERR "- checking for 64bit-cpu... " if ($options{debug});
# different sysctl variables for intel and ppc
my @keys64 = ('hw.optional.x86_64', 'hw.optional.64bitops', 'hw.cpu64bit_capable');
$hash = {};
$hash->{package} = "64bit-cpu";
my $is64bit = 0;
if (open(SYSCTL, "sysctl " . join(' ', @keys64) . " 2>/dev/null |")) {
my ($key, $value);
while (<SYSCTL>) {
($key, $value) = $_ =~ /^(\S+)\s*\:\s*(.*?)\s*$/;
next unless (defined $key and defined $value);
if (grep(/^$key$/, @keys64) and $value eq "1") {
$is64bit = 1;
last;
}
}
close(SYSCTL);
}
if ($is64bit) {
print STDERR "64 bit capable\n" if ($options{debug});
$hash->{status} = STATUS_PRESENT;
} else {
print STDERR "not 64 bit capable\n" if ($options{debug});
$hash->{status} = STATUS_ABSENT;
}
$hash->{description} = "[virtual package representing the 64bit capability of the CPU]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{descdetail} = <<END;
The presence of the 64bit-cpu package indicates that the CPU on which we
are running is 64bit capable.
END
$hash->{compilescript} = &gen_compile_script($hash);
$hash->{version} = '0-1';
$self->{$hash->{package}} = $hash;
=item "cups-dev"
This package represents and existing installation of the CUPS
headers in /usr/include/cups.
It is called "cups-dev" instead of "system-cups-dev" for the
purposes of versioned cups-dev dependencies.
=cut
print STDERR "- checking for cups headers... " if ($options{debug});
$hash = {};
$hash->{package} = "cups-dev";
$hash->{version} = '0-0';
$hash->{status} = STATUS_ABSENT;
$hash->{description} = "[virtual package representing CUPS headers]";
$hash->{provides} = "system-cups-dev";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{descdetail} = <<END;
This package represents the version of CUPS headers installed
in /usr/include/cups.
END
$hash->{compilescript} = &gen_compile_script($hash);
if (open(FILEIN, '/usr/include/cups/cups.h')) {
while (<FILEIN>) {
if (/\#\s*define\s+CUPS_VERSION\s+(.*?)\s*$/) {
$hash->{version} = $1 . '-1';
last;
}
}
close(FILEIN);
$hash->{status} = STATUS_PRESENT;
print STDERR $hash->{version}, "\n" if ($options{debug});
} else {
print STDERR "no\n" if ($options{debug});
}
$self->{$hash->{package}} = $hash;
=item "system-perl"
This package represents the version of the perl in /usr/bin. It
is determined by parsing the $^V variable in a perl script. It
also provides the perlI<XXX>-core package that corresponds with it's
version.
=cut
# create dummy object for system perl
print STDERR "- checking system perl version... " if ($options{debug});
$hash = {};
$hash->{package} = "system-perl";
$hash->{description} = "[virtual package representing perl]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{descdetail} = <<END;
This package represents the version of perl installed on the
system in /usr/bin/perl.
END
$hash->{compilescript} = &gen_compile_script($hash);
if ((defined Fink::Services::get_system_perl_version()) and (!(Fink::FinkVersion::get_arch() eq "x86_64") or !($distribution eq "10.5"))) {
$hash->{version} = Fink::Services::get_system_perl_version()."-1";
$hash->{status} = STATUS_PRESENT;
print STDERR Fink::Services::get_system_perl_version(), "\n" if ($options{debug});
my $perlver = my $shortver = Fink::Services::get_system_perl_version();
$perlver = sprintf "%d.%03d%03d", split( /\./, $perlver );
$shortver =~ s/\.//g;
my $perlprovides = 'perl' . $shortver . '-core, system-perl' . $shortver;
my @modules;
if ($perlver >= 5.008001) {
push(@modules,
'attribute-handlers',
'cgi',
'data-dumper',
'db',
'devel-dprof',
'devel-peek',
'digest',
'digest-md5',
'extutils-makemaker',
'file-find',
'file-path',
'file-spec',
'file-temp',
'filter-simple',
'getopt-long',
'i18n-langtags',
'libnet',
'list-util',
'locale-maketext',
'math-bigint',
'memoize',
'mime-base64',
'podparser',
'pod-parser',
'switch',
'sys-syslog',
'term-readline',
'test-harness',
'test-simple',
'text-tabs',
'text-wrap',
'time-hires',
'unicode-normalize',
);
}
if ($perlver >= 5.008006) {
push(@modules,
'apache',
'compress-zlib',
'convert-tnef',
'html-parser',
'perlobjcbridge',
'scalar-list-utils',
'uri',
);
}
if ($perlver >= 5.008008) {
push(@modules,
'algorithm-diff',
'carp',
'class-autouse',
'class-isa',
'corefoundation',
'data-hierarchy',
'date-parse',
'freezethaw',
'io-pager',
'ipc-run3',
'locale-maketext-lexicon',
'perlio-eol',
'pod-simple',
'svn',
'svk',
'timedate',
'vcp',
'yaml',
);
}
if ($perlver >= 5.010000) {
push(@modules,
'archive-tar',
'cpanplus',
'cpanplus-dist-build',
'compress-raw-zlib',
'digest-sha',
'extutils-cbuilder',
'extutils-parsexs',
'io-zlib',
'locale-maketext-simple',
'module-build',
'module-corelist',
'module-load',
'module-load-conditional',
'module-pluggable',
'package-constants',
'params-check',
'pod-escapes',
);
}
$perlprovides .= ', ' . join(', ', map { $_ . '-pm' . $shortver } sort @modules);
$hash->{provides} = $perlprovides;
} else {
$hash->{version} = '0-0';
$hash->{status} = STATUS_ABSENT;
print STDERR "unknown\n" if ($options{debug});
}
$self->{$hash->{package}} = $hash;
=item "system-javaI<XX>"
This package represents an installed version of Apple's Java.
It is considered present if the
/System/Library/Frameworks/JavaVM.framework/Versions/[VERSION]/Commands
directory exists.
=cut
# create dummy object for java
print STDERR "- checking Java versions:\n" if ($options{debug});
my $javadir = '/System/Library/Frameworks/JavaVM.framework/Versions';
my ($latest_java, $latest_javadev);
if (opendir(DIR, $javadir)) {
chomp(my @dirs = grep(!/^\.\.?$/, readdir(DIR)));
for my $dir (reverse(sort(@dirs, '1.3', '1.4', '1.5'))) {
my $ver = $dir;
# chop the version down to major/minor without dots
$ver =~ s/[^\d]+//g;
$ver =~ s/^(..).*$/$1/;
next if ($ver eq "");
print STDERR " - $dir... " if ($options{debug});
$hash = {};
$hash->{package} = "system-java${ver}";
$hash->{version} = $dir . "-1";
$hash->{description} = "[virtual package representing Java $dir]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{provides} = 'system-java';
if ($ver >= 14) {
$hash->{provides} .= ', jdbc, jdbc2, jdbc3, jdbc-optional';
}
$hash->{descdetail} = <<END;
This package represents the currently installed version
of Java $dir.
END
$hash->{compilescript} = &gen_compile_script($hash);
if ($dir =~ /^\d[\d\.]*$/ and -d $javadir . '/' . $dir . '/Commands') {
print STDERR "$dir/Commands " if ($options{debug});
$hash->{status} = STATUS_PRESENT;
$self->{$hash->{package}} = $hash unless (exists $self->{$hash->{package}});
$latest_java = $dir unless (defined $latest_java);
=item "system-javaI<XX>-dev"
This package represents an installed version of Apple's Java SDK.
It is considered present if the
/System/Library/Frameworks/JavaVM.framework/Versions/[VERSION]/Headers
directory exists.
=cut
$hash = {};
$hash->{package} = "system-java${ver}-dev";
$hash->{status} = STATUS_PRESENT;
$hash->{version} = $dir . "-1";
$hash->{description} = "[virtual package representing Java $dir development headers]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{descdetail} = <<END;
This package represents the development headers for
Java $dir. If this package shows as not being installed,
you must download the Java SDK from Apple at:
http://connect.apple.com/
(free registration required)
END
$hash->{compilescript} = &gen_compile_script($hash);
if (-r $javadir . '/' . $dir . '/Headers/jni.h') {
print STDERR "$dir/Headers/jni.h " if ($options{debug});
$latest_javadev = $dir unless (defined $latest_javadev);
} elsif ($distribution ge "10.5" && $ver >= 14 && -r $javadir . '/Current/Headers/jni.h') {
print STDERR "Current/Headers/jni.h " if ($options{debug});
$latest_javadev = $dir unless (defined $latest_javadev);
} else {
print STDERR "$javadir/$dir/Headers/jni.h missing " if ($options{debug});
$hash->{status} = STATUS_ABSENT;
}
$self->{$hash->{package}} = $hash unless (exists $self->{$hash->{package}});
print STDERR "\n" if ($options{debug});
} else {
$hash->{status} = STATUS_ABSENT;
$self->{$hash->{package}} = $hash unless (exists $self->{$hash->{package}});
print STDERR "nothing\n" if ($options{debug});
}
}
closedir(DIR);
}
=item "system-java"
This is a convenience package that represents the latest Java version
that is considered installed, based on the previous tests.
=cut
if (defined $latest_java) {
$hash = {};
$hash->{package} = "system-java";
$hash->{status} = "install ok installed";
$hash->{version} = $latest_java . "-1";
$hash->{description} = "[virtual package representing Java $latest_java]";
$self->{$hash->{package}} = $hash;
}
=item "system-java-dev"
This is a convenience package that represents the latest Java SDK
version that is considered installed, based on the previous tests.
=cut
if (defined $latest_javadev) {
$hash = {};
$hash->{package} = "system-java-dev";
$hash->{status} = "install ok installed";
$hash->{version} = $latest_javadev . "-1";
$hash->{description} = "[virtual package representing Java SDK $latest_java]";
$self->{$hash->{package}} = $hash;
}
=item "system-java3d"
This package represents the Java3D APIs available as a separate download
from Apple. It is considered present if the j3dcore.jar file exists in
the system Java extensions directory.
=cut
# create dummy object for Java3D
$hash = {};
$hash->{package} = "system-java3d";
$hash->{status} = STATUS_PRESENT;
$hash->{version} = "0-1";
$hash->{description} = "[virtual package representing Java3D]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{descdetail} = <<END;
This package represents the Java3D API. If it does not show
as installed, you can download it from Apple at:
http://www.apple.com/downloads/macosx/apple/java3dandjavaadvancedimagingupdate.html
END
$hash->{compilescript} = &gen_compile_script($hash);
print STDERR "- searching for java3d... " if ($options{debug});
if (-f '/System/Library/Java/Extensions/j3dcore.jar') {
print STDERR "found /System/Library/Java/Extensions/j3dcore.jar\n" if ($options{debug});
if (open(FILEIN, '/Library/Receipts/Java3D.pkg/Contents/Info.plist')) {
local $/ = undef;
if (<FILEIN> =~ /<key>CFBundleShortVersionString<\/key>[\r\n\s]*<string>([\d\.]+)<\/string>/) {
$hash->{version} = $1 . '-1';
}
close(FILEIN);
}
} else {
$hash->{status} = STATUS_ABSENT;
$hash->{version} = '0-0';
print STDERR "missing /System/Library/Java/Extensions/j3dcore.jar\n" if ($options{debug});
}
$self->{$hash->{package}} = $hash;
=item "system-javaai"
This package represents the JavaAdvancedImaging APIs available as a
separate download from Apple. It is considered present if the jai_core.jar
file exists in the system Java extensions directory.
=cut
# create dummy object for JavaAdvancedImaging
$hash = {};
$hash->{package} = "system-javaai";
$hash->{status} = STATUS_PRESENT;
$hash->{version} = "0-1";
$hash->{description} = "[virtual package representing Java Advanced Imaging]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{descdetail} = <<END;
This package represents the Java Advanced Imaging API. If it
does not show as installed, you can download it from Apple at:
http://www.apple.com/downloads/macosx/apple/java3dandjavaadvancedimagingupdate.html
END
$hash->{compilescript} = &gen_compile_script($hash);
print STDERR "- searching for javaai... " if ($options{debug});
if (-f '/System/Library/Java/Extensions/jai_core.jar') {
print STDERR "found /System/Library/Java/Extensions/jai_core.jar\n" if ($options{debug});
if (open(FILEIN, '/Library/Receipts/JavaAdvancedImaging.pkg/Contents/Info.plist')) {
local $/ = undef;
if (<FILEIN> =~ /<key>CFBundleShortVersionString<\/key>[\r\n\s]*<string>([\d\.]+)<\/string>/) {
$hash->{version} = $1 . '-1';
}
close(FILEIN);
}
} else {
$hash->{status} = STATUS_ABSENT;
$hash->{version} = '0-0';
print STDERR "missing /System/Library/Java/Extensions/jai_core.jar\n" if ($options{debug});
}
$self->{$hash->{package}} = $hash;
=item "xcode"
This package represents your Xcode version.
=cut
print STDERR "- checking for xcode version... " if ($options{debug});
$hash = {};
$hash->{package} = "xcode";
$hash->{version} = '0-0';
$hash->{status} = STATUS_ABSENT;
$hash->{description} = "[virtual package representing the developer tools]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{descdetail} = <<END;
This package represents the C/C++/ObjC developer tools
provided by Apple. If it does not show as installed,
you can download it from Apple at:
http://connect.apple.com/
(free registration required)
END
$hash->{compilescript} = &gen_compile_script($hash);
chomp(my $xcodepath=`xcode-select -print-path`);
# Xcode 4.3+ is relocatable
my $result=`defaults read $xcodepath/../version CFBundleShortVersionString 2>&1`;
if ($?) {
$result = `defaults read $xcodepath/Applications/Xcode.app/Contents/version CFBundleShortVersionString 2>&1`;
}
if (not $?) {
# didn't fail
chomp $result;
$hash->{version} = $result . '-1';
print STDERR $hash->{version}, "\n" if $options{debug};
$hash->{status} = STATUS_PRESENT;
} elsif ($options{debug}) {
# failed, so display whatever error message or diagnostics we can find
if ($!) {
print STDERR "unknown ($!)\n"; # have ERRNO string, so use that
} else {
print STDERR "unknown:\n$result\n"; # dump command's own diagnostics
}
}
$self->{$hash->{package}} = $hash;
=item "system-sdk-*"
These packages represent the SDKs available
as part of the Xcode tools.
=cut
my @SDKDIRS;
my $osxversion=Fink::Services::get_kernel_vers();
if ($osxversion == 9) {
@SDKDIRS= qw(
MacOSX10.3.9.sdk
MacOSX10.4u.sdk
MacOSX10.5.sdk
);
} elsif ($osxversion == 10) {
@SDKDIRS= qw(
MacOSX10.4u.sdk
MacOSX10.5.sdk
MacOSX10.6.sdk
);
} elsif ($osxversion == 11) {
@SDKDIRS=qw(
MacOSX10.6.sdk
MacOSX10.7.sdk
);
}
# Portable SDK path finder which works on 10.5 and later
my $sdkpath;
{
my @sdkread=`xcodebuild -version -sdk 2>&1`;
foreach (@sdkread) {
chomp;
$sdkpath=$1 if /Path:\s(.*)MacOSX.*\.sdk/;
last if $sdkpath;
}
}
$sdkpath="/not/a/real/path" if !$sdkpath;
for my $dir (sort @SDKDIRS) {
my $isuniversal = 0;
if ($dir =~ /MacOSX([\d\.]+)(u?)\.sdk/) {
my $version = $1;
$isuniversal = 1 if ($2 eq "u");
my ($shortversion) = $version =~ /^(\d+\.\d+)/;
my $versiontext = "$shortversion";
$hash = {};
$hash->{version} = $version . '-1';
if ($isuniversal) {
$hash->{package} = "system-sdk-${shortversion}-universal";
$versiontext = "$shortversion Universal";
$hash->{provides} = "system-sdk-${shortversion}";
} else {
$hash->{package} = "system-sdk-${shortversion}";
}
$hash->{status} = STATUS_ABSENT;
$hash->{description} = "[virtual package representing the Mac OS X $versiontext SDK]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{builddependsonly} = "true";
$hash->{descdetail} = <<END;
This package represents the Mac OS X $versiontext SDK
provided by Apple, as part of Xcode. If it does not show as
installed, you can download Xcode from Apple at:
http://connect.apple.com/
(free registration required)
END
$hash->{compilescript} = &gen_compile_script($hash);
if (-d "$sdkpath$dir" ) {
$hash->{status} = STATUS_PRESENT;
$self->{$hash->{package}} = $hash;
} else {
$self->{$hash->{package}} = $hash
unless (exists $self->{$hash->{package}}->{status} and $self->{$hash->{package}}->{status} eq STATUS_PRESENT);
}
}
}
=item "cctools-I<XXX>"
This package represents the compiler tools provided by Apple. It is
considered present if either I</usr/bin/what /usr/bin/ld> or
I</usr/bin/ld -v> contain a valid cctools-I<XXX> string.
=cut
# create dummy object for cctools version, if version was found in Config.pm
print STDERR "- checking for cctools version... " if ($options{debug});
if (-x "/usr/bin/as" and -x "/usr/bin/what") {
my $LD_OUTPUT = '';
if (my $tempfile = tmpnam()) {
$LD_OUTPUT = `/usr/bin/as -v 2>&1 </dev/null -o $tempfile`;
unlink $tempfile;
} else {
print STDERR "unable to get temporary file: $!" if ($options{debug});
};
if ($LD_OUTPUT =~ /^.*version cctools-(\d+).*?$/) {
$cctools_version = $1;
} elsif (-x "/usr/bin/ld" and `/usr/bin/what /usr/bin/ld` =~ /^.*PROJECT:\s*cctools-(\d+).*?$/) {
$cctools_version = $1;
}
} else {
print STDERR "/usr/bin/ld or /usr/bin/what not executable... " if ($options{debug});
}
$hash = {};
$hash->{package} = "cctools";
$hash->{status} = STATUS_PRESENT;
$hash->{description} = "[virtual package representing the developer tools]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{builddependsonly} = "true";
$hash->{descdetail} = <<END;
This package represents the C/C++/ObjC developer tools
provided by Apple. If it does not show as installed,
you can download it from Apple at:
http://connect.apple.com/
(free registration required)
END
$hash->{compilescript} = &gen_compile_script($hash);
if (defined ($cctools_version)) {
$hash->{version} = $cctools_version."-1";
print STDERR $hash->{version}, "\n" if ($options{debug});
} else {
print STDERR "unknown\n" if ($options{debug});
$hash->{version} = '0-0';
$hash->{status} = STATUS_ABSENT;
}
$self->{$hash->{package}} = $hash;
=item "cctools-single-module"
This package represents whether the cctools linker is capable
of using the -single_module flag. It is considered present
if a dummy file can be linked using the -single_module flag.
=cut
# create dummy object for cctools-single-module, if supported
print STDERR "- checking for cctools -single_module support... " if ($options{debug});
if ($cctools_version) {
if ($cctools_version >= 446) {
$cctools_single_module = $cctools_version;
print STDERR "yes, $cctools_version has it\n" if ($options{debug});
} else {
print STDERR "nope. oh well.\n" if ($options{debug});
}
} else {
print STDERR "nope. oh well.\n" if ($options{debug});
}
$hash = {};
$hash->{package} = "cctools-single-module";
$hash->{description} = "[virtual package, your dev tools support -single_module]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{builddependsonly} = "true";
$hash->{descdetail} = <<END;
This package represents support for the -single_module
flag in the development tools provided by Apple. If it
does not show as installed, you can download the latest
developer tools (called Xcode) from Apple at:
http://connect.apple.com/
(free registration required)
END
$hash->{compilescript} = &gen_compile_script($hash);
if ($cctools_single_module) {
$hash->{status} = STATUS_PRESENT;
$hash->{version} = $cctools_single_module."-1";
} else {
$hash->{status} = STATUS_ABSENT;
if ($cctools_version) {
$hash->{version} = $cctools_version;
} else {
$hash->{version} = '0-0';
}
}
$self->{$hash->{package}} = $hash;
=item "gcc-*"
The GCC virtual packages exist based on gcc* commands
in /usr/bin. They are considered present based on
the successful execution of "gcc --version".
=cut
print STDERR "- checking for various GCC versions:\n" if ($options{debug});
if (opendir(DIR, "/usr/bin")) {
for my $gcc (grep(/^gcc(-[\d\.]+)?$/, readdir(DIR))) {
next if (-l "/usr/bin/$gcc");
if (open(GCC, '/usr/bin/' . $gcc . ' -### -v -x c /dev/null 2>&1 |')) {
my ($versionoutput, $version, $build);
{ local $/ = undef; $versionoutput = <GCC> }
close(GCC);
next unless (defined $versionoutput);
if ($versionoutput =~ /version gcc-(\d+), based on gcc version ([\d\.\-]+)/s) {
($build, $version) = ($1, $2);
} elsif ($versionoutput =~ /version (\d+), based on gcc version ([\d\.\-]+)/s) {
($build, $version) = ($1, $2);
} elsif ($versionoutput =~ /version ([\d\.\-]+) .*? build (\d+)/s) {
($version, $build) = ($1, $2);
} else {
print STDERR " - warning, unable to determine the version for $gcc\n" if ($options{debug});
next;
}
$version =~ s/[\.\-]*$//;
my ($shortversion) = $version =~ /^(\d+\.\d+)/;
$shortversion = 2 if ($version eq "2.95.2");
my $pkgname = "gcc$shortversion";
# Don't interfere with real packages
if (Fink::Status->query_package($pkgname)) {
print STDERR " - skipping $pkgname, there's a real package\n" if ($options{debug});
next;
}
my $status = STATUS_PRESENT;
if (my ($match) = $versionoutput =~ /^\s*\"?(\S*cc1(obj)?)\"?\s/s) {
if (not -x $match or $match !~ m,^/,) {
$status = STATUS_ABSENT;
print STDERR " - $gcc is looking for $1 to build on this arch, but it's not there\n" if ($options{debug});
}
}
$hash = &gen_gcc_hash($pkgname, $version, $build, 0, $status);
$self->{$hash->{package}} = $hash;
print STDERR " - found $version\n" if ($options{debug});
}
}
closedir(DIR);
} else {
print STDERR " - couldn't get the contents of /usr/bin: $!\n" if ($options{debug});
}
{
# force presence of structs for some expected compilers
# list each as %n=>%v
my %expected_gcc = (
'gcc2' => '2.95.2',
'gcc2.95' => '2.95.2',
'gcc3.1' => '3.1',
'gcc3.3' => '3.3',
'gcc4.0' => '4.0',
);
foreach my $key (sort keys %expected_gcc) {
if (not exists $self->{$key} && not Fink::Status->query_package($key)) {
$hash = &gen_gcc_hash($key, $expected_gcc{$key}, 0, 0, STATUS_ABSENT);
$self->{$hash->{package}} = $hash;
print STDERR " - missing $expected_gcc{$key}\n" if ($options{debug});
}
}
}
=item "broken-gcc"
This package represents broken versions of the GCC compiler
as shipped by Apple. Currently it checks for the Xcode 1.5
cc1plus.
=cut
my @badbuilds = qw(1666);
print STDERR "- checking for broken GCCs:\n" if ($options{debug});
$hash = {};
$hash->{package} = "broken-gcc";
$hash->{status} = STATUS_ABSENT;
$hash->{version} = "3.3-1";
$hash->{description} = "[virtual package representing a broken gcc compiler]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{builddependsonly} = "true";
$hash->{descdetail} = <<END;
This package represents broken versions of the GCC compiler
as shipped by Apple. If this package shows as installed,
you should see if there is a newer version of the developer
tools at:
http://connect.apple.com/
(free registration required)
END
$hash->{compilescript} = &gen_compile_script($hash);
for my $key (keys %$self) {
if ($key =~ /^gcc/) {
my ($buildnum) = $self->{$key}->{version} =~ /^.*\-(\d+)$/;
print STDERR " - $key build number is $buildnum" if ($options{debug});
if (grep /^${buildnum}$/, @badbuilds) {
print STDERR " (bad)\n" if ($options{debug});
$hash->{status} = STATUS_PRESENT;
$hash->{version} = $self->{$key}->{version};
} else {
print STDERR " (not broken)\n" if ($options{debug});
}
}
}
$self->{$hash->{package}} = $hash;
=item "dev-tools"
This package represents a developer suite of command-line compilers
and related programs, for example, Apple's DevTools (OS X <= 10.2) or
Xcode (OS X >= 10.3). This package is considered "installed" iff
/usr/bin/gcc and /usr/bin/gcc exist and are executable.
=cut
# create dummy object for devtools
$hash = {
package => 'dev-tools',
version => '0-1',
status => STATUS_PRESENT,
description => '[virtual package representing developer commands]',
homepage => 'http://www.finkproject.org/faq/usage-general.php#virtpackage',
descdetail => <<END,
This package represents the basic command-line compiler and
related programs. In order for this package to be "installed",
you must have /usr/bin/gcc and /usr/bin/make available on your
system. You can obtain them by installing the Apple developer
tools (also known as Xcode). The latest versions of the Apple
developer tools are always available from Apple at:
http://connect.apple.com/
(free registration required)
END
};
print STDERR "- checking for dev-tools commands:\n" if ($options{debug});
foreach my $file (qw| /usr/bin/gcc /usr/bin/make |) {
$options{debug} && printf STDERR " - %s... %s\n", $file, -x $file ? "found" : "missing!";
$hash->{status} = STATUS_ABSENT if not -x $file;
}
$hash->{compilescript} = &gen_compile_script($hash);
$self->{$hash->{package}} = $hash;
=item "gimp-print-shlibs"
This package represents the GIMP printing libraries
provided by Apple on Mac OS X 10.3 and higher. They
are considered present if libgimpprint.1.dylib exists
in /usr/lib.
=cut
$hash = {};
$hash->{package} = "gimp-print-shlibs";
$hash->{version} = "4.2.5-1";
$hash->{description} = "[virtual package representing Apple's install of Gimp Print]";
$hash->{homepage} = "http://www.finkproject.org/faq/usage-general.php#virtpackage";
$hash->{descdetail} = <<END;
This package represents the version of Gimp-Print that
comes with Mac OS X 10.3 and above. If it shows as not
installed, you must install the GimpPrintPrinterDrivers
package that came with your Mac OS X CDs.
END