alibuild 2.0.1__tar.gz → 2.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. {alibuild-2.0.1 → alibuild-2.0.3}/PKG-INFO +1 -1
  2. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild.egg-info/PKG-INFO +1 -1
  3. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/_version.py +3 -3
  4. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/reconstruct.py +79 -6
  5. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/sync_reapi.py +12 -6
  6. {alibuild-2.0.1 → alibuild-2.0.3}/docs/docs/user.md +8 -0
  7. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_reconstruct.py +135 -0
  8. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_sync_reapi.py +45 -0
  9. {alibuild-2.0.1 → alibuild-2.0.3}/.claude/skills/s3-conditional-writes/SKILL.md +0 -0
  10. {alibuild-2.0.1 → alibuild-2.0.3}/.claude/skills/support-architecture/SKILL.md +0 -0
  11. {alibuild-2.0.1 → alibuild-2.0.3}/.flake8 +0 -0
  12. {alibuild-2.0.1 → alibuild-2.0.3}/.github/dependabot.yml +0 -0
  13. {alibuild-2.0.1 → alibuild-2.0.3}/.github/workflows/documentation.yml +0 -0
  14. {alibuild-2.0.1 → alibuild-2.0.3}/.github/workflows/homebrew.yml +0 -0
  15. {alibuild-2.0.1 → alibuild-2.0.3}/.github/workflows/pr-check.yml +0 -0
  16. {alibuild-2.0.1 → alibuild-2.0.3}/.github/workflows/release.yml +0 -0
  17. {alibuild-2.0.1 → alibuild-2.0.3}/.gitignore +0 -0
  18. {alibuild-2.0.1 → alibuild-2.0.3}/.pylintrc +0 -0
  19. {alibuild-2.0.1 → alibuild-2.0.3}/ANALYTICS.md +0 -0
  20. {alibuild-2.0.1 → alibuild-2.0.3}/DESIGN.md +0 -0
  21. {alibuild-2.0.1 → alibuild-2.0.3}/LICENSE.md +0 -0
  22. {alibuild-2.0.1 → alibuild-2.0.3}/PACKAGING.md +0 -0
  23. {alibuild-2.0.1 → alibuild-2.0.3}/README.rst +0 -0
  24. {alibuild-2.0.1 → alibuild-2.0.3}/REMOTE_STORE_CAS_AC.md +0 -0
  25. {alibuild-2.0.1 → alibuild-2.0.3}/alfaBuild +0 -0
  26. {alibuild-2.0.1 → alibuild-2.0.3}/aliBuild +0 -0
  27. {alibuild-2.0.1 → alibuild-2.0.3}/aliDeps +0 -0
  28. {alibuild-2.0.1 → alibuild-2.0.3}/aliDoctor +0 -0
  29. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild.egg-info/SOURCES.txt +0 -0
  30. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild.egg-info/dependency_links.txt +0 -0
  31. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild.egg-info/requires.txt +0 -0
  32. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild.egg-info/top_level.txt +0 -0
  33. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/__init__.py +0 -0
  34. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/analytics.py +0 -0
  35. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/args.py +0 -0
  36. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/build.py +0 -0
  37. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/build_template.sh +0 -0
  38. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/clean.py +0 -0
  39. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/cmd.py +0 -0
  40. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/completion.py +0 -0
  41. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/completions/__init__.py +0 -0
  42. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/completions/bash.sh +0 -0
  43. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/completions/zsh.sh +0 -0
  44. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/deps.py +0 -0
  45. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/doctor.py +0 -0
  46. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/git.py +0 -0
  47. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/init.py +0 -0
  48. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/install.py +0 -0
  49. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/keyring.json +0 -0
  50. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/log.py +0 -0
  51. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/migrate.py +0 -0
  52. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/sandbox.py +0 -0
  53. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/scm.py +0 -0
  54. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/signing.py +0 -0
  55. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/sl.py +0 -0
  56. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/source.py +0 -0
  57. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/sync.py +0 -0
  58. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/templating_plugin.py +0 -0
  59. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/utilities.py +0 -0
  60. {alibuild-2.0.1 → alibuild-2.0.3}/alibuild_helpers/workarea.py +0 -0
  61. {alibuild-2.0.1 → alibuild-2.0.3}/alienv +0 -0
  62. {alibuild-2.0.1 → alibuild-2.0.3}/codecov.yml +0 -0
  63. {alibuild-2.0.1 → alibuild-2.0.3}/debian/changelog +0 -0
  64. {alibuild-2.0.1 → alibuild-2.0.3}/debian/compat +0 -0
  65. {alibuild-2.0.1 → alibuild-2.0.3}/debian/control +0 -0
  66. {alibuild-2.0.1 → alibuild-2.0.3}/debian/copyright +0 -0
  67. {alibuild-2.0.1 → alibuild-2.0.3}/debian/files +0 -0
  68. {alibuild-2.0.1 → alibuild-2.0.3}/debian/rules +0 -0
  69. {alibuild-2.0.1 → alibuild-2.0.3}/docs/SUPPORT +0 -0
  70. {alibuild-2.0.1 → alibuild-2.0.3}/docs/docs/alice_logo.png +0 -0
  71. {alibuild-2.0.1 → alibuild-2.0.3}/docs/docs/deps.png +0 -0
  72. {alibuild-2.0.1 → alibuild-2.0.3}/docs/docs/index.md +0 -0
  73. {alibuild-2.0.1 → alibuild-2.0.3}/docs/docs/quick.md +0 -0
  74. {alibuild-2.0.1 → alibuild-2.0.3}/docs/docs/reference.md +0 -0
  75. {alibuild-2.0.1 → alibuild-2.0.3}/docs/docs/stylesheets/extra.css +0 -0
  76. {alibuild-2.0.1 → alibuild-2.0.3}/docs/docs/troubleshooting.md +0 -0
  77. {alibuild-2.0.1 → alibuild-2.0.3}/docs/mkdocs.yml +0 -0
  78. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/alibuild_nix.jnj +0 -0
  79. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/alidist-aliphysics.nix +0 -0
  80. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/alidist-helpers.nix +0 -0
  81. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/alidist.nix +0 -0
  82. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/flake.lock +0 -0
  83. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/flake.nix +0 -0
  84. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/hyperloop.nix +0 -0
  85. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/hyperloopTest.nix +0 -0
  86. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/nix-interactive.bash +0 -0
  87. {alibuild-2.0.1 → alibuild-2.0.3}/extras/nix/update-envs.sh +0 -0
  88. {alibuild-2.0.1 → alibuild-2.0.3}/pb +0 -0
  89. {alibuild-2.0.1 → alibuild-2.0.3}/pyproject.toml +0 -0
  90. {alibuild-2.0.1 → alibuild-2.0.3}/requirements.txt +0 -0
  91. {alibuild-2.0.1 → alibuild-2.0.3}/setup.cfg +0 -0
  92. {alibuild-2.0.1 → alibuild-2.0.3}/setup.py +0 -0
  93. {alibuild-2.0.1 → alibuild-2.0.3}/templates/alibuild_nix.jnj +0 -0
  94. {alibuild-2.0.1 → alibuild-2.0.3}/templates/alibuild_to_please.jnj +0 -0
  95. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_analytics.py +0 -0
  96. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_args.py +0 -0
  97. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_build.py +0 -0
  98. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_clean.py +0 -0
  99. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_cmd.py +0 -0
  100. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_completion.py +0 -0
  101. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_deps.py +0 -0
  102. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_doctor.py +0 -0
  103. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_git.py +0 -0
  104. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_hashing.py +0 -0
  105. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_init.py +0 -0
  106. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_install.py +0 -0
  107. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_log.py +0 -0
  108. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_migrate.py +0 -0
  109. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_packagelist.py +0 -0
  110. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_parseRecipe.py +0 -0
  111. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_sandbox.py +0 -0
  112. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_signing.py +0 -0
  113. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_source.py +0 -0
  114. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_sync.py +0 -0
  115. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_utilities.py +0 -0
  116. {alibuild-2.0.1 → alibuild-2.0.3}/tests/test_workarea.py +0 -0
  117. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/broken1.sh +0 -0
  118. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/broken2.sh +0 -0
  119. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/broken3.sh +0 -0
  120. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/broken4.sh +0 -0
  121. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/broken5.sh +0 -0
  122. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/broken6.sh +0 -0
  123. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/broken7.sh +0 -0
  124. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/clobber-initdotsh.sh +0 -0
  125. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/defaults-o2.sh +0 -0
  126. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/delete-etc.sh +0 -0
  127. {alibuild-2.0.1 → alibuild-2.0.3}/tests/testdist/tracking-env.sh +0 -0
  128. {alibuild-2.0.1 → alibuild-2.0.3}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alibuild
