Compare commits
4 Commits
bb6b8523a3
...
5a2c16ff28
Author | SHA1 | Date | |
---|---|---|---|
5a2c16ff28 | |||
7c16cc2cdc | |||
0ea2b7fb48 | |||
a5f757140b |
@ -57,8 +57,6 @@ RUN rm -rf /etc/yum.repos.d/*.repo /get_arch
|
|||||||
|
|
||||||
RUN pip install awscli
|
RUN pip install awscli
|
||||||
|
|
||||||
ARG BRANCH=r9
|
|
||||||
RUN git clone https://git.resf.org/sig_core/kickstarts.git --branch $BRANCH /kickstarts
|
|
||||||
|
|
||||||
RUN pip install 'git+https://git.resf.org/sig_core/toolkit.git@devel#egg=empanadas&subdirectory=iso/empanadas'
|
RUN pip install 'git+https://git.resf.org/sig_core/toolkit.git@devel#egg=empanadas&subdirectory=iso/empanadas'
|
||||||
|
|
||||||
|
@ -65,7 +65,8 @@ config = {
|
|||||||
"x86_64": "amd64",
|
"x86_64": "amd64",
|
||||||
"aarch64": "arm64",
|
"aarch64": "arm64",
|
||||||
"ppc64le": "ppc64le",
|
"ppc64le": "ppc64le",
|
||||||
"s390x": "s390x"
|
"s390x": "s390x",
|
||||||
|
"i686": "386"
|
||||||
},
|
},
|
||||||
"aws_region": "us-east-2",
|
"aws_region": "us-east-2",
|
||||||
"bucket": "resf-empanadas",
|
"bucket": "resf-empanadas",
|
||||||
|
@ -55,6 +55,9 @@ STORAGE_DIR = pathlib.Path("/var/lib/imagefactory/storage")
|
|||||||
KICKSTART_PATH = pathlib.Path(os.environ.get("KICKSTART_PATH", "/kickstarts"))
|
KICKSTART_PATH = pathlib.Path(os.environ.get("KICKSTART_PATH", "/kickstarts"))
|
||||||
BUILDTIME = datetime.datetime.utcnow()
|
BUILDTIME = datetime.datetime.utcnow()
|
||||||
|
|
||||||
|
|
||||||
|
CMD_PARAM_T = List[Union[str, Callable[..., str]]]
|
||||||
|
|
||||||
@define(kw_only=True)
|
@define(kw_only=True)
|
||||||
class ImageBuild:
|
class ImageBuild:
|
||||||
architecture: Architecture = field()
|
architecture: Architecture = field()
|
||||||
@ -89,10 +92,12 @@ class ImageBuild:
|
|||||||
self.command_args = self._command_args()
|
self.command_args = self._command_args()
|
||||||
self.package_args = self._package_args()
|
self.package_args = self._package_args()
|
||||||
self.common_args = self._common_args()
|
self.common_args = self._common_args()
|
||||||
self.kickstart_arg = self.kickstart_imagefactory_args()
|
|
||||||
|
|
||||||
self.metadata = pathlib.Path(self.outdir, "metadata.json")
|
self.metadata = pathlib.Path(self.outdir, "metadata.json")
|
||||||
|
|
||||||
|
self.checkout_kickstarts()
|
||||||
|
self.kickstart_arg = self.kickstart_imagefactory_args()
|
||||||
|
|
||||||
# Yes, this is gross. I'll fix it later.
|
# Yes, this is gross. I'll fix it later.
|
||||||
if self.image_type in ["Container"]:
|
if self.image_type in ["Container"]:
|
||||||
self.stage_commands = [
|
self.stage_commands = [
|
||||||
@ -112,8 +117,6 @@ class ImageBuild:
|
|||||||
["/prep-azure.sh", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{STORAGE_DIR}"],
|
["/prep-azure.sh", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{STORAGE_DIR}"],
|
||||||
["cp", lambda: f"{STORAGE_DIR}/{self.target_uuid}.vhd", f"{self.outdir}/{self.outname}.vhd"]
|
["cp", lambda: f"{STORAGE_DIR}/{self.target_uuid}.vhd", f"{self.outdir}/{self.outname}.vhd"]
|
||||||
]
|
]
|
||||||
# ["qemu-img", "resize", "-f", "raw", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", lambda: f"{self.rounded_size()}"],
|
|
||||||
# ["qemu-img", "convert", "-f", "raw", "-o", "subformat=fixed,force_size" ,"-O", "vpc", lambda: f"{STORAGE_DIR}/{self.target_uuid}.body", f"{self.outdir}/{self.outname}.vhd"]
|
|
||||||
if self.image_type in ["Vagrant"]:
|
if self.image_type in ["Vagrant"]:
|
||||||
_map = {
|
_map = {
|
||||||
"Vbox": "vmdk",
|
"Vbox": "vmdk",
|
||||||
@ -147,12 +150,27 @@ class ImageBuild:
|
|||||||
finally:
|
finally:
|
||||||
f.flush()
|
f.flush()
|
||||||
|
|
||||||
# def rounded_size(self) -> int:
|
def checkout_kickstarts(self) -> int:
|
||||||
# # Azure images need to be rounded to the nearest 1MB boundary.
|
cmd = ["git", "clone", "--branch", f"r{self.architecture.major}", rlvars['livemap']['git_repo'], f"{KICKSTART_PATH}"]
|
||||||
# MB=1024*1024
|
ret, out, err, _ = self.runCmd(cmd, search=False)
|
||||||
#
|
log.debug(out)
|
||||||
# raw_size = pathlib.Path(STORAGE_DIR},f"{self.target_uuid}.body").stat().st_size
|
log.debug(err)
|
||||||
# rounded_size = raw
|
if ret > 0:
|
||||||
|
ret = self.pull_kickstarts()
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def pull_kickstarts(self) -> int:
|
||||||
|
cmd: CMD_PARAM_T = ["git", "-C", f"{KICKSTART_PATH}", "reset", "--hard", "HEAD"]
|
||||||
|
ret, out, err, _ = self.runCmd(cmd, search=False)
|
||||||
|
log.debug(out)
|
||||||
|
log.debug(err)
|
||||||
|
if ret == 0:
|
||||||
|
cmd = ["git", "-C", f"{KICKSTART_PATH}", "pull"]
|
||||||
|
ret, out, err, _ = self.runCmd(cmd, search=False)
|
||||||
|
log.debug(out)
|
||||||
|
log.debug(err)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def output_name(self) -> Tuple[pathlib.Path, str]:
|
def output_name(self) -> Tuple[pathlib.Path, str]:
|
||||||
directory = f"Rocky-{self.architecture.major}-{self.type_variant}-{self.architecture.version}-{BUILDTIME.strftime('%Y%m%d')}.{self.release}"
|
directory = f"Rocky-{self.architecture.major}-{self.type_variant}-{self.architecture.version}-{BUILDTIME.strftime('%Y%m%d')}.{self.release}"
|
||||||
@ -301,7 +319,7 @@ class ImageBuild:
|
|||||||
log.info(f"Build complete! Output available in {self.outdir}/")
|
log.info(f"Build complete! Output available in {self.outdir}/")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def runCmd(self, command: List[Union[str, Callable]], search: bool = True) -> Tuple[int, Union[bytes,None], Union[bytes,None], Union[str,None]]:
|
def runCmd(self, command: CMD_PARAM_T, search: bool = True) -> Tuple[int, Union[bytes,None], Union[bytes,None], Union[str,None]]:
|
||||||
prepared, _ = self.prepare_command(command)
|
prepared, _ = self.prepare_command(command)
|
||||||
log.info(f"Running command: {' '.join(prepared)}")
|
log.info(f"Running command: {' '.join(prepared)}")
|
||||||
|
|
||||||
@ -332,7 +350,7 @@ class ImageBuild:
|
|||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def prepare_command(self, command_list: List[Union[str, Callable]]) -> Tuple[List[str],List[None]]:
|
def prepare_command(self, command_list: CMD_PARAM_T) -> Tuple[List[str],List[None]]:
|
||||||
"""
|
"""
|
||||||
Commands may be a callable, which should be a lambda to be evaluated at
|
Commands may be a callable, which should be a lambda to be evaluated at
|
||||||
preparation time with available locals. This can be used to, among
|
preparation time with available locals. This can be used to, among
|
||||||
|
@ -21,7 +21,8 @@ SOURCE_AMI_NAME=$(aws --profile resf-ami ec2 describe-images \
|
|||||||
|
|
||||||
# Enforce a name structure
|
# Enforce a name structure
|
||||||
# Rocky-8-ec2-8.6-20220515.0.x86_64
|
# Rocky-8-ec2-8.6-20220515.0.x86_64
|
||||||
if [[ ! "${SOURCE_AMI_NAME}" =~ Rocky-[89]-ec2-[89]\.[0-9]-[0-9]+\.[0-9]+\.((aarch|x86_)64|ppc64le|s390x) ]]; then
|
pat="Rocky-[89]-[Ee][Cc]2-[89]\.[0-9]-[0-9]+\.[0-9]+\.((aarch|x86_)64|ppc64le|s390x)"
|
||||||
|
if [[ ! "${SOURCE_AMI_NAME}" =~ $pat ]]; then
|
||||||
echo "Bad source ami (${SOURCE_AMI_NAME}). Exiting."
|
echo "Bad source ami (${SOURCE_AMI_NAME}). Exiting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user