13
13
from alibuild_helpers .utilities import Hasher
14
14
from alibuild_helpers .utilities import yamlDump
15
15
from alibuild_helpers .utilities import resolve_tag , resolve_version
16
- from alibuild_helpers .git import git , clone_speedup_options , Git
16
+ from alibuild_helpers .git import Git , git
17
17
from alibuild_helpers .sl import Sapling
18
18
from alibuild_helpers .scm import SCMError
19
19
from alibuild_helpers .sync import remote_from_url
20
20
import yaml
21
- from alibuild_helpers .workarea import logged_scm , updateReferenceRepoSpec
21
+ from alibuild_helpers .workarea import logged_scm , updateReferenceRepoSpec , checkout_sources
22
22
from alibuild_helpers .log import ProgressPrint , log_current_package
23
23
from glob import glob
24
24
from textwrap import dedent
@@ -69,9 +69,7 @@ def update_repo(package, git_prompt):
69
69
if exists (os .path .join (specs [package ]["source" ], ".sl" )):
70
70
specs [package ]["scm" ] = Sapling ()
71
71
updateReferenceRepoSpec (args .referenceSources , package , specs [package ],
72
- fetch = args .fetchRepos ,
73
- usePartialClone = not args .docker ,
74
- allowGitPrompt = git_prompt )
72
+ fetch = args .fetchRepos , allowGitPrompt = git_prompt )
75
73
76
74
# Retrieve git heads
77
75
output = logged_scm (specs [package ]["scm" ], package , args .referenceSources ,
@@ -967,10 +965,6 @@ def doBuild(args, parser):
967
965
if spec ["cachedTarball" ] else "No cache tarballs found" )
968
966
969
967
# The actual build script.
970
- referenceStatement = ""
971
- if "reference" in spec :
972
- referenceStatement = "export GIT_REFERENCE=${GIT_REFERENCE_OVERRIDE:-%s}/%s" % (dirname (spec ["reference" ]), basename (spec ["reference" ]))
973
-
974
968
debug ("spec = %r" , spec )
975
969
976
970
cmd_raw = ""
@@ -982,22 +976,14 @@ def doBuild(args, parser):
982
976
from pkg_resources import resource_string
983
977
cmd_raw = resource_string ("alibuild_helpers" , 'build_template.sh' )
984
978
985
- source = spec .get ("source" , "" )
986
- # Shortend the commit hash in case it's a real commit hash and not simply
987
- # the tag.
988
- commit_hash = spec ["commit_hash" ]
989
- if spec ["tag" ] != spec ["commit_hash" ]:
990
- commit_hash = spec ["commit_hash" ][0 :10 ]
991
-
992
- # Split the source in two parts, sourceDir and sourceName. This is done so
993
- # that when we use Docker we can replace sourceDir with the correct
994
- # container path, if required. No changes for what concerns the standard
995
- # bash builds, though.
996
979
if args .docker :
997
980
cachedTarball = re .sub ("^" + workDir , "/sw" , spec ["cachedTarball" ])
998
981
else :
999
982
cachedTarball = spec ["cachedTarball" ]
1000
983
984
+ if not cachedTarball :
985
+ checkout_sources (spec , workDir , args .referenceSources , args .docker )
986
+
1001
987
scriptDir = join (workDir , "SPECS" , args .architecture , spec ["package" ],
1002
988
spec ["version" ] + "-" + spec ["revision" ])
1003
989
@@ -1011,11 +997,6 @@ def doBuild(args, parser):
1011
997
"workDir" : workDir ,
1012
998
"configDir" : abspath (args .configDir ),
1013
999
"incremental_recipe" : spec .get ("incremental_recipe" , ":" ),
1014
- "sourceDir" : (dirname (source ) + "/" ) if source else "" ,
1015
- "sourceName" : basename (source ) if source else "" ,
1016
- "referenceStatement" : referenceStatement ,
1017
- "gitOptionsStatement" : "" if args .docker else
1018
- "export GIT_CLONE_SPEEDUP=" + quote (" " .join (clone_speedup_options ())),
1019
1000
"requires" : " " .join (spec ["requires" ]),
1020
1001
"build_requires" : " " .join (spec ["build_requires" ]),
1021
1002
"runtime_requires" : " " .join (spec ["runtime_requires" ]),
@@ -1028,14 +1009,14 @@ def doBuild(args, parser):
1028
1009
("BUILD_REQUIRES" , " " .join (spec ["build_requires" ])),
1029
1010
("CACHED_TARBALL" , cachedTarball ),
1030
1011
("CAN_DELETE" , args .aggressiveCleanup and "1" or "" ),
1031
- ("COMMIT_HASH" , commit_hash ),
1012
+ # Shorten the commit hash if it's a real commit hash and not simply the tag.
1013
+ ("COMMIT_HASH" , spec ["tag" ] if spec ["tag" ] == spec ["commit_hash" ] else spec ["commit_hash" ][:10 ]),
1032
1014
("DEPS_HASH" , spec .get ("deps_hash" , "" )),
1033
1015
("DEVEL_HASH" , spec .get ("devel_hash" , "" )),
1034
1016
("DEVEL_PREFIX" , develPrefix ),
1035
1017
("BUILD_FAMILY" , spec ["build_family" ]),
1036
1018
("GIT_COMMITTER_NAME" , "unknown" ),
1037
1019
("GIT_COMMITTER_EMAIL" , "unknown" ),
1038
- ("GIT_TAG" , spec ["tag" ]),
1039
1020
("INCREMENTAL_BUILD_HASH" , spec .get ("incremental_hash" , "0" )),
1040
1021
("JOBS" , str (args .jobs )),
1041
1022
("PKGHASH" , spec ["hash" ]),
@@ -1048,7 +1029,6 @@ def doBuild(args, parser):
1048
1029
("FULL_RUNTIME_REQUIRES" , " " .join (spec ["full_runtime_requires" ])),
1049
1030
("FULL_BUILD_REQUIRES" , " " .join (spec ["full_build_requires" ])),
1050
1031
("FULL_REQUIRES" , " " .join (spec ["full_requires" ])),
1051
- ("WRITE_REPO" , spec .get ("write_repo" , source )),
1052
1032
]
1053
1033
# Add the extra environment as passed from the command line.
1054
1034
buildEnvironment += [e .partition ('=' )[::2 ] for e in args .environment ]
@@ -1059,15 +1039,13 @@ def doBuild(args, parser):
1059
1039
build_command = (
1060
1040
"docker run --rm --entrypoint= --user $(id -u):$(id -g) "
1061
1041
"-v {workdir}:/sw -v {scriptDir}/build.sh:/build.sh:ro "
1062
- "-e GIT_REFERENCE_OVERRIDE=/mirror -e WORK_DIR_OVERRIDE=/sw "
1063
1042
"{mirrorVolume} {develVolumes} {additionalEnv} {additionalVolumes} "
1064
- "{overrideSource} {extraArgs} {image} bash -ex /build.sh"
1043
+ "-e WORK_DIR_OVERRIDE=/sw {extraArgs} {image} bash -ex /build.sh"
1065
1044
).format (
1066
1045
image = quote (args .dockerImage ),
1067
1046
workdir = quote (abspath (args .workDir )),
1068
1047
scriptDir = quote (scriptDir ),
1069
1048
extraArgs = " " .join (map (quote , args .docker_extra_args )),
1070
- overrideSource = "-e SOURCE0_DIR_OVERRIDE=/" if source .startswith ("/" ) else "" ,
1071
1049
additionalEnv = " " .join (
1072
1050
"-e {}={}" .format (var , quote (value )) for var , value in buildEnvironment ),
1073
1051
# Used e.g. by O2DPG-sim-tests to find the O2DPG repository.
0 commit comments