3
- Version: 2.0.1
3
+ Version: 2.0.3
4
4
  Summary: ALICE Build Tool
5
5
  Home-page: https://alisw.github.io/alibuild
6
6
  Author: Giulio Eulisse
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: alibuild
3
- Version: 2.0.1
3
+ Version: 2.0.3
4
4
  Summary: ALICE Build Tool
5
5
  Home-page: https://alisw.github.io/alibuild
6
6
  Author: Giulio Eulisse
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '2.0.1'
32
- __version_tuple__ = version_tuple = (2, 0, 1)
31
+ __version__ = version = '2.0.3'
32
+ __version_tuple__ = version_tuple = (2, 0, 3)
33
33
 
34
- __commit_id__ = commit_id = 'g0096f2c8c'
34
+ __commit_id__ = commit_id = 'g826f20271'
@@ -66,6 +66,17 @@ def add_parser(subparsers, detected_arch, work_dir_default):
66
66
  help="With --verify --rebuild: treat a non-identical rebuilt tarball as a failure "
67
67
  "(default: soft, since legacy pre-normalisation tarballs are not "
68
68
  "bit-reproducible).")
69
+ p.add_argument("--docker-image", dest="dockerImage", default=None, metavar="IMAGE",
70
+ help="Rebuild in IMAGE instead of the build container recorded in the AC "
71
+ "entry, e.g. when that image is gone from the registry. The container "
72
+ "is not an input to the action hash; --rebaseline --apply records "
73
+ "IMAGE as the entry's action.container.")
74
+ p.add_argument("--docker-extra-args", dest="dockerExtraArgs", default="", metavar="ARGLIST",
75
+ help="As for 'aliBuild build': passed to the rebuild's 'docker run', e.g. "
76
+ "--docker-extra-args='--cpus=8 --memory=32g' (with '=').")
77
+ p.add_argument("-j", "--jobs", dest="jobs", type=int, default=None, metavar="N",
78
+ help="Parallel compilation processes for the rebuild ('aliBuild build -j'). "
79
+ "Default: build's, all the cores of the machine.")
69
80
  p.add_argument("--alidist", dest="alidist", default=None, metavar="DIR",
70
81
  help="alidist checkout used to supply the defaults config file "
71
82
  "(defaults-<name>.sh) when it is not archived in the ledger (it is a config, "
@@ -93,6 +104,25 @@ def add_parser(subparsers, detected_arch, work_dir_default):
93
104
  choices=("ephemeral", "permanent"),
94
105
  help="Retention tag for a blob restored by --persist. Default '%(default)s' (a "
95
106
  "deliberately reconstructed blob should not be LRU-expired).")
