build_release.pl (9dd622cd) build_release.pl (1108b05e)
1#!/usr/bin/perl
2#**************************************************************
3#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements. See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership. The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the

--- 7 unchanged lines hidden (view full) ---

16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied. See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21#**************************************************************
22
23use strict;
1#!/usr/bin/perl
2#**************************************************************
3#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements. See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership. The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the

--- 7 unchanged lines hidden (view full) ---

16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied. See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21#**************************************************************
22
23use strict;
24use warnings;
24use XML::LibXML;
25use open OUT => ":utf8";
26use LWP::Simple;
27use Digest;
28use Digest::MD5;
29use Digest::SHA;
30use File::Temp;
31use File::Path;

--- 182 unchanged lines hidden (view full) ---

214
215
216
217my %EnUSBasedLanguages = (
218 'ast' => 1
219 );
220
221
25use XML::LibXML;
26use open OUT => ":utf8";
27use LWP::Simple;
28use Digest;
29use Digest::MD5;
30use Digest::SHA;
31use File::Temp;
32use File::Path;

--- 182 unchanged lines hidden (view full) ---

215
216
217
218my %EnUSBasedLanguages = (
219 'ast' => 1
220 );
221
222
222sub GetInstallationPackageName ($$$$$);
223sub ProcessCommandline (@);
224sub PrintUsageAndExit ();
225sub Trim ($);
226sub ReadReleaseDescription ($$);
227sub ProcessBuildDescription ($$$);
228sub ProcessPlatformDescription ($$);
229sub ProcessDownloadDescription ($$);
230sub ProcessPackageDescription ($$);
231sub ProcessWikiPackageDescription ($$$);
232sub ProcessLanguageDescription ($$);
233sub PostprocessLanguageList ($$);
234sub PostprocessPlatformList ($$);
235sub CheckLanguageSet ($@);
236sub WriteMakefile ($$);
237sub Upload ($$);
238sub PrepareUploadArea ($@);
239sub UploadFilesViaRsync ($$@);
240sub CollectDownloadSets ($);
241sub ProvideChecksums ($@);
242sub IsOlderThan ($$);
243sub GetInstallationPackageName ($$$$);
244sub ResolveTemplate ($$$$$);
245sub GetCurrentPlatformDescriptor ($);
246sub Wiki ($$);
247sub GetTableList ($);
248sub GetPackagesForTable ($$);
249sub GetLanguagesForTable ($@);
250sub GetPlatformsForTable ($@);
251sub WriteDownloadLinks ($$$$$$$);
252sub FindDownload ($$$$$);
253sub CreateLink ($$$);
254sub CheckLink ($);
255sub SignFile ($$);
223
224sub ProcessCommandline (@)
225{
226 my @arguments = @_;
227
228 my $command = undef;
229 my $description_filename = undef;
230 my $max_process_count = 1;

--- 50 unchanged lines hidden (view full) ---

281 {
282 printf STDERR "unknown option $argument %s\n", $argument;
283 $error = 1;
284 }
285 }
286 elsif ( ! defined $command)
287 {
288 $command = $argument;
256
257sub ProcessCommandline (@)
258{
259 my @arguments = @_;
260
261 my $command = undef;
262 my $description_filename = undef;
263 my $max_process_count = 1;

--- 50 unchanged lines hidden (view full) ---

314 {
315 printf STDERR "unknown option $argument %s\n", $argument;
316 $error = 1;
317 }
318 }
319 elsif ( ! defined $command)
320 {
321 $command = $argument;
289 if ($command eq "build-missing")
290 {
291 $command = "build";
292 $build_only_missing = 1;
293 }
322 if ($command eq "build-missing")
323 {
324 $command = "build";
325 $build_only_missing = 1;
326 }
294 elsif ($command !~ /^(build|build-missing|upload|wiki)$/)
295 {
296 printf STDERR "unknown command '%s'\n", $command;
297 $error = 1;
298 }
299 }
300 else
301 {

--- 5 unchanged lines hidden (view full) ---

307 }
308 }
309 }
310
311 if ( ! defined $description_filename)
312 {
313 $error = 1;
314 }
327 elsif ($command !~ /^(build|build-missing|upload|wiki)$/)
328 {
329 printf STDERR "unknown command '%s'\n", $command;
330 $error = 1;
331 }
332 }
333 else
334 {

--- 5 unchanged lines hidden (view full) ---

340 }
341 }
342 }
343
344 if ( ! defined $description_filename)
345 {
346 $error = 1;
347 }
315 if ($command =~ /^(wiki)$/)
348 if (! defined $command)
316 {
349 {
350 printf STDERR "ERROR: no command\n";
351 $error = 1;
352 }
353 elsif ($command =~ /^(wiki)$/)
354 {
317 if ( ! defined $output_filename)
318 {
319 printf STDERR "ERROR: no output filename\n",
320 $error = 1;
321 }
322 }
323
324 if ($error)

--- 68 unchanged lines hidden (view full) ---

393
394 my $document = XML::LibXML->load_xml('location' => $filename);
395 my $root = $document->documentElement();
396
397 # Initialize the release description.
398 my $release = {
399 'name' => $root->getAttribute("name"),
400 'version' => $root->getAttribute("version"),
355 if ( ! defined $output_filename)
356 {
357 printf STDERR "ERROR: no output filename\n",
358 $error = 1;
359 }
360 }
361
362 if ($error)

--- 68 unchanged lines hidden (view full) ---

431
432 my $document = XML::LibXML->load_xml('location' => $filename);
433 my $root = $document->documentElement();
434
435 # Initialize the release description.
436 my $release = {
437 'name' => $root->getAttribute("name"),
438 'version' => $root->getAttribute("version"),
439 'previous-version' => $root->getAttribute("previous-version"),
401 'builds' => [],
402 'languages' => {},
403 'language-ids' => [],
404 'platforms' => {},
405 'downloads' => [],
406 'packages' => {},
407 'platform-ids' => [],
408 'wiki-packages' => []

--- 20 unchanged lines hidden (view full) ---

429 # Process the package descriptions.
430 for my $package_element ($root->getChildrenByTagName("package"))
431 {
432 my $package_descriptor = ProcessPackageDescription($package_element, $context);
433 $release->{'packages'}->{$package_descriptor->{'id'}} = $package_descriptor;
434 }
435 printf "%d packages\n", scalar keys %{$release->{'packages'}};
436
440 'builds' => [],
441 'languages' => {},
442 'language-ids' => [],
443 'platforms' => {},
444 'downloads' => [],
445 'packages' => {},
446 'platform-ids' => [],
447 'wiki-packages' => []

--- 20 unchanged lines hidden (view full) ---

468 # Process the package descriptions.
469 for my $package_element ($root->getChildrenByTagName("package"))
470 {
471 my $package_descriptor = ProcessPackageDescription($package_element, $context);
472 $release->{'packages'}->{$package_descriptor->{'id'}} = $package_descriptor;
473 }
474 printf "%d packages\n", scalar keys %{$release->{'packages'}};
475
476 # Platform specific the package descriptions.
477 for my $package_element ($root->getChildrenByTagName("platform-package"))
478 {
479 my $package_descriptor = ProcessPlatformPackageDescription($package_element, $context);
480 my $key = $package_descriptor->{'platform-id'} . "/" . $package_descriptor->{'package-id'};
481 $release->{'platform-packages'}->{$key} = $package_descriptor;
482 }
483 printf "%d platform packages\n", scalar keys %{$release->{'platform-packages'}};
484
437 # Process the download descriptions.
438 for my $download_element ($root->getChildrenByTagName("download"))
439 {
440 my $download_descriptor = ProcessDownloadDescription($download_element, $context);
441 push @{$release->{'downloads'}}, $download_descriptor;
442 }
443 printf "%d downloads\n", scalar @{$release->{'downloads'}};
444

--- 97 unchanged lines hidden (view full) ---

542 foreach my $id ("id", "display-name", "archive-platform", "word-size", "package-types")
543 {
544 $descriptor->{$id} = $element->getAttribute($id);
545 die "release/platform has no attribute $id" unless defined $descriptor->{$id};
546 }
547 # Optional tags.
548 foreach my $id ("extension", "add-package-type-to-archive-name")
549 {
485 # Process the download descriptions.
486 for my $download_element ($root->getChildrenByTagName("download"))
487 {
488 my $download_descriptor = ProcessDownloadDescription($download_element, $context);
489 push @{$release->{'downloads'}}, $download_descriptor;
490 }
491 printf "%d downloads\n", scalar @{$release->{'downloads'}};
492

--- 97 unchanged lines hidden (view full) ---

590 foreach my $id ("id", "display-name", "archive-platform", "word-size", "package-types")
591 {
592 $descriptor->{$id} = $element->getAttribute($id);
593 die "release/platform has no attribute $id" unless defined $descriptor->{$id};
594 }
595 # Optional tags.
596 foreach my $id ("extension", "add-package-type-to-archive-name")
597 {
550 $descriptor->{$id} = $element->getAttribute($id);
598 my $value = $element->getAttribute($id);
599 $descriptor->{$id} = $value if defined $value;
551 }
552
600 }
601
602 $descriptor->{'add-package-type-to-archive-name'} = 0
603 unless defined $descriptor->{'add-package-type-to-archive-name'};
553 $descriptor->{'package-types'} = [split(/;/, $descriptor->{'package-types'})];
554
555 return $descriptor;
556}
557
558
559
560

--- 25 unchanged lines hidden (view full) ---

586
587=head2 ProcessPackageDescription ($element, $context)
588
589 Process one <package> element.
590
591 The corresponding package descriptor is returned as a hash.
592
593=cut
604 $descriptor->{'package-types'} = [split(/;/, $descriptor->{'package-types'})];
605
606 return $descriptor;
607}
608
609
610
611

