Commit f162a229f677a5f5b95dd36021d6203dc2f9b3d3

Authored by Jay Berkenbilt
1 parent ad0fd53f

CI mode for make_dist

Showing 1 changed file with 64 additions and 37 deletions
make_dist
@@ -17,6 +17,7 @@ my $whoami = basename($0); @@ -17,6 +17,7 @@ my $whoami = basename($0);
17 17
18 my $run_tests = 1; 18 my $run_tests = 1;
19 my $keep_tmp = 0; 19 my $keep_tmp = 0;
  20 +my $ci_mode = 0;
20 my $version = undef; 21 my $version = undef;
21 foreach my $arg (@ARGV) 22 foreach my $arg (@ARGV)
22 { 23 {
@@ -28,6 +29,10 @@ foreach my $arg (@ARGV) @@ -28,6 +29,10 @@ foreach my $arg (@ARGV)
28 { 29 {
29 $keep_tmp = 1; 30 $keep_tmp = 1;
30 } 31 }
  32 + elsif ($arg eq '--ci')
  33 + {
  34 + $ci_mode = 1;
  35 + }
31 elsif (! defined $version) 36 elsif (! defined $version)
32 { 37 {
33 $version = $arg; 38 $version = $arg;
@@ -38,6 +43,11 @@ foreach my $arg (@ARGV) @@ -38,6 +43,11 @@ foreach my $arg (@ARGV)
38 } 43 }
39 } 44 }
40 45
  46 +if ($ci_mode && (! defined $version))
  47 +{
  48 + $version = get_version_from_configure();
  49 +}
  50 +
41 usage() unless defined $version; 51 usage() unless defined $version;
42 usage() unless $version =~ m/^(\d+\.\d+(?:\.(a|b|rc)?\d+)?)$/; 52 usage() unless $version =~ m/^(\d+\.\d+(?:\.(a|b|rc)?\d+)?)$/;
43 my $distname = "qpdf-$version"; 53 my $distname = "qpdf-$version";
@@ -50,41 +60,9 @@ run("git archive --prefix=qpdf-$version/ HEAD . | (cd /tmp; tar xf -)"); @@ -50,41 +60,9 @@ run("git archive --prefix=qpdf-$version/ HEAD . | (cd /tmp; tar xf -)");
50 cd($tmpdir); 60 cd($tmpdir);
51 61
52 # Check versions 62 # Check versions
53 -my $fh = safe_open("configure.ac");  
54 -my $config_version = 'unknown';  
55 -while (<$fh>)  
56 -{  
57 - if (m/^AC_INIT\(\[qpdf\],\[([^\)]+)\]\)/)  
58 - {  
59 - $config_version = $1;  
60 - last;  
61 - }  
62 -}  
63 -$fh->close();  
64 -  
65 -$fh = safe_open("libqpdf/QPDF.cc");  
66 -my $code_version = 'unknown';  
67 -while (<$fh>)  
68 -{  
69 - if (m/QPDF::qpdf_version = \"([^\"]+)\"/)  
70 - {  
71 - $code_version = $1;  
72 - last;  
73 - }  
74 -}  
75 -$fh->close();  
76 -  
77 -$fh = safe_open("manual/qpdf-manual.xml");  
78 -my $doc_version = 'unknown';  
79 -while (<$fh>)  
80 -{  
81 - if (m/swversion "([^\"]+)\"/)  
82 - {  
83 - $doc_version = $1;  
84 - last;  
85 - }  
86 -}  
87 -$fh->close(); 63 +my $config_version = get_version_from_configure();
  64 +my $code_version = get_version_from_source();
  65 +my $doc_version = get_version_from_manual();
88 66
89 my $version_error = 0; 67 my $version_error = 0;
90 if ($version ne $config_version) 68 if ($version ne $config_version)
@@ -120,7 +98,8 @@ if ($run_tests) @@ -120,7 +98,8 @@ if ($run_tests)
120 run("make check"); 98 run("make check");
121 cd("/tmp"); 99 cd("/tmp");
122 } 100 }
123 -rename "$distname.tar.gz-candidate", "$distname.tar.gz" or die; 101 +my $distfile = ($ci_mode ? "$distname-ci.tar.gz" : "$distname.tar.gz");
  102 +rename "$distname.tar.gz-candidate", $distfile or die;
124 103
125 if (! $keep_tmp) 104 if (! $keep_tmp)
126 { 105 {
@@ -128,12 +107,60 @@ if (! $keep_tmp) @@ -128,12 +107,60 @@ if (! $keep_tmp)
128 } 107 }
129 108
130 print " 109 print "
131 -Source distribution created as $tmpdir.tar.gz 110 +Source distribution created as /tmp/$distfile
132 If this is a release, don't forget to tag the version control system and 111 If this is a release, don't forget to tag the version control system and
133 make a backup of the release tar file. 112 make a backup of the release tar file.
134 113
135 "; 114 ";
136 115
  116 +sub get_version_from_configure
  117 +{
  118 + my $fh = safe_open("configure.ac");
  119 + my $config_version = 'unknown';
  120 + while (<$fh>)
  121 + {
  122 + if (m/^AC_INIT\(\[qpdf\],\[([^\)]+)\]\)/)
  123 + {
  124 + $config_version = $1;
  125 + last;
  126 + }
  127 + }
  128 + $fh->close();
  129 + $config_version;
  130 +}
  131 +
  132 +sub get_version_from_source
  133 +{
  134 + my $fh = safe_open("libqpdf/QPDF.cc");
  135 + my $code_version = 'unknown';
  136 + while (<$fh>)
  137 + {
  138 + if (m/QPDF::qpdf_version = \"([^\"]+)\"/)
  139 + {
  140 + $code_version = $1;
  141 + last;
  142 + }
  143 + }
  144 + $fh->close();
  145 + $code_version;
  146 +}
  147 +
  148 +sub get_version_from_manual
  149 +{
  150 + my $fh = safe_open("manual/qpdf-manual.xml");
  151 + my $doc_version = 'unknown';
  152 + while (<$fh>)
  153 + {
  154 + if (m/swversion "([^\"]+)\"/)
  155 + {
  156 + $doc_version = $1;
  157 + last;
  158 + }
  159 + }
  160 + $fh->close();
  161 + $doc_version;
  162 +}
  163 +
137 sub safe_open 164 sub safe_open
138 { 165 {
139 my $file = shift; 166 my $file = shift;