107
+ # Publishing options, spelt as `aliBuild build` spells them: --rebaseline --apply
108
+ # rewrites the legacy store object and link, and the AC entry it re-signs.
109
+ p.add_argument("--legacy-links-store", dest="legacyStore", default="", metavar="STORE",
110
+ help="As for 'aliBuild build': where the legacy TARS/<arch>/ links and "
111
+ "store objects live, if not in the artifact store.")
112
+ p.add_argument("--cas-public-url", dest="casPublicUrl", default="", metavar="URL",
113
+ help="As for 'aliBuild build': public base URL of the CAS bucket, which "
114
+ "the store objects in --legacy-links-store redirect to.")
115
+ p.add_argument("--sign-url", dest="signUrl", default="", metavar="URL",
116
+ help="Security-proxy sign route for the re-baselined AC entry. "
117
+ "--rebaseline --apply requires it unless --no-sign.")
118
+ p.add_argument("--sign-token", dest="signToken", default="", metavar="TOKEN",
119
+ help="Gate token presented to --sign-url.")
120
+ p.add_argument("--sign-token-file", dest="signTokenFile", default="", metavar="FILE",
121
+ help="Read the credential for --sign-url from FILE, for every request.")
122
+ p.add_argument("--signer", dest="signer", default="alibuild", metavar="NAME",
123
+ help="Signer label recorded in the signature. Default '%(default)s'.")
124
+ p.add_argument("--no-sign", dest="noSign", action="store_true",
125
+ help="Re-baseline without signing: the AC entry is left unsigned.")
96
126
  return p
97
127
 
98
128
 
@@ -449,6 +479,11 @@ def verify_rebuild(args, sync, closure, build_runner=None):
449
479
  ac_store = ac_store[:-4]
450
480
  container = entry["action"].get("container") or {}
451
481
  image = container.get("digest") or container.get("image")
482
+ if getattr(args, "dockerImage", None):
483
+ warning("NOT rebuilding %s in its recorded build container:\n"
484
+ " recorded: %s\n using : %s",
485
+ args.package, image or "none (native build)", args.dockerImage)
486
+ image = args.dockerImage
452
487
  # Rebuild with the defaults this build actually used (they feed the action
453
488
  # hash), not a hardcoded guess: prefer the recorded field, else recover the
454
489
  # flavour from the archived defaults recipe (migrated entries lack the field).
@@ -456,9 +491,12 @@ def verify_rebuild(args, sync, closure, build_runner=None):
456
491
  or defaults_from_closure(sync, closure) or "release")
457
492
 
458
493
  # Read-only remote store (no ::rw) => dependencies are fetched and reused,
459
- # nothing is uploaded. --force-rebuild only the target, so only it is
460
- # recompiled; its action hash changes but that does not affect the *content*
461
- # we compare against the recorded output digest. Propagate -d so the rebuild
494
+ # nothing is uploaded. The action hash and the revision are in the tarball
495
+ # (.meta.json, init.sh, relocate-me.sh), so a rebuild can only reproduce the
496
+ # recorded bytes under the recorded ones: a missing blob is rebuilt anyway, and
497
+ # with the legacy links in view the recorded revision is reused. Only a present
498
+ # blob needs --force-rebuild, which randomises the hash and takes a localN
499
+ # revision, so that rebuild never matches. Propagate -d so the rebuild
462
500
  # streams a debug build log when reconstruct is run with --debug (-d is a
