Repository: archlinux/archinstall

Issue:
Installing gnome, gdm and gnome-tweaks fails
Choosing gnome as the desktop environment will fail at one of the last stages if the device's hardware clock or system clock is wrong or the timezone is set wrongfully. This leads to GPG keys failing to be imported or validated during the integrity checks, which leads to a failure.
I would argue that it would be great to enforce some time sync of the hardware/system clock and an NTP synchronization before the package installation phase.


Discussion:
We do, but it's optional as we wish to enforce as little as possible on the users. Selecting NTP during the first stages of the installer will perform a NTP sync before installing packages :)
I did choose to perform an NTP sync earlier in the installation process, but the problem persisted up until I forcefully synced manually from outside the archinstall script.

> We do, but it's optional as we wish to enforce as little as possible on the users. Selecting NTP during the first stages of the installer will perform a NTP sync before installing packages :)


That's strange, I'll have a try here.
It might be that the time sync took too long and you ran through the menue's quick enough? We don't perform a check currently if the NTP service has finished syncing up (which can take anywhere between 0.5 seconds - 1 minute if the latency is bad).

I'll leave this open and push a check for the NTP service prior to running `minimal_installation()` if NTP has been chosen!

Edit: Also, thank you for bringing this to our attention, forgot to mention it! :)
I'm having trouble recreating this issue.
This is for me the Archiso releng just clean build with archinstall autostarting:
![screenshot](https://user-images.githubusercontent.com/861439/162943183-a1c5f706-4342-4601-8450-c0dd744ab261.jpg)

To me this is a behavior we need to disable, the fact that it *forcefully* actives NTP without asking the users for it.
So if anything, this issue has shed light on this behavior.. But I can't recreated time being out of sync other than the sync not having access to network while trying to perform the NTP sync. (not sure how often it retries)
I am having trouble recreating the issue with the latest Archiso as well. I had a maybe two-month-old Archiso when I initially encountered the problems. It might have been the case that the hardware clock was somehow messed up by the Windows time sync, which I know does not use UTC.

I just used the script, and it worked flawlessly for me, so probably the issue is not relevant anymore.
Perfect. Yea we introduced NTP sync about 1-2 months ago as standard practice by archinstall.
But it should be optional, so I'll leave this issue open until I can sort out why it's auto-enabling NTP instead of asking :) Easy fix probably but I need something to remind me of it hehe
I am sure that the Archiso I had was asking for it, so NTP sync was already a thing in the archinstall version bundled with the Archiso I used. So it may be the case that there is a different reason for the NTP not working correctly due to the dual-boot present on the system. Anyway, that's all speculation as long as the problem is reproducible. Thank you, nevertheless, for a great script and tool!

Resolving patch:
diff --git a/examples/guided.py b/examples/guided.py
--- a/examples/guided.py
+++ b/examples/guided.py
@@ -151,6 +151,25 @@ def perform_installation(mountpoint):
 		while archinstall.service_state('reflector') not in ('dead', 'failed'):
 			time.sleep(1)
 
+		# If we've activated NTP, make sure at least one time-sync finishes
+		# before we continue with the installation
+		if archinstall.arguments.get('ntp', False):
+			# TODO: First block might be redundant, but this service is not activated unless
+			# `timedatectl set-ntp true` is executed.
+			logged = False
+			while archinstall.service_state('dbus-org.freedesktop.timesync1.service') not in ('running'):
+				if not logged:
+					installation.log(f"Waiting for dbus-org.freedesktop.timesync1.service to enter running state", level=logging.INFO)
+					logged = True
+				time.sleep(1)
+
+			logged = False
+			while 'Server: n/a' in archinstall.SysCommand('timedatectl timesync-status --no-pager --property=Server --value'):
+				if not logged:
+					installation.log(f"Waiting for timedatectl timesync-status to report a timesync against a server", level=logging.INFO)
+					logged = True
+				time.sleep(1)
+
 		# Set mirrors used by pacstrap (outside of installation)
 		if archinstall.arguments.get('mirror-region', None):
 			archinstall.use_mirrors(archinstall.arguments['mirror-region'])  # Set the mirrors for the live medium


Test patch: