[Git][reproducible-builds/reprotest][master] 2 commits: Consistently use 398 days for time variation rather than choosing

Vagrant Cascadian (@vagrant) gitlab at salsa.debian.org
Thu Apr 11 21:26:55 UTC 2024



Vagrant Cascadian pushed to branch master at Reproducible Builds / reprotest


Commits:
42a53ed6 by Vagrant Cascadian at 2024-04-11T14:24:51-07:00
Consistently use 398 days for time variation rather than choosing
randomly.

- - - - -
cdabc071 by Vagrant Cascadian at 2024-04-11T14:24:58-07:00
Enable specific number of cpus using --vary=num_cpus.cpus=X.

- - - - -


2 changed files:

- README.rst
- reprotest/build.py


Changes:

=====================================
README.rst
=====================================
@@ -288,9 +288,9 @@ user_group.available
     a $user, with no $group variation.
 time.faketimes
     A semicolon-separated ordered set, specifying possible ``faketime(1)`` time
-    descriptors to use. Default is empty, in which case we randomly choose a
+    descriptors to use. Default is empty, in which case we choose a
     time: either now (if the latest file-modtime in ``source_root`` is older
-    than about half-a-year) or more than half-a-year in the future.
+    than 398 days) or more than 398 days in the future.
 
     Note that the clock continues to run during the build. It is possible for
     ``faketime(1)`` to freeze it, but we don't yet support that yet; it has a
@@ -302,6 +302,9 @@ locales.locale
     Locales with different properties than en_US.UTF-8 are fr_CH.UTF-8,
     ru_RU.CP1251, kk_KZ.RK1048 or zh_CN.
     Default is et_EE.UTF-8 if unspecified.
+num_cpus.cpus
+    A semicolon-separated list of one or more numeric values to select
+    the number of cpus used when performing num_cpus variations.
 
 The difference between --vary and --variations is that the former appends onto
 previous values but the latter resets them. Furthermore, the last value set for


=====================================
reprotest/build.py
=====================================
@@ -340,12 +340,21 @@ def aslr(ctx, build, vary):
 
 def num_cpus(ctx, build, vary):
     _ = build
-    _ = _.append_setup_exec_raw('CPU_MAX=$(nproc)')
+    if not vary:
+        _ = _.append_setup_exec_raw('CPU_MAX=$(nproc)')
+    elif not ctx.spec.num_cpus.cpus:
+        _ = _.append_setup_exec_raw('CPU_MAX=$(nproc)')
+    else:
+        _ = _.append_setup_exec_raw('CPU_MAX=%s' % random.choice(ctx.spec.num_cpus.cpus))
     _ = _.append_setup_exec_raw('CPU_MIN=$({ echo $CPU_MAX; echo %s; } | sort -n | head -n1)' % ctx.min_cpus)
     if ctx.min_cpus <= 0:
         raise ValueError("--min-cpus must be a positive integer: " % ctx.min_cpus)
     if not vary:
         _ = _.append_setup_exec_raw('CPU_NUM=$CPU_MIN')
+    elif ctx.spec.num_cpus.cpus:
+        _ = _.append_setup_exec_raw('CPU_NUM=$(if [ $CPU_MIN = $CPU_MAX ]; \
+            then echo $CPU_MIN; echo >&2 "only 1 CPU is available; num_cpus is ineffective"; \
+            else echo %s; fi)' % random.choice(ctx.spec.num_cpus.cpus))
     else:
         # random number between min_cpus and $(nproc)
         _ = _.append_setup_exec_raw('CPU_NUM=$(if [ $CPU_MIN = $CPU_MAX ]; \
@@ -420,17 +429,16 @@ def faketime(ctx, build, vary):
     else:
         now = time.time()
         base = int(ctx.base_faketime[1:]) if ctx.base_faketime.startswith("@") else now
-        # 15552000 = 180 days
-        if base < now - 15552000 and not random.randint(0, 1):
-            # if ctx.base_faketime is far in the past, with 1/2 probability
-            # reuse the current time and don't fake it
-            if ctx.verbosity >= 1:
-                logger.info("FAKETIME variation: enabled but chosen randomly not to fake!")
+        # 34387200 = 398 days
+        if base < now - 34387200:
+            logger.info("FAKETIME variation: enabled but avoiding use of faketime as build environment is sufficiently old!")
             return build
         else:
-            # otherwise use a date far in the future
+            # otherwise use a date far in the future, specifically 398
+            # days (one year, a large month, a leap day, and one extra
+            # for good measure). Let the hours and minutes vary a bit.
             faket = '+%sdays+%shours+%sminutes' % (
-                random.randint(180, 540), random.randint(0, 23), random.randint(0, 59))
+                398, random.randint(0, 23), random.randint(0, 59))
 
     # faketime's manpages are stupidly misleading; it also modifies file timestamps.
     # this is only mentioned in the README. we do not want this, it really really
@@ -594,6 +602,11 @@ class BuildPathVariation(collections.namedtuple('_BuildPathVariation', 'path')):
     def default(cls):
         return cls('')
 
+class NumCpusVariation(collections.namedtuple('_NumCpusVariation', 'cpus')):
+    @classmethod
+    def default(cls):
+        return cls(mdiffconf.strlist_set(";"))
+
 class VariationSpec(mdiffconf.ImmutableNamespace):
     @classmethod
     def default(cls, variations=VARIATIONS):
@@ -604,6 +617,7 @@ class VariationSpec(mdiffconf.ImmutableNamespace):
             "domain_host": DomainHostVariation.default(),
             "locales": LocalesVariation.default(),
             "build_path": BuildPathVariation.default(),
+            "num_cpus": NumCpusVariation.default(),
         }
         return cls(**{k: default_overrides.get(k, True) for k in variations})
 



View it on GitLab: https://salsa.debian.org/reproducible-builds/reprotest/-/compare/923586225a5a680fb8601e59af95e23a44a81c7b...cdabc07163cb784c52272874c12e29460b0ce7d2

-- 
View it on GitLab: https://salsa.debian.org/reproducible-builds/reprotest/-/compare/923586225a5a680fb8601e59af95e23a44a81c7b...cdabc07163cb784c52272874c12e29460b0ce7d2
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.reproducible-builds.org/pipermail/rb-commits/attachments/20240411/78aad5dd/attachment.htm>


More information about the rb-commits mailing list