Recent versions of rpm dropped Berkely DB support and use SQLite as
backend DB by default. If host machine's rpm uses bdb as default backend
db, use Photon builder docker image to install toolchain rpms and it
will result in using SQLite as default db because Photon's latest docker
image uses SQLite by default.
We need to build and use photon_builder image because k8s build image
script use this docker image for various reasons.
build.py:
- Code cleanups & refactoring in few places
- Import docker image whenever necessary
- Use single instance of CommandUtils
- Remove PHOTON_DOCKER_IMAGE environment variable support
- Use a helper script to import docker image.
- Move docker related checks to check_tools
- Check for tools once in the beginning of build
- Use --update with createrepo, reduces repodata IO operations
tools/scripts:
- Add a helper script for importing docker image
- tools/src:
- Use makefile to build contain_priv
support/dockerfiles:
- Get active network interface name dynamically
- Get builder tag name from caller as function arg in k8s build scripts
support/image-builder/iso:
- Check for sqlite support in host rpm and init rpm db accordingly.
support/image-builder/ostree-tools:
- Use rpms from local repo
- Rectify the script and repo file
Change-Id: I5d7af557ad51a1201d17625c2b56f3b6cb60416a
Signed-off-by: Shreenidhi Shedi <sshedi@vmware.com>
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/16591
Tested-by: gerrit-photon <photon-checkins@vmware.com>
| 6 | 6 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,21 @@ |
| 0 |
+{
|
|
| 1 |
+ "photon-build-param" : {
|
|
| 2 |
+ "photon-build-type" : "chroot", |
|
| 3 |
+ "photon-dist-tag" : ".ph4", |
|
| 4 |
+ "photon-release-version" : "4.0", |
|
| 5 |
+ "threads" : 4, |
|
| 6 |
+ "loglevel" : "info", |
|
| 7 |
+ "full-package-list-file" : "build_install_options_all.json", |
|
| 8 |
+ "pkg-build-options" : "pkg_build_options.json", |
|
| 9 |
+ |
|
| 10 |
+ "photon-docker-image" : "photon:4.0", |
|
| 11 |
+ "ph-docker-img-url" : "https://github.com/vmware/photon-docker-image/raw/ARCH/4.0-20220715/docker/photon-rootfs-4.0-fe8804ac9.tar.gz", |
|
| 12 |
+ "ph-builder-tag" : "photon_builder:4.0", |
|
| 13 |
+ |
|
| 14 |
+ "target": "iso", |
|
| 15 |
+ "compression-macro": "w19.zstdio" |
|
| 16 |
+ }, |
|
| 17 |
+ "photon-path" : "", |
|
| 18 |
+ "stage-path" : "" , |
|
| 19 |
+ "spec-path" : "" |
|
| 20 |
+} |
| ... | ... |
@@ -1,53 +1,60 @@ |
| 1 | 1 |
#!/usr/bin/env python3 |
| 2 | 2 |
|
| 3 |
-import sys |
|
| 4 | 3 |
import os |
| 4 |
+import sys |
|
| 5 |
+ |
|
| 5 | 6 |
sys.path.insert(0, os.path.join(os.path.dirname(os.path.realpath(__file__)), "support/package-builder")) |
| 6 | 7 |
sys.path.insert(1, os.path.join(os.path.dirname(os.path.realpath(__file__)), "support/image-builder")) |
| 7 |
-from pathlib import PurePath |
|
| 8 |
-from constants import constants |
|
| 9 |
-from argparse import ArgumentParser |
|
| 10 |
-from CommandUtils import CommandUtils |
|
| 11 |
-from builder import Builder |
|
| 12 |
-from Logger import Logger |
|
| 13 |
-from utils import Utils |
|
| 14 |
-from StringUtils import StringUtils |
|
| 15 |
-import subprocess |
|
| 16 |
-import json |
|
| 8 |
+ |
|
| 17 | 9 |
import docker |
| 10 |
+import glob |
|
| 11 |
+import io |
|
| 12 |
+import json |
|
| 13 |
+import subprocess |
|
| 18 | 14 |
import shutil |
| 19 | 15 |
import traceback |
| 20 |
-import glob |
|
| 16 |
+ |
|
| 17 |
+import imagebuilder |
|
| 21 | 18 |
import PullSources as downloader |
| 22 |
-from subprocess import PIPE, Popen |
|
| 23 |
-from distutils.util import strtobool |
|
| 19 |
+ |
|
| 20 |
+from argparse import ArgumentParser |
|
| 21 |
+from builder import Builder |
|
| 22 |
+from constants import constants |
|
| 23 |
+from CommandUtils import CommandUtils |
|
| 24 |
+from Logger import Logger |
|
| 25 |
+from pathlib import PurePath |
|
| 26 |
+from StringUtils import StringUtils |
|
| 24 | 27 |
from SpecDeps import SpecDependencyGenerator |
| 25 | 28 |
from SpecData import SPECS |
| 26 | 29 |
from support.check_spec import check_specs |
| 30 |
+from utils import Utils |
|
| 31 |
+ |
|
| 32 |
+from distutils.util import strtobool |
|
| 33 |
+from subprocess import PIPE, Popen |
|
| 27 | 34 |
|
| 28 | 35 |
configdict = {}
|
| 29 | 36 |
|
| 30 | 37 |
targetList = {
|
| 31 |
- "image":["iso", "ami", "gce", "azure", "rpi", "ova", "ova_uefi", "all", "src-iso", "ls1012afrwy", |
|
| 32 |
- "photon-docker-image", "k8s-docker-images", "all-images", "minimal-iso", "rt-iso"], |
|
| 38 |
+ "image":["iso", "ami", "gce", "azure", "rpi", "ova", "ova_uefi", "all", "src-iso", "ls1012afrwy", |
|
| 39 |
+ "photon-docker-image", "k8s-docker-images", "all-images", "minimal-iso", "rt-iso"], |
|
| 33 | 40 |
|
| 34 |
- "rpmBuild": ["packages", "packages-minimal", "packages-initrd", "packages-docker", |
|
| 35 |
- "updated-packages", "tool-chain-stage1", "tool-chain-stage2", "check-packages", |
|
| 36 |
- "ostree-repo", "generate-yaml-files", "create-repo", "distributed-build"], |
|
| 41 |
+ "rpmBuild": ["packages", "packages-minimal", "packages-initrd", "packages-docker", |
|
| 42 |
+ "updated-packages", "tool-chain-stage1", "tool-chain-stage2", "check-packages", |
|
| 43 |
+ "ostree-repo", "generate-yaml-files", "create-repo", "distributed-build"], |
|
| 37 | 44 |
|
| 38 |
- "buildEnvironment": ["packages-cached", "sources", "sources-cached", "publish-rpms", "publish-x-rpms", |
|
| 39 |
- "publish-rpms-cached", "publish-x-rpms-cached", "photon-stage","photon_builder_image"], |
|
| 45 |
+ "buildEnvironment": ["packages-cached", "sources", "sources-cached", "publish-rpms", "publish-x-rpms", |
|
| 46 |
+ "publish-rpms-cached", "publish-x-rpms-cached", "photon-stage","photon_builder_image"], |
|
| 40 | 47 |
|
| 41 |
- "cleanup": ["clean", "clean-install", "clean-chroot", "clean-stage-for-incremental-build"], |
|
| 48 |
+ "cleanup": ["clean", "clean-install", "clean-chroot", "clean-stage-for-incremental-build"], |
|
| 42 | 49 |
|
| 43 |
- "tool-checkup": ["check-tools", "check-docker", "check-docker-service", "check-docker-py", |
|
| 44 |
- "check-bison", "check-texinfo", "check-g++", "check-gawk", "check-repo-tool", |
|
| 45 |
- "check-kpartx", "check-sanity", "start-docker", "install-photon-docker-image", |
|
| 46 |
- "check-spec-files", "check-pyopenssl", "check-photon-installer"], |
|
| 50 |
+ "tool-checkup": ["check-pre-reqs", "check-docker", "photon-builder-image", |
|
| 51 |
+ "check-bison", "check-texinfo", "check-g++", "check-gawk", "check-repo-tool", |
|
| 52 |
+ "check-kpartx", "check-sanity", |
|
| 53 |
+ "check-spec-files", "check-pyopenssl", "check-photon-installer"], |
|
| 47 | 54 |
|
| 48 |
- "utilities": ["generate-dep-lists", "pkgtree", "imgtree", "who-needs", |
|
| 49 |
- "print-upward-deps", "pull-stage-rpms", "clean-stage-rpms"] |
|
| 50 |
- } |
|
| 55 |
+ "utilities": ["generate-dep-lists", "pkgtree", "imgtree", "who-needs", |
|
| 56 |
+ "print-upward-deps", "pull-stage-rpms", "clean-stage-rpms"] |
|
| 57 |
+} |
|
| 51 | 58 |
|
| 52 | 59 |
photonDir = os.path.dirname(os.path.realpath(__file__)) |
| 53 | 60 |
curDir = os.getcwd() |
| ... | ... |
@@ -59,11 +66,14 @@ check_prerequesite = {
|
| 59 | 59 |
"initialize-constants": False |
| 60 | 60 |
} |
| 61 | 61 |
|
| 62 |
+cmdUtils = CommandUtils() |
|
| 63 |
+ |
|
| 64 |
+ |
|
| 62 | 65 |
def vixdiskutil(): |
| 63 | 66 |
check_prerequesite["vixdiskutil"] = True |
| 64 | 67 |
if not check_prerequesite["tools-bin"]: |
| 65 | 68 |
tools_bin() |
| 66 |
- if subprocess.Popen(["cd " + photonDir + "/tools/src/vixDiskUtil && make"], shell=True).wait() != 0: |
|
| 69 |
+ if subprocess.Popen(["make -C " + photonDir + "/tools/src/vixDiskUtil"], shell=True).wait(): |
|
| 67 | 70 |
raise Exception("Not able to make vixDiskUtil")
|
| 68 | 71 |
|
| 69 | 72 |
def tools_bin(): |
| ... | ... |
@@ -76,9 +86,7 @@ def contain(): |
| 76 | 76 |
if not check_prerequesite["tools-bin"]: |
| 77 | 77 |
tools_bin() |
| 78 | 78 |
|
| 79 |
- if subprocess.Popen(["gcc -O2 -std=gnu99 -Wall -Wextra " + photonDir + \ |
|
| 80 |
- "/tools/src/contain/*.c -o "+ photonDir + "/tools/bin/contain_unpriv && sudo install -o root -g root \ |
|
| 81 |
- -m 4755 " + photonDir + "/tools/bin/contain_unpriv " + photonDir + "/tools/bin/contain"], shell=True).wait() != 0: |
|
| 79 |
+ if subprocess.Popen(["make -C " + photonDir + "/tools/src/contain install"], shell=True).wait(): |
|
| 82 | 80 |
raise Exception("contain failed")
|
| 83 | 81 |
|
| 84 | 82 |
|
| ... | ... |
@@ -185,10 +193,10 @@ class Build_Config: |
| 185 | 185 |
def setPullPublishRPMS(pullPublishRPMS): |
| 186 | 186 |
Build_Config.pullPublishRPMS = pullPublishRPMS |
| 187 | 187 |
|
| 188 |
-# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 189 |
-# class Utilities is used for generating spec dependency, printing upward dependencies for package.. + |
|
| 190 |
-# + |
|
| 191 |
-# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 188 |
+ |
|
| 189 |
+""" |
|
| 190 |
+class Utilities is used for generating spec dependency, printing upward dependencies for package.. |
|
| 191 |
+""" |
|
| 192 | 192 |
class Utilities: |
| 193 | 193 |
|
| 194 | 194 |
global configdict |
| ... | ... |
@@ -196,7 +204,6 @@ class Utilities: |
| 196 | 196 |
|
| 197 | 197 |
def __init__(self, args): |
| 198 | 198 |
|
| 199 |
- cmdUtils = CommandUtils() |
|
| 200 | 199 |
self.img = configdict.get("utility", {}).get("img", None)
|
| 201 | 200 |
self.json_file = configdict.get("utility", {}).get("file", "packages_*.json")
|
| 202 | 201 |
self.display_option = configdict.get("utility", {}).get("display-option", "json")
|
| ... | ... |
@@ -292,13 +299,9 @@ class Utilities: |
| 292 | 292 |
print("Error while removing file {0}: {1}".format(filePath, error))
|
| 293 | 293 |
|
| 294 | 294 |
|
| 295 |
- |
|
| 296 |
-# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 297 |
-# class Buildenvironmentsetup does job like pulling toolchain RPMS and creating stage... + |
|
| 298 |
-# + |
|
| 299 |
-# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 300 |
- |
|
| 301 |
- |
|
| 295 |
+""" |
|
| 296 |
+class Buildenvironmentsetup does job like pulling toolchain RPMS and creating stage... |
|
| 297 |
+""" |
|
| 302 | 298 |
class BuildEnvironmentSetup: |
| 303 | 299 |
|
| 304 | 300 |
global configdict |
| ... | ... |
@@ -306,10 +309,10 @@ class BuildEnvironmentSetup: |
| 306 | 306 |
|
| 307 | 307 |
def packages_cached(): |
| 308 | 308 |
check_prerequesite["packages-cached"]=True |
| 309 |
- CommandUtils.runCommandInShell("rm -rf " + Build_Config.rpmNoArchPath + "/*")
|
|
| 310 |
- CommandUtils.runCommandInShell("rm -rf " + Build_Config.rpmArchPath + "/*")
|
|
| 311 |
- CommandUtils.runCommandInShell("cp -rf " + configdict["additional-path"]["photon-cache-path"] + "/RPMS/noarch/* " + Build_Config.rpmNoArchPath)
|
|
| 312 |
- CommandUtils.runCommandInShell("cp -rf " + configdict["additional-path"]["photon-cache-path"] + \
|
|
| 309 |
+ cmdUtils.runCommandInShell("rm -rf " + Build_Config.rpmNoArchPath + "/*")
|
|
| 310 |
+ cmdUtils.runCommandInShell("rm -rf " + Build_Config.rpmArchPath + "/*")
|
|
| 311 |
+ cmdUtils.runCommandInShell("cp -rf " + configdict["additional-path"]["photon-cache-path"] + "/RPMS/noarch/* " + Build_Config.rpmNoArchPath)
|
|
| 312 |
+ cmdUtils.runCommandInShell("cp -rf " + configdict["additional-path"]["photon-cache-path"] + \
|
|
| 313 | 313 |
"/RPMS/" + constants.currentArch + "/* " + Build_Config.rpmArchPath) |
| 314 | 314 |
RpmBuildTarget.create_repo() |
| 315 | 315 |
|
| ... | ... |
@@ -324,7 +327,7 @@ class BuildEnvironmentSetup: |
| 324 | 324 |
def sources_cached(): |
| 325 | 325 |
check_prerequesite["sources-cached"]=True |
| 326 | 326 |
print("Using cached SOURCES...")
|
| 327 |
- CommandUtils.runCommandInShell("ln -sf " + configdict["additional-path"]["photon-sources-path"] + " " + constants.sourcePath)
|
|
| 327 |
+ cmdUtils.runCommandInShell("ln -sf " + configdict["additional-path"]["photon-sources-path"] + " " + constants.sourcePath)
|
|
| 328 | 328 |
|
| 329 | 329 |
def publish_rpms(): |
| 330 | 330 |
if configdict['additional-path']['photon-publish-rpms-path'] is None: |
| ... | ... |
@@ -403,59 +406,33 @@ class BuildEnvironmentSetup: |
| 403 | 403 |
os.mkdir(constants.logPath) |
| 404 | 404 |
|
| 405 | 405 |
if not os.path.isfile(Build_Config.stagePath + "/COPYING"): |
| 406 |
- CommandUtils.runCommandInShell("install -m 444 " + photonDir + "/COPYING " + Build_Config.stagePath + "/COPYING")
|
|
| 406 |
+ cmdUtils.runCommandInShell("install -m 444 " + photonDir + "/COPYING " + Build_Config.stagePath + "/COPYING")
|
|
| 407 | 407 |
|
| 408 | 408 |
if not os.path.isfile(Build_Config.stagePath + "/NOTICE-GPL2.0"): |
| 409 |
- CommandUtils.runCommandInShell("install -m 444 " + photonDir + "/NOTICE-GPL2.0 " + Build_Config.stagePath + "/NOTICE-GPL2.0")
|
|
| 409 |
+ cmdUtils.runCommandInShell("install -m 444 " + photonDir + "/NOTICE-GPL2.0 " + Build_Config.stagePath + "/NOTICE-GPL2.0")
|
|
| 410 | 410 |
|
| 411 | 411 |
if not os.path.isfile(Build_Config.stagePath + "/NOTICE-Apachev2"): |
| 412 |
- CommandUtils.runCommandInShell("install -m 444 " + photonDir + "/NOTICE-Apachev2 " + Build_Config.stagePath + "/NOTICE-Apachev2")
|
|
| 412 |
+ cmdUtils.runCommandInShell("install -m 444 " + photonDir + "/NOTICE-Apachev2 " + Build_Config.stagePath + "/NOTICE-Apachev2")
|
|
| 413 | 413 |
if not os.path.isfile(Build_Config.stagePath + "/EULA.txt"): |
| 414 |
- CommandUtils.runCommandInShell("install -m 444 " + photonDir + "/EULA.txt " + Build_Config.stagePath + "/EULA.txt")
|
|
| 415 |
- |
|
| 416 |
- def create_photon_builder_image(): |
|
| 417 |
- # docker image with rpm preinstalled |
|
| 418 |
- check_prerequesite["photon_builder_image"] = True |
|
| 419 |
- import docker |
|
| 420 |
- import io |
|
| 421 |
- dockerClient = docker.from_env(version="auto") |
|
| 422 |
- dockerfilePath=os.path.join(curDir, "support/package-builder/Dockerfile.photon_builder") |
|
| 423 |
- dfile="" |
|
| 424 |
- with open(dockerfilePath, 'r') as f: |
|
| 425 |
- tmpdfile=f.read() |
|
| 426 |
- if "photon-docker-image" in configdict["photon-build-param"]: |
|
| 427 |
- dfile=tmpdfile.replace("photon:latest",configdict["photon-build-param"]["photon-docker-image"])
|
|
| 428 |
- else: |
|
| 429 |
- dfile = tmpdfile |
|
| 430 |
- |
|
| 431 |
- print("Creating photon builder docker image ...")
|
|
| 432 |
- try: |
|
| 433 |
- image = dockerClient.images.build(tag='photon_builder:latest', |
|
| 434 |
- fileobj=io.BytesIO(dfile.encode()), |
|
| 435 |
- rm=True) |
|
| 414 |
+ cmdUtils.runCommandInShell("install -m 444 " + photonDir + "/EULA.txt " + Build_Config.stagePath + "/EULA.txt")
|
|
| 436 | 415 |
|
| 437 |
- print("Created Image {0}".format(image[0]))
|
|
| 438 |
- except Exception as e: |
|
| 439 |
- print("Non-zero tdnf code? Try running `docker pull photon:latest`")
|
|
| 440 |
- raise e |
|
| 441 | 416 |
|
| 442 |
-# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 443 |
-# class Cleanup does the job of cleaning up the stage directory... + |
|
| 444 |
-# + |
|
| 445 |
-# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 417 |
+""" |
|
| 418 |
+class Cleanup does the job of cleaning up the stage directory... |
|
| 419 |
+""" |
|
| 446 | 420 |
class CleanUp: |
| 447 | 421 |
|
| 448 | 422 |
def clean(): |
| 449 | 423 |
CleanUp.clean_install() |
| 450 | 424 |
CleanUp.clean_chroot() |
| 451 | 425 |
print("Deleting Photon ISO...")
|
| 452 |
- CommandUtils.runCommandInShell("rm -f " + Build_Config.stagePath + "/photon-*.iso")
|
|
| 426 |
+ cmdUtils.runCommandInShell("rm -f " + Build_Config.stagePath + "/photon-*.iso")
|
|
| 453 | 427 |
print("Deleting stage dir...")
|
| 454 |
- CommandUtils.runCommandInShell("rm -rf " + Build_Config.stagePath)
|
|
| 428 |
+ cmdUtils.runCommandInShell("rm -rf " + Build_Config.stagePath)
|
|
| 455 | 429 |
print("Deleting chroot path...")
|
| 456 |
- CommandUtils.runCommandInShell("rm -rf " + constants.buildRootPath)
|
|
| 430 |
+ cmdUtils.runCommandInShell("rm -rf " + constants.buildRootPath)
|
|
| 457 | 431 |
print("Deleting tools/bin...")
|
| 458 |
- CommandUtils.runCommandInShell("rm -rf tools/bin")
|
|
| 432 |
+ cmdUtils.runCommandInShell("rm -rf tools/bin")
|
|
| 459 | 433 |
|
| 460 | 434 |
def clean_install(): |
| 461 | 435 |
print("Cleaning installer working directory...")
|
| ... | ... |
@@ -470,7 +447,6 @@ class CleanUp: |
| 470 | 470 |
raise Exception("Not able to clean chroot")
|
| 471 | 471 |
|
| 472 | 472 |
def removeUpwardDeps(pkg, display_option): |
| 473 |
- cmdUtils = CommandUtils() |
|
| 474 | 473 |
specDeps = SpecDependencyGenerator(constants.logPath, constants.logLevel) |
| 475 | 474 |
isToolChainPkg = specDeps.process("is-toolchain-pkg", pkg, display_option)
|
| 476 | 475 |
if isToolChainPkg: |
| ... | ... |
@@ -498,7 +474,7 @@ class CleanUp: |
| 498 | 498 |
" && {{ echo 'Remove all staged RPMs'; rm -rf {}; }} || :")
|
| 499 | 499 |
command = command.format(ph_path, rpm_path) |
| 500 | 500 |
|
| 501 |
- if CommandUtils.runCommandInShell(command): |
|
| 501 |
+ if cmdUtils.runCommandInShell(command): |
|
| 502 | 502 |
raise Exception('Not able to run clean_stage_for_incremental_build')
|
| 503 | 503 |
|
| 504 | 504 |
if not os.path.exists(rpm_path): |
| ... | ... |
@@ -525,11 +501,10 @@ class CleanUp: |
| 525 | 525 |
print('Error in clean_stage_for_incremental_build: %s' % (error))
|
| 526 | 526 |
|
| 527 | 527 |
|
| 528 |
-# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 529 |
-# class Rpmbuildtarget does the job of building all the RPMs for the SPECS + |
|
| 530 |
-# It uses Builder class in builder.py in order to build packages. + |
|
| 531 |
-# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 532 |
- |
|
| 528 |
+""" |
|
| 529 |
+class Rpmbuildtarget does the job of building all the RPMs for the SPECS |
|
| 530 |
+It uses Builder class in builder.py in order to build packages. |
|
| 531 |
+""" |
|
| 533 | 532 |
class RpmBuildTarget: |
| 534 | 533 |
|
| 535 | 534 |
global configdict |
| ... | ... |
@@ -538,12 +513,6 @@ class RpmBuildTarget: |
| 538 | 538 |
def __init__(self): |
| 539 | 539 |
self.logger = Logger.getLogger("Main", constants.logPath, constants.logLevel)
|
| 540 | 540 |
|
| 541 |
- if not check_prerequesite["check-docker-py"]: |
|
| 542 |
- CheckTools.check_docker_py() |
|
| 543 |
- |
|
| 544 |
- if not check_prerequesite["check-tools"]: |
|
| 545 |
- CheckTools.check_tools() |
|
| 546 |
- |
|
| 547 | 541 |
if not check_prerequesite["photon-stage"]: |
| 548 | 542 |
BuildEnvironmentSetup.photon_stage() |
| 549 | 543 |
|
| ... | ... |
@@ -568,14 +537,13 @@ class RpmBuildTarget: |
| 568 | 568 |
if not check_prerequesite["contain"]: |
| 569 | 569 |
contain() |
| 570 | 570 |
|
| 571 |
- if not check_prerequesite["check-spec-files"]: |
|
| 572 |
- CheckTools.check_spec_files() |
|
| 571 |
+ CheckTools.check_spec_files() |
|
| 573 | 572 |
|
| 574 | 573 |
a = Utilities(None) |
| 575 | 574 |
a.generate_dep_lists() |
| 576 | 575 |
|
| 577 | 576 |
if constants.buildArch != constants.targetArch: |
| 578 |
- CommandUtils.runCommandInShell("mkdir -p " + constants.rpmPath + "/" + constants.targetArch)
|
|
| 577 |
+ cmdUtils.runCommandInShell("mkdir -p " + constants.rpmPath + "/" + constants.targetArch)
|
|
| 579 | 578 |
|
| 580 | 579 |
self.logger.debug("Source Path :" + constants.sourcePath)
|
| 581 | 580 |
self.logger.debug("Spec Path :" + constants.specPath)
|
| ... | ... |
@@ -597,41 +565,36 @@ class RpmBuildTarget: |
| 597 | 597 |
constants.currentArch = constants.targetArch |
| 598 | 598 |
constants.crossCompiling = True |
| 599 | 599 |
|
| 600 |
- # if rpm doesnt have zstd support we will create and use photon_builder image with preinstalled rpm |
|
| 601 |
- command="rpm --showrc | grep -i 'rpmlib(PayloadIsZstd)'" |
|
| 602 |
- process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
|
| 603 |
- retval = process.wait() |
|
| 604 |
- if retval !=0 and not check_prerequesite["photon_builder_image"]: |
|
| 605 |
- constants.hostRpmIsNotUsable = True |
|
| 606 |
- self.logger.info('rpm doesnt have zstd support')
|
|
| 607 |
- BuildEnvironmentSetup.create_photon_builder_image() |
|
| 608 |
- else: |
|
| 609 |
- self.logger.info('rpm has zstd support')
|
|
| 600 |
+ if check_prerequesite["photon-builder-image"]: |
|
| 601 |
+ return |
|
| 610 | 602 |
|
| 611 | 603 |
@staticmethod |
| 612 | 604 |
def create_repo(): |
| 613 |
- check_prerequesite["create-repo"]=True |
|
| 614 |
- if subprocess.Popen(["createrepo " + constants.rpmPath], shell=True).wait() != 0: |
|
| 605 |
+ if check_prerequesite["create-repo"]: |
|
| 606 |
+ return |
|
| 607 |
+ |
|
| 608 |
+ if subprocess.Popen(["createrepo --update " + constants.rpmPath], shell=True).wait(): |
|
| 615 | 609 |
raise Exception("Not able to create repodata")
|
| 616 | 610 |
|
| 611 |
+ check_prerequesite["create-repo"] = True |
|
| 612 |
+ |
|
| 617 | 613 |
@staticmethod |
| 618 | 614 |
def ostree_repo(): |
| 619 |
- check_prerequesite["ostree-repo"]=True |
|
| 620 |
- if not check_prerequesite["start-docker"]: |
|
| 621 |
- CheckTools.start_docker() |
|
| 622 |
- if constants.currentArch == "x86_64": |
|
| 623 |
- ph_docker_image = "vmware/photon-build:rpm-ostree-3.0" |
|
| 624 |
- else: |
|
| 625 |
- ph_docker_image = "vmware/photon-build:rpm-ostree-aarch64-3.0" |
|
| 615 |
+ if check_prerequesite["ostree-repo"]: |
|
| 616 |
+ return |
|
| 617 |
+ |
|
| 618 |
+ ph_docker_img = configdict["photon-build-param"]["photon-docker-image"] |
|
| 626 | 619 |
if not os.path.isfile(os.path.join(Build_Config.stagePath, "ostree-repo.tar.gz")): |
| 627 |
- process = subprocess.Popen([photonDir + "/support/image-builder/ostree-tools/make-ostree-image.sh", photonDir, Build_Config.stagePath, |
|
| 628 |
- ph_docker_image]) |
|
| 620 |
+ print("Creating OSTree repo from local RPMs in ostree-repo.tar.gz...")
|
|
| 621 |
+ RpmBuildTarget.create_repo() |
|
| 622 |
+ process = subprocess.Popen([photonDir + "/support/image-builder/ostree-tools/make-ostree-image.sh", photonDir, Build_Config.stagePath, ph_docker_img]) |
|
| 629 | 623 |
|
| 630 |
- retval = process.wait() |
|
| 631 |
- if retval != 0: |
|
| 624 |
+ if process.wait(): |
|
| 632 | 625 |
print("Not able to execute make-ostree-image.sh")
|
| 633 | 626 |
else: |
| 634 |
- print("Creating OSTree repo from local RPMs in ostree-repo.tar.gz...")
|
|
| 627 |
+ print("OSTree repo already exists...")
|
|
| 628 |
+ |
|
| 629 |
+ check_prerequesite["ostree-repo"] = True |
|
| 635 | 630 |
|
| 636 | 631 |
def packages(self): |
| 637 | 632 |
check_prerequesite["packages"]=True |
| ... | ... |
@@ -713,8 +676,6 @@ class RpmBuildTarget: |
| 713 | 713 |
|
| 714 | 714 |
print("Generating yaml files for packages...")
|
| 715 | 715 |
check_prerequesite["generate-yaml-files"] = True |
| 716 |
- if not check_prerequesite["check-tools"]: |
|
| 717 |
- CheckTools.check_tools() |
|
| 718 | 716 |
if not check_prerequesite["photon-stage"]: |
| 719 | 717 |
BuildEnvironmentSetup.photon_stage() |
| 720 | 718 |
if not check_prerequesite["packages"]: |
| ... | ... |
@@ -728,18 +689,20 @@ class RpmBuildTarget: |
| 728 | 728 |
GenerateOSSFiles.buildSourcesList(Build_Config.stagePath, blackListPkgs, logger) |
| 729 | 729 |
GenerateOSSFiles.buildSRPMList(constants.sourceRpmPath, Build_Config.stagePath, blackListPkgs, constants.dist, logger) |
| 730 | 730 |
|
| 731 |
-# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 732 |
-# class CheckTools does the job of checking weather all the tools required for starting build process are present on the system + |
|
| 733 |
-# + |
|
| 734 |
-# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 735 | 731 |
|
| 732 |
+""" |
|
| 733 |
+class CheckTools does the job of checking weather all the tools required for |
|
| 734 |
+starting build process are present on the system |
|
| 735 |
+""" |
|
| 736 | 736 |
class CheckTools: |
| 737 | 737 |
|
| 738 | 738 |
global configdict |
| 739 | 739 |
global check_prerequesite |
| 740 | 740 |
|
| 741 |
- def check_tools(): |
|
| 742 |
- check_prerequesite["check-tools"] = True |
|
| 741 |
+ def check_pre_reqs(): |
|
| 742 |
+ if check_prerequesite["check-pre-reqs"]: |
|
| 743 |
+ return |
|
| 744 |
+ |
|
| 743 | 745 |
CheckTools.check_bison() |
| 744 | 746 |
CheckTools.check_gplusplus() |
| 745 | 747 |
CheckTools.check_gawk() |
| ... | ... |
@@ -748,6 +711,25 @@ class CheckTools: |
| 748 | 748 |
CheckTools.check_sanity() |
| 749 | 749 |
CheckTools.check_docker() |
| 750 | 750 |
CheckTools.check_pyopenssl() |
| 751 |
+ CheckTools.create_ph_builder_img() |
|
| 752 |
+ check_prerequesite["check-pre-reqs"] = True |
|
| 753 |
+ |
|
| 754 |
+ def create_ph_builder_img(): |
|
| 755 |
+ if check_prerequesite["photon-builder-image"]: |
|
| 756 |
+ return |
|
| 757 |
+ |
|
| 758 |
+ ph_docker_img = configdict["photon-build-param"]["photon-docker-image"] |
|
| 759 |
+ ph_docker_img_url = configdict["photon-build-param"]["ph-docker-img-url"] |
|
| 760 |
+ ph_builder_tag = configdict["photon-build-param"]["ph-builder-tag"] |
|
| 761 |
+ |
|
| 762 |
+ ph_docker_img_url = ph_docker_img_url.replace("ARCH", constants.currentArch)
|
|
| 763 |
+ |
|
| 764 |
+ if subprocess.Popen([photonDir + "/tools/scripts/ph4-docker-img-import.sh %s %s %s" |
|
| 765 |
+ %(ph_docker_img_url, ph_docker_img, ph_builder_tag)], |
|
| 766 |
+ shell=True).wait(): |
|
| 767 |
+ raise Exception("ERROR: failed to build photon builder docker image")
|
|
| 768 |
+ |
|
| 769 |
+ check_prerequesite["photon-builder-image"] = True |
|
| 751 | 770 |
|
| 752 | 771 |
def check_bison(): |
| 753 | 772 |
check_prerequesite["check-bison"]=True |
| ... | ... |
@@ -776,23 +758,26 @@ class CheckTools: |
| 776 | 776 |
|
| 777 | 777 |
def check_sanity(): |
| 778 | 778 |
check_prerequesite["check-sanity"]=True |
| 779 |
- if subprocess.Popen([photonDir + "/support/sanity_check.sh"], shell=True).wait() != 0: |
|
| 779 |
+ if subprocess.Popen([photonDir + "/support/sanity_check.sh"], shell=True).wait(): |
|
| 780 | 780 |
raise Exception("Not able to run script sanity_check.sh")
|
| 781 | 781 |
|
| 782 | 782 |
def check_docker(): |
| 783 |
- check_prerequesite["check-docker"]=True |
|
| 784 | 783 |
if not glob.glob(Build_Config.dockerEnv) and shutil.which('docker') is None:
|
| 785 | 784 |
raise Exception("docker not present")
|
| 786 | 785 |
|
| 787 |
- def check_docker_service(): |
|
| 788 |
- check_prerequesite["check-docker-service"]=True |
|
| 789 |
- if not glob.glob(Build_Config.dockerEnv) and subprocess.Popen(["docker ps >/dev/null 2>&1"], shell=True).wait() != 0: |
|
| 786 |
+ if subprocess.Popen(["systemctl start docker"], shell=True).wait(): |
|
| 787 |
+ raise Exception("Not able to start docker")
|
|
| 788 |
+ |
|
| 789 |
+ if not glob.glob(Build_Config.dockerEnv) and subprocess.Popen(["docker ps >/dev/null 2>&1"], shell=True).wait(): |
|
| 790 | 790 |
raise Exception("Docker service is not running. Aborting.")
|
| 791 | 791 |
|
| 792 |
- def check_docker_py(): |
|
| 793 |
- check_prerequesite["check-docker-py"]=True |
|
| 794 |
- if not glob.glob(Build_Config.dockerEnv) and docker.__version__ < "2.3.0": |
|
| 795 |
- raise Exception("Error: Python3 package docker-py3 2.3.0 not installed.\nPlease use: pip3 install docker==2.3.0")
|
|
| 792 |
+ docker_py_ver = "2.3.0" |
|
| 793 |
+ if not glob.glob(Build_Config.dockerEnv) and docker.__version__ < docker_py_ver: |
|
| 794 |
+ print(f"\nError: Python3 package docker-{docker_py_ver} not installed.")
|
|
| 795 |
+ print(f"Please use: pip3 install docker=={docker_py_ver}\n")
|
|
| 796 |
+ raise Exception() |
|
| 797 |
+ |
|
| 798 |
+ check_prerequesite["check-docker"]=True |
|
| 796 | 799 |
|
| 797 | 800 |
def check_pyopenssl(): |
| 798 | 801 |
check_prerequesite["check-pyopenssl"]=True |
| ... | ... |
@@ -802,6 +787,9 @@ class CheckTools: |
| 802 | 802 |
raise Exception(e) |
| 803 | 803 |
|
| 804 | 804 |
def check_spec_files(): |
| 805 |
+ if check_prerequesite["check-spec-files"]: |
|
| 806 |
+ return |
|
| 807 |
+ |
|
| 805 | 808 |
command = ("[ -z \"$(git diff --name-only HEAD --)\" ] && "
|
| 806 | 809 |
"git diff --name-only @~ || git diff --name-only") |
| 807 | 810 |
|
| ... | ... |
@@ -815,8 +803,6 @@ class CheckTools: |
| 815 | 815 |
if process.returncode: |
| 816 | 816 |
raise Exception("Something went wrong in check_spec_files")
|
| 817 | 817 |
|
| 818 |
- check_prerequesite["check-spec-files"] = True |
|
| 819 |
- |
|
| 820 | 818 |
files = [fn for fn in files if fn.endswith('.spec')]
|
| 821 | 819 |
if not files: |
| 822 | 820 |
print("No spec files to check for now")
|
| ... | ... |
@@ -825,6 +811,8 @@ class CheckTools: |
| 825 | 825 |
if check_specs(files): |
| 826 | 826 |
raise Exception("Spec file check failed")
|
| 827 | 827 |
|
| 828 |
+ check_prerequesite["check-spec-files"] = True |
|
| 829 |
+ |
|
| 828 | 830 |
def check_kpartx(): |
| 829 | 831 |
check_prerequesite["check-kpartx"]=True |
| 830 | 832 |
if shutil.which('kpartx') is None:
|
| ... | ... |
@@ -835,7 +823,7 @@ class CheckTools: |
| 835 | 835 |
cmd = "pip3 install git+%s" % url |
| 836 | 836 |
|
| 837 | 837 |
def install_from_url(cmd): |
| 838 |
- if CommandUtils.runCommandInShell(cmd): |
|
| 838 |
+ if cmdUtils.runCommandInShell(cmd): |
|
| 839 | 839 |
raise Exception("Failed to run: %s" % cmd)
|
| 840 | 840 |
print("%s - Success" % cmd)
|
| 841 | 841 |
|
| ... | ... |
@@ -866,23 +854,11 @@ class CheckTools: |
| 866 | 866 |
else: |
| 867 | 867 |
install_from_url(cmd) |
| 868 | 868 |
|
| 869 |
- def start_docker(): |
|
| 870 |
- check_prerequesite["start-docker"]=True |
|
| 871 |
- CheckTools.check_docker() |
|
| 872 |
- if subprocess.Popen(["systemctl start docker"], shell=True).wait() != 0: |
|
| 873 |
- raise Exception("Not able to start docker")
|
|
| 874 |
- |
|
| 875 |
- def install_photon_docker_image(): |
|
| 876 |
- if not check_prerequesite["photon-docker-image"]: |
|
| 877 |
- BuildImage.photon_docker_image() |
|
| 878 |
- if subprocess.Popen("sudo docker build -t photon:tdnf .").wait() != 0:
|
|
| 879 |
- raise Exception("Not able to install photon docker image")
|
|
| 880 |
- |
|
| 881 |
-# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 882 |
-# class BuildImage does the job of building all the images like iso, rpi, ami, gce, azure, ova ova_uefi and ls1012afrwy... + |
|
| 883 |
-# It uses class ImageBuilder to build different images. + |
|
| 884 |
-# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 885 | 869 |
|
| 870 |
+""" |
|
| 871 |
+class BuildImage does the job of building all the images like iso, rpi, ami, gce, azure, ova ova_uefi and ls1012afrwy |
|
| 872 |
+It uses class ImageBuilder to build different images. |
|
| 873 |
+""" |
|
| 886 | 874 |
class BuildImage: |
| 887 | 875 |
|
| 888 | 876 |
global configdict |
| ... | ... |
@@ -900,6 +876,7 @@ class BuildImage: |
| 900 | 900 |
self.srpm_path = constants.sourceRpmPath |
| 901 | 901 |
self.pkg_to_rpm_map_file = os.path.join(Build_Config.stagePath, "pkg_info.json") |
| 902 | 902 |
self.ph_docker_image = configdict["photon-build-param"]["photon-docker-image"] |
| 903 |
+ self.ph_builder_tag = configdict["photon-build-param"]["ph-builder-tag"] |
|
| 903 | 904 |
self.ova_cloud_images = ["ami", "gce", "azure", "ova_uefi", "ova"] |
| 904 | 905 |
self.photon_release_version = constants.releaseVersion |
| 905 | 906 |
|
| ... | ... |
@@ -939,12 +916,7 @@ class BuildImage: |
| 939 | 939 |
|
| 940 | 940 |
|
| 941 | 941 |
def build_iso(self): |
| 942 |
- |
|
| 943 |
- import imagebuilder |
|
| 944 |
- |
|
| 945 | 942 |
rpmBuildTarget = RpmBuildTarget() |
| 946 |
- if not check_prerequesite["check-tools"]: |
|
| 947 |
- CheckTools.check_tools() |
|
| 948 | 943 |
if not check_prerequesite["photon-stage"]: |
| 949 | 944 |
BuildEnvironmentSetup.photon_stage() |
| 950 | 945 |
if self.img_name == "iso" and not check_prerequesite["packages"]: |
| ... | ... |
@@ -955,18 +927,15 @@ class BuildImage: |
| 955 | 955 |
rpmBuildTarget.packages_minimal() |
| 956 | 956 |
if self.img_name in ["rt-iso", "minimal-iso"] and not check_prerequesite["packages-initrd"]: |
| 957 | 957 |
rpmBuildTarget.packages_initrd() |
| 958 |
- if not check_prerequesite["create-repo"]: |
|
| 959 |
- RpmBuildTarget.create_repo() |
|
| 958 |
+ RpmBuildTarget.create_repo() |
|
| 960 | 959 |
if self.img_name != "minimal-iso" and not check_prerequesite["ostree-repo"]: |
| 961 | 960 |
RpmBuildTarget.ostree_repo() |
| 962 | 961 |
self.generated_data_path = Build_Config.generatedDataPath |
| 962 |
+ |
|
| 963 | 963 |
print("Building Full ISO...")
|
| 964 | 964 |
imagebuilder.createIso(self) |
| 965 | 965 |
|
| 966 | 966 |
def build_image(self): |
| 967 |
- |
|
| 968 |
- import imagebuilder |
|
| 969 |
- |
|
| 970 | 967 |
if not check_prerequesite["check-kpartx"]: |
| 971 | 968 |
CheckTools.check_kpartx() |
| 972 | 969 |
if not check_prerequesite["check-photon-installer"]: |
| ... | ... |
@@ -988,36 +957,56 @@ class BuildImage: |
| 988 | 988 |
|
| 989 | 989 |
@staticmethod |
| 990 | 990 |
def photon_docker_image(): |
| 991 |
- if not check_prerequesite["create-repo"]: |
|
| 992 |
- RpmBuildTarget.create_repo() |
|
| 993 |
- if subprocess.Popen(["cd " + configdict["photon-path"] + ";sudo docker build --no-cache --tag photon-build " + photonDir + "/support/dockerfiles/photon && sudo docker run --rm --privileged --net=host -e PHOTON_BUILD_NUMBER="+constants.buildNumber + " -e PHOTON_RELEASE_VERSION="+constants.releaseVersion + " -v "+photonDir+":/workspace photon-build ./support/dockerfiles/photon/make-docker-image.sh"], shell=True).wait(): |
|
| 991 |
+ if check_prerequesite["photon-docker-image"]: |
|
| 992 |
+ return |
|
| 993 |
+ |
|
| 994 |
+ RpmBuildTarget.create_repo() |
|
| 995 |
+ |
|
| 996 |
+ docker_file_dir = "support/dockerfiles/photon" |
|
| 997 |
+ docker_file = docker_file_dir + "/Dockerfile" |
|
| 998 |
+ docker_script = docker_file_dir + "/make-docker-image.sh" |
|
| 999 |
+ |
|
| 1000 |
+ cmd = "cd " + photonDir |
|
| 1001 |
+ cmd += " && sudo docker build --no-cache --tag photon-build " + docker_file_dir |
|
| 1002 |
+ cmd += " && sudo docker run --rm --privileged --net=host -e PHOTON_BUILD_NUMBER=" + constants.buildNumber |
|
| 1003 |
+ cmd += " -e PHOTON_RELEASE_VERSION=" + constants.releaseVersion |
|
| 1004 |
+ cmd += " -v " + photonDir + ":/workspace photon-build ./" + docker_script |
|
| 1005 |
+ |
|
| 1006 |
+ if subprocess.Popen([cmd], shell=True).wait(): |
|
| 994 | 1007 |
raise Exception("Not able to run photon-docker-image")
|
| 995 | 1008 |
|
| 1009 |
+ check_prerequesite["photon-docker-image"] = True |
|
| 1010 |
+ |
|
| 996 | 1011 |
def k8s_docker_images(self): |
| 997 |
- if not check_prerequesite["start-docker"]: |
|
| 998 |
- CheckTools.start_docker() |
|
| 999 |
- if not check_prerequesite["photon_builder_image"]: |
|
| 1000 |
- BuildEnvironmentSetup.create_photon_builder_image() |
|
| 1001 |
- if not check_prerequesite["photon-docker-image"]: |
|
| 1002 |
- BuildImage.photon_docker_image() |
|
| 1012 |
+ BuildImage.photon_docker_image() |
|
| 1013 |
+ |
|
| 1003 | 1014 |
if not os.path.isdir(os.path.join(Build_Config.stagePath, "docker_images")): |
| 1004 | 1015 |
os.mkdir(os.path.join(Build_Config.stagePath, "docker_images")) |
| 1016 |
+ |
|
| 1005 | 1017 |
os.chdir(os.path.join(photonDir, 'support/dockerfiles/k8s-docker-images')) |
| 1006 |
- if subprocess.Popen(['./build-k8s-base-image.sh', constants.releaseVersion, constants.buildNumber, Build_Config.stagePath]).wait() == 0 and \ |
|
| 1007 |
- subprocess.Popen(['./build-k8s-docker-images.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 1008 |
- subprocess.Popen(['./build-k8s-metrics-server-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() ==0 and \ |
|
| 1009 |
- subprocess.Popen(['./build-k8s-coredns-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 1010 |
- subprocess.Popen(['./build-k8s-dns-docker-images.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 1011 |
- subprocess.Popen(['./build-k8s-dashboard-docker-images.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 1012 |
- subprocess.Popen(['./build-flannel-docker-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 1013 |
- subprocess.Popen(['./build-calico-docker-images.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 1014 |
- subprocess.Popen(['./build-k8s-heapster-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 1015 |
- subprocess.Popen(['./build-k8s-nginx-ingress.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0 and \ |
|
| 1016 |
- subprocess.Popen(['./build-wavefront-proxy-docker-image.sh', configdict["photon-build-param"]["photon-dist-tag"], constants.releaseVersion, constants.specPath, Build_Config.stagePath]).wait() == 0: |
|
| 1017 |
- print("Successfully built all the docker images")
|
|
| 1018 | 1018 |
|
| 1019 |
- else: |
|
| 1020 |
- raise Exception("k8s-docker-images build failed")
|
|
| 1019 |
+ ph_dist_tag = configdict["photon-build-param"]["photon-dist-tag"] |
|
| 1020 |
+ ph_builder_tag = configdict["photon-build-param"]["ph-builder-tag"] |
|
| 1021 |
+ |
|
| 1022 |
+ k8s_build_scripts = [ |
|
| 1023 |
+ "build-k8s-docker-images.sh", "build-k8s-metrics-server-image.sh", |
|
| 1024 |
+ "build-k8s-coredns-image.sh", "build-k8s-dns-docker-images.sh", |
|
| 1025 |
+ "build-k8s-dashboard-docker-images.sh", "build-flannel-docker-image.sh", |
|
| 1026 |
+ "build-calico-docker-images.sh", "build-k8s-heapster-image.sh", |
|
| 1027 |
+ "build-k8s-nginx-ingress.sh", "build-wavefront-proxy-docker-image.sh", |
|
| 1028 |
+ ] |
|
| 1029 |
+ |
|
| 1030 |
+ script = "build-k8s-base-image.sh" |
|
| 1031 |
+ if subprocess.Popen(["./" + script, constants.releaseVersion, |
|
| 1032 |
+ constants.buildNumber, Build_Config.stagePath]).wait(): |
|
| 1033 |
+ raise Exception(f"{script} script failed")
|
|
| 1034 |
+ |
|
| 1035 |
+ for script in k8s_build_scripts: |
|
| 1036 |
+ if subprocess.Popen(["./" + script, ph_dist_tag, constants.releaseVersion, |
|
| 1037 |
+ constants.specPath, Build_Config.stagePath, ph_builder_tag]).wait(): |
|
| 1038 |
+ raise Exception(f"{script} script failed")
|
|
| 1039 |
+ |
|
| 1040 |
+ print("Successfully built all the k8s docker images")
|
|
| 1021 | 1041 |
os.chdir(photonDir) |
| 1022 | 1042 |
|
| 1023 | 1043 |
def all_images(self): |
| ... | ... |
@@ -1036,16 +1025,14 @@ class BuildImage: |
| 1036 | 1036 |
configdict["targetName"] = img.replace('-', '_')
|
| 1037 | 1037 |
getattr(self, configdict["targetName"])() |
| 1038 | 1038 |
|
| 1039 |
-# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 1040 |
-# initialize_constants initialize all the paths like stage Path, spec path, rpm path, and other parameters + |
|
| 1041 |
-# used by package-builder and imagebuilder... + |
|
| 1042 |
-# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
|
| 1043 |
- |
|
| 1039 |
+""" |
|
| 1040 |
+initialize_constants initialize all the paths like stage Path, spec path, rpm path, and other parameters |
|
| 1041 |
+used by package-builder and imagebuilder... |
|
| 1042 |
+""" |
|
| 1044 | 1043 |
def initialize_constants(): |
| 1045 | 1044 |
|
| 1046 | 1045 |
global configdict |
| 1047 | 1046 |
global check_prerequesite |
| 1048 |
- check_prerequesite["initialize-constants"]=True |
|
| 1049 | 1047 |
|
| 1050 | 1048 |
Build_Config.setStagePath(os.path.join(str(PurePath(configdict["photon-path"], configdict.get("stage-path", ""))), "stage"))
|
| 1051 | 1049 |
constants.setSpecPath(os.path.join(str(PurePath(configdict["photon-path"], configdict.get("spec-path", ""))), "SPECS"))
|
| ... | ... |
@@ -1088,8 +1075,11 @@ def initialize_constants(): |
| 1088 | 1088 |
Build_Config.setCommonDir(PurePath(photonDir, "common", "data")) |
| 1089 | 1089 |
constants.setStartSchedulerServer(configdict["photon-build-param"]['start-scheduler-server']) |
| 1090 | 1090 |
constants.setCompressionMacro(configdict["photon-build-param"]["compression-macro"]) |
| 1091 |
+ constants.phBuilderTag = configdict["photon-build-param"]["ph-builder-tag"] |
|
| 1091 | 1092 |
constants.initialize() |
| 1092 | 1093 |
|
| 1094 |
+ check_prerequesite["initialize-constants"]=True |
|
| 1095 |
+ |
|
| 1093 | 1096 |
|
| 1094 | 1097 |
def set_default_value_of_config(): |
| 1095 | 1098 |
|
| ... | ... |
@@ -1118,18 +1108,20 @@ def main(): |
| 1118 | 1118 |
|
| 1119 | 1119 |
options = parser.parse_args() |
| 1120 | 1120 |
|
| 1121 |
- if options.photonBranch is None and options.configPath is None and not os.path.isfile(os.path.join(curDir, "config.json")): |
|
| 1121 |
+ build_cfg = "build-config.json" |
|
| 1122 |
+ |
|
| 1123 |
+ if options.photonBranch is None and options.configPath is None and not os.path.isfile(os.path.join(curDir, build_cfg)): |
|
| 1122 | 1124 |
raise Exception("Either specify branchName or configpath...")
|
| 1123 | 1125 |
|
| 1124 | 1126 |
if options.photonBranch is not None and not os.path.isdir(os.path.join(curDir ,"photon-" + options.photonBranch)): |
| 1125 |
- CommandUtils.runCommandInShell("git clone https://github.com/vmware/photon.git -b " + options.photonBranch + " photon-" + options.photonBranch)
|
|
| 1127 |
+ cmdUtils.runCommandInShell("git clone https://github.com/vmware/photon.git -b " + options.photonBranch + " photon-" + options.photonBranch)
|
|
| 1126 | 1128 |
elif options.photonBranch is not None: |
| 1127 | 1129 |
print("Using already cloned repository...")
|
| 1128 | 1130 |
|
| 1129 | 1131 |
if options.configPath is None: |
| 1130 |
- options.configPath = os.path.join(curDir, "config.json") |
|
| 1132 |
+ options.configPath = os.path.join(curDir, build_cfg) |
|
| 1131 | 1133 |
if not os.path.isfile(options.configPath) or options.photonBranch: |
| 1132 |
- options.configPath = str(PurePath(curDir, "photon-" + options.photonBranch, "config.json")) |
|
| 1134 |
+ options.configPath = str(PurePath(curDir, "photon-" + options.photonBranch, build_cfg)) |
|
| 1133 | 1135 |
|
| 1134 | 1136 |
global configdict |
| 1135 | 1137 |
global check_prerequesite |
| ... | ... |
@@ -1144,11 +1136,9 @@ def main(): |
| 1144 | 1144 |
os.environ['PHOTON_RELEASE_VER']=configdict["photon-build-param"]["photon-release-version"] |
| 1145 | 1145 |
os.environ['PHOTON_BUILD_NUM']=configdict["photon-build-param"]["input-photon-build-number"] |
| 1146 | 1146 |
|
| 1147 |
- |
|
| 1148 | 1147 |
if configdict.get("photon-path", "") == "":
|
| 1149 | 1148 |
configdict["photon-path"] = os.path.dirname(options.configPath) |
| 1150 | 1149 |
|
| 1151 |
- |
|
| 1152 | 1150 |
if 'INPUT_PHOTON_BUILD_NUMBER' in os.environ: |
| 1153 | 1151 |
configdict["photon-build-param"]["input-photon-build-number"] = os.environ['INPUT_PHOTON_BUILD_NUMBER'] |
| 1154 | 1152 |
|
| ... | ... |
@@ -1215,8 +1205,8 @@ def main(): |
| 1215 | 1215 |
if 'DOCKER_ENV' in os.environ: |
| 1216 | 1216 |
Build_Config.setDockerEnv(os.environ['DOCKER_ENV']) |
| 1217 | 1217 |
|
| 1218 |
- if 'PHOTON_DOCKER_IMAGE' in os.environ: |
|
| 1219 |
- configdict['photon-build-param']['photon-docker-image'] = os.environ['PHOTON_DOCKER_IMAGE'] |
|
| 1218 |
+ if "PH_DOCKER_IMAGE_URL" in os.environ: |
|
| 1219 |
+ configdict["photon-build-param"]["ph-docker-image-url"] = os.environ["PH_DOCKER_IMAGE_URL"] |
|
| 1220 | 1220 |
|
| 1221 | 1221 |
initialize_constants() |
| 1222 | 1222 |
|
| ... | ... |
@@ -1231,6 +1221,8 @@ def main(): |
| 1231 | 1231 |
|
| 1232 | 1232 |
configdict["targetName"] = options.targetName.replace('-', '_')
|
| 1233 | 1233 |
|
| 1234 |
+ CheckTools.check_pre_reqs() |
|
| 1235 |
+ |
|
| 1234 | 1236 |
try: |
| 1235 | 1237 |
if options.targetName in targetList["image"]: |
| 1236 | 1238 |
buildImage = BuildImage(options.targetName) |
| 1237 | 1239 |
deleted file mode 100644 |
| ... | ... |
@@ -1,17 +0,0 @@ |
| 1 |
-{
|
|
| 2 |
- "photon-build-param" : {
|
|
| 3 |
- "photon-build-type" : "chroot", |
|
| 4 |
- "photon-dist-tag" : ".ph4", |
|
| 5 |
- "photon-release-version" : "4.0", |
|
| 6 |
- "threads" : 1, |
|
| 7 |
- "loglevel" : "info", |
|
| 8 |
- "full-package-list-file" : "build_install_options_all.json", |
|
| 9 |
- "pkg-build-options" : "pkg_build_options.json", |
|
| 10 |
- "photon-docker-image" : "photon:3.0", |
|
| 11 |
- "target": "iso", |
|
| 12 |
- "compression-macro": "w19.zstdio" |
|
| 13 |
- }, |
|
| 14 |
- "photon-path" : "", |
|
| 15 |
- "stage-path" : "" , |
|
| 16 |
- "spec-path" : "" |
|
| 17 |
-} |
| ... | ... |
@@ -6,6 +6,7 @@ DIST_TAG=$1 |
| 6 | 6 |
DIST_VER=$2 |
| 7 | 7 |
SPEC_DIR=$3 |
| 8 | 8 |
STAGE_DIR=$4 |
| 9 |
+PH_BUILDER_TAG=$5 |
|
| 9 | 10 |
ARCH=x86_64 |
| 10 | 11 |
|
| 11 | 12 |
# |
| ... | ... |
@@ -152,7 +153,7 @@ cp ${CALICO_CNI_RPM_FILE} tmp/calico/
|
| 152 | 152 |
cp ${K8S_CNI_RPM_FILE} tmp/calico/
|
| 153 | 153 |
cp ${CALICO_K8S_POLICY_RPM_FILE} tmp/calico/
|
| 154 | 154 |
pushd ./tmp/calico |
| 155 |
-docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && \
|
|
| 155 |
+docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && \
|
|
| 156 | 156 |
rpm2cpio '${CALICO_RPM}' | cpio -vid && \
|
| 157 | 157 |
rpm2cpio '${CALICO_BGP_RPM}' | cpio -vid && \
|
| 158 | 158 |
rpm2cpio '${GO_BGP_RPM}' | cpio -vid && \
|
| ... | ... |
@@ -6,6 +6,7 @@ DIST_TAG=$1 |
| 6 | 6 |
DIST_VER=$2 |
| 7 | 7 |
SPEC_DIR=$3 |
| 8 | 8 |
STAGE_DIR=$4 |
| 9 |
+PH_BUILDER_TAG=$5 |
|
| 9 | 10 |
ARCH=x86_64 |
| 10 | 11 |
|
| 11 | 12 |
# |
| ... | ... |
@@ -34,7 +35,7 @@ fi |
| 34 | 34 |
mkdir -p tmp/flannel |
| 35 | 35 |
cp ${FLANNEL_RPM_FILE} tmp/flannel/
|
| 36 | 36 |
pushd ./tmp/flannel |
| 37 |
-docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && rpm2cpio '${FLANNEL_RPM}' | cpio -vid"
|
|
| 37 |
+docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && rpm2cpio '${FLANNEL_RPM}' | cpio -vid"
|
|
| 38 | 38 |
popd |
| 39 | 39 |
|
| 40 | 40 |
setup_repo |
| ... | ... |
@@ -4,6 +4,7 @@ DIST_TAG=$1 |
| 4 | 4 |
DIST_VER=$2 |
| 5 | 5 |
SPEC_DIR=$3 |
| 6 | 6 |
STAGE_DIR=$4 |
| 7 |
+PH_BUILDER_TAG=$5 |
|
| 7 | 8 |
ARCH=x86_64 |
| 8 | 9 |
|
| 9 | 10 |
# |
| ... | ... |
@@ -32,7 +33,7 @@ fi |
| 32 | 32 |
mkdir -p tmp |
| 33 | 33 |
cp ${K8S_COREDNS_RPM_FILE} tmp
|
| 34 | 34 |
pushd ./tmp |
| 35 |
-docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && rpm2cpio '${K8S_COREDNS_RPM}' | cpio -vid"
|
|
| 35 |
+docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && rpm2cpio '${K8S_COREDNS_RPM}' | cpio -vid"
|
|
| 36 | 36 |
popd |
| 37 | 37 |
|
| 38 | 38 |
docker build --rm -t ${IMG_NAME} -f ./Dockerfile.coredns .
|
| ... | ... |
@@ -4,6 +4,7 @@ DIST_TAG=$1 |
| 4 | 4 |
DIST_VER=$2 |
| 5 | 5 |
SPEC_DIR=$3 |
| 6 | 6 |
STAGE_DIR=$4 |
| 7 |
+PH_BUILDER_TAG=$5 |
|
| 7 | 8 |
ARCH=x86_64 |
| 8 | 9 |
|
| 9 | 10 |
# |
| ... | ... |
@@ -32,7 +33,7 @@ fi |
| 32 | 32 |
mkdir -p tmp/k8dash |
| 33 | 33 |
cp ${K8S_DASH_RPM_FILE} tmp/k8dash/
|
| 34 | 34 |
pushd ./tmp/k8dash |
| 35 |
-docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && rpm2cpio '${K8S_DASH_RPM}' | cpio -vid"
|
|
| 35 |
+docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && rpm2cpio '${K8S_DASH_RPM}' | cpio -vid"
|
|
| 36 | 36 |
mkdir -p img |
| 37 | 37 |
cp -p usr/bin/dashboard img/ |
| 38 | 38 |
cp -p -r opt/k8dashboard/* img/ |
| ... | ... |
@@ -6,6 +6,7 @@ DIST_TAG=$1 |
| 6 | 6 |
DIST_VER=$2 |
| 7 | 7 |
SPEC_DIR=$3 |
| 8 | 8 |
STAGE_DIR=$4 |
| 9 |
+PH_BUILDER_TAG=$5 |
|
| 9 | 10 |
ARCH=x86_64 |
| 10 | 11 |
|
| 11 | 12 |
# |
| ... | ... |
@@ -35,7 +36,7 @@ done |
| 35 | 35 |
mkdir -p tmp/k8dns |
| 36 | 36 |
cp ${K8S_DNS_RPM_FILE} tmp/k8dns/
|
| 37 | 37 |
pushd ./tmp/k8dns |
| 38 |
-docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && rpm2cpio '${K8S_DNS_RPM}' | cpio -vid"
|
|
| 38 |
+docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && rpm2cpio '${K8S_DNS_RPM}' | cpio -vid"
|
|
| 39 | 39 |
popd |
| 40 | 40 |
|
| 41 | 41 |
setup_repo |
| ... | ... |
@@ -4,6 +4,7 @@ DIST_TAG=$1 |
| 4 | 4 |
DIST_VER=$2 |
| 5 | 5 |
SPEC_DIR=$3 |
| 6 | 6 |
STAGE_DIR=$4 |
| 7 |
+PH_BUILDER_TAG=$5 |
|
| 7 | 8 |
ARCH=x86_64 |
| 8 | 9 |
|
| 9 | 10 |
# |
| ... | ... |
@@ -37,7 +38,7 @@ for file in ${SPEC_DIR}/kubernetes/kubernetes*.spec; do
|
| 37 | 37 |
cp ${K8S_RPM_FILE} tmp/k8s/
|
| 38 | 38 |
cp ${K8S_PAUSE_RPM_FILE} tmp/k8s/
|
| 39 | 39 |
pushd ./tmp/k8s |
| 40 |
- docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && \
|
|
| 40 |
+ docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && \
|
|
| 41 | 41 |
rpm2cpio '${K8S_RPM}' | cpio -vid && rpm2cpio '${K8S_PAUSE_RPM}' | cpio -vid"
|
| 42 | 42 |
popd |
| 43 | 43 |
|
| ... | ... |
@@ -4,6 +4,7 @@ DIST_TAG=$1 |
| 4 | 4 |
DIST_VER=$2 |
| 5 | 5 |
SPEC_DIR=$3 |
| 6 | 6 |
STAGE_DIR=$4 |
| 7 |
+PH_BUILDER_TAG=$5 |
|
| 7 | 8 |
ARCH=x86_64 |
| 8 | 9 |
|
| 9 | 10 |
# |
| ... | ... |
@@ -31,7 +32,7 @@ fi |
| 31 | 31 |
mkdir -p tmp/k8heapster |
| 32 | 32 |
cp ${K8S_HEAPSTER_RPM_FILE} tmp/k8heapster/
|
| 33 | 33 |
pushd ./tmp/k8heapster |
| 34 |
-docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && rpm2cpio '${K8S_HEAPSTER_RPM}' | cpio -vid"
|
|
| 34 |
+docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && rpm2cpio '${K8S_HEAPSTER_RPM}' | cpio -vid"
|
|
| 35 | 35 |
popd |
| 36 | 36 |
|
| 37 | 37 |
K8S_TAR_NAME=k8s-heapster-${K8S_HEAPSTER_VER_REL}.tar
|
| ... | ... |
@@ -4,6 +4,7 @@ DIST_TAG=$1 |
| 4 | 4 |
DIST_VER=$2 |
| 5 | 5 |
SPEC_DIR=$3 |
| 6 | 6 |
STAGE_DIR=$4 |
| 7 |
+PH_BUILDER_TAG=$5 |
|
| 7 | 8 |
ARCH=x86_64 |
| 8 | 9 |
|
| 9 | 10 |
# |
| ... | ... |
@@ -32,7 +33,7 @@ fi |
| 32 | 32 |
mkdir -p tmp/k8smetserv |
| 33 | 33 |
cp ${K8S_MET_SERV_RPM_FILE} tmp/k8smetserv/
|
| 34 | 34 |
pushd ./tmp/k8smetserv |
| 35 |
-docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && rpm2cpio '${K8S_MET_SERV_RPM}' | cpio -vid"
|
|
| 35 |
+docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && rpm2cpio '${K8S_MET_SERV_RPM}' | cpio -vid"
|
|
| 36 | 36 |
popd |
| 37 | 37 |
|
| 38 | 38 |
docker build --rm -t ${IMG_NAME} -f ./Dockerfile.metrics-server .
|
| ... | ... |
@@ -6,6 +6,7 @@ DIST_TAG=$1 |
| 6 | 6 |
DIST_VER=$2 |
| 7 | 7 |
SPEC_DIR=$3 |
| 8 | 8 |
STAGE_DIR=$4 |
| 9 |
+PH_BUILDER_TAG=$5 |
|
| 9 | 10 |
ARCH=x86_64 |
| 10 | 11 |
|
| 11 | 12 |
# |
| ... | ... |
@@ -34,7 +35,7 @@ fi |
| 34 | 34 |
mkdir -p tmp/nginxinc |
| 35 | 35 |
cp ${NGINX_INC_RPM_FILE} tmp/nginxinc/
|
| 36 | 36 |
pushd ./tmp/nginxinc |
| 37 |
-docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && rpm2cpio '${NGINX_INC_RPM}' | cpio -vid"
|
|
| 37 |
+docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && rpm2cpio '${NGINX_INC_RPM}' | cpio -vid"
|
|
| 38 | 38 |
popd |
| 39 | 39 |
|
| 40 | 40 |
setup_repo |
| ... | ... |
@@ -6,6 +6,7 @@ DIST_TAG=$1 |
| 6 | 6 |
DIST_VER=$2 |
| 7 | 7 |
SPEC_DIR=$3 |
| 8 | 8 |
STAGE_DIR=$4 |
| 9 |
+PH_BUILDER_TAG=$5 |
|
| 9 | 10 |
ARCH=noarch |
| 10 | 11 |
|
| 11 | 12 |
# |
| ... | ... |
@@ -34,7 +35,7 @@ fi |
| 34 | 34 |
mkdir -p tmp/wavefront-proxy |
| 35 | 35 |
cp ${WAVEFRONT_PROXY_RPM_FILE} tmp/wavefront-proxy/
|
| 36 | 36 |
pushd ./tmp/wavefront-proxy |
| 37 |
-docker run --rm --privileged -v ${PWD}:${PWD} photon_builder bash -c "cd '${PWD}' && rpm2cpio '${WAVEFRONT_PROXY_RPM}' | cpio -vid"
|
|
| 37 |
+docker run --rm --privileged -v ${PWD}:${PWD} $PH_BUILDER_TAG bash -c "cd '${PWD}' && rpm2cpio '${WAVEFRONT_PROXY_RPM}' | cpio -vid"
|
|
| 38 | 38 |
popd |
| 39 | 39 |
|
| 40 | 40 |
setup_repo |
| ... | ... |
@@ -3,12 +3,13 @@ setup_repo() |
| 3 | 3 |
{
|
| 4 | 4 |
mkdir -p tmp |
| 5 | 5 |
ln -fs ${STAGE_DIR}/RPMS tmp/RPMS
|
| 6 |
- ETH0_IP=`ip -4 addr show eth0 scope global | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/'`
|
|
| 7 |
- cat stage-rpms.repo | sed 's/ETH0_IP/'"${ETH0_IP}"'/g' > tmp/stage-rpms.repo
|
|
| 6 |
+ iface="$(ip route list | awk '/^default/ {print $5}')"
|
|
| 7 |
+ IFACE_IP=$(ip -4 addr show "${iface}" scope global | grep 'inet ' | awk '{print $2}' | cut -f1 -d'/')
|
|
| 8 |
+ cat stage-rpms.repo | sed 's/IFACE_IP/'"${IFACE_IP}"'/g' > tmp/stage-rpms.repo
|
|
| 8 | 9 |
if ! iptables -C INPUT -p tcp --dport 62965 -j ACCEPT &> /dev/null; then |
| 9 | 10 |
iptables -A INPUT -p tcp --dport 62965 -j ACCEPT |
| 10 | 11 |
fi |
| 11 |
- python3 -m http.server --bind ${ETH0_IP} 62965 &
|
|
| 12 |
+ python3 -m http.server --bind ${IFACE_IP} 62965 &
|
|
| 12 | 13 |
PY_WS_PID=$! |
| 13 | 14 |
if [ -z "${PY_WS_PID}" ]; then
|
| 14 | 15 |
echo "Failed to start repo server" |
| 9 | 5 |
deleted file mode 100644 |
| ... | ... |
@@ -1,26 +0,0 @@ |
| 1 |
-# |
|
| 2 |
-# Ubuntu-Dev Dockerfile for building Linux Distribution. |
|
| 3 |
-# |
|
| 4 |
- |
|
| 5 |
-FROM ubuntu:14.04 |
|
| 6 |
- |
|
| 7 |
-RUN \ |
|
| 8 |
- sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list && \ |
|
| 9 |
- apt-get update && \ |
|
| 10 |
- apt-get -y upgrade && \ |
|
| 11 |
- apt-get install -y build-essential && \ |
|
| 12 |
- apt-get install -y \ |
|
| 13 |
- bison \ |
|
| 14 |
- createrepo \ |
|
| 15 |
- docker.io \ |
|
| 16 |
- gawk \ |
|
| 17 |
- genisoimage \ |
|
| 18 |
- g++ \ |
|
| 19 |
- python-aptdaemon && \ |
|
| 20 |
- rm -f /bin/sh && \ |
|
| 21 |
- ln -s /bin/bash /bin/sh && \ |
|
| 22 |
- rm -rf /var/lib/apt/lists/* |
|
| 23 |
- |
|
| 24 |
-WORKDIR ~/ |
|
| 25 |
- |
|
| 26 |
-CMD ["bash"] |
| ... | ... |
@@ -128,7 +128,7 @@ def createIso(options): |
| 128 | 128 |
options.rpm_path, options.package_list_file, |
| 129 | 129 |
rpm_list, options.stage_path, files_to_copy, |
| 130 | 130 |
options.generated_data_path, initrd_pkgs, |
| 131 |
- options.ph_docker_image]) |
|
| 131 |
+ options.ph_docker_image, options.ph_builder_tag]) |
|
| 132 | 132 |
|
| 133 | 133 |
if retval: |
| 134 | 134 |
raise Exception("Unable to create install ISO")
|
| ... | ... |
@@ -23,6 +23,7 @@ PACKAGE_LIST_FILE_BASE_NAME=$(basename "${PACKAGE_LIST_FILE}")
|
| 23 | 23 |
INITRD=${WORKINGDIR}/photon-chroot
|
| 24 | 24 |
PACKAGES=$8 |
| 25 | 25 |
PHOTON_DOCKER_IMAGE=$9 |
| 26 |
+PH_BUILDER_TAG=${10}
|
|
| 26 | 27 |
|
| 27 | 28 |
rm -rf $WORKINGDIR/* |
| 28 | 29 |
mkdir -m 755 -p $INITRD |
| ... | ... |
@@ -51,7 +52,15 @@ clean_requirements_on_remove=true |
| 51 | 51 |
repodir=${WORKINGDIR}
|
| 52 | 52 |
EOF |
| 53 | 53 |
|
| 54 |
-rpm --root $INITRD --initdb --dbpath /var/lib/rpm |
|
| 54 |
+rpmdb_init_cmd="rpm --root ${INITRD} --initdb --dbpath /var/lib/rpm"
|
|
| 55 |
+if [ "$(rpm -E %{_db_backend})" != "sqlite" ]; then
|
|
| 56 |
+ rpmdb_init_cmd="docker run --rm -v ${INITRD}:${INITRD} $PH_BUILDER_TAG /bin/bash -c \"${rpmdb_init_cmd}\""
|
|
| 57 |
+fi |
|
| 58 |
+ |
|
| 59 |
+if ! eval "${rpmdb_init_cmd}"; then
|
|
| 60 |
+ echo "ERROR: failed to initialize rpmdb" 1>&2 |
|
| 61 |
+ exit 1 |
|
| 62 |
+fi |
|
| 55 | 63 |
|
| 56 | 64 |
TDNF_CMD="tdnf install -qy \ |
| 57 | 65 |
--releasever $PHOTON_RELEASE_VER \ |
| ... | ... |
@@ -61,7 +70,7 @@ TDNF_CMD="tdnf install -qy \ |
| 61 | 61 |
${PACKAGES}"
|
| 62 | 62 |
|
| 63 | 63 |
# run host's tdnf, if fails - try one from photon:latest docker image |
| 64 |
-$TDNF_CMD || docker run -v $RPMS_PATH:$RPMS_PATH -v $WORKINGDIR:$WORKINGDIR $PHOTON_DOCKER_IMAGE /bin/bash -c "$TDNF_CMD" |
|
| 64 |
+$TDNF_CMD || docker run --rm -v $RPMS_PATH:$RPMS_PATH -v $WORKINGDIR:$WORKINGDIR $PHOTON_DOCKER_IMAGE /bin/bash -c "$TDNF_CMD" |
|
| 65 | 65 |
|
| 66 | 66 |
rm -f ${WORKINGDIR}/photon-local.repo ${WORKINGDIR}/tdnf.conf
|
| 67 | 67 |
|
| ... | ... |
@@ -4,8 +4,8 @@ set -x |
| 4 | 4 |
|
| 5 | 5 |
if [ "$#" -lt 0 ]; then |
| 6 | 6 |
echo "Script to create new Photon OSTree repo inside a docker container." |
| 7 |
- echo "Usage: $0 " |
|
| 8 |
- exit -1 |
|
| 7 |
+ echo "Usage: $0" |
|
| 8 |
+ exit 1 |
|
| 9 | 9 |
fi |
| 10 | 10 |
|
| 11 | 11 |
PROGRAM=$0 |
| ... | ... |
@@ -18,8 +18,12 @@ cat > ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh << EOF
|
| 18 | 18 |
|
| 19 | 19 |
ROOT=$1 |
| 20 | 20 |
|
| 21 |
-sed -i 's#https://dl.bintray.com/vmware#https://packages.vmware.com/photon/\$releasever#g' /etc/yum.repos.d/*.repo |
|
| 22 |
-tdnf install -y rpm |
|
| 21 |
+cp photon-ostree.repo /etc/yum.repos.d |
|
| 22 |
+if ! tdnf install -y rpm ostree rpm-ostree --disablerepo=* --enablerepo=photon-ostree; then |
|
| 23 |
+ echo "ERROR: failed to install packages while preparing ostree server" 1>&2 |
|
| 24 |
+ exit 1 |
|
| 25 |
+fi |
|
| 26 |
+ |
|
| 23 | 27 |
mkdir -p ${ROOT}/srv/rpm-ostree
|
| 24 | 28 |
ostree --repo=${ROOT}/srv/rpm-ostree/repo init --mode=archive-z2
|
| 25 | 29 |
rpm-ostree compose tree --repo=${ROOT}/srv/rpm-ostree/repo photon-base.json
|
| ... | ... |
@@ -27,20 +31,19 @@ EOF |
| 27 | 27 |
|
| 28 | 28 |
chmod +x ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh
|
| 29 | 29 |
|
| 30 |
-cp ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo.bak
|
|
| 31 |
-echo "baseurl=file:///RPMS" >> ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo
|
|
| 32 |
- |
|
| 33 | 30 |
rm -rf ${STAGE_DIR}/ostree-repo
|
| 34 | 31 |
mkdir -p ${STAGE_DIR}/ostree-repo
|
| 35 | 32 |
|
| 36 |
-sudo docker run --privileged -v ${SRCROOT}:/photon -v ${STAGE_DIR}/RPMS:/RPMS -v ${STAGE_DIR}/ostree-repo:/srv/rpm-ostree -w="/photon/support/image-builder/ostree-tools/" ${PHOTON_DOCKER_IMAGE} ./mk-ostree-server.sh /
|
|
| 33 |
+sudo docker run --privileged -v ${SRCROOT}:/photon \
|
|
| 34 |
+ -v ${STAGE_DIR}/RPMS:/RPMS \
|
|
| 35 |
+ -v ${STAGE_DIR}/ostree-repo:/srv/rpm-ostree \
|
|
| 36 |
+ -w="/photon/support/image-builder/ostree-tools/" \ |
|
| 37 |
+ ${PHOTON_DOCKER_IMAGE} ./mk-ostree-server.sh /
|
|
| 37 | 38 |
|
| 38 | 39 |
REPODIR=${STAGE_DIR}/ostree-repo/repo
|
| 39 | 40 |
if [ -d "$REPODIR" ]; then |
| 40 | 41 |
tar -zcf ${STAGE_DIR}/ostree-repo.tar.gz -C ${REPODIR} .
|
| 41 | 42 |
fi |
| 42 | 43 |
|
| 43 |
-# Restore file |
|
| 44 |
-mv -f ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo.bak ${SRCROOT}/support/image-builder/ostree-tools/photon-ostree.repo
|
|
| 45 |
-sudo rm ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh
|
|
| 46 |
-sudo rm -rf ${STAGE_DIR}/ostree-repo
|
|
| 44 |
+sudo rm -rf ${SRCROOT}/support/image-builder/ostree-tools/mk-ostree-server.sh \
|
|
| 45 |
+ ${STAGE_DIR}/ostree-repo
|
| ... | ... |
@@ -1,6 +1,7 @@ |
| 1 | 1 |
import os |
| 2 | 2 |
import threading |
| 3 | 3 |
import copy |
| 4 |
+import docker |
|
| 4 | 5 |
from PackageBuildDataGenerator import PackageBuildDataGenerator |
| 5 | 6 |
from Logger import Logger |
| 6 | 7 |
from constants import constants |
| ... | ... |
@@ -30,7 +31,6 @@ class PackageManager(object): |
| 30 | 30 |
self.listOfPackagesAlreadyBuilt = set() |
| 31 | 31 |
self.pkgBuildType = pkgBuildType |
| 32 | 32 |
if self.pkgBuildType == "container": |
| 33 |
- import docker |
|
| 34 | 33 |
self.dockerClient = docker.from_env(version="auto") |
| 35 | 34 |
|
| 36 | 35 |
def buildToolChain(self): |
| ... | ... |
@@ -129,22 +129,21 @@ class ToolChainUtils(object): |
| 129 | 129 |
self.logger.debug(rpmFiles) |
| 130 | 130 |
self.logger.debug(packages) |
| 131 | 131 |
cmd = (self.rpmCommand + " -i -v --nodeps --noorder --force --root " + |
| 132 |
- chroot.getID() +" --define \'_dbpath /var/lib/rpm\' "+ rpmFiles) |
|
| 132 |
+ chroot.getID() + " -D \'_dbpath /var/lib/rpm\' " + rpmFiles) |
|
| 133 | 133 |
|
| 134 | 134 |
# If rpm doesn't have zstd support, use rpm from photon_builder image |
| 135 |
- if constants.hostRpmIsNotUsable: |
|
| 135 |
+ if constants.checkIfHostRpmNotUsable(): |
|
| 136 | 136 |
# if we are not root, make installed files owned by effective user to |
| 137 | 137 |
# support pure non-root package building. |
| 138 |
- if os.geteuid() != 0: |
|
| 138 |
+ if os.geteuid(): |
|
| 139 | 139 |
cmd = cmd + "; chown -R {0}:{1} {2}".format(os.geteuid(), os.getegid(), chroot.getID())
|
| 140 |
- cmd = ("docker run -i -v " + constants.prevPublishRPMRepo + ":" + constants.prevPublishRPMRepo +
|
|
| 140 |
+ cmd = ("docker run --rm -i -v " + constants.prevPublishRPMRepo + ":" + constants.prevPublishRPMRepo +
|
|
| 141 | 141 |
" -v " + constants.inputRPMSPath + ":" + constants.inputRPMSPath + |
| 142 | 142 |
" -v " + constants.rpmPath + ":" + constants.rpmPath + " -v " + chroot.getID() + ":" + |
| 143 |
- chroot.getID() + " photon_builder:latest " + "/bin/bash -c \"" + cmd + "\"") |
|
| 143 |
+ chroot.getID() + " " + constants.phBuilderTag + " /bin/bash -c \"" + cmd + "\"") |
|
| 144 | 144 |
|
| 145 | 145 |
self.logger.debug("Executing cmd: " + cmd)
|
| 146 |
- retVal = CommandUtils.runCommandInShell(cmd, logfn=self.logger.debug) |
|
| 147 |
- if retVal != 0: |
|
| 146 |
+ if CommandUtils.runCommandInShell(cmd, logfn=self.logger.debug): |
|
| 148 | 147 |
self.logger.error("Installing toolchain RPMS failed")
|
| 149 | 148 |
raise Exception("RPM installation failed")
|
| 150 | 149 |
self.logger.debug("Successfully installed default toolchain RPMS in Chroot:" + chroot.getID())
|
| ... | ... |
@@ -213,9 +212,9 @@ class ToolChainUtils(object): |
| 213 | 213 |
CommandUtils.runCommandInShell(cmd, logfn=self.logger.debug) |
| 214 | 214 |
|
| 215 | 215 |
if rpmFiles != "": |
| 216 |
- cmd = (self.rpmCommand+" -Uvh --nodeps --ignorearch --noscripts --root "+ |
|
| 217 |
- chroot.getID() +"/target-"+ constants.targetArch+ |
|
| 218 |
- " --define \'_dbpath /var/lib/rpm\' "+rpmFiles) |
|
| 216 |
+ cmd = (self.rpmCommand + " -Uvh --nodeps --ignorearch --noscripts --root " + |
|
| 217 |
+ chroot.getID() + "/target-" + |
|
| 218 |
+ constants.targetArch + " -D \'_dbpath /var/lib/rpm\' " + rpmFiles) |
|
| 219 | 219 |
retVal = CommandUtils.runCommandInShell(cmd, logfn=self.logger.debug) |
| 220 | 220 |
if retVal != 0: |
| 221 | 221 |
self.logger.debug("Command Executed:" + cmd)
|
| ... | ... |
@@ -1,5 +1,7 @@ |
| 1 | 1 |
import platform |
| 2 |
+ |
|
| 2 | 3 |
from Logger import Logger |
| 4 |
+from CommandUtils import CommandUtils as cmdUtils |
|
| 3 | 5 |
|
| 4 | 6 |
class constants(object): |
| 5 | 7 |
specPath = "" |
| ... | ... |
@@ -36,7 +38,8 @@ class constants(object): |
| 36 | 36 |
targetArch = platform.machine() |
| 37 | 37 |
crossCompiling = False |
| 38 | 38 |
currentArch = buildArch |
| 39 |
- hostRpmIsNotUsable = False |
|
| 39 |
+ hostRpmIsNotUsable = -1 |
|
| 40 |
+ phBuilderTag = "" |
|
| 40 | 41 |
|
| 41 | 42 |
noDepsPackageList = [ |
| 42 | 43 |
"texinfo", |
| ... | ... |
@@ -477,3 +480,24 @@ class constants(object): |
| 477 | 477 |
k, v = m.split(' ', 1)
|
| 478 | 478 |
macros[k] = v |
| 479 | 479 |
return macros |
| 480 |
+ |
|
| 481 |
+ def checkIfHostRpmNotUsable(): |
|
| 482 |
+ if constants.hostRpmIsNotUsable >= 0: |
|
| 483 |
+ return constants.hostRpmIsNotUsable |
|
| 484 |
+ |
|
| 485 |
+ # if rpm doesn't have zstd support |
|
| 486 |
+ # if host rpm doesn't support sqlite backend db |
|
| 487 |
+ cmds = [ |
|
| 488 |
+ "rpm --showrc | grep -qw 'rpmlib(PayloadIsZstd)'", |
|
| 489 |
+ "rpm -E %{_db_backend} | grep -qw 'sqlite'",
|
|
| 490 |
+ ] |
|
| 491 |
+ |
|
| 492 |
+ for cmd in cmds: |
|
| 493 |
+ if cmdUtils.runCommandInShell(cmd): |
|
| 494 |
+ constants.hostRpmIsNotUsable = 1 |
|
| 495 |
+ break |
|
| 496 |
+ |
|
| 497 |
+ if constants.hostRpmIsNotUsable < 0: |
|
| 498 |
+ constants.hostRpmIsNotUsable = 0 |
|
| 499 |
+ |
|
| 500 |
+ return constants.hostRpmIsNotUsable |
| 480 | 501 |
new file mode 100755 |
| ... | ... |
@@ -0,0 +1,36 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+ |
|
| 2 |
+if [ $# -ne 3 ]; then |
|
| 3 |
+ echo "$0: ERROR: invalid number of args" 1>&2 |
|
| 4 |
+ exit 1 |
|
| 5 |
+fi |
|
| 6 |
+ |
|
| 7 |
+img_url=$1 |
|
| 8 |
+img_tag=$2 |
|
| 9 |
+ph_builder_tag=$3 |
|
| 10 |
+ |
|
| 11 |
+ret="$(docker image inspect -f {{.Comment}} ${img_tag} 2>/dev/null)"
|
|
| 12 |
+if [ $? -eq 0 ]; then |
|
| 13 |
+ ret="$(echo ${ret} | cut -d' ' -f3)"
|
|
| 14 |
+else |
|
| 15 |
+ ret="" |
|
| 16 |
+fi |
|
| 17 |
+ |
|
| 18 |
+photon_builder_dockerfile="support/package-builder/Dockerfile.photon_builder" |
|
| 19 |
+ |
|
| 20 |
+if [ "${ret}" != "${img_url}" ]; then
|
|
| 21 |
+ docker rmi -f "${img_tag}" "${ph_builder_tag}"
|
|
| 22 |
+ |
|
| 23 |
+ echo "Creating photon builder docker image ..." |
|
| 24 |
+ if ! docker import "${img_url}" "${img_tag}"; then
|
|
| 25 |
+ echo "ERROR: docker import of ph3 docker image failed" 1>&2 |
|
| 26 |
+ exit 1 |
|
| 27 |
+ fi |
|
| 28 |
+ |
|
| 29 |
+ if ! docker build --tag "${ph_builder_tag}" -f ${photon_builder_dockerfile} . 1>/dev/null; then
|
|
| 30 |
+ echo "ERROR: failed to build ${ph_builder_tag} docker image" 1>&2
|
|
| 31 |
+ exit 1 |
|
| 32 |
+ fi |
|
| 33 |
+fi |
|
| 34 |
+ |
|
| 35 |
+exit 0 |
| 0 | 36 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,26 @@ |
| 0 |
+CC := gcc |
|
| 1 |
+RM := /bin/rm |
|
| 2 |
+CFLAGS := -O2 -std=gnu99 -Wall -Wextra |
|
| 3 |
+ |
|
| 4 |
+SRC_DIR := . |
|
| 5 |
+SRCS := $(wildcard $(SRC_DIR)/*.c) |
|
| 6 |
+HDRS := $(wildcard $(SRC_DIR)/*.h) |
|
| 7 |
+TARGET_EXEC := contain_unpriv |
|
| 8 |
+ |
|
| 9 |
+.PHONY: clean |
|
| 10 |
+ |
|
| 11 |
+all: $(TARGET_EXEC) |
|
| 12 |
+ |
|
| 13 |
+$(TARGET_EXEC): $(SRCS) $(HDRS) |
|
| 14 |
+ @$(CC) $(CFLAGS) -o $@ $(SRCS) |
|
| 15 |
+ |
|
| 16 |
+install: all |
|
| 17 |
+ifneq ($(shell id -u), 0) |
|
| 18 |
+ @echo "You must be root to perform this action." |
|
| 19 |
+else |
|
| 20 |
+ @cp ./$(TARGET_EXEC) ../../bin/ |
|
| 21 |
+ @install -o root -g root -m 4755 ../../bin/$(TARGET_EXEC) ../../bin/contain |
|
| 22 |
+endif |
|
| 23 |
+ |
|
| 24 |
+clean: |
|
| 25 |
+ @$(RM) -f ../../bin/$(TARGET_EXEC) ./$(TARGET_EXEC) |