summaryrefslogtreecommitdiff
path: root/inc/Menlo/Sqitch.pm
blob: 9541f1d30e28bbe9d28d4450a14c75ff2b9e0016 (plain)
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
package Menlo::Sqitch;

use strict;
use warnings;
use base 'Menlo::CLI::Compat';

sub new {
    my %deps;
    while (<DATA>) {
        last if /^Build-only dependencies/;
    }
    while (<DATA>) {
        chomp;
        last unless s/^\s+//;
        $deps{$_} = 1;
    }
    use Data::Dump; ddx \%deps; exit;
    shift->SUPER::new(
        @_,
        _remove   => [],
        _bld_deps => \%deps,
    );
}

sub find_prereqs {
    my ($self, $dist) = @_;
    # Menlo defaults to config, test, runtime. We just want to bundle runtime.
    $dist->{want_phases} = ['runtime'];
    return $self->SUPER::find_prereqs($dist);
}

sub configure {
    my $self = shift;
    my $cmd = $_[0];
    return $self->SUPER::configure(@_) if ref $cmd ne 'ARRAY';
    # Always use vendor install dirs. Hack for
    # https://github.com/miyagawa/cpanminus/issues/581.
    if ($cmd->[1] eq 'Makefile.PL') {
        push @{ $cmd } => 'INSTALLDIRS=vendor';
    } elsif ($cmd->[1] eq 'Build.PL') {
        push @{ $cmd } => '--installdirs', 'vendor';
    }
    return $self->SUPER::configure(@_);
}

sub save_meta {
    my $self = shift;
    my ($module, $dist) = @_;
    # Record if we've installed a build-only dependency.
    my $dname = $dist->{meta}{name};
    push @{ $self->{_remove} } => $module if $self->{_bld_deps}{$dname};
    $self->SUPER::save_meta(@_);
}

sub remove_build_dependencies {
    # Uninstall modules for distributions not actually needed to run Sqitch.
    my $self = shift;
    local $self->{force} = 1;
    my @fail;
    for my $mod (reverse @{ $self->{_remove} }) {
        $self->uninstall_module($mod) or push @fail, $mod;
    }
    return !@fail;
}

1;

# List of distirbutions that might be installed but are not actually needed to
# run Sqitch. Used to track unneeded installs so they can be removed by
# remove_build_dependencies().
#
# Data pasted from the report of build-only dependencies by
# dev/dependency_report.
__DATA__
Build-only dependencies
        Archive-Tar
        Archive-Zip
        CPAN
        CPAN-Checksums
        CPAN-Common-Index
        CPAN-DistnameInfo
        CPAN-Meta
        CPAN-Meta-Check
        CPAN-Meta-Requirements
        CPAN-Meta-YAML
        CPAN-Perl-Releases
        Capture-Tiny
        Class-Tiny
        Compress-Bzip2
        Compress-Raw-Bzip2
        Compress-Raw-Lzma
        Compress-Raw-Zlib
        Config-AutoConf
        DBD-CSV
        Data-Compare
        Date-Manip
        Devel-CheckLib
        Devel-GlobalDestruction
        Devel-Symdump
        Digest
        Digest-MD5
        Dist-CheckConflicts
        Dumpvalue
        Expect
        ExtUtils-CBuilder
        ExtUtils-Config
        ExtUtils-Constant
        ExtUtils-Helpers
        ExtUtils-Install
        ExtUtils-InstallPaths
        ExtUtils-MakeMaker
        ExtUtils-MakeMaker-CPANfile
        ExtUtils-ParseXS
        File-Fetch
        File-Find-Rule
        File-Find-Rule-Perl
        File-HomeDir
        File-Listing
        File-ShareDir-Install
        File-Slurper
        File-pushd
        HTML-Parser
        HTML-Tagset
        HTTP-CookieJar
        HTTP-Cookies
        HTTP-Date
        HTTP-Message
        HTTP-Negotiate
        HTTP-Tiny
        HTTP-Tinyish
        IO-Compress
        IO-Compress-Brotli
        IO-Compress-Lzma
        IO-HTML
        IO-Socket-IP
        IO-Socket-SSL
        IO-Tty
        IO-Zlib
        IPC-Cmd
        JSON-PP
        LWP-MediaTypes
        Locale-Maketext-Simple
        Log-Dispatch
        Log-Dispatch-FileRotate
        Log-Log4perl
        Math-Base-Convert
        Math-BigInt
        Math-BigRat
        Math-Complex
        Menlo
        Menlo-Legacy
        Module-Build
        Module-CPANfile
        Module-CoreList
        Module-Load
        Module-Load-Conditional
        Module-Metadata
        Module-Signature
        Mozilla-CA
        Mozilla-PublicSuffix
        Net-HTTP
        Net-Ping
        Net-SSLeay
        Number-Compare
        Params-Check
        Parse-PMFile
        Perl-Tidy
        Pod-Coverage
        SQL-Statement
        Safe
        Search-Dict
        Sub-Uplevel
        Sys-Syslog
        Test
        Test-Exception
        Test-Fatal
        Test-Harness
        Test-NoWarnings
        Test-Pod
        Test-Pod-Coverage
        Test-Simple
        Test-Version
        Text-Balanced
        Text-CSV_XS
        Text-Glob
        Text-Soundex
        Thread-Semaphore
        Tie-File
        Tie-Handle-Offset
        TimeDate
        WWW-RobotRules
        Win32-ShellQuote
        XML-DOM
        XML-Parser
        XML-RegExp
        YAML
        YAML-LibYAML
        YAML-Syck
        bignum
        inc-latest
        lib
        libwww-perl
        libxml-perl
        local-lib
        threads
        threads-shared