463
501
  # global flag, so it must precede the "build" subcommand).
464
502
  # Re-invoke through the *same interpreter*, not just the same script: executing
@@ -476,16 +514,24 @@ def verify_rebuild(args, sync, closure, build_runner=None):
476
514
  # dependency (e.g. alibuild-recipe-tools under the cwd) would otherwise
477
515
  # be picked up as a development package -- rebuilt from local sources and,
478
516
  # worse, disabling the remote write store for the whole build.
479
- "--force-tracked",
480
- "--force-rebuild", args.package, "--defaults", defaults]
517
+ "--force-tracked", "--defaults", defaults]
518
+ if sync.artifact_blob_exists(recorded_hash, algo):
519
+ cmd += ["--force-rebuild", args.package]
481
520
  if ac_store:
482
521
  cmd += ["--ac-store", ac_store]
522
+ if getattr(args, "legacyStore", ""):
523
+ cmd += ["--legacy-links-store", args.legacyStore,
524
+ "--cas-public-url", args.casPublicUrl]
483
525
  if getattr(args, "insecure", False):
484
526
  cmd += ["--insecure"]
485
527
  if os.path.isdir(reference_dir):
486
528
  cmd += ["--reference-sources", reference_dir]
529
+ if getattr(args, "jobs", None):
530
+ cmd += ["-j", str(args.jobs)]
487
531
  if image:
488
532
  cmd += ["--docker", "--docker-image", image]
533
+ if getattr(args, "dockerExtraArgs", ""):
534
+ cmd.append("--docker-extra-args=" + args.dockerExtraArgs)
489
535
 
490
536
  # The materialised recipes are a plain directory, not an SCM checkout; pass the
491
537
  # alidist provenance explicitly so the build doesn't require a git repo (the
@@ -548,6 +594,17 @@ def do_rebaseline(args, sync, closure, result):
548
594
  result.algo, result.rebuilt)
549
595
  info(" orphaned old CAS blob: %s%s", old_cas,
550
596
  " (will delete)" if getattr(args, "delete_old", False) else " (left in place)")
597
+ if getattr(args, "dockerImage", None):
598
+ # Rebuilt in another image: record the one actually used, as `aliBuild build`
599
+ # does. Not in the action hash nor in the signed payload, so the entry keeps
600
+ # its key and is re-signed below like any re-baseline.
601
+ from argparse import Namespace
602
+ from alibuild_helpers.build import resolve_container_provenance
603
+ container = resolve_container_provenance(Namespace(docker=True,
604
+ dockerImage=args.dockerImage))
605
+ info(" rewrite action.container: %s -> %s", entry["action"].get("container"),
606
+ container)
607
+ entry = dict(entry, action=dict(entry["action"], container=container))
551
608
 
552
609
  if not getattr(args, "apply", False):
553
610
  warning("DRY RUN: nothing written. Re-run with --apply to perform the "
@@ -686,10 +743,26 @@ def doReconstruct(args, parser):
686
743
  ac_store = (getattr(args, "acStore", "") or "").rstrip()
687
744
  if ac_store.endswith("::rw"):
688
745
  ac_store = ac_store[:-4]
746
+ # A re-baseline changes the digest the AC entry's signature covers, so it must
747
+ # re-sign it: refuse to write without a way to, as `aliBuild build` does.
748
+ no_sign = getattr(args, "noSign", False)
749
+ dieOnError(getattr(args, "rebaseline", False) and getattr(args, "apply", False) and
750
+ not no_sign and not (getattr(args, "signUrl", "") and
751
+ (getattr(args, "signToken", "") or
752
+ getattr(args, "signTokenFile", ""))),
753
+ "--rebaseline --apply re-signs the rewritten Action Cache entry: pass "
754
+ "--sign-url and --sign-token (or --sign-token-file), or --no-sign to "
755
+ "leave it unsigned.")
689
756
  sync = remote_from_url(args.remoteStore, args.remoteStore, args.architecture,
690
757
  args.workDir, getattr(args, "insecure", False),
691
758
  ac_url=ac_store, ac_write_url=ac_store,
692
- storage=getattr(args, "storage", "permanent"))
759
+ storage=getattr(args, "storage", "permanent"),
760
+ sign_url="" if no_sign else getattr(args, "signUrl", ""),
761
+ sign_token=getattr(args, "signToken", ""),
762
+ sign_token_file=getattr(args, "signTokenFile", ""),
763
+ signer=getattr(args, "signer", "alibuild"),
764
+ legacy_url=getattr(args, "legacyStore", ""),
765
+ cas_public_url=getattr(args, "casPublicUrl", ""))
693
766
  dieOnError(not isinstance(sync, REAPIRemoteSync),
694
767
  "'aliBuild reconstruct' requires a reapi:// remote store, but got %r" %
695
768
  (args.remoteStore or "(none)"))
@@ -861,7 +861,7 @@ class REAPIRemoteSync(Boto3RemoteSync):
861
861
  match = re.search(r"store/[0-9a-f]{2}/([0-9a-f]+)/", target)
862
862
  return match.group(1) if match else None
863
863
 
864
- def migrate_put(self, ac_entry, tarball_path, recipe_text):
864
+ def migrate_put(self, ac_entry, tarball_path, recipe_text, sign=False):
865
865
  """Write a migrated legacy release into the reapi store: the tarball as a
866
866
  CAS blob, the recovered recipe blob, the Action Cache entry, plus the legacy
867
867
  store redirect and per-package link so it stays installable and
@@ -870,7 +870,8 @@ class REAPIRemoteSync(Boto3RemoteSync):
870
870
  Migrated entries are intentionally left *unsigned*: their provenance is
871
871
  reconstructed after the fact, so a signature would falsely assert a trusted
872
872
  signer built them. They are consumed as legacy (tolerated under
873
- --require-signature=warn, refused under require). Do not sign here."""
873
+ --require-signature=warn, refused under require). Only a re-baseline, which
874
+ rebuilt the tarball itself, passes sign=True."""
874
875
  action = ac_entry["action"]
875
876
  arch, pkg = action["architecture"], action["package"]
876
877
  action_hash = action["actionHash"]
@@ -892,6 +893,8 @@ class REAPIRemoteSync(Boto3RemoteSync):
892
893
  "outputDigest": "%s:%s" % (self.CAS_ALGO, content_hash),
893
894
  "size": os.path.getsize(tarball_path),
894
895
  })
896
+ if sign:
897
+ entry = self._sign_ac_entry(entry)
895
898
  ac_path = resolve_ac_path(arch, action_hash)
896
899
  debug("S3 put_object %s/%s (AC entry)", self.acWriteStore, ac_path)
897
900
  self.s3.put_object(Bucket=self.acWriteStore, Key=ac_path,
@@ -899,14 +902,14 @@ class REAPIRemoteSync(Boto3RemoteSync):
899
902
  ContentType="application/json")
900
903
 
901
904
  store_key = os.path.join(resolve_store_path(arch, action_hash), tarball)
902
- debug("S3 put_object %s/%s (store redirect)", self.writeStore, store_key)
905
+ debug("S3 put_object %s/%s (store redirect)", self.legacyWriteStore, store_key)
903
906
  self.s3.put_object(Bucket=self.legacyWriteStore, Key=store_key,
904
907
  Body=os.fsencode(cas_path),
905
908
  WebsiteRedirectLocation=self._cas_redirect(cas_path))
906
909
 
907
910
  link_target = "../../%s/store/%s/%s/%s" % (arch, action_hash[:2], action_hash, tarball)
908
911
  link_key = os.path.join(resolve_links_path(arch, pkg), tarball)
909
- debug("S3 put_object %s/%s (link)", self.writeStore, link_key)
912
+ debug("S3 put_object %s/%s (link)", self.legacyWriteStore, link_key)
910
913
  # The link stays RELATIVE: it points at the store object beside it in the
911
914
  # same tree, and the client reads its body rather than following the header.
912
915
  self.s3.put_object(Bucket=self.legacyWriteStore, Key=link_key,
@@ -971,7 +974,9 @@ class REAPIRemoteSync(Boto3RemoteSync):
971
974
  is an in-place pointer swap. The new blob is stored *before* the AC entry is
972
975
  repointed, so a failure never leaves the entry dangling; the old blob is left
973
976
  orphaned (delete it separately via delete_artifact_blob). The retention of the
974
- blob being replaced is preserved (untagged == keep-forever == permanent).
977
+ blob being replaced is preserved (untagged == keep-forever == permanent). The
978
+ old signatures covered the old digest: they are dropped, and the entry is
979
+ signed afresh when signing is configured.
975
980
  Returns (old_hash, new_hash, old_cas_path)."""
976
981
  old_digest = (entry.get("result") or {}).get("outputDigest", "")
977
982
  old_hash = old_digest.split(":", 1)[-1]
@@ -982,7 +987,8 @@ class REAPIRemoteSync(Boto3RemoteSync):
982
987
  self.storage = self._retention_of(self.writeStore, old_cas_path) or "permanent"
983
988
  try:
984
989
  new_hash = self.migrate_put(
985
- {k: v for k, v in entry.items() if k != "result"}, tarball_path, recipe_text)
990
+ {k: v for k, v in entry.items() if k not in ("result", "signatures")},
991
+ tarball_path, recipe_text, sign=True)
986
992
  finally:
987
993
  self.storage = prev_storage
988
994
  return old_hash, new_hash, old_cas_path
@@ -404,6 +404,14 @@ aliBuild reconstruct O2 --version nightly-20261015 \
404
404
  store redirect to the rebuilt hash, so later verifications are byte-identical.
405
405
  A dry run unless `--apply`; `--delete-old` additionally removes the blob the
406
406
  re-baseline orphans.
407
+ - `--docker-image IMAGE`: rebuild in `IMAGE` instead of the recorded build
408
+ container, e.g. when that has been deleted from the registry. The container is
409
+ not part of the action hash; `--rebaseline --apply` records `IMAGE` as the
410
+ entry's `action.container`. Expect `--persist` to reproduce only packages whose
411
+ output does not depend on the image.
412
+ - `-j N`, `--docker-extra-args ARGS`: passed to the rebuild's `aliBuild build`,
413
+ e.g. `-j 8 --docker-extra-args='--cpus=8 --memory=32g'` to keep it within a
414
+ batch slot.
407
415
  - `--output-config DIR`: where to materialise the recipes. Defaults to
408
416
  `WORKDIR/reconstruct-PACKAGE`.
409
417
  - `--alidist DIR`: an alidist checkout to take the defaults file
@@ -1,4 +1,5 @@
1
1
  import hashlib
2
+ import json
2
3
  import os
3
4
  import os.path
4
5
  import shutil
@@ -551,6 +552,140 @@ class ReconstructTestCase(unittest.TestCase):
551
552
  workDir="/sw", outputConfig=None)
552
553
  self.assertRaises(SystemExit, doReconstruct, args, None)
553
554
 
555
+ def _publish_args(self, **kw):
556
+ return Namespace(package="zlib", version="v1", revision="1", architecture=ARCH,
557
+ remoteStore="reapi://proxy/cas", acStore="reapi://proxy/ac::rw",
558
+ insecure=True, workDir="/sw", outputConfig=None,
559
+ rebaseline=True, apply=True, legacyStore="reapi://proxy/repo",
560
+ casPublicUrl="https://example/cas", **kw)
561
+
562
+ def test_doReconstruct_refuses_rebaseline_apply_without_signer(self):
563
+ with patch("alibuild_helpers.reconstruct.remote_from_url") as remote:
564
+ self.assertRaises(SystemExit, doReconstruct, self._publish_args(), None)
565
+ remote.assert_not_called() # refused before touching any store
566
+
567
+ def test_doReconstruct_passes_publishing_options_like_build(self):
568
+ # Stop right after the store is built: it is not a REAPIRemoteSync.
569
+ for no_sign, sign_url in ((False, "https://proxy/sign"), (True, "")):
570
+ args = self._publish_args(signUrl="https://proxy/sign", signToken="",
571
+ signTokenFile="/tok", signer="ci", noSign=no_sign)
572
+ with patch("alibuild_helpers.reconstruct.remote_from_url",
573
+ return_value=object()) as remote:
574
+ self.assertRaises(SystemExit, doReconstruct, args, None)
575
+ kw = remote.call_args.kwargs
576
+ self.assertEqual((kw["legacy_url"], kw["cas_public_url"]),
577
+ ("reapi://proxy/repo", "https://example/cas"))
578
+ self.assertEqual((kw["sign_url"], kw["sign_token_file"], kw["signer"]),
579
+ (sign_url, "/tok", "ci"))
580
+
581
+ @patch("alibuild_helpers.signing.sign_via_proxy")
582
+ @patch("alibuild_helpers.sync_reapi.REAPIRemoteSync._s3_init", new=MagicMock())
583
+ def test_do_rebaseline_reproduced_digest_leaves_ac_entry_untouched(self, sign_via_proxy):
584
+ s = sync_reapi.REAPIRemoteSync(
585
+ "reapi://proxy/cas", "reapi://proxy/cas", ARCH, "/sw",
586
+ legacyStore="reapi://proxy/repo", casPublicUrl="https://example/cas",
587
+ sign_url="https://proxy/sign", sign_token="tok")
588
+ s.s3 = MagicMock()
589
+ result = RebuildResult(True, kind="match", algo="sha256",
590
+ recorded="a" * 64, rebuilt="a" * 64, tarball="/x")
591
+ self.assertTrue(do_rebaseline(Namespace(package="zlib", version="v1", apply=True,
592
+ delete_old=False), s,
593
+ [self._rebaseline_entry()], result))
594
+ sign_via_proxy.assert_not_called()
595
+ s.s3.put_object.assert_not_called()
596
+ s.s3.upload_file.assert_not_called()
597
+
598
+ def test_verify_rebuild_keeps_the_recorded_hash_and_revision(self):
599
+ """A missing blob is rebuilt under its recorded action hash and revision,
600
+ which are in the tarball: no --force-rebuild, and the legacy links in view."""
601
+ closure = [make_entry("zlib", "v1", "1", "c" * 64, "rz")]
602
+ args = self._rebuild_args()
603
+ args.legacyStore, args.casPublicUrl = "reapi://x/repo", "https://example/cas"
604
+ for present, forced in ((False, False), (True, True)):
605
+ commands = []
606
+ with patch("alibuild_helpers.reconstruct.materialize_recipes"), \
607
+ patch("alibuild_helpers.reconstruct.restore_sources", return_value=([], [])), \
608
+ patch("alibuild_helpers.reconstruct.GitSourceStore"):
609
+ verify_rebuild(args, self.make_sync({"c" * 64} if present else ()), closure,
610
+ build_runner=lambda cmd: commands.append(cmd) or 1)
611
+ self.assertEqual("--force-rebuild" in commands[0], forced)
612
+ self.assertIn("--legacy-links-store", commands[0])
613
+ self.assertIn("https://example/cas", commands[0])
614
+
615
+ def test_verify_rebuild_docker_image_override_and_jobs(self):
616
+ """--docker-image replaces the recorded container; -j and
617
+ --docker-extra-args reach the isolated build."""
618
+ closure = [self.entries["hash-zlib"]] # recorded alisw/slc7-builder@sha256:abc
619
+ for override, jobs, image in ((None, None, "alisw/slc7-builder@sha256:abc"),
620
+ ("reg/new@sha256:def", 8, "reg/new@sha256:def")):
621
+ args = self._rebuild_args()
622
+ args.dockerImage, args.jobs, args.dockerExtraArgs = override, jobs, "--cpus=8"
623
+ commands = []
624
+ with patch("alibuild_helpers.reconstruct.materialize_recipes"), \
625
+ patch("alibuild_helpers.reconstruct.restore_sources", return_value=([], [])), \
626
+ patch("alibuild_helpers.reconstruct.GitSourceStore"):
627
+ verify_rebuild(args, self.make_sync(()), closure,
628
+ build_runner=lambda cmd: commands.append(cmd) or 1)
629
+ cmd = commands[0]
630
+ self.assertEqual(cmd[cmd.index("--docker-image") + 1], image)
631
+ self.assertIn("--docker-extra-args=--cpus=8", cmd)
632
+ if jobs:
633
+ self.assertEqual(cmd[cmd.index("-j") + 1], "8")
634
+ else:
635
+ self.assertNotIn("-j", cmd)
636
+
637
+ @patch("alibuild_helpers.signing.sign_via_proxy")
638
+ @patch("alibuild_helpers.sync_reapi.REAPIRemoteSync._s3_init", new=MagicMock())
639
+ def test_do_rebaseline_records_the_override_container_and_stays_signed(self, sign_via_proxy):
640
+ from alibuild_helpers import signing
641
+ seed = bytes(range(32))
642
+ keyid, pub = signing.public_key(seed)
643
+ sign_via_proxy.side_effect = lambda entry, url, tok, signer, **kw: \
644
+ signing.sign(entry, seed, signer)
645
+ s = sync_reapi.REAPIRemoteSync(
646
+ "reapi://proxy/cas", "reapi://proxy/cas", ARCH, "/sw",
647
+ legacyStore="reapi://proxy/repo", casPublicUrl="https://example/cas",
648
+ sign_url="https://proxy/sign", sign_token="tok")
649
+ s.s3 = MagicMock()
650
+ tarball = os.path.join(self.tmp, "zlib.tar.gz")
651
+ with open(tarball, "wb") as handle:
652
+ handle.write(b"rebuilt")
653
+ rebuilt = hashlib.sha256(b"rebuilt").hexdigest()
654
+ result = RebuildResult(True, kind="differ", algo="sha256", recorded="a" * 64,
655
+ rebuilt=rebuilt, tarball=tarball)
656
+ used = {"runtime": "docker", "image": "reg/new@sha256:def",
657
+ "digest": "reg/new@sha256:def"}
658
+ entry = make_entry("zlib", "v1", "1", "a" * 64, "rz",
659
+ container={"image": "reg/gone", "digest": "reg/gone@sha256:abc"})
660
+ with patch("alibuild_helpers.build.resolve_container_provenance",
661
+ return_value=used) as resolve:
662
+ self.assertTrue(do_rebaseline(
663
+ Namespace(package="zlib", version="v1", apply=True, delete_old=False,
664
+ dockerImage="reg/new@sha256:def"), s, [entry], result))
665
+ self.assertEqual(resolve.call_args.args[0].dockerImage, "reg/new@sha256:def")
666
+ written = [json.loads(c.kwargs["Body"]) for c in s.s3.put_object.call_args_list
667
+ if c.kwargs["Key"].startswith("ac/")]
668
+ self.assertEqual(len(written), 1)
669
+ self.assertEqual(written[0]["action"]["container"], used)
670
+ self.assertEqual(written[0]["result"]["outputDigest"], "sha256:" + rebuilt)
671
+ ring = signing.load_keyring({"keys": {keyid: {"publicKey": pub, "signer": "ci"}},
672
+ "revoked": []})
673
+ self.assertTrue(signing.verify(written[0], ring)[0])
674
+ # The closure's own entry is not mutated.
675
+ self.assertEqual(entry["action"]["container"]["image"], "reg/gone")
676
+
677
+ def test_do_persist_with_override_leaves_the_ac_entry_alone(self):
678
+ result = RebuildResult(True, kind="match", algo="sha256",
679
+ recorded="a" * 64, rebuilt="a" * 64, tarball="/x")
680
+ sync_mock = MagicMock()
681
+ sync_mock.artifact_blob_exists.return_value = False
682
+ sync_mock.put_artifact_blob.return_value = "a" * 64
683
+ args = self._persist_args(apply=True)
684
+ args.dockerImage = "reg/new@sha256:def"
685
+ self.assertTrue(do_persist(args, sync_mock, [self._rebaseline_entry()], result))
686
+ self.assertEqual({call[0] for call in sync_mock.method_calls},
687
+ {"artifact_blob_exists", "put_artifact_blob"})
688
+
554
689
 
