-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_manifest
executable file
·50 lines (40 loc) · 1.73 KB
/
update_manifest
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
#!/usr/local/cpanel/3rdparty/bin/perl
use cPstrict;
use lib "../ea-tools/lib/ea4_tool"; # assumes ea-tools is checked out next to this repo
use ea4_tool::util ();
my $manifest_path = "SOURCES/pkg-manifest.json";
my $pre_update = ea4_tool::util::read_json_from_file($manifest_path);
ea4_tool::util::write_ea4_manifest($manifest_path);
my $pst_update = ea4_tool::util::read_json_from_file($manifest_path);
# To manually test you can do this sort of thing:
# push @{ $pre_update->{EA4}{CentOS_7} }, "ea-oldandbusted"; # simulate a package being removed
# push @{ $pst_update->{EA4}{CentOS_7} }, "ea-newhotness"; # simulate a package being added
my $changes = 0;
for my $proj ( keys %{ $pre_update->{EA4} } ) {
my %old_lookup = map { $_ => 1 } @{ $pre_update->{EA4}{$proj} };
my %new_lookup = map { $_ => 1 } @{ $pst_update->{EA4}{$proj} };
for my $opkg ( keys %old_lookup ) {
if ( !exists $new_lookup{$opkg} ) {
my @new_list = grep { $_ ne $opkg } @{ $pst_update->{"EA4-production"}{$proj} };
@{ $pst_update->{"EA4-production"}{$proj} } = @new_list;
print "Removing $opkg from EA4-production $proj\n";
$changes++;
}
}
for my $npkg ( keys %new_lookup ) {
if ( !grep { $_ eq $npkg } @{ $pst_update->{"EA4-production"}{$proj} } ) {
push @{ $pst_update->{"EA4-production"}{$proj} }, $npkg;
print "Adding $npkg to EA4-production $proj\n";
$changes++;
}
}
@{ $pst_update->{"EA4-production"}{$proj} } = sort @{ $pst_update->{"EA4-production"}{$proj} };
}
if ($changes) {
ea4_tool::util::read_modify_save_json(
$manifest_path,
sub {
%{ shift() } = %{$pst_update};
}
);
}