xray-16 icon indicating copy to clipboard operation
xray-16 copied to clipboard

calculate_xray_build_id broken when date earlier than 31.01.1999

Open OPNA2608 opened this issue 1 year ago • 4 comments

Describe the bug https://github.com/OpenXRay/xray-16/blob/92c550c591a57491371e7b8d3d3494d4224a9c38/cmake/utils.cmake#L52-L53

https://cmake.org/cmake/help/v3.28/command/string.html#timestamp notes:

New in version 3.8: If the SOURCE_DATE_EPOCH environment variable is set, its value will be used instead of the current time. See https://reproducible-builds.org/specs/source-date-epoch/ for details.

SOURCE_DATE_EPOCH is often set to a value that results in a date of 01.01.1970 or 01.01.1980. This seemingly breaks the calculation here: https://github.com/OpenXRay/xray-16/blob/92c550c591a57491371e7b8d3d3494d4224a9c38/cmake/utils.cmake#L61-L62

Which finally produces an invalid project version, erroring out the configure call:

CMake Error at CMakeLists.txt:13 (project):
  VERSION "1.6.02.-6965" format invalid.

To Reproduce Steps to reproduce the behavior:

  1. export SOURCE_DATE_EPOCH=315532800, meaning 01.01.1980
  2. Try to build latest master (92c550c591a57491371e7b8d3d3494d4224a9c38)

Expected behavior CMake configuring doesn't break.

Screenshots, videos n/a

BugTrap error report n/a

Desktop (please complete the following information):

  • OS: NixOS 23.11
  • OpenXRay build version: apparently -6965 :upside_down_face:

Additional context

this derivation will be built:
  /nix/store/wb56kbxnzrirnlyhnx2r2h585ziwvbfm-openxray-2188-november-2023-rc1-unstable-2024-02-15.drv
building '/nix/store/wb56kbxnzrirnlyhnx2r2h585ziwvbfm-openxray-2188-november-2023-rc1-unstable-2024-02-15.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/ll5rbda359kxn8991mzwmyd3anka8is0-source
source root is source
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./Externals/lzo/autoconf/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./src/utils/mp_gpprof_server/libraries/fcgi-2.4.0/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./Externals/lzo/autoconf/config.guess
Updating Autotools / GNU config script to a newer upstream version: ./src/utils/mp_gpprof_server/libraries/fcgi-2.4.0/config.guess
Running phase: configurePhase
fixing cmake files...
cmake flags: -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=OFF -DCMAKE_INSTALL_LOCALEDIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/share/locale -DCMAKE_INSTALL_LIBEXECDIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/libexec -DCMAKE_INSTALL_LIBDIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/lib -DCMAKE_INSTALL_DOCDIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/share/doc/OpenXRay -DCMAKE_INSTALL_INFODIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/share/info -DCMAKE_INSTALL_MANDIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/share/man -DCMAKE_INSTALL_OLDINCLUDEDIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/include -DCMAKE_INSTALL_INCLUDEDIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/include -DCMAKE_INSTALL_SBINDIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/sbin -DCMAKE_INSTALL_BINDIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/bin -DCMAKE_INSTALL_NAME_DIR=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15/lib -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -DCMAKE_OSX_SYSROOT= -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_STRIP=/nix/store/4cjqvbp1jbkps185wl8qnbjpf8bdy8j9-gcc-wrapper-13.2.0/bin/strip -DCMAKE_RANLIB=/nix/store/4cjqvbp1jbkps185wl8qnbjpf8bdy8j9-gcc-wrapper-13.2.0/bin/ranlib -DCMAKE_AR=/nix/store/4cjqvbp1jbkps185wl8qnbjpf8bdy8j9-gcc-wrapper-13.2.0/bin/ar -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_INSTALL_PREFIX=/nix/store/2z24xig62bpi0h9v9hfdwlnh2szy6bgg-openxray-2188-november-2023-rc1-unstable-2024-02-15  
-- CMAKE_VERSION: 3.27.9
CMake Error at CMakeLists.txt:13 (project):
  VERSION "1.6.02.-6965" format invalid.


-- Configuring incomplete, errors occurred!
error: builder for '/nix/store/wb56kbxnzrirnlyhnx2r2h585ziwvbfm-openxray-2188-november-2023-rc1-unstable-2024-02-15.drv' failed with exit code 1;

I guess this was a problem since that function was introduced, but it only ever affected the banner on launch.

OPNA2608 avatar Feb 15 '24 22:02 OPNA2608

Is it possible to robustly get the exact current date? Ignoring SOURCE_DATE_EPOCH if it's less than 31.01.1999?

Xottab-DUTY avatar Feb 16 '24 06:02 Xottab-DUTY

Ignoring SOURCE_DATE_EPOCH is bad: It's set precisely because the build is supposed to not rely on the current date, to provide the same build results no matter when it's built. If a workaround is implemented that gets the current date in another way, then I will have to patch it out and hardcode some fixed value in Nixpkgs.

OPNA2608 avatar Feb 16 '24 09:02 OPNA2608

The simplest workaround I see it to replace - with 0, so the build id would be 1.6.02.06965 :)

Xottab-DUTY avatar Feb 16 '24 09:02 Xottab-DUTY

Should be fairly easy to fix. What about just returning 0 if the current date is before the start date? So we would just get 1.6.02.0

AMS21 avatar Feb 16 '24 13:02 AMS21