555
690
  if __name__ == "__main__":
556
691
  unittest.main()
@@ -572,6 +572,51 @@ class REAPIRemoteSyncTestCase(unittest.TestCase):
572
572
  # storage restored to its original value afterwards (no leak).
573
573
  self.assertEqual(reapi.storage, "ephemeral")
574
574
 
575
+ @patch("alibuild_helpers.signing.sign_via_proxy")
576
+ @patch("os.path.getsize", new=MagicMock(return_value=4096))
577
+ def test_rebaseline_resigns_and_publishes_to_the_legacy_store(self, sign_via_proxy) -> None:
578
+ """A re-baselined entry carries a fresh signature over the NEW digest, and
579
+ its store object and link go to the legacy bucket with an absolute redirect."""
580
+ sign_via_proxy.return_value = {"keyid": "new", "signer": "ci", "sig": "fresh"}
581
+ old_hash, new_hash = "a" * 64, "b" * 64
582
+ client = self.make_client()
583
+ reapi = sync_reapi.REAPIRemoteSync(
584
+ remoteStore="reapi://localhost/bucket", writeStore="reapi://localhost/bucket",
585
+ architecture=ARCHITECTURE, workdir="/sw", legacyStore="reapi://localhost/legacy",
586
+ casPublicUrl="https://example/cas", sign_url="https://proxy/sign",
587
+ sign_token="tok")
588
+ reapi.s3 = client
589
+ entry = {
590
+ "schemaVersion": 3,
591
+ "action": {"package": "zlib", "version": "v1", "revision": "1",
592
+ "architecture": ARCHITECTURE, "actionHash": REAPI_HASH,
593
+ "recipeDigest": "sha256:" + REAPI_RECIPE_DIGEST},
594
+ "result": {"tarball": "zlib-v1-1.%s.tar.gz" % ARCHITECTURE,
595
+ "outputDigest": "sha256:" + old_hash, "size": 1},
596
+ "signatures": [{"keyid": "old", "signer": "ci", "sig": "stale"}],
597
+ }
598
+ with patch("alibuild_helpers.sync_reapi.file_digest", return_value=new_hash):
599
+ reapi.rebaseline_ac_entry(entry, "/tmp/zlib.tar.gz", "recipe")
600
+ # Signed over the new digest, with the stale signature gone.
601
+ signed = sign_via_proxy.call_args.args[0]
602
+ self.assertEqual(signed["result"]["outputDigest"], "sha256:" + new_hash)
603
+ self.assertNotIn("signatures", signed)
604
+ puts = {c.kwargs["Key"]: c.kwargs for c in client.put_object.call_args_list}
605
+ ac = json.loads(puts[resolve_ac_path(ARCHITECTURE, REAPI_HASH)]["Body"].decode())
606
+ self.assertEqual(ac["signatures"], [sign_via_proxy.return_value])
607
+ self.assertEqual(ac["result"]["outputDigest"], "sha256:" + new_hash)
608
+ # Store object and link: legacy bucket, absolute redirect to the new blob.
609
+ tarball = "zlib-v1-1.%s.tar.gz" % ARCHITECTURE
610
+ stub = puts[resolve_store_path(ARCHITECTURE, REAPI_HASH) + "/" + tarball]
611
+ link = puts[resolve_links_path(ARCHITECTURE, "zlib") + "/" + tarball]
612
+ self.assertEqual(stub["Bucket"], "legacy")
613
+ self.assertEqual(stub["WebsiteRedirectLocation"],
614
+ "https://example/cas/" + resolve_cas_path(new_hash))
615
+ self.assertEqual(link["Bucket"], "legacy")
616
+ # The bytes and the ledger stay where they were.
617
+ self.assertEqual(client.upload_file.call_args.kwargs["Bucket"], "bucket")
618
+ self.assertEqual(puts[resolve_ac_path(ARCHITECTURE, REAPI_HASH)]["Bucket"], "bucket")
619
+
575
620
  @patch("alibuild_helpers.sync_reapi.file_digest", new=MagicMock(return_value="e" * 64))
576
621
  @patch("os.path.getsize", new=MagicMock(return_value=4096))
577
622
  def test_put_legacy_artifact(self) -> None:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes