Skip to content

Script to create Debian Package of the OS Image Composer Tool#268

Closed
srmungar wants to merge 2 commits intomainfrom
package-oic-tool
Closed

Script to create Debian Package of the OS Image Composer Tool#268
srmungar wants to merge 2 commits intomainfrom
package-oic-tool

Conversation

@srmungar
Copy link
Copy Markdown
Contributor

@srmungar srmungar commented Oct 14, 2025

Merge Checklist

All boxes should be checked before merging the PR

  • [] The changes in the PR have been built and tested
  • [] Ready to merge

Description

Adding a script to create a debian package of OS image composer from the cloned repository. The flow is that this script can invoked in the gitrunner as part of the existing VM test workflow. This is to keep the script upto date as well as ensure that the file layout in the os image composer layout is not changed.

Any Newly Introduced Dependencies

How Has This Been Tested?

@srmungar srmungar requested review from Copilot and elvin03 and removed request for Copilot October 14, 2025 22:36
Comment thread validate.sh
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.

Copilot AI review requested due to automatic review settings October 27, 2025 07:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds functionality to create a Debian package for the OS Image Composer Tool. The new function can be integrated into CI/CD workflows to ensure the package creation script stays up-to-date with repository changes.

Key Changes:

  • Added build_oic_deb_package() function to create a Debian package
  • Package includes configuration files and image templates in /etc/oic
  • Generates DEBIAN control file with package metadata

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread validate.sh
Comment on lines +486 to +490
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
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.
Comment thread validate.sh
fi
if [ -z "$(ls -A ./image-templates)" ]; then
echo "image-templates Directory is empty."
exit 0 # should be return 1
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.
Comment thread validate.sh
Comment on lines +492 to +495
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
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.
Comment thread validate.sh
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.
Comment thread validate.sh
echo "image-templates Directory is empty."
exit 0 # should be return 1
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.
Comment thread validate.sh
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.
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.
Copy link
Copy Markdown
Contributor

@magerstam magerstam left a comment

Choose a reason for hiding this comment

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

I think we should leverage the infrastructure we have already in the Earthfile, better to add a .deb target in the Earthfile and then easy to run from the command line or invoke as a github action, so we can simply run it as follows:

earthly +deb --VERSION=1.1.0 --ARCH=amd64

Reworking your script, something like this:

# syntax = docker/dockerfile:1.4
VERSION ?= 1.0.0
ARCH ?= amd64

# Base Go build
FROM golang:1.22-alpine AS build
WORKDIR /src

COPY go.mod go.sum ./
RUN go mod download

COPY . .
RUN go build -o oic ./cmd/oic/main.go

---

# Build .deb package
FROM debian:bookworm-slim AS deb
WORKDIR /pkg

# Copy build artifacts and config templates
COPY --from=build /src/oic usr/local/bin/os-image-composer
COPY config etc/oic/config
COPY image-templates etc/oic/image-templates

# Create DEBIAN control metadata
RUN mkdir -p DEBIAN && cat > DEBIAN/control <<EOF
Package: os-image-composer
Version: ${VERSION}
Section: utils
Priority: optional
Architecture: ${ARCH}
Maintainer: Intel Edge Software Team <edge.platform@intel.com>
Depends: bash, coreutils
Description: OS Image Composer (OIC)
 OIC enables users to compose custom bootable OS images based on a
 user-provided template that specifies package lists, configurations,
 and output formats for supported distributions.
EOF

# Build Debian package
RUN dpkg-deb --build . os-image-composer_${VERSION}_${ARCH}.deb

# Output artifact
SAVE ARTIFACT os-image-composer_${VERSION}_${ARCH}.deb AS LOCAL os-image-composer_${VERSION}_${ARCH}.deb

@magerstam
Copy link
Copy Markdown
Contributor

The dependencies needs to be added as well in the deb metadata

@arodage
Copy link
Copy Markdown
Contributor

arodage commented Nov 4, 2025

@srmungar please close this, as we already have debian package support with earthly

@arodage
Copy link
Copy Markdown
Contributor

arodage commented Nov 7, 2025

Implemented with earthly #278

@arodage arodage closed this Nov 7, 2025
@yockgen yockgen deleted the package-oic-tool branch December 18, 2025 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants