Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,41 @@ clean_build_dirs() {
sudo rm -rf cache/ tmp/
}

#build oic debian package
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to add this feature right now in this simple way.
There are more details need to be covered further:

  1. The dependencies info
  2. The binary build and install place, the correspond os-image-composer.yml file update.
  3. The package build method.

Suggest to hold.

build_oic_deb_package() {
echo "Building Debian Package that installs OS Image Composer Tool "
echo "Ensuring we're in the working directory before starting deb package build..."
cd "$WORKING_DIR"
echo "Current working directory: $(pwd)"

if [ -z "$(ls -A ./config)" ]; then
echo "Config Directory is empty."
exit 0 # should be return 1
fi
if [ -z "$(ls -A ./image-templates)" ]; then
echo "image-templates Directory is empty."
exit 0 # should be return 1
Comment on lines +486 to +490
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment indicates this should return 1, but the code exits with 0 (success). This will cause the script to exit successfully even when the config directory is empty, masking a critical validation failure. Change exit 0 to exit 1.

Suggested change
exit 0 # should be return 1
fi
if [ -z "$(ls -A ./image-templates)" ]; then
echo "image-templates Directory is empty."
exit 0 # should be return 1
exit 1 # should be return 1
fi
if [ -z "$(ls -A ./image-templates)" ]; then
echo "image-templates Directory is empty."
exit 1 # should be return 1

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment indicates this should return 1, but the code exits with 0 (success). This will cause the script to exit successfully even when the image-templates directory is empty, masking a critical validation failure. Change exit 0 to exit 1.

Suggested change
exit 0 # should be return 1
exit 1 # should be return 1

Copilot uses AI. Check for mistakes.
fi
mkdir os-image-composer-1.0
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version number '1.0' is hardcoded in multiple places (lines 492, 499, 501, 508, 509). Consider extracting this into a variable at the function start (e.g., OIC_VERSION='1.0') to make version updates easier and reduce the risk of inconsistencies.

Copilot uses AI. Check for mistakes.
mkdir os-image-composer-1.0/etc
mkdir os-image-composer-1.0/etc/oic
mkdir os-image-composer-1.0/DEBIAN
Comment on lines +492 to +495
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Multiple sequential mkdir commands can be replaced with a single command using the -p flag: mkdir -p os-image-composer-1.0/{etc/oic,DEBIAN}. This is more efficient and ensures parent directories are created automatically.

Suggested change
mkdir os-image-composer-1.0
mkdir os-image-composer-1.0/etc
mkdir os-image-composer-1.0/etc/oic
mkdir os-image-composer-1.0/DEBIAN
mkdir -p os-image-composer-1.0/{etc/oic,DEBIAN}

Copilot uses AI. Check for mistakes.
cp -r config os-image-composer-1.0/etc/oic
cp -r image-templates os-image-composer-1.0/etc/oic

cat > os-image-composer-1.0/DEBIAN/control << EOF
Package: os-image-composer
Version: 1.0
Section: utils
Priority: optional
Architecture: amd64
Maintainer: Subba Mungara <subba.r.mungara@intel.com>
Description: OS Image Composer (OIC) enables users to compose a custom bootable OS image for supported OS distros based on user populated template file that captures  package list, configurations and formats of the output OS image.
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra whitespace in description: 'custom bootable' has two spaces instead of one.

Suggested change
Description: OS Image Composer (OIC) enables users to compose a custom bootable OS image for supported OS distros based on user populated template file that captures  package list, configurations and formats of the output OS image.
Description: OS Image Composer (OIC) enables users to compose a custom bootable OS image for supported OS distros based on user populated template file that captures  package list, configurations and formats of the output OS image.

Copilot uses AI. Check for mistakes.
EOF
dpkg-deb --build os-image-composer-1.0
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dpkg-deb --build command should include error checking. If the build fails, the function will continue and print the installation command even though no valid package was created. Add a check for the command's exit status and exit with an error if it fails.

Suggested change
dpkg-deb --build os-image-composer-1.0
if ! dpkg-deb --build os-image-composer-1.0; then
echo "Error: Failed to build Debian package with dpkg-deb." >&2
exit 1
fi

Copilot uses AI. Check for mistakes.
echo "command to install the package is : sudo dpkg -i os-image-composer-1.0.deb"
}

# Call the build functions with cleaning before each except the first one
build_azl3_raw_image

Expand Down
Loading