You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/08/11 15:00:14 UTC

[tomcat] branch 9.0.x updated: Ensure zip files use UTC times. By default zip uses local time.

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new e7a01f3e90 Ensure zip files use UTC times. By default zip uses local time.
e7a01f3e90 is described below

commit e7a01f3e904be44b7edfdadd7fdb05072f01b671
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Aug 11 15:57:29 2022 +0100

    Ensure zip files use UTC times. By default zip uses local time.
---
 build.xml                                          | 45 ++++++++++++----------
 .../apache/tomcat/buildutil/ForceUtcTimeZone.java  | 30 +++++++++++++++
 webapps/docs/changelog.xml                         |  8 ++++
 3 files changed, 63 insertions(+), 20 deletions(-)

diff --git a/build.xml b/build.xml
index 2a2bf779bd..f36bbcecf3 100644
--- a/build.xml
+++ b/build.xml
@@ -248,7 +248,7 @@
     <format property="today" pattern="MMM d yyyy" locale="en" timezone="UTC"/>
     <format property="today-iso-8601" pattern="yyyy-MM-dd" locale="en" timezone="UTC"/>
     <format property="tstamp" pattern="HH:mm:ss" locale="en" timezone="UTC"/>
-    <format property="tstamp.file" pattern="yyyy-MM-dd HH:mm:ss"/>
+    <format property="tstamp.file" pattern="yyyy-MM-dd HH:mm:ss" timezone="UTC"/>
     <format property="tstamp.iso.release" pattern="yyyy-MM-dd'T'HH:mm:ssX" timezone="UTC"/>
   </tstamp>
   <filterset id="version.filters">
@@ -1176,7 +1176,7 @@
     <!-- i18n JARs -->
     <jar jarfile="${tomcat.build}/lib/tomcat-i18n-cs.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.i18n}">
         <include name="**/LocalStrings_cs.properties" />
       </fileset>
@@ -1187,7 +1187,7 @@
     </jar>
     <jar jarfile="${tomcat.build}/lib/tomcat-i18n-de.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.i18n}">
         <include name="**/LocalStrings_de.properties" />
       </fileset>
@@ -1198,7 +1198,7 @@
     </jar>
     <jar jarfile="${tomcat.build}/lib/tomcat-i18n-es.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.i18n}">
         <include name="**/LocalStrings_es.properties" />
       </fileset>
@@ -1209,7 +1209,7 @@
     </jar>
     <jar jarfile="${tomcat.build}/lib/tomcat-i18n-fr.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.i18n}">
         <include name="**/LocalStrings_fr.properties" />
       </fileset>
@@ -1220,7 +1220,7 @@
     </jar>
     <jar jarfile="${tomcat.build}/lib/tomcat-i18n-ja.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.i18n}">
         <include name="**/LocalStrings_ja.properties" />
       </fileset>
@@ -1231,7 +1231,7 @@
     </jar>
     <jar jarfile="${tomcat.build}/lib/tomcat-i18n-ko.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.i18n}">
         <include name="**/LocalStrings_ko.properties" />
       </fileset>
@@ -1242,7 +1242,7 @@
     </jar>
     <jar jarfile="${tomcat.build}/lib/tomcat-i18n-pt-BR.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.i18n}">
         <include name="**/LocalStrings_pt_BR.properties" />
       </fileset>
@@ -1253,7 +1253,7 @@
     </jar>
     <jar jarfile="${tomcat.build}/lib/tomcat-i18n-ru.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.i18n}">
         <include name="**/LocalStrings_ru.properties" />
       </fileset>
@@ -1264,7 +1264,7 @@
     </jar>
     <jar jarfile="${tomcat.build}/lib/tomcat-i18n-zh-CN.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.i18n}">
         <include name="**/LocalStrings_zh_CN.properties" />
       </fileset>
@@ -1763,7 +1763,7 @@
     </fixcrlf>
 
     <zip destfile="${tomcat.embed}/${final.name}-embed.zip"
-         modificationtime="${tstamp.file}"
+         modificationtime="${tstamp.iso.release}"
          encoding="UTF8">
       <fileset dir="${tomcat.embed}">
         <include name="**" />
@@ -2329,7 +2329,7 @@ Apache Tomcat ${version} native binaries for Win64 AMD64/EMT64 platform.
     <!-- Digester and dependencies -->
     <jar jarfile="${tomcat.deployer}/lib/catalina-deployer.jar"
          manifest="${tomcat.manifests}/default.manifest"
-         modificationtime="${tstamp.file}">
+         modificationtime="${tstamp.iso.release}">
       <fileset dir="${tomcat.classes}">
         <include name="org/apache/catalina/startup/DigesterFactory.class" />
         <include name="org/apache/catalina/util/SchemaResolver.class" />
@@ -2703,7 +2703,12 @@ asf.ldap.username=${release.asfusername}
   </target>
 
   <!-- Sets properties only required for releases -->
