Package: elan
Version: 1.4.2-2

We would like to update the zip crate to 0.6, I have uploaded the new version
to experimental to allow testing with it.

I bumped the dependency in elan and most of the code built fine, but there was
one chunk of code that failed.

            let mtime = entry.last_modified().to_time().to_timespec();
            let mtime = filetime::FileTime::from_unix_time(mtime.sec, 
mtime.nsec as u32);

zip 0.6 has moved from time 0.1 to time 0.3 and as a result of this the return
type of to_time() has changed from "Tm" to
"Result<OffsetDateTime, ComponentRange>"

This raises a couple of issues, the first is that OffsetDateTime does not have a
to_timespec function, it does however have a unix_timestamp_nanos function which
can be used to achieve much the same goal.

The second though, is what to do about error handling. The old code in time 0.1
just blundered on if invalid values were supplied, but the new time 0.3 codepath
includes error checking. So that leaves the question of what to do if an error
happens during timestamp conversion, should some default value be used or
should the error be propagated to the caller.

My current patch takes the latter approach, passing the error up to the caller.

I have also raised this issue upstream at 
https://github.com/leanprover/elan/issues/85

At the present time, this bug report is filed for information, I still need
to check out the other reverse dependencies of rust-zip, and I would also like
feedback from upstream on this issue if possible.
diff -Nru elan-1.4.2/debian/changelog elan-1.4.2/debian/changelog
--- elan-1.4.2/debian/changelog 2022-12-01 20:58:32.000000000 +0000
+++ elan-1.4.2/debian/changelog 2022-12-23 02:54:30.000000000 +0000
@@ -1,3 +1,10 @@
+elan (1.4.2-2.1) UNRELEASED; urgency=medium
+
+  * Non-maintainer upload.
+  * Update for rust-zip 0.6
+
+ -- Peter Michael Green <plugw...@debian.org>  Fri, 23 Dec 2022 02:54:30 +0000
+
 elan (1.4.2-2) unstable; urgency=medium
 
   * Add lake symlink
diff -Nru elan-1.4.2/debian/control elan-1.4.2/debian/control
--- elan-1.4.2/debian/control   2022-12-01 20:52:28.000000000 +0000
+++ elan-1.4.2/debian/control   2022-12-23 02:10:54.000000000 +0000
@@ -24,7 +24,7 @@
  librust-toml-dev,
  librust-url-dev,
  librust-wait-timeout-dev,
- librust-zip-dev,
+ librust-zip-0.6-dev,
  librust-clap+atty-dev,
  librust-clap+strsim-dev,
  librust-clap+vec-map-dev,
@@ -41,7 +41,7 @@
  librust-openssl-probe-dev,
  librust-backtrace-sys-dev,
  librust-markdown-dev,
- librust-zip+time-dev,
+ librust-zip-0.6+time-dev,
  librust-zstd-dev,
  bash-completion
 Standards-Version: 4.6.1.0
diff -Nru elan-1.4.2/debian/patches/series elan-1.4.2/debian/patches/series
--- elan-1.4.2/debian/patches/series    2022-12-01 20:52:28.000000000 +0000
+++ elan-1.4.2/debian/patches/series    2022-12-23 02:13:45.000000000 +0000
@@ -1,2 +1,3 @@
 build.patch
 0002-dependencies.patch
+zip-0.6.patch
diff -Nru elan-1.4.2/debian/patches/zip-0.6.patch 
elan-1.4.2/debian/patches/zip-0.6.patch
--- elan-1.4.2/debian/patches/zip-0.6.patch     1970-01-01 00:00:00.000000000 
+0000
+++ elan-1.4.2/debian/patches/zip-0.6.patch     2022-12-23 02:54:30.000000000 
+0000
@@ -0,0 +1,87 @@
+Description: update for zip 0.6
+ Zip 0.6 moved from time 0.1 to time 0.3 which changes how timestamps are
+ handled.
+
+ The old implementation did not do any checking of validity during the
+ timestamp conversion process and just blundered on if an invalid timestamp
+ was supplied. The new implementation on the other hand can return an error.
+
+ This patch makes elan build with the new version of zip, currently it
+ handles the new error by passing it up to the caller.
+Author: Peter Michael Green <plugw...@debian.org>
+
+Index: elan-1.4.2/Cargo.toml
+===================================================================
+--- elan-1.4.2.orig/Cargo.toml
++++ elan-1.4.2/Cargo.toml
+@@ -47,7 +47,7 @@ time = "0.3.4"
+ toml = "0.5.8"
+ url = "2.2.0"
+ wait-timeout = "0.2.0"
+-zip = "0.5.9"
++zip = "0.6"
+ tar = ">=0.4.36"
+ flate2 = "1.0.14"
+ json = "0.12.4"
+Index: elan-1.4.2/src/elan-dist/Cargo.toml
+===================================================================
+--- elan-1.4.2.orig/src/elan-dist/Cargo.toml
++++ elan-1.4.2/src/elan-dist/Cargo.toml
+@@ -22,8 +22,9 @@ remove_dir_all = "0.7.0"
+ elan-utils = { path = "../elan-utils" }
+ error-chain = "0.12.4"
+ json = "0.12.4"
+-zip = "0.5.13"
++zip = "0.6"
+ filetime = "0.2.14"
++time = "0.3"
+ 
+ [target."cfg(not(windows))".dependencies]
+ libc = "0.2.88"
+Index: elan-1.4.2/src/elan-dist/src/component/package.rs
+===================================================================
+--- elan-1.4.2.orig/src/elan-dist/src/component/package.rs
++++ elan-1.4.2/src/elan-dist/src/component/package.rs
+@@ -122,8 +122,8 @@ impl<'a> ZipPackage<'a> {
+                     }
+                 }
+             } // make sure to close `dst` before setting mtime
+-            let mtime = entry.last_modified().to_time().to_timespec();
+-            let mtime = filetime::FileTime::from_unix_time(mtime.sec, 
mtime.nsec as u32);
++            let mtime = 
entry.last_modified().to_time()?.unix_timestamp_nanos();
++            let mtime = filetime::FileTime::from_unix_time((mtime / 
1000000000) as i64 , (mtime % 1000000000) as u32);
+             filetime::set_file_times(&full_path, mtime, mtime).unwrap();
+         }
+ 
+Index: elan-1.4.2/src/elan-dist/src/errors.rs
+===================================================================
+--- elan-1.4.2.orig/src/elan-dist/src/errors.rs
++++ elan-1.4.2/src/elan-dist/src/errors.rs
+@@ -4,6 +4,7 @@ use std::io::{self, Write};
+ use std::path::PathBuf;
+ use temp;
+ use toml;
++use time::error::ComponentRange;
+ 
+ error_chain! {
+     links {
+@@ -13,6 +14,7 @@ error_chain! {
+     foreign_links {
+         Temp(temp::Error);
+         Io(io::Error);
++        Time(ComponentRange);
+     }
+ 
+     errors {
+Index: elan-1.4.2/src/elan-dist/src/lib.rs
+===================================================================
+--- elan-1.4.2.orig/src/elan-dist/src/lib.rs
++++ elan-1.4.2/src/elan-dist/src/lib.rs
+@@ -13,6 +13,7 @@ extern crate error_chain;
+ extern crate json;
+ extern crate sha2;
+ extern crate zip;
++extern crate time;
+ 
+ #[cfg(not(windows))]
+ extern crate libc;

Reply via email to