-
Notifications
You must be signed in to change notification settings - Fork 0
/
ea4-tool-post-update
executable file
·97 lines (71 loc) · 2.94 KB
/
ea4-tool-post-update
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
#!/usr/local/cpanel/3rdparty/bin/perl
# cpanel - ea4-tool-post-update Copyright(c) 2022 cPanel, L.L.C.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
package ea_passenger_src::ea4_tool_post_update;
use strict;
use warnings;
use lib "../ea-tools/lib/ea4_tool"; # assumes ea-tools is checked out next to this repo
use ea4_tool::util ();
use ea4_tool::util::gitapi;
use File::chdir;
use Path::Tiny;
exit( run(@ARGV) ? 0 : 1 ) if !caller;
sub run {
my ( $old_ver, $new_ver ) = @_;
# Update the cxxcodebuilder sourceball
my $tarball_url = 'https://github.com/phusion/cxxcodebuilder/archive/refs/heads/master.tar.gz';
my $tarball_location = 'SOURCES/cxxcodebuilder.tar.gz';
my $response = ea4_tool::util::http()->mirror( $tarball_url, $tarball_location );
die "Unable to download the tarball ($tarball_url)" if ( !$response->{success} );
# Update the include binary for debian to the newest sourceball version
my $file = 'debify/debian/source/include-binaries';
my @lines = path($file)->lines;
foreach my $line (@lines) {
if ( $line =~ /\Q$old_ver\E/ ) {
$line =~ s/\Q$old_ver\E/$new_ver/;
}
}
path($file)->spew(@lines);
print "Committing change to $file …\n";
my $git = ea4_tool::util::git($CWD);
my $branch = $git->current_branch();
$git->run( add => $tarball_location );
$git->run( add => $file );
$git->run( commit => "-m", "$branch: ea4-tool-post-update update include-binaries to new tarball" );
ea4_tool::util::pushup( $git, $branch );
print "Done!\n";
my $case;
if ( $branch =~ m/^(.*)-ea-passenger-src$/ ) {
$case = $1;
}
die "Could not determine case" if !$case;
my $et = '/root/git/ea-tools/bin/ea4-tool';
my $changelog = "ea-passenger-src was updated from v$old_ver to v$new_ver";
for my $repo (qw(ea-apache24-mod-passenger ea-nginx-passenger)) {
my $cmd = "$et change $repo $case '$changelog' $new_ver";
system($cmd) && warn "Could not update ‘$repo’! This will need done manually:\n\t$cmd\n";
_generate_pr( $repo, $changelog );
print "Done!\n";
}
return 1;
}
sub _generate_pr {
my ( $repo, $changelog ) = @_;
my $repo_path = ea4_tool::util::get_path_of_repo($repo);
local $CWD = $repo_path;
my $git = ea4_tool::util::git($CWD);
my $branch = $git->current_branch();
my $case;
if ( $branch =~ m/^(.*)-\Q$repo\E$/ ) {
$case = $1;
}
die "Could not determine case" if !$case;
ea4_tool::util::pushup( $git, "$branch" );
my $gitapi = ea4_tool::util::gitapi->new();
my $title = "$case: $changelog";
$gitapi->create_pull_request( $repo => $title, $branch => "master" );
return;
}
1;