Skip to content

Commit 3a23e6d

Browse files
committed
tools: Enhancing the tool to support iso build
pytest: Adding test to build iso for 4.0 and 5.0
1 parent 93a5f96 commit 3a23e6d

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

create-image-util

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ create_flavor_image()
125125
if [ $IMAGE_FLAVOR = "azure" ]; then
126126
#build azure
127127
exec_docker_cmd="$exec_docker_cmd create-azure --raw-image ${RAW_IMAGE}"
128+
elif [ $IMAGE_FLAVOR = "iso" ]; then
129+
#build iso
130+
exec_docker_cmd="$exec_docker_cmd photon-iso-builder -f build-iso -v ${RELEASE_VERSION} -p ${KS_CONFIG_FILE}"
128131
elif [ $IMAGE_FLAVOR = "ova" ]; then
129132
#build ova
130133
exec_docker_cmd="$exec_docker_cmd create-ova --installer-config ${KS_CONFIG_FILE} --ova-config ${OVA_CONFIG} --ova-name ${OVA_NAME} --raw-image ${RAW_IMAGE}"
@@ -236,6 +239,17 @@ usage() {
236239
echo "create 4.0 RPI with remote repo"
237240
echo "$0 --config-file rpi_ks.yaml --local-repo-path /home/dbx/poi/repo/4.0 --poi-path /home/dbx/workspace/poi_gitlab/photon-os-installer/ --flavor rpi --arch aarch64 --releasever 4.0 --src-repo-url=https://packages.vmware.com/photon/4.0/photon_updates_4.0_x86_64/"
238241
echo "============================================================"
242+
echo " create ISO image "
243+
echo "============================================================"
244+
echo "create 5.0 ISO"
245+
echo "$0 --config-file packages_minimal.json --local-repo-path /home/dbx/poi/repo/5.0 --poi-path /home/dbx/workspace/poi_gitlab/photon-os-installer/ --flavor iso"
246+
echo "-------------------------------------------------------------"
247+
echo "create 4.0 ISO"
248+
echo "$0 --config-file packages_minimal.json --local-repo-path /home/dbx/poi/repo/4.0 --poi-path /home/dbx/workspace/poi_gitlab/photon-os-installer/ --flavor iso --releasever 4.0"
249+
echo "-------------------------------------------------------------"
250+
echo "create 4.0 ISO with remote repo"
251+
echo "$0 --config-file packages_minimal.json --local-repo-path /home/dbx/poi/repo/4.0 --poi-path /home/dbx/workspace/poi_gitlab/photon-os-installer/ --flavor iso --releasever 4.0 --src-repo-url=https://packages.vmware.com/photon/4.0/photon_updates_4.0_x86_64/"
252+
echo "============================================================"
239253

240254
}
241255

@@ -271,7 +285,7 @@ while true; do
271285
done
272286

273287
if [ -z "${RAW_IMAGE}" ]; then
274-
if [ $IMAGE_FLAVOR != "ami" -a $IMAGE_FLAVOR != "rpi" ] ; then
288+
if [ $IMAGE_FLAVOR != "ami" -a $IMAGE_FLAVOR != "rpi" -a $IMAGE_FLAVOR != "iso" ] ; then
275289
echo "raw image is missing" >&2
276290
usage
277291
echo "Terminating." >&2
@@ -327,9 +341,11 @@ fi
327341
init_env
328342

329343
#Create repository and raw image
330-
create_repo_and_raw_image
344+
if [ ${IMAGE_FLAVOR} != "iso" ] ; then
345+
create_repo_and_raw_image
346+
fi
331347

332348
#Create final image
333-
if [ ${IMAGE_FLAVOR} = "ova" -o ${IMAGE_FLAVOR} = "azure" ] ; then
349+
if [ ${IMAGE_FLAVOR} = "ova" -o ${IMAGE_FLAVOR} = "azure" -o ${IMAGE_FLAVOR} = "iso" ] ; then
334350
create_flavor_image
335351
fi

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ FROM ${DOCKER_PROXY}library/photon:5.0 as poi-rpm-builder
3434
ARG TDNF_OPTIONS
3535

3636
RUN tdnf ${TDNF_OPTIONS} makecache && \
37-
tdnf ${TDNF_OPTIONS} -y install git rpm-build python3 createrepo
37+
tdnf ${TDNF_OPTIONS} -y install git rpm-build python3 createrepo ca-certificates openssl
3838

3939
COPY --from=poi-helper / /photon-os-installer
4040

@@ -61,7 +61,7 @@ RUN tdnf ${TDNF_OPTIONS} makecache && \
6161
python3-rpm \
6262
qemu-img \
6363
open-vmdk ostree rpm-ostree \
64-
stig-hardening \
64+
stig-hardening ca-certificates openssl \
6565
$([ "${TARGETARCH}" == "amd64" ] && echo grub2-pc) && \
6666
rm -rf /var/cache/tdnf
6767

tests/poi-container-test.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
LOCAL_REPO_PATH = POI_TEST_PATH + "/repo"
1616

1717
BASE_COMMAND = f"{POI_PATH}/create-image-util --poi-path {POI_PATH} --local-repo-path"
18-
IMAGE_FLAVOR = ["azure", "ova", "rpi", "ami"]
18+
IMAGE_FLAVOR = ["azure", "ova", "rpi", "ami", "iso"]
1919

2020

2121
def create_repo_path():
2222
os.makedirs(LOCAL_REPO_PATH, exist_ok=True)
2323

2424

2525
def remove_build_images(directory):
26-
patterns = ["*.vhd.tar.gz", "*.ova", "*.ovf", "*.mf", "*.raw", "*.img", "poi-manifest.json"]
26+
patterns = ["*.vhd.tar.gz", "*.ova", "*.ovf", "*.mf", "*.raw", "*.img"," *.iso", "poi-manifest.json"]
2727

2828
files = [file for pattern in patterns for file in glob.glob(f"{directory}/{pattern}")]
2929
for file in files:
@@ -93,6 +93,11 @@ def test_build_ph5_local_ami_image(self):
9393
subprocess.check_call(exec_command, shell = True)
9494
assert(image_exist("ami", "photon-ami.raw") == True)
9595

96+
def test_build_ph5_local_iso_image(self):
97+
exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/5.0 --config-file packages_minimal.json --flavor iso"
98+
99+
subprocess.check_call(exec_command, shell = True)
100+
assert(image_exist("iso", "something.iso") == True)
96101
'''
97102
def test_build_ph5_local_rpi_image(self):
98103
exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/5.0 --config-file rpi_ks.yaml --flavor rpi --arch aarch64"
@@ -138,9 +143,15 @@ def test_build_ph4_local_lvm_ova_image(self):
138143

139144
def test_build_ph4_local_ami_image(self):
140145
exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/4.0 --config-file ami_40_ks.yaml --flavor ami --releasever 4.0"
146+
141147
subprocess.check_call(exec_command, shell = True)
142148
assert(image_exist("ami", "photon-ami-4.0.raw") == True)
143149

150+
def test_build_ph4_local_iso_image(self):
151+
exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/4.0 --config-file packages_minimal.json --flavor iso --releasever 4.0"
152+
153+
subprocess.check_call(exec_command, shell = True)
154+
assert(image_exist("iso", "something.iso") == True)
144155
'''
145156
def test_build_ph4_local_rpi_image(self):
146157
exec_command = f"{BASE_COMMAND} {LOCAL_REPO_PATH}/4.0 --config-file rpi_ks.yaml --flavor rpi --arch aarch64 --releasever 4.0"

0 commit comments

Comments
 (0)