Comment 3 for bug 1890046

I see this happen to. I think the problem is that mksquashfs from the snapd snap (or the core snap is too old).

This is from strace when invoking `snap pack`:

[pid 57453] execve("/var/lib/snapd/snap/snapd/current/lib/x86_64-linux-gnu/ld-2.23.so", ["/var/lib/snapd/snap/snapd/current/lib/x86_64-linux-gnu/ld-2.23.so", "--library-path", "/var/lib/snapd/snap/snapd/current/usr/local/lib:/var/lib/snapd/snap/snapd/current/lib/x86_64-linux-gnu:/var/lib/snapd/snap/snapd/current/usr/lib/x86_64-linux-gnu", "/var/lib/snapd/snap/snapd/current/usr/bin
/mksquashfs", ".", "/home/maciek/work/canonical/image/snapd_2.45.3.1+git2336.g484f47d_amd64.snap", "-noappend", "-comp", "xz", "-no-fragments", "-no-progress", "-wildcards", "-ef", "/tmp/.snap-pack-exclude-981155965", "-all-root", "-no-xattrs"], ["DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus", "DISPLAY=:0", "HOME=/home/maciek", "INVOCATION_ID=6b2d474429d64baebb7b8457e0057
a7e", "JOURNAL_STREAM=8:39754", "LANG=en_US.UTF-8", "LC_TIME=pl_PL.UTF-8", "LOGNAME=maciek", "MAIL=/var/spool/mail/maciek", "MANAGERPID=1483", "PATH=/usr/local/bin:/usr/bin:/var/lib/snapd/snap/bin:/home/maciek/bin:/home/maciek/.local/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl", "PLASMA_USE_QT
_SCALING=1", "PWD=/home/maciek/work/canonical/image", "SHELL=/usr/bin/zsh", "SSH_AUTH_SOCK=/run/user/1000/keyring/ssh", "TERM=screen-256color", "TMUX=/tmp//tmux-1000/default,1557,0", "TMUX_PANE=%8", "USER=maciek", "XAUTHORITY=/run/user/1000/gdm/Xauthority", "XDG_DATA_DIRS=/home/maciek/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/
var/lib/snapd/desktop", "XDG_RUNTIME_DIR=/run/user/1000", "SHLVL=1", "OLDPWD=/home/maciek", "KWIN_TRIPLE_BUFFER=1", "HG=/usr/bin/hg", "MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins", "EDITOR=emacsclient -t -a ''", "PAGER=less", "LC_MESSAGES=", "_=/usr/bin/strace", "SOURCE_DATE_EPOCH=1596107149"]) = 0

Clearly the environment variable is passed to mksquashfs. However, the mksquashfs binary is not aware of SOURCE_DATE_EPOCH at all:

$ strings /var/lib/snapd/snap/snapd/current/usr/bin/mksquashfs| grep SOURCE_DATE

Now my local binary is:

$ strings /usr/bin/mksquashfs| grep SOURCE_DATE
SOURCE_DATE_EPOCH
FATAL ERROR:SOURCE_DATE_EPOCH and command line options can't be used at the same time to set timestamp(s)
Env Var SOURCE_DATE_EPOCH has invalid time value

We would need to update the mksquashfs that goes into the snap binary for this to work. The version we currently have comes from 16.04.