-  <target name="release-init" depends="gpg-init-1,gpg-init-2" />
+  <target name="release-init" depends="gpg-init-1,gpg-init-2,compile" >
+    <taskdef name="forceUtcTimeZone"
+             classname="org.apache.tomcat.buildutil.ForceUtcTimeZone"
+             classpath="${tomcat.classes}" />
+    <forceUtcTimeZone />
+  </target>
 
   <target name="gpg-init-1">
     <available file="${gpg.exec}" property="gpg.exec.available"/>
@@ -2723,7 +2728,7 @@ asf.ldap.username=${release.asfusername}
     </fixcrlf>
 
     <zip zipfile="${tomcat.release}/v${version}/bin/${final.name}.zip"
-         modificationtime="${tstamp.file}"
+         modificationtime="${tstamp.iso.release}"
          encoding="UTF8">
       <zipfileset file="${tomcat.dist}" fullpath="${final.name}"/>
       <zipfileset dir="${tomcat.dist}" prefix="${final.name}">
@@ -2760,7 +2765,7 @@ asf.ldap.username=${release.asfusername}
 
     <!-- Windows x86 package -->
     <zip zipfile="${tomcat.release}/v${version}/bin/${final.name}-windows-x86.zip"
-         modificationtime="${tstamp.file}"
+         modificationtime="${tstamp.iso.release}"
          encoding="UTF8">
       <zipfileset file="${tomcat.dist}" fullpath="${final.name}"/>
       <zipfileset dir="${tomcat.dist}" prefix="${final.name}">
@@ -2788,7 +2793,7 @@ asf.ldap.username=${release.asfusername}
 
     <!-- Windows x64 package -->
     <zip zipfile="${tomcat.release}/v${version}/bin/${final.name}-windows-x64.zip"
-         modificationtime="${tstamp.file}"
+         modificationtime="${tstamp.iso.release}"
          encoding="UTF8">
       <zipfileset file="${tomcat.dist}" fullpath="${final.name}"/>
       <zipfileset dir="${tomcat.dist}" prefix="${final.name}">
@@ -2832,7 +2837,7 @@ asf.ldap.username=${release.asfusername}
     </fixcrlf>
 
     <zip zipfile="${tomcat.release}/v${version}/bin/${final.name}-deployer.zip"
-         modificationtime="${tstamp.file}"
+         modificationtime="${tstamp.iso.release}"
          encoding="UTF8">
       <zipfileset file="${tomcat.deployer}" fullpath="${final.name}-deployer"/>
       <zipfileset dir="${tomcat.deployer}" prefix="${final.name}-deployer" includes="**" />
@@ -2984,7 +2989,7 @@ asf.ldap.username=${release.asfusername}
     </fixcrlf>
 
     <zip zipfile="${tomcat.release}/v${version}/src/${final-src.name}.zip"
-         modificationtime="${tstamp.file}"
+         modificationtime="${tstamp.iso.release}"
          encoding="UTF8">
       <zipfileset file="${tomcat.dist}/src" fullpath="${final-src.name}" />
       <zipfileset dir="${tomcat.dist}/src" prefix="${final-src.name}" />
@@ -3844,7 +3849,7 @@ Read the Building page on the Apache Tomcat documentation site for details on ho
       <sequential unless:true="${jar.uptodate}">
         <jar jarfile="@{jarfile}"
              manifest="@{manifest}"
-             modificationtime="${tstamp.file}">
+             modificationtime="${tstamp.iso.release}">
           <fileset dir="@{filesDir}">
             <patternset refid="@{filesId}"/>
             <!-- Javadoc exclusions -->
@@ -3900,7 +3905,7 @@ Read the Building page on the Apache Tomcat documentation site for details on ho
     <fixcrlf srcdir="${tomcat.graal}/${graalPrefix}" eol="lf"
         encoding="ISO-8859-1" fixlast="false" />
     <zip destfile="${jarfile}" update="true" filesonly="true"
-         modificationtime="${tstamp.file}"
+         modificationtime="${tstamp.iso.release}"
          encoding="UTF8">
       <zipfileset dir="${tomcat.graal}/${graalPrefix}" prefix="META-INF/native-image/${graalPrefix}" includes="*.*"/>
     </zip>
diff --git a/java/org/apache/tomcat/buildutil/ForceUtcTimeZone.java b/java/org/apache/tomcat/buildutil/ForceUtcTimeZone.java
new file mode 100644
index 0000000000..d4e4529798
--- /dev/null
+++ b/java/org/apache/tomcat/buildutil/ForceUtcTimeZone.java
@@ -0,0 +1,30 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.tomcat.buildutil;
+
+import java.util.TimeZone;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+
+public class ForceUtcTimeZone extends Task {
+
+    @Override
+    public void execute() throws BuildException {
+        TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+    }
+}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 11a73a1017..f2f3f6fde6 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -159,6 +159,14 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Other">
+    <changelog>
+      <fix>
+        Ensure that zip archives use UTC for file modification times to ensure
+        repeatable builds across time zones. (markt)
+      </fix>
+    </changelog>
+  </subsection>
 </section>
 <section name="Tomcat 9.0.65 (remm)" rtext="2022-07-20">
   <subsection name="Catalina">


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org