| |
@@ -127,18 +127,23 @@
|
| |
|
| |
# Get a list of the original English repos
|
| |
repos = []
|
| |
+ default_branch = site_yml["content"].get("branches", ["master"])
|
| |
+ if type(default_branch) is str:
|
| |
+ default_branch = [default_branch]
|
| |
+
|
| |
for repo_data in site_yml["content"]["sources"]:
|
| |
|
| |
- if "branches" not in repo_data:
|
| |
- repo_data["branches"] = ["master"]
|
| |
- if "start_path" not in repo_data:
|
| |
- repo_data["start_path"] = ""
|
| |
+ branches = repo_data.get("branches", default_branch)
|
| |
+ if type(branches) is str:
|
| |
+ branches = [branches]
|
| |
+
|
| |
+ start_path = repo_data.get("start_path", "")
|
| |
|
| |
- for branch in repo_data["branches"]:
|
| |
+ for branch in branches:
|
| |
repo = {}
|
| |
repo["url"] = repo_data["url"]
|
| |
repo["branch"] = branch
|
| |
- repo["start_path"] = repo_data["start_path"]
|
| |
+ repo["start_path"] = start_path
|
| |
|
| |
repos.append(repo)
|
| |
|
| |
@@ -177,11 +182,11 @@
|
| |
original_module_dir = os.path.join(repo_dir, "modules", module)
|
| |
module_dir = os.path.join(en_sources, component, version, "modules", module)
|
| |
|
| |
- subprocess.run(["cp", "-r", original_module_dir, module_dir])
|
| |
+ subprocess.run(["cp", "-a", original_module_dir, module_dir])
|
| |
|
| |
if module == "ROOT" or "nav" in antora_yml:
|
| |
# if this is the main antora.yml file
|
| |
- subprocess.run(["cp", "-r", antora_yml_file, os.path.join(en_sources, component, version, "antora.yml")])
|
| |
+ subprocess.run(["cp", "-a", antora_yml_file, os.path.join(en_sources, component, version, "antora.yml")])
|
| |
log("----- copying antora.yml for {component} {module} {version}".format(
|
| |
component=component, module=module, version=version))
|
| |
else:
|
| |
@@ -202,13 +207,13 @@
|
| |
lang_dir = os.path.join(translated_sources, language)
|
| |
for component in components:
|
| |
en_component_dir = os.path.join(en_sources, component)
|
| |
- subprocess.run(["cp", "-r", en_component_dir, lang_dir])
|
| |
+ subprocess.run(["cp", "-a", en_component_dir, lang_dir])
|
| |
|
| |
# And finally copy the original translated sources
|
| |
# into translated_sources
|
| |
for language in languages:
|
| |
src = os.path.join(translated_sources_original, language)
|
| |
- subprocess.run(["cp", "-r", src, translated_sources + "/"])
|
| |
+ subprocess.run(["cp", "-a", src, translated_sources + "/"])
|
| |
|
| |
return components
|
| |
|
| |
@@ -299,7 +304,7 @@
|
| |
target_dir_copied = "/antora/output/en-US.building/en-US"
|
| |
target_dir_final = "/antora/output/en-US"
|
| |
shutil.rmtree(target_dir_copying, ignore_errors=True)
|
| |
- subprocess.run(["cp", "-r", source_dir, target_dir_copying])
|
| |
+ subprocess.run(["cp", "-a", source_dir, target_dir_copying])
|
| |
shutil.rmtree(target_dir_final, ignore_errors=True)
|
| |
shutil.move(target_dir_copied, target_dir_final)
|
| |
shutil.rmtree(target_dir_copying, ignore_errors=True)
|
| |
@@ -363,18 +368,48 @@
|
| |
sys.exit(1)
|
| |
|
| |
# Copying all the translated sites
|
| |
+ log("")
|
| |
+ log("=== Copying translated sites ===")
|
| |
+
|
| |
+ results_dir = os.path.join(docs_repo, "public")
|
| |
+ publish_dir = "/antora/output"
|
| |
+ copying_dir = os.path.join(publish_dir, "copying.tmp")
|
| |
+
|
| |
+ # I have:
|
| |
+ # docs_repo/public <- results_dir (local partition)
|
| |
+ # /antora/output/copying.tmp <- copying_dir (mounted partition)
|
| |
+ # /antora/output <- publish_dir (mounted partition)
|
| |
+ #
|
| |
+ # I need to:
|
| |
+ # 1/ copy from local to mounted
|
| |
+ # 2/ remove old in mounted
|
| |
+ # 3/ move new within mounted
|
| |
+ # 4/ remove the copying dir
|
| |
+
|
| |
+ # Make sure copying_dir exists and is empty
|
| |
+ shutil.rmtree(copying_dir, ignore_errors=True)
|
| |
+ subprocess.run(["mkdir", copying_dir])
|
| |
+
|
| |
+ # Copy results from local partition to a mounted partition
|
| |
+ log("Copying between partitions...")
|
| |
+ subprocess.run(["cp", "-a", results_dir, "{}/".format(copying_dir)])
|
| |
+
|
| |
+ # Swap the old tree for the new one for each language
|
| |
+ log("Moving languages to the final place:")
|
| |
for lang in languages:
|
| |
- log("")
|
| |
- log("===== Copying the {lang} site =====".format(lang=lang))
|
| |
- source_dir = os.path.join(docs_repo, "public")
|
| |
- target_dir_copying = "/antora/output/{lang}.building".format(lang=lang)
|
| |
- target_dir_copied = "/antora/output/{lang}.building/{lang}".format(lang=lang)
|
| |
- target_dir_final = "/antora/output/{lang}".format(lang=lang)
|
| |
- shutil.rmtree(target_dir_copying, ignore_errors=True)
|
| |
- subprocess.run(["cp", "-r", source_dir, target_dir_copying])
|
| |
- shutil.rmtree(target_dir_final, ignore_errors=True)
|
| |
- shutil.move(target_dir_copied, target_dir_final)
|
| |
- shutil.rmtree(target_dir_copying, ignore_errors=True)
|
| |
+ log(" - {}".format(lang))
|
| |
+ shutil.rmtree(os.path.join(publish_dir, lang), ignore_errors=True)
|
| |
+ subprocess.run(["mv", os.path.join(copying_dir, "public", lang), "{}/".format(publish_dir)])
|
| |
+
|
| |
+ # https://pagure.io/fedora-infrastructure/issue/8964
|
| |
+ log("Consolidate files with hardlink...")
|
| |
+ subprocess.run(["hardlink", "-v", "{}/".format(publish_dir)])
|
| |
+
|
| |
+ # And finally remove the copying dir
|
| |
+ log("Removing the copying dir...")
|
| |
+ shutil.rmtree(copying_dir, ignore_errors=True)
|
| |
+
|
| |
+ log("DONE!")
|
| |
|
| |
|
| |
|
| |
Related: https://pagure.io/fedora-docs/docs-fp-o/issue/160
These are some missing commits from prod that should also be in stg.
It should be enough to get translated build working on staging again.