Script to create Debian Package of the OS Image Composer Tool#268
Script to create Debian Package of the OS Image Composer Tool#268
Conversation
| sudo rm -rf cache/ tmp/ | ||
| } | ||
|
|
||
| #build oic debian package |
There was a problem hiding this comment.
We don't need to add this feature right now in this simple way.
There are more details need to be covered further:
- The dependencies info
- The binary build and install place, the correspond os-image-composer.yml file update.
- The package build method.
Suggest to hold.
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| 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 |
| fi | ||
| if [ -z "$(ls -A ./image-templates)" ]; then | ||
| echo "image-templates Directory is empty." | ||
| exit 0 # should be return 1 |
There was a problem hiding this comment.
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.
| exit 0 # should be return 1 | |
| exit 1 # should be return 1 |
| 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 |
There was a problem hiding this comment.
[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.
| 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} |
| 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. |
There was a problem hiding this comment.
Extra whitespace in description: 'custom bootable' has two spaces instead of one.
| 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. |
| echo "image-templates Directory is empty." | ||
| exit 0 # should be return 1 | ||
| fi | ||
| mkdir os-image-composer-1.0 |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| 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 |
magerstam
left a comment
There was a problem hiding this comment.
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
|
The dependencies needs to be added as well in the deb metadata |
|
@srmungar please close this, as we already have debian package support with earthly |
|
Implemented with earthly #278 |
Merge Checklist
All boxes should be checked before merging the PR
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?