Skip to content

Commit d1f6011

Browse files
authored
(olss): OL9 support (#70)
* fix(olit): 🐛 do not remove psmisc Fixes #65 Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * feat(olit): ✨ support for distr::seal provisioner Support for "sealing" the image from inside the VM instead of using the *::cleanup scripts on the host. This provides a alternative when mounting the image filesystem on the host is not possible of desirable. Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * feat(olit): ✨ use virtio network driver for VirtualBox Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * feat(olit): ✨ set cpu to "host" for x86 qemu builds Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * refactor(olit): ♻️ ol8-slim use seal Refactor OL8 Slim distr to use "seal" instead of "image_cleanup" as workaround to the "slow boot" issue experienced when images are repackaged Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * feat(olss): ✨ add ol9-slim distribution Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * feat(olss): ✨ add ol9-aarch64 distribution Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * docs(olss): 📝 readme update for ol9 Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * feat(olss): ✨ ol9 - handle kernel-core / kernel-modules Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * feat(olss): ✨ ol8 - uek7 update Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com> * fix(olss): 🐛 Ensure we have the correct boot options Signed-off-by: Philippe Vanhaesendonck <philippe.vanhaesendonck@oracle.com>
1 parent 800f002 commit d1f6011

34 files changed

+1891
-204
lines changed

oracle-linux-image-tools/README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ The tool currently supports:
1111

1212
- Distributions:
1313
- Oracle Linux 7 update 9 -- Slim (x86_64)
14-
- Oracle Linux 8 update 5 -- Slim (x86_64 and aarch64)
14+
- Oracle Linux 8 update 6 -- Slim (x86_64 and aarch64)
15+
__Note__: for aarch64, only Generic and OCI clouds are supported
16+
- Oracle Linux 9 update 0 -- Slim (x86_64 and aarch64)
1517
__Note__: for aarch64, only Generic and OCI clouds are supported
1618
- Clouds:
1719
- Microsoft Azure cloud
@@ -87,12 +89,13 @@ The build script requires a Linux environment and has been tested on Oracle Linu
8789
Instead of providing an Oracle Linux distribution ISO you can use a _boot_ ISO image.
8890
In that case, you will have to provide an URL to an installation tree and optionally additional yum repositories required by the installation.
8991

90-
Example for an Oracle Linux 8 Update 5 using the UEK boot ISO:
92+
Example for an Oracle Linux 9 using the UEK boot ISO:
9193

9294
```Shell
93-
ISO_URL="https://yum.oracle.com/ISOS/OracleLinux/OL8/u5/x86_64/x86_64-boot-uek.iso"
94-
REPO_URL="https://yum.oracle.com/repo/OracleLinux/OL8/baseos/latest/x86_64"
95-
REPO[AppStream]="https://yum.oracle.com/repo/OracleLinux/OL8/appstream/x86_64"
95+
ISO_URL="https://yum.oracle.com/ISOS/OracleLinux/OL9/u0/x86_64/OracleLinux-R9-U0-x86_64-boot-uek.iso"
96+
REPO_URL="https://yum.oracle.com/repo/OracleLinux/OL9/baseos/latest/x86_64"
97+
REPO[AppStream]="https://yum.oracle.com/repo/OracleLinux/OL9/appstream/x86_64"
98+
REPO[ol9_UEKR7]="https://yum.oracle.com/repo/OracleLinux/OL9/UEKR7/x86_64"
9699
```
97100

98101
### Customizing builds
@@ -211,7 +214,8 @@ The builder will process the directories in the following order:
211214
- cloud_distr::cleanup
212215
- cloud::cleanup
213216
- distr::cleanup
214-
1. Image cleanup: the generated image is mounted on the host and the `image-scripts` scripts are run:
217+
- distr::seal[^1]
218+
1. Image cleanup: the generated image is mounted on the host and the `image-scripts` scripts are run[^1]:
215219
- custom::cleanup
216220
- cloud_distr::cleanup
217221
- cloud::cleanup
@@ -222,6 +226,11 @@ The builder will process the directories in the following order:
222226
- cloud_distr::image_package
223227
- cloud::image_package
224228

229+
[^1]: `provision` `seal` vs. `image-scripts` `cleanup`.
230+
These functions have the same purpose: _seal_ the image before packaging.
231+
The difference is that the former runs in the VM while the latter runs on the host.
232+
Sealing on the host might be more efficient, but when it is not possible to mount the image disk on the host, in-VM sealing can be used. When no `image-scripts` `cleanup` are defined, no attempt will be made to mount the filesystem on the host.
233+
225234
## Feedback
226235

227236
Please provide feedback of any kind via GitHub issues on this repository.

oracle-linux-image-tools/bin/build-image.sh

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Create minimal Oracle Linux images
55
#
6-
# Copyright (c) 2019-2022 Oracle and/or its affiliates.
6+
# Copyright (c) 2019, 2022 Oracle and/or its affiliates.
77
# Licensed under the Universal Permissive License v 1.0 as shown at
88
# https://oss.oracle.com/licenses/upl.
99
#
@@ -545,7 +545,7 @@ image_cleanup() {
545545
cd "${WORKSPACE}/${VM_NAME}"
546546
if common::is_vbox ; then
547547
tar -xf "${VM_NAME}.ova"
548-
rm "${VM_NAME}.ova"
548+
mv "${VM_NAME}.ova" System.ova
549549
mv -f "${VM_NAME}"-disk*.vmdk System.vmdk
550550
vbox-img convert \
551551
--srcfilename System.vmdk \
@@ -555,68 +555,76 @@ image_cleanup() {
555555
rm -f System.vmdk
556556
fi
557557

558-
echo_message "Loopback mount image"
559-
# Loopback mount the image
560-
# We will have the following subdirectories:
561-
# - 1: /boot
562-
# - 2: root filesystem (/)
563-
# In case of a btrfs filesystem, / will be in root subvolume
564-
# Should /boot be part of the btrfs volume we then have:
565-
# - 1: btrfs volume with boot and root subvolumes
566-
rm -rf "${mnt}"
567-
mkdir "${mnt}"
568-
sudo "${MOUNT_IMAGE}" System.img "${mnt}"
569-
if [[ $(stat -f -c "%T" "${mnt}/1") = "btrfs" ]]; then
570-
# Both / and /boot are on BTRFS
571-
boot_fs="${mnt}/1/boot"
572-
root_fs="${mnt}/1/root"
573-
else
574-
boot_fs="${mnt}/1"
575-
if [[ $(stat -f -c "%T" "${mnt}/2") = "btrfs" ]]; then
576-
root_fs="${mnt}/2/root"
558+
# Run cleanup scripts
559+
if [[ "$(type -t custom::image_cleanup)" = 'function' ||
560+
"$(type -t cloud_distr::image_cleanup)" = 'function' ||
561+
"$(type -t cloud::image_cleanup)" = 'function' ||
562+
"$(type -t distr::image_cleanup)" = 'function' ]]; then
563+
# Only mount the image if we have an image_cleanup function defined
564+
echo_message "Loopback mount image"
565+
# Loopback mount the image
566+
# We will have the following subdirectories:
567+
# - 1: /boot
568+
# - 2: root filesystem (/)
569+
# In case of a btrfs filesystem, / will be in root subvolume
570+
# Should /boot be part of the btrfs volume we then have:
571+
# - 1: btrfs volume with boot and root subvolumes
572+
rm -rf "${mnt}"
573+
mkdir "${mnt}"
574+
sudo "${MOUNT_IMAGE}" System.img "${mnt}"
575+
if [[ $(stat -f -c "%T" "${mnt}/1") = "btrfs" ]]; then
576+
# Both / and /boot are on BTRFS
577+
boot_fs="${mnt}/1/boot"
578+
root_fs="${mnt}/1/root"
577579
else
578-
root_fs="${mnt}/2"
580+
boot_fs="${mnt}/1"
581+
if [[ $(stat -f -c "%T" "${mnt}/2") = "btrfs" ]]; then
582+
root_fs="${mnt}/2/root"
583+
else
584+
root_fs="${mnt}/2"
585+
fi
586+
fi
587+
588+
# Basic check to see if we have the "right" partitions mounted
589+
if [[ ! -d "${root_fs}/etc" || ! -d "${boot_fs}/grub2" ]]; then
590+
sudo "${MOUNT_IMAGE}" -u System.img
591+
rm -rf "${mnt}"
592+
error "Loopback mount failed"
593+
fi
594+
595+
# Run cleanup scripts
596+
if [[ "$(type -t custom::image_cleanup)" = 'function' ]]; then
597+
echo_message "Run custom cleanup"
598+
custom::image_cleanup "${root_fs}" "${boot_fs}"
599+
fi
600+
if [[ "$(type -t cloud_distr::image_cleanup)" = 'function' ]]; then
601+
echo_message "Run cloud distribution cleanup"
602+
cloud_distr::image_cleanup "${root_fs}" "${boot_fs}"
603+
fi
604+
if [[ "$(type -t cloud::image_cleanup)" = 'function' ]]; then
605+
echo_message "Run cloud cleanup"
606+
cloud::image_cleanup "${root_fs}" "${boot_fs}"
607+
fi
608+
if [[ "$(type -t distr::image_cleanup)" = 'function' ]]; then
609+
echo_message "Run distribution cleanup"
610+
distr::image_cleanup "${root_fs}" "${boot_fs}"
579611
fi
580-
fi
581612

582-
# Basic check to see if we have the "right" partitions mounted
583-
if [[ ! -d "${root_fs}/etc" || ! -d "${boot_fs}/grub2" ]]; then
613+
# Ensure we are still in the image directory
614+
cd "${WORKSPACE}/${VM_NAME}"
615+
# unmount and trim image
616+
echo_message "Unmount and trim image"
617+
sudo -- bash -c '
618+
sync; sync; sync;
619+
fstrim "'"${boot_fs}"'";
620+
fstrim "'"${root_fs}"'";
621+
'
584622
sudo "${MOUNT_IMAGE}" -u System.img
585623
rm -rf "${mnt}"
586-
error "Loopback mount failed"
587-
fi
588624

589-
# Run cleanup scripts
590-
if [[ "$(type -t custom::image_cleanup)" = 'function' ]]; then
591-
echo_message "Run custom cleanup"
592-
custom::image_cleanup "${root_fs}" "${boot_fs}"
593-
fi
594-
if [[ "$(type -t cloud_distr::image_cleanup)" = 'function' ]]; then
595-
echo_message "Run cloud distribution cleanup"
596-
cloud_distr::image_cleanup "${root_fs}" "${boot_fs}"
625+
cp --sparse=always System.img System.img.sparse
626+
mv -f System.img.sparse System.img
597627
fi
598-
if [[ "$(type -t cloud::image_cleanup)" = 'function' ]]; then
599-
echo_message "Run cloud cleanup"
600-
cloud::image_cleanup "${root_fs}" "${boot_fs}"
601-
fi
602-
if [[ "$(type -t distr::image_cleanup)" = 'function' ]]; then
603-
echo_message "Run distribution cleanup"
604-
distr::image_cleanup "${root_fs}" "${boot_fs}"
605-
fi
606-
607-
# Ensure we are still in the image directory
608-
cd "${WORKSPACE}/${VM_NAME}"
609-
# unmount and trim image
610-
echo_message "Unmount and trim image"
611-
sudo -- bash -c '
612-
sync; sync; sync;
613-
fstrim "'"${boot_fs}"'";
614-
fstrim "'"${root_fs}"'";
615-
'
616-
sudo "${MOUNT_IMAGE}" -u System.img
617-
cp --sparse=always System.img System.img.sparse
618-
mv -f System.img.sparse System.img
619-
rm -rf "${mnt}"
620628

621629
echo_message "Package image"
622630
if [[ "$(type -t custom::image_package)" = 'function' ]]; then
@@ -631,6 +639,7 @@ image_cleanup() {
631639

632640
if common::is_vbox ; then
633641
rm "${WORKSPACE}/${VM_NAME}/${VM_NAME}.ovf"
642+
rm "${WORKSPACE}/${VM_NAME}/System.ova"
634643
fi
635644
}
636645

oracle-linux-image-tools/bin/provision.sh

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
#
44
# Packer main provisioning script
55
#
6-
# Copyright (c) 2019,2020 Oracle and/or its affiliates.
6+
# Copyright (c) 2019, 2022 Oracle and/or its affiliates.
77
# Licensed under the Universal Permissive License v 1.0 as shown at
88
# https://oss.oracle.com/licenses/upl.
99
#
10-
# Description: provision image by calling child provisioners
10+
# Description:
11+
# - provision image by calling child provisioners
12+
# - Seal image by calling distribution seal function (final cleanup
13+
# cleanup before packaging)
1114
#
1215
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
1316
#
@@ -57,7 +60,9 @@ echo_error() {
5760
load_env() {
5861
local dir
5962

60-
source "${ENV_FILE}"
63+
if [[ -r "${ENV_FILE}" ]]; then
64+
source "${ENV_FILE}"
65+
fi
6166

6267
if [[ -n "${PROXY_URL}" ]]; then
6368
export http_proxy="${PROXY_URL}"
@@ -79,9 +84,9 @@ load_env() {
7984
}
8085

8186
#######################################
82-
# Main
87+
# provision
8388
#######################################
84-
main () {
89+
provision () {
8590
echo_header "Load environment"
8691
load_env
8792
if [[ "$(type -t distr::provision)" = 'function' ]]; then
@@ -118,4 +123,38 @@ main () {
118123
fi
119124
}
120125

126+
#######################################
127+
# seal
128+
#######################################
129+
seal () {
130+
echo_header "Load environment"
131+
load_env
132+
if [[ "$(type -t distr::seal)" = 'function' ]]; then
133+
echo_header "Seal VM image"
134+
distr::seal
135+
else
136+
echo_message "No seal function defined"
137+
fi
138+
}
139+
140+
#######################################
141+
# Main
142+
#######################################
143+
main () {
144+
if [[ -z ${OLIT_ACTION} ]]; then
145+
echo_error "OLIT_ACTION undefined"
146+
fi
147+
case "${OLIT_ACTION}" in
148+
provision)
149+
provision
150+
;;
151+
seal)
152+
seal
153+
;;
154+
*)
155+
echo_error "Unexpected action: ${OLIT_ACTION}"
156+
;;
157+
esac
158+
}
159+
121160
main "$@"

oracle-linux-image-tools/cloud/azure/image-scripts.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Cleanup and package image for Azure
44
#
5-
# Copyright (c) 2019-2022 Oracle and/or its affiliates.
5+
# Copyright (c) 2019, 2022 Oracle and/or its affiliates.
66
# Licensed under the Universal Permissive License v 1.0 as shown at
77
# https://oss.oracle.com/licenses/upl
88
#
@@ -25,9 +25,9 @@
2525
# Returns:
2626
# None
2727
#######################################
28-
cloud::image_cleanup() {
29-
:
30-
}
28+
# cloud::image_cleanup() {
29+
# :
30+
# }
3131

3232
#######################################
3333
# Image packaging

oracle-linux-image-tools/cloud/none/image-scripts.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Cleanup and package image for the "None" image
44
#
5-
# Copyright (c) 2019-2022 Oracle and/or its affiliates.
5+
# Copyright (c) 2019, 2022 Oracle and/or its affiliates.
66
# Licensed under the Universal Permissive License v 1.0 as shown at
77
# https://oss.oracle.com/licenses/upl
88
#
@@ -25,9 +25,9 @@
2525
# Returns:
2626
# None
2727
#######################################
28-
cloud::image_cleanup() {
29-
:
30-
}
28+
# cloud::image_cleanup() {
29+
# :
30+
# }
3131

3232
#######################################
3333
# Image packaging:

oracle-linux-image-tools/cloud/oci/image-scripts.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Cleanup and package image for OCI
44
#
5-
# Copyright (c) 2020-2022 Oracle and/or its affiliates.
5+
# Copyright (c) 2020, 2022 Oracle and/or its affiliates.
66
# Licensed under the Universal Permissive License v 1.0 as shown at
77
# https://oss.oracle.com/licenses/upl
88
#
@@ -25,9 +25,9 @@
2525
# Returns:
2626
# None
2727
#######################################
28-
cloud::image_cleanup() {
29-
:
30-
}
28+
# cloud::image_cleanup() {
29+
# :
30+
# }
3131

3232
#######################################
3333
# Image packaging - creates a PVM and PVHVM OVA

oracle-linux-image-tools/cloud/olvm/image-scripts.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Cleanup and package image for OLVM
44
#
5-
# Copyright (c) 2020-2022 Oracle and/or its affiliates.
5+
# Copyright (c) 2020, 2022 Oracle and/or its affiliates.
66
# Licensed under the Universal Permissive License v 1.0 as shown at
77
# https://oss.oracle.com/licenses/upl
88
#
@@ -40,9 +40,9 @@ cloud::validate() {
4040
# Returns:
4141
# None
4242
#######################################
43-
cloud::image_cleanup() {
44-
:
45-
}
43+
# cloud::image_cleanup() {
44+
# :
45+
# }
4646

4747
#######################################
4848
# Image packaging - creates an OVA

oracle-linux-image-tools/cloud/olvm/mk-envelope.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44
Generate OLVM compatible OVF file.
55
6-
Copyright (c) 2020-2022 Oracle and/or its affiliates.
6+
Copyright (c) 2020, 2022 Oracle and/or its affiliates.
77
Licensed under the Universal Permissive License v 1.0 as shown at
88
https://oss.oracle.com/licenses/upl
99
@@ -26,6 +26,7 @@
2626
'OL6': 5002,
2727
'OL7': 5003,
2828
'OL8': 5006,
29+
'OL9': 5006, # Use OL8 ID for now, to support older OLVM versions
2930
}
3031

3132

0 commit comments

Comments
 (0)