--- 25 unchanged lines hidden (view full) ---

637
638=head2 ProcessPackageDescription ($element, $context)
639
640 Process one <package> element.
641
642 The corresponding package descriptor is returned as a hash.
643
644=cut
594sub ProcessPackageDescription ($$$)
645sub ProcessPackageDescription ($$)
595{
646{
596 my ($element, $context, $release_descriptor) = @_;
647 my ($element, $context) = @_;
597
598 my $descriptor = {};
599
600 # Mandatory tags.
648
649 my $descriptor = {};
650
651 # Mandatory tags.
601 foreach my $id ("id", "target", "archive-name", "display-name")
652 foreach my $id ("id", "target", "archive-path", "archive-name", "display-name")
602 {
603 $descriptor->{$id} = $element->getAttribute($id);
604 die "release/package has no attribute $id" unless defined $descriptor->{$id};
605 die "release/package attribute $id is empty" unless $descriptor->{$id} !~ /^\s*$/;
606 }
607 # Optional tags.
608 foreach my $id ("link-tooltip", "link-URL", "download-extension")
609 {
653 {
654 $descriptor->{$id} = $element->getAttribute($id);
655 die "release/package has no attribute $id" unless defined $descriptor->{$id};
656 die "release/package attribute $id is empty" unless $descriptor->{$id} !~ /^\s*$/;
657 }
658 # Optional tags.
659 foreach my $id ("link-tooltip", "link-URL", "download-extension")
660 {
661 my $value = $element->getAttribute($id);
662 $descriptor->{$id} = $value if defined $value;
663 }
664
665 return $descriptor;
666}
667
668
669
670
671=head2 ProcessPlatformPackageDescription ($element, $context)
672
673 Process one <platform-package> element.
674
675 The corresponding package descriptor is returned as a hash.
676
677=cut
678sub ProcessPlatformPackageDescription ($$)
679{
680 my ($element, $context) = @_;
681
682 my $descriptor = {};
683
684 # Mandatory tags.
685 foreach my $id ("platform-id", "package-id")
686 {
610 $descriptor->{$id} = $element->getAttribute($id);
687 $descriptor->{$id} = $element->getAttribute($id);
688 die "release/package has no attribute $id" unless defined $descriptor->{$id};
689 die "release/package attribute $id is empty" unless $descriptor->{$id} !~ /^\s*$/;
611 }
690 }
691 # Optional tags.
692 foreach my $id ("extension", "package-types")
693 {
694 my $value = $element->getAttribute($id);
695 $descriptor->{$id} = $value if defined $value;
696 }
697 if (defined $descriptor->{'package-types'})
698 {
699 $descriptor->{'package-types'} = [split(/;/, $descriptor->{'package-types'})];
700 }
612
613 return $descriptor;
614}
615
616
617
618
619=head2 ProcessWikiPackageDescription ($element, $context)

--- 159 unchanged lines hidden (view full) ---

779 }
780
781 return @present_languages;
782}
783
784
785
786
701
702 return $descriptor;
703}
704
705
706
707
708=head2 ProcessWikiPackageDescription ($element, $context)

