-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSlayMakefile
129 lines (116 loc) · 4.08 KB
/
SlayMakefile
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
{
package MyPH;
use base 'Pod::Simple::HTML';
sub html_header_after_title {
my $self = shift;
if (@_) {
$self->SUPER::html_header_after_title(@_);
} else {
$self->SUPER::html_header_after_title . "\n<h1>CPAN in a nutshell</h1>";
}
}
sub html_footer {
my $self = shift;
if (@_) {
$self->SUPER::html_footer(@_);
} else {
"\n<h1>Author</h1>Slaven Rezić" . $self->SUPER::html_footer;
}
}
sub force_title { "CPAN in a nutshell" }
sub index {1}
sub html_css { "http://search.cpan.org/s/style.css" }
}
{
sub is_in_path {
my($prog) = @_;
require File::Spec;
if (File::Spec->file_name_is_absolute($prog)) {
if ($^O eq 'MSWin32') {
return $prog if (-f $prog && -x $prog);
return "$prog.bat" if (-f "$prog.bat" && -x "$prog.bat");
return "$prog.com" if (-f "$prog.com" && -x "$prog.com");
return "$prog.exe" if (-f "$prog.exe" && -x "$prog.exe");
return "$prog.cmd" if (-f "$prog.cmd" && -x "$prog.cmd");
} else {
return $prog if -f $prog and -x $prog;
}
}
require Config;
%Config::Config = %Config::Config if 0; # cease -w
my $sep = $Config::Config{'path_sep'} || ':';
foreach (split(/$sep/o, $ENV{PATH})) {
if ($^O eq 'MSWin32') {
# maybe use $ENV{PATHEXT} like maybe_command in ExtUtils/MM_Win32.pm?
return "$_\\$prog" if (-f "$_\\$prog" && -x "$_\\$prog");
return "$_\\$prog.bat" if (-f "$_\\$prog.bat" && -x "$_\\$prog.bat");
return "$_\\$prog.com" if (-f "$_\\$prog.com" && -x "$_\\$prog.com");
return "$_\\$prog.exe" if (-f "$_\\$prog.exe" && -x "$_\\$prog.exe");
return "$_\\$prog.cmd" if (-f "$_\\$prog.cmd" && -x "$_\\$prog.cmd");
} else {
return "$_/$prog" if (-x "$_/$prog" && !-d "$_/$prog");
}
}
undef;
}
}
{
use vars '$CPAN_PREREQS';
$CPAN_PREREQS = q(VCS Date::ICal Data::ICal Text::vCard PerlIO::gzip Email::MIME Tk Tk::More MLDBM DB_File HTML::TreeBuilder::XPath CPAN::DistnameInfo Archive::Zip Test::Reporter YAML Date::Parse Config::Perl::V List::MoreUtils LWP::UserAgent Net::OpenSSH Time::Fake);
}
all: permissions
/tmp/cpan_in_a_nutshell.html: cpan_in_a_nutshell/cpan_in_a_nutshell.pod SlayMakefile
{
MyPH->parse_from_file("cpan_in_a_nutshell/cpan_in_a_nutshell.pod", "/tmp/cpan_in_a_nutshell.html");
"";
}
permissions:
cd scripts && chmod ugo+rx *
chmod ugo+rx scripts
# XXX does not work --- tty is missing within slaymake, but is needed for password input
# XXX maybe these should go into pistachio-perl-manager.pl?
install-prereqs:
cpan_smoke_modules -notypescript -install -perl $CPAN_PREREQS
install-prereqs-with-cpanm:
cpanm --quiet --notest $CPAN_PREREQS
install-prereqs-with-cpan:
cpan $CPAN_PREREQS >/tmp/srezic-misc-prereq-install.log 2>&1 || (cat /tmp/srezic-misc-prereq-install.log; false)
# Additional check
{
for my $mod (split / /, $CPAN_PREREQS) {
system 'perl', '-e', 'require ' . $mod;
}
}
# XXX Unfortunately SlayMakefile does not fail if any of the targets fail
# XXX So best is to call the targets separately
test: test-t test-compile
test-compile:
{
require Test::More;
import Test::More;
plan('no_plan');
my $perl = is_in_path('pistachio-perl');
if (!$perl) {
diag("pistachio-perl not found in PATH, fallback to standard perl");
$perl = $^X;
}
system('perl', '-e', 'use 5.010;'); # cannot use $^V (does not work with 5.8) and the newer version variable,
# because slaymake miscalculates matching
# parens then and interprets actions as shell actions
my $perl_5010_or_better = $? == 0;
for my $script (<scripts/*>) {
next if $script =~ m{/00MIGRATED$};
next if $script =~ m{/reports-sent-cache.pl$} && !$perl_5010_or_better;
next if $script =~ m{/capture-tiny-watcher.pl$}; # only interesting on Windows systems; needs P9Y::ProcessTable
next if $script =~ m{/firefox_cookie_finder.pl$} && !eval { require DBI; 1 };
next if $script =~ m{/git-safe-amend$} && !eval { require Doit; 1 };
system($perl, '-c', $script);
is($?, 0, "$script compiled OK");
}
}
test-t:
{
my @cmd = qw(prove -r t);
system @cmd;
die "@cmd failed" if $? != 0;
}