Runtime-only dependencies
        Algorithm-Backoff
        Class-Inspector
        Class-Singleton
        Clone-Choose
        Config-GitLike
        DBD-Firebird
        DBD-ODBC
        DBD-Oracle
        DBD-Pg
        DBD-mysql
        Data-OptList
        DateTime
        DateTime-Locale
        DateTime-TimeZone
        Exporter-Tiny
        File-ShareDir
        Hash-Merge
        IO-Pager
        IPC-System-Simple
        List-MoreUtils
        List-MoreUtils-XS
        Moo
        MooX-Types-MooseLike
        MySQL-Config
        Path-Class
        Ref-Util-XS
        Regexp-Util
        String-Formatter
        Sub-Exporter
        Sub-Install
        Template-Tiny
        Template-Toolkit
        Term-ANSIColor
        Throwable
        Type-Tiny
        Type-Tiny-XS
        URI-Nested
        URI-db
        libintl-perl
        strictures

Overlapping dependencies
        B-Hooks-EndOfScope
        Carp
        Class-Data-Inheritable
        Class-Method-Modifiers
        Class-XSAccessor
        Clone
        DBD-SQLite
        DBI
        Data-Dumper
        Devel-Caller
        Devel-LexAlias
        Devel-StackTrace
        Digest-SHA
        Encode
        Encode-Locale
        Env
        Eval-Closure
        Exception-Class
        Exporter
        File-Path
        File-Temp
        File-Which
        Getopt-Long
        IO
        IPC-Run3
        MIME-Base64
        MRO-Compat
        Module-Implementation
        Module-Runtime
        Package-Stash
        Package-Stash-XS
        PadWalker
        Params-Util
        Params-ValidationCompiler
        PathTools
        Perl-OSType
        PerlIO-utf8_strict
        Pod-Escapes
        Pod-Parser
        Pod-Perldoc
        Pod-Simple
        Pod-Usage
        Ref-Util
        Role-Tiny
        Scalar-List-Utils
        Socket
        Specio
        Storable
        String-ShellQuote
        Sub-Exporter-Progressive
        Sub-Identify
        Sub-Quote
        TermReadKey
        Text-ParseWords
        Text-Tabs+Wrap
        Time-HiRes
        Time-Local
        Try-Tiny
        URI
        XSLoader
        base
        constant
        if
        libnet
        namespace-autoclean
        namespace-clean
        parent
        podlators
        version