--- 159 unchanged lines hidden (view full) ---

868 }
869
870 return @present_languages;
871}
872
873
874
875
787=head2 WriteMakefile ($release_description, $context)
876=head2 WriteMakefile ($release_descriptor, $context)
788
789 Write a makefile with all targets that match the <build> elements.
790
791 The use of a makefile allows us to use make to handle concurrent building.
792
793 When an output file was specified on the command line (option -o) then the
794 makefile is written to that file but make is not run.
795
796 When no output file was specified then the makefile is written to a temporary
797 file. Then make is run for this makefile.
798
799=cut
800sub WriteMakefile ($$)
801{
877
878 Write a makefile with all targets that match the <build> elements.
879
880 The use of a makefile allows us to use make to handle concurrent building.
881
882 When an output file was specified on the command line (option -o) then the
883 makefile is written to that file but make is not run.
884
885 When no output file was specified then the makefile is written to a temporary
886 file. Then make is run for this makefile.
887
888=cut
889sub WriteMakefile ($$)
890{
802 my ($release_description, $context) = @_;
891 my ($release_descriptor, $context) = @_;
803
804 my $filename = $context->{'output-filename'};
805 if ( ! defined $filename)
806 {
807 $filename = File::Temp->new();
808 }
809
810 # Collect the targets to make.
811 my @targets = ();
892
893 my $filename = $context->{'output-filename'};
894 if ( ! defined $filename)
895 {
896 $filename = File::Temp->new();
897 }
898
899 # Collect the targets to make.
900 my @targets = ();
812 foreach my $build (@{$release_description->{'builds'}})
901 foreach my $build (@{$release_descriptor->{'builds'}})
813 {
902 {
814 my $platform_descriptor = GetCurrentPlatformDescriptor($release_description);
815 my $package_descriptor = $release_description->{'packages'}->{$build->{'package-id'}};
903 my $platform_descriptor = GetCurrentPlatformDescriptor($release_descriptor);
904 my $package_descriptor = $release_descriptor->{'packages'}->{$build->{'package-id'}};
905 my $platform_package_descriptor = GetPlatformPackage(
906 $release_descriptor,
907 $platform_descriptor,
908 $package_descriptor);
909
816 foreach my $language_id (@{$build->{'language-list'}})
817 {
910 foreach my $language_id (@{$build->{'language-list'}})
911 {
818 foreach my $package_format (@{$platform_descriptor->{'package-types'}})
912 foreach my $package_format (@{$platform_package_descriptor->{'package-types'}})
819 {
820 my $full_target = sprintf("%s_%s.%s",
821 $package_descriptor->{'target'},
822 $language_id,
823 $package_format);
824 if ($context->{'build-only-missing'})
825 {
913 {
914 my $full_target = sprintf("%s_%s.%s",
915 $package_descriptor->{'target'},
916 $language_id,
917 $package_format);
918 if ($context->{'build-only-missing'})
919 {
826 my $source_path = GetInstallationPackagePath(
827 $platform_descriptor,
920 my ($archive_path, $archive_name) = GetInstallationPackageName(
921 $release_descriptor,
922 $platform_package_descriptor,
828 $package_format,
829 $language_id);
923 $package_format,
924 $language_id);
830 my $archive_name = GetInstallationPackageName(
831 $release_description,
832 $package_descriptor,
833 $package_format,
834 $platform_descriptor,
835 $language_id);
836 my $candidate = $source_path . "/" . $archive_name;
925 my $candidate = $archive_path . "/" . $archive_name;
837 if (-f $candidate)
838 {
839 printf "download set for %s already exists, skipping\n", $full_target;
840 next;
841 }
926 if (-f $candidate)
927 {
928 printf "download set for %s already exists, skipping\n", $full_target;
929 next;
930 }
931 else
932 {
933 printf "%s %s\n", $archive_path, $archive_name;
934 }
842 }
843 push @targets, $full_target;
844 }
845 }
846 }
847
848 # Write the makefile.
849 open my $make, ">", $filename;

--- 37 unchanged lines hidden (view full) ---

887 }
888}
889
890
891
892
893sub Upload ($$)
894{
935 }
936 push @targets, $full_target;
937 }
938 }
939 }
940
941 # Write the makefile.
942 open my $make, ">", $filename;

--- 37 unchanged lines hidden (view full) ---

980 }
981}
982
983
984
985
986sub Upload ($$)
987{
895 my ($release_description, $context) = @_;
988 my ($release_descriptor, $context) = @_;
896
897 if ( ! defined $context->{'upload-destination'})
898 {
899 printf STDERR "ERROR: upload destination is missing\n";
900 PrintUsageAndExit();
901 }
902
989
990 if ( ! defined $context->{'upload-destination'})
991 {
992 printf STDERR "ERROR: upload destination is missing\n";
993 PrintUsageAndExit();
994 }
995
903 my @download_sets = CollectDownloadSets($release_description);
996 my @download_sets = CollectDownloadSets($release_descriptor);
904
905 ProvideChecksums($context, @download_sets);
906 my $source_path = PrepareUploadArea($context, @download_sets);
907 if ( ! defined $source_path)
908 {
909 exit(1);
910 }
911 if ( ! UploadFilesViaRsync($context, $source_path, @download_sets))

--- 18 unchanged lines hidden (view full) ---

930 my ($context, @download_sets) = @_;
931
932 my $tmpdir = File::Temp->newdir();
933 foreach my $download_set (@download_sets)
934 {
935 foreach my $extension ("", ".md5", ".sha256", ".asc")
936 {
937 my $basename = sprintf("%s%s", $download_set->{'archive-name'}, $extension);
997
998 ProvideChecksums($context, @download_sets);
999 my $source_path = PrepareUploadArea($context, @download_sets);
1000 if ( ! defined $source_path)
1001 {
1002 exit(1);
1003 }
1004 if ( ! UploadFilesViaRsync($context, $source_path, @download_sets))

--- 18 unchanged lines hidden (view full) ---

1023 my ($context, @download_sets) = @_;
1024
1025 my $tmpdir = File::Temp->newdir();
1026 foreach my $download_set (@download_sets)
1027 {
1028 foreach my $extension ("", ".md5", ".sha256", ".asc")
1029 {
1030 my $basename = sprintf("%s%s", $download_set->{'archive-name'}, $extension);
938 my $source = sprintf("%s/%s", $download_set->{'source-path'}, $basename);
939 my $target_path = sprintf("%s/%s/%s", $tmpdir, $download_set->{'destination-path'});
1031 my $source_path = $download_set->{'source-path'};
1032 my $source = sprintf("%s/%s", $source_path, $basename);
1033 my $target_path = sprintf("%s/%s", $tmpdir, $download_set->{'destination-path'});
940 my $target = sprintf("%s/%s", $target_path, $basename);
941 if ($context->{'dry-run'})
942 {
943 printf "would create link for %s\n", $basename;
1034 my $target = sprintf("%s/%s", $target_path, $basename);
1035 if ($context->{'dry-run'})
1036 {
1037 printf "would create link for %s\n", $basename;
1038 printf " %s\n", $source_path;
1039 printf " to %s\n", $target_path;
944 }
945 else
946 {
947 mkpath($target_path);
948 unlink $target if ( -f $target);
949 my $result = symlink($source, $target);
950 if ($result != 1)
951 {

--- 59 unchanged lines hidden (view full) ---

1011 }
1012}
1013
1014
1015
1016
1017sub CollectDownloadSets ($)
1018{
1040 }
1041 else
1042 {
1043 mkpath($target_path);
1044 unlink $target if ( -f $target);
1045 my $result = symlink($source, $target);
1046 if ($result != 1)
1047 {

--- 59 unchanged lines hidden (view full) ---

1107 }
1108}
1109
1110
1111
1112
1113sub CollectDownloadSets ($)
1114{
1019 my ($release_description) = @_;
1115 my ($release_descriptor) = @_;
1020
1021 my @download_sets = ();
1022
1116
1117 my @download_sets = ();
1118
1023 foreach my $platform_descriptor (values %{$release_description->{'platforms'}})
1119 foreach my $platform_descriptor (values %{$release_descriptor->{'platforms'}})
1024 {
1025 my $platform_path = sprintf("%s/instsetoo_native/%s",
1026 $ENV{'SOLARSRC'},
1027 $platform_descriptor->{'id'});
1028 if ( ! -d $platform_path)
1029 {
1030 printf "ignoring missing %s\n", $platform_path;
1031 next;
1032 }
1120 {
1121 my $platform_path = sprintf("%s/instsetoo_native/%s",
1122 $ENV{'SOLARSRC'},
1123 $platform_descriptor->{'id'});
1124 if ( ! -d $platform_path)
1125 {
1126 printf "ignoring missing %s\n", $platform_path;
1127 next;
1128 }
1033 for my $package_descriptor (values %{$release_description->{'packages'}})
1129 for my $package_descriptor (values %{$release_descriptor->{'packages'}})
1034 {
1130 {
1035
1131 my $platform_package_descriptor = GetPlatformPackage(
1132 $release_descriptor,
1133 $platform_descriptor,
1134 $package_descriptor);
1036 my @package_formats = @{$platform_descriptor->{'package-types'}};
1037 for my $package_format (@package_formats)
1038 {
1135 my @package_formats = @{$platform_descriptor->{'package-types'}};
1136 for my $package_format (@package_formats)
1137 {
1039 for my $language_id (@{$release_description->{'language-ids'}})
1138 for my $language_id (@{$release_descriptor->{'language-ids'}})
1040 {
1139 {
1041 my $source_path = GetInstallationPackagePath(
1042 $platform_descriptor,
1140 my ($archive_path, $archive_name) = GetInstallationPackageName(
1141 $release_descriptor,
1142 $platform_package_descriptor,
1043 $package_format,
1044 $language_id);
1143 $package_format,
1144 $language_id);
1045 my $archive_name = GetInstallationPackageName(
1046 $release_description,
1047 $package_descriptor,
1048 $package_format,
1049 $platform_descriptor,
1050 $language_id);
1051 my $candidate = $source_path."/".$archive_name;
1145 my $candidate = $archive_path."/".$archive_name;
1052 if ( ! -f $candidate)
1053 {
1054# printf STDERR "ERROR: can not find download set '%s'\n", $candidate;
1055 next;
1056 }
1057 printf "adding %s\n", $archive_name;
1146 if ( ! -f $candidate)
1147 {
1148# printf STDERR "ERROR: can not find download set '%s'\n", $candidate;
1149 next;
1150 }
1151 printf "adding %s\n", $archive_name;
1058 push @download_sets, {
1059 'source-path' => $source_path,
1152 my $download_set = {
1153 'source-path' => $archive_path,
1060 'archive-name' => $archive_name,
1154 'archive-name' => $archive_name,
1061 'platform' => $platform_descriptor->{'pack-platform'},
1155 'platform' => $platform_descriptor->{'archive-platform'},
1062 'destination-path' => sprintf("developer-snapshots/%s/%s",
1156 'destination-path' => sprintf("developer-snapshots/%s/%s",
1063 $release_description->{'name'},
1064 $platform_descriptor->{'pack-platform'})
1157 $release_descriptor->{'name'},
1158 $platform_descriptor->{'archive-platform'})
1065 };
1159 };
1160 printf " %s\n", $download_set->{'destination-path'};
1161 push @download_sets, $download_set;
1066 }
1067 }
1068 }
1069 }
1070
1071 return @download_sets;
1072}
1073

--- 22 unchanged lines hidden (view full) ---

1096 {
1097 if ($context->{'dry-run'})
1098 {
1099 printf " would create MD5\n";
1100 }
1101 else
1102 {
1103 my $digest = Digest::MD5->new();
1162 }
1163 }
1164 }
1165 }
1166
1167 return @download_sets;
1168}
1169

--- 22 unchanged lines hidden (view full) ---

1192 {
1193 if ($context->{'dry-run'})
1194 {
1195 printf " would create MD5\n";
1196 }
1197 else
1198 {
1199 my $digest = Digest::MD5->new();
1104 open my $in, $full_archive_name;
1200 open my ($in), $full_archive_name;
1105 $digest->addfile($in);
1106 my $checksum = $digest->hexdigest();
1107 close $in;
1108
1201 $digest->addfile($in);
1202 my $checksum = $digest->hexdigest();
1203 close $in;
1204
1109 open my $out, ">", $md5_filename;
1205 open my ($out), ">", $md5_filename;
1110 printf $out "%s *%s", $checksum, $download_set->{'archive-name'};
1111 close $out;
1112
1113 printf " created MD5\n";
1114 }
1115 }
1116 else
1117 {

--- 5 unchanged lines hidden (view full) ---

1123 {
1124 if ($context->{'dry-run'})
1125 {
1126 printf " would create SHA256\n";
1127 }
1128 else
1129 {
1130 my $digest = Digest::SHA->new("sha256");
1206 printf $out "%s *%s", $checksum, $download_set->{'archive-name'};
1207 close $out;
1208
1209 printf " created MD5\n";
1210 }
1211 }
1212 else
1213 {

--- 5 unchanged lines hidden (view full) ---

1219 {
1220 if ($context->{'dry-run'})
1221 {
1222 printf " would create SHA256\n";
1223 }
1224 else
1225 {
1226 my $digest = Digest::SHA->new("sha256");
1131 open my $in, $full_archive_name;
1227 open my ($in), $full_archive_name;
1132 $digest->addfile($in);
1133 my $checksum = $digest->hexdigest();
1134 close $in;
1135
1228 $digest->addfile($in);
1229 my $checksum = $digest->hexdigest();
1230 close $in;
1231
1136 open my $out, ">", $sha256_filename;
1232 open my ($out), ">", $sha256_filename;
1137 printf $out "%s *%s", $checksum, $download_set->{'archive-name'};
1138 close $out;
1139
1140 printf " created SHA256\n";
1141 }
1142 }
1143 else
1144 {

--- 40 unchanged lines hidden (view full) ---

1185 my @stat2 = stat $filename2;
1186
1187 return $stat1[9] < $stat2[9];
1188}
1189
1190
1191
1192
1233 printf $out "%s *%s", $checksum, $download_set->{'archive-name'};
1234 close $out;
1235
1236 printf " created SHA256\n";
1237 }
1238 }
1239 else
1240 {

--- 40 unchanged lines hidden (view full) ---

1281 my @stat2 = stat $filename2;
1282
1283 return $stat1[9] < $stat2[9];
1284}
1285
1286
1287
1288
1193sub GetInstallationPackageName ($$$$$)
1289sub GetInstallationPackageName ($$$$)
1194{
1290{
1195 my ($release_description, $package_descriptor, $package_format, $platform_descriptor, $language) = @_;
1291 my ($release_descriptor, $platform_package_descriptor, $package_format, $language) = @_;
1196
1292
1197 my $name = $package_descriptor->{'archive-name'};
1293 my $path = ResolveTemplate(
1294 $platform_package_descriptor->{'archive-path'},
1295 $release_descriptor,
1296 $platform_package_descriptor,
1297 $package_format,
1298 $language);
1299 my $name = ResolveTemplate(
1300 $platform_package_descriptor->{'archive-name'},
1301 $release_descriptor,
1302 $platform_package_descriptor,
1303 $package_format,
1304 $language);
1198
1305
1199 my $archive_package_type = "";
1200 if ($platform_descriptor->{'add-package-type-to-archive-name'} =~ /^(1|true|yes)$/i)
1201 {
1202 $archive_package_type = "-".$package_format;
1203 }
1204
1205 $name =~ s/%V/$release_description->{'version'}/g;
1206 $name =~ s/%P/$platform_descriptor->{'archive-platform'}/g;
1207 $name =~ s/%T/$archive_package_type/g;
1208 $name =~ s/%L/$language/g;
1209 $name =~ s/%E/$platform_descriptor->{'extension'}/g;
1210 return $name;
1306 return ($path, $name);
1211}
1212
1213
1214
1215
1307}
1308
1309
1310
1311
1216sub GetInstallationPackagePath ($$$)
1312sub ResolveTemplate ($$$$$)
1217{
1313{
1218 my ($product_descriptor, $package_format, $language) = @_;
1219
1314 my ($template, $release_descriptor, $platform_package_descriptor, $package_format, $language) = @_;
1315
1316 my $archive_package_type = "";
1317 if ($platform_package_descriptor->{'add-package-type-to-archive-name'} =~ /^(1|true|yes)$/i)
1318 {
1319 $archive_package_type = "-".$package_format;
1320 }
1220 my $full_language = $language;
1221 if ($EnUSBasedLanguages{$language})
1222 {
1223 $full_language = "en-US_".$language;
1224 }
1321 my $full_language = $language;
1322 if ($EnUSBasedLanguages{$language})
1323 {
1324 $full_language = "en-US_".$language;
1325 }
1326 my $extension = $platform_package_descriptor->{'download-extension'};
1327 if ( ! defined $extension)
1328 {
1329 $extension = $platform_package_descriptor->{'extension'};
1330 }
1331
1332 my $old_to_new_version_dash = sprintf(
1333 "v-%s_v-%s",
1334 $release_descriptor->{'previous-version'},
1335 $release_descriptor->{'version'});
1336 $old_to_new_version_dash =~ s/\./-/g;
1337 my $old_to_new_version_dots = sprintf(
1338 "%s-%s",
1339 $release_descriptor->{'previous-version'},
1340 $release_descriptor->{'version'});
1225
1341
1226 return sprintf("%s/instsetoo_native/%s/Apache_OpenOffice%s/%s/install/%s_download",
1227 $ENV{'SOLARSRC'},
1228 $ENV{'INPATH'},
1229 $product_descriptor->{'product-name-tail'},
1230 $package_format,
1231 $full_language);
1342
1343 my $name = $template;
1344
1345 # Resolve %? template paramters.
1346 $name =~ s/%V/$release_descriptor->{'version'}/g;
1347 $name =~ s/%W/$old_to_new_version_dash/g;
1348 $name =~ s/%w/$old_to_new_version_dots/g;
1349 $name =~ s/%P/$platform_package_descriptor->{'archive-platform'}/g;
1350 $name =~ s/%t/$archive_package_type/g;
1351 $name =~ s/%T/$package_format/g;
1352 $name =~ s/%l/$full_language/g;
1353 $name =~ s/%L/$language/g;
1354 $name =~ s/%E/$extension/g;
1355
1356 # Resolve $name environment references.
1357 while ($name =~ /^(.*?)\$([a-zA-Z0-9_]+)(.*)$/)
1358 {
1359 $name = $1 . $ENV{$2} . $3;
1360 }
1361
1362 return $name;
1232}
1233
1234
1235
1236
1237sub GetCurrentPlatformDescriptor ($)
1238{
1363}
1364
1365
1366
1367
1368sub GetCurrentPlatformDescriptor ($)
1369{
1239 my ($release_description) = @_;
1370 my ($release_descriptor) = @_;
1240
1371
1241 my $platform_descriptor = $release_description->{'platforms'}->{$ENV{'INPATH'}};
1372 my $platform_descriptor = $release_descriptor->{'platforms'}->{$ENV{'INPATH'}};
1242 if ( ! defined $platform_descriptor)
1243 {
1244 printf STDERR "ERROR: platform '%s' is not supported\n", $ENV{'INPATH'};
1245 }
1246 return $platform_descriptor;
1247}
1248
1249
1250
1251
1373 if ( ! defined $platform_descriptor)
1374 {
1375 printf STDERR "ERROR: platform '%s' is not supported\n", $ENV{'INPATH'};
1376 }
1377 return $platform_descriptor;
1378}
1379
1380
1381
1382
1383sub GetPlatformPackage ($$$)
1384{
1385 my ($release_descriptor, $platform_descriptor, $package_descriptor) = @_;
1386 my $key = sprintf("%s/%s", $platform_descriptor->{'id'}, $package_descriptor->{'id'});
1387
1388 my $platform_package = $release_descriptor->{'platform-packages'}->{$key};
1389 $platform_package = {}
1390 unless defined $platform_package;
1391
1392 my $joined_descriptor = {
1393 %$platform_descriptor,
1394 %$package_descriptor,
1395 %$platform_package,
1396 'id' => $key,
1397 'platform-id' => $platform_descriptor->{'id'},
1398 'package-id' => $package_descriptor->{'id'}
1399 };
1400 return $joined_descriptor;
1401}
1402
1403
1404
1405
1252sub Wiki ($$)
1253{
1254 my ($release_descriptor, $context) = @_;
1255
1256 open my $out, ">", $context->{'output-filename'};
1257
1258 my @table_list = GetTableList($release_descriptor);
1259 foreach my $table_name (@table_list)

--- 23 unchanged lines hidden (view full) ---

1283 }
1284 }
1285
1286 foreach my $language_descriptor (@table_languages)
1287 {
1288 if ($context->{'check-links'})
1289 {
1290 $| = 1;
1406sub Wiki ($$)
1407{
1408 my ($release_descriptor, $context) = @_;
1409
1410 open my $out, ">", $context->{'output-filename'};
1411
1412 my @table_list = GetTableList($release_descriptor);
1413 foreach my $table_name (@table_list)

--- 23 unchanged lines hidden (view full) ---

1437 }
1438 }
1439
1440 foreach my $language_descriptor (@table_languages)
1441 {
1442 if ($context->{'check-links'})
1443 {
1444 $| = 1;
1291 printf "%-5%s: ", $language_descriptor->{'id'};
1445 printf "%-5s: ", $language_descriptor->{'id'};
1292 }
1293
1294 print $out "|-\n";
1295 printf $out "| rowspan=\"%d\" | %s\n", scalar @table_packages, $language_descriptor->{'english-name'};
1296 printf $out "| rowspan=\"%d\" | %s\n", scalar @table_packages, $language_descriptor->{'local-name'};
1297
1298 my $is_first = 1;
1299 foreach my $wiki_package_descriptor (@table_packages)

--- 18 unchanged lines hidden (view full) ---

1318 }
1319 else
1320 {
1321 printf $out "| %s\n", $package_descriptor->{'display-name'};
1322 }
1323
1324 foreach my $platform_descriptor (@table_platforms)
1325 {
1446 }
1447
1448 print $out "|-\n";
1449 printf $out "| rowspan=\"%d\" | %s\n", scalar @table_packages, $language_descriptor->{'english-name'};
1450 printf $out "| rowspan=\"%d\" | %s\n", scalar @table_packages, $language_descriptor->{'local-name'};
1451
1452 my $is_first = 1;
1453 foreach my $wiki_package_descriptor (@table_packages)

--- 18 unchanged lines hidden (view full) ---

1472 }
1473 else
1474 {
1475 printf $out "| %s\n", $package_descriptor->{'display-name'};
1476 }
1477
1478 foreach my $platform_descriptor (@table_platforms)
1479 {
1326 foreach my $package_type (@{$platform_descriptor->{'package-types'}})
1480 my $platform_package_descriptor = GetPlatformPackage(
1481 $release_descriptor,
1482 $platform_descriptor,
1483 $package_descriptor);
1484
1485 foreach my $package_type (@{$platform_package_descriptor->{'package-types'}})
1327 {
1328 WriteDownloadLinks(
1329 $out,
1330 $release_descriptor,
1331 $context,
1486 {
1487 WriteDownloadLinks(
1488 $out,
1489 $release_descriptor,
1490 $context,
1332 $release_descriptor,
1333 $language_descriptor,
1334 $wiki_package_descriptor,
1491 $language_descriptor,
1492 $wiki_package_descriptor,
1335 $platform_descriptor,
1493 $platform_package_descriptor,
1336 $package_type);
1337 }
1338 }
1339 }
1340
1341 if ($context->{'check-links'})
1342 {
1343 printf "\n";

--- 123 unchanged lines hidden (view full) ---

1467my $broken_link_end = "</span>";
1468
1469
1470sub WriteDownloadLinks ($$$$$$$)
1471{
1472 my ($out,
1473 $release_descriptor,
1474 $context,
1494 $package_type);
1495 }
1496 }
1497 }
1498
1499 if ($context->{'check-links'})
1500 {
1501 printf "\n";

--- 123 unchanged lines hidden (view full) ---

1625my $broken_link_end = "</span>";
1626
1627
1628sub WriteDownloadLinks ($$$$$$$)
1629{
1630 my ($out,
1631 $release_descriptor,
1632 $context,
1475 $release_descriptor,
1476 $language_descriptor,
1477 $wiki_package_descriptor,
1633 $language_descriptor,
1634 $wiki_package_descriptor,
1478 $platform_descriptor,
1635 $platform_package_descriptor,
1479 $package_type) = @_;
1480
1636 $package_type) = @_;
1637
1481 my $package_descriptor = $wiki_package_descriptor->{'package'};
1482
1483 # Check if the current language and platform match the package.
1638 # Check if the current language and platform match the package.
1484 if (defined $wiki_package_descriptor->{'platforms'}->{$platform_descriptor->{'id'}}
1639 my $platform_id = $platform_package_descriptor->{'platform-id'};
1640 if (defined $wiki_package_descriptor->{'platforms'}->{$platform_id}
1485 && defined $wiki_package_descriptor->{'languages'}->{$language_descriptor->{'id'}})
1486 {
1487 my $archive_package_name = "";
1488 my $extension = $package_type;
1641 && defined $wiki_package_descriptor->{'languages'}->{$language_descriptor->{'id'}})
1642 {
1643 my $archive_package_name = "";
1644 my $extension = $package_type;
1489 if (defined $platform_descriptor->{'extension'})
1645 if (defined $platform_package_descriptor->{'extension'})
1490 {
1646 {
1491 $extension = $platform_descriptor->{'extension'};
1647 $extension = $platform_package_descriptor->{'extension'};
1492 }
1648 }
1493 if (defined $package_descriptor->{'download-extension'})
1649 if (defined $platform_package_descriptor->{'download-extension'})
1494 {
1650 {
1495 $extension = $package_descriptor->{'download-extension'};
1651 $extension = $platform_package_descriptor->{'download-extension'};
1496 }
1497 $archive_package_name = "-".$package_type if ($package_type =~ /deb|rpm/);
1498
1652 }
1653 $archive_package_name = "-".$package_type if ($package_type =~ /deb|rpm/);
1654
1499 my $archive_name = GetInstallationPackageName(
1655 my ($archive_path, $archive_name) = GetInstallationPackageName(
1500 $release_descriptor,
1656 $release_descriptor,
1501 $package_descriptor,
1657 $platform_package_descriptor,
1502 $package_type,
1658 $package_type,
1503 $platform_descriptor,
1504 $language_descriptor->{'id'});
1505
1506 printf $out "| align=\"center\" | ";
1507 my $download = FindDownload(
1508 $context,
1509 $release_descriptor,
1659 $language_descriptor->{'id'});
1660
1661 printf $out "| align=\"center\" | ";
1662 my $download = FindDownload(
1663 $context,
1664 $release_descriptor,
1510 $platform_descriptor,
1665 $platform_package_descriptor,
1511 $package_type,
1512 $archive_name);
1513 if (defined $download)
1514 {
1515 my $url = $download->{'base-url'} . "/". $archive_name;
1516 printf $out "%s%s%s<br><br>%s%s %s<br>%s%s",
1517 $bold_text_start,
1518 CreateLink($url, $extension, $context),

--- 13 unchanged lines hidden (view full) ---

1532}
1533
1534
1535
1536
1537sub FindDownload ($$$$$)
1538{
1539 my ($context,
1666 $package_type,
1667 $archive_name);
1668 if (defined $download)
1669 {
1670 my $url = $download->{'base-url'} . "/". $archive_name;
1671 printf $out "%s%s%s<br><br>%s%s %s<br>%s%s",
1672 $bold_text_start,
1673 CreateLink($url, $extension, $context),

--- 13 unchanged lines hidden (view full) ---

1687}
1688
1689
1690
1691
1692sub FindDownload ($$$$$)
1693{
1694 my ($context,
1540 $release_descriptor,
1541 $platform_descriptor,
1542 $package_type,
1695 $release_descriptor,
1696 $platform_package_descriptor,
1697 $package_type,
1543 $archive_name) = @_;
1544
1545 foreach my $download (@{$release_descriptor->{'downloads'}})
1546 {
1698 $archive_name) = @_;
1699
1700 foreach my $download (@{$release_descriptor->{'downloads'}})
1701 {
1547 if ($download->{'platform-id'} eq $platform_descriptor->{'id'})
1702 if ($download->{'platform-id'} eq $platform_package_descriptor->{'platform-id'})
1548 {
1549 my $url = $download->{'base-url'} . "/". $archive_name;
1550 if ($context->{'check-links'})
1551 {
1552 if (CheckLink($url))
1553 {
1554 # URL points to an existing file.
1555 printf "+";

--- 68 unchanged lines hidden (view full) ---

1624
1625
1626=head2 CheckLink ($url)
1627
1628 Check if the file referenced by $url can be downloaded.
1629 This is determined by downloading only the header.
1630
1631=cut
1703 {
1704 my $url = $download->{'base-url'} . "/". $archive_name;
1705 if ($context->{'check-links'})
1706 {
1707 if (CheckLink($url))
1708 {
1709 # URL points to an existing file.
1710 printf "+";

--- 68 unchanged lines hidden (view full) ---

1779
1780
1781=head2 CheckLink ($url)
1782
1783 Check if the file referenced by $url can be downloaded.
1784 This is determined by downloading only the header.
1785
1786=cut
1632my $LastCheckedURL = undef;
1787my $LastCheckedURL = "";
1633my $LastCheckedResult = undef;
1634sub CheckLink ($)
1635{
1636 my ($url) = @_;
1637
1638 if ($url ne $LastCheckedURL)
1639 {
1640 my $head = LWP::Simple::head($url);

--- 16 unchanged lines hidden (view full) ---

1657 $filename,
1658 $filename);
1659}
1660
1661
1662
1663
1664my $context = ProcessCommandline(@ARGV);
1788my $LastCheckedResult = undef;
1789sub CheckLink ($)
1790{
1791 my ($url) = @_;
1792
1793 if ($url ne $LastCheckedURL)
1794 {
1795 my $head = LWP::Simple::head($url);

--- 16 unchanged lines hidden (view full) ---

1812 $filename,
1813 $filename);
1814}
1815
1816
1817
1818
1819my $context = ProcessCommandline(@ARGV);
1665my $release_description = ReadReleaseDescription($context->{'filename'}, $context);
1820my $release_descriptor = ReadReleaseDescription($context->{'filename'}, $context);
1666if ($context->{'command'} eq "build")
1667{
1821if ($context->{'command'} eq "build")
1822{
1668 WriteMakefile($release_description, $context);
1823 WriteMakefile($release_descriptor, $context);
1669}
1670elsif ($context->{'command'} eq "upload")
1671{
1824}
1825elsif ($context->{'command'} eq "upload")
1826{
1672 Upload($release_description, $context);
1827 Upload($release_descriptor, $context);
1673}
1674elsif ($context->{'command'} eq "wiki")
1675{
1828}
1829elsif ($context->{'command'} eq "wiki")
1830{
1676 Wiki($release_description, $context);
1831 Wiki($release_descriptor, $context);
1677}
1832}