Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calculate_xray_build_id broken when date earlier than 31.01.1999 #1611

Closed
OPNA2608 opened this issue Feb 15, 2024 · 4 comments · Fixed by #1615
Closed

calculate_xray_build_id broken when date earlier than 31.01.1999 #1611

OPNA2608 opened this issue Feb 15, 2024 · 4 comments · Fixed by #1615
Labels
Build issue The issue in the build-time.

Comments

@OPNA2608
Copy link
Contributor

Describe the bug

# Acquire timestamp in "date month year" format
string(TIMESTAMP current_date "%d %m %Y")

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:

# Calculate XRAY build ID
math(EXPR build_id "(${CURRENT_DATE_YEAR} - ${XRAY_START_YEAR}) * 365 + ${CURRENT_DATE_DAY} - ${XRAY_START_DAY}")

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 (92c550c)

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 🙃

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 OPNA2608 added the Bug The issue in the run-time. label Feb 15, 2024
@Xottab-DUTY
Copy link
Member

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

@Xottab-DUTY Xottab-DUTY added Build issue The issue in the build-time. and removed Bug The issue in the run-time. labels Feb 16, 2024
@OPNA2608
Copy link
Contributor Author

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.

@Xottab-DUTY
Copy link
Member

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

@AMS21
Copy link
Contributor

AMS21 commented Feb 16, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build issue The issue in the build-time.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants