Skip to content

Commit fe49b04

Browse files
committed
Add Debian package build target to Earthfile
1 parent f29677e commit fe49b04

2 files changed

Lines changed: 120 additions & 1 deletion

File tree

Earthfile

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,57 @@ test-debug:
139139

140140
test-quick:
141141
FROM +golang-base
142-
RUN go test ./...
142+
RUN go test ./...
143+
144+
deb:
145+
FROM debian:bookworm-slim
146+
ARG VERSION=1.0.0
147+
ARG ARCH=amd64
148+
149+
WORKDIR /pkg
150+
151+
# Create directory structure following FHS (Filesystem Hierarchy Standard)
152+
RUN mkdir -p usr/local/bin \
153+
etc/os-image-composer/config \
154+
usr/share/os-image-composer/examples \
155+
usr/share/doc/os-image-composer \
156+
DEBIAN
157+
158+
# Copy the built binary from the build target
159+
COPY +build/os-image-composer usr/local/bin/os-image-composer
160+
161+
# Make the binary executable
162+
RUN chmod +x usr/local/bin/os-image-composer
163+
164+
# Copy default global configuration (user-editable)
165+
COPY os-image-composer.yml etc/os-image-composer/os-image-composer.yml
166+
167+
# Copy OS variant configuration files (user-editable)
168+
COPY config etc/os-image-composer/config
169+
170+
# Copy image templates as examples (read-only, for reference)
171+
COPY image-templates usr/share/os-image-composer/examples
172+
173+
# Copy documentation
174+
COPY README.md usr/share/doc/os-image-composer/
175+
COPY LICENSE usr/share/doc/os-image-composer/
176+
COPY docs/architecture/os-image-composer-cli-specification.md usr/share/doc/os-image-composer/
177+
178+
# Create the DEBIAN control file with proper metadata
179+
RUN echo "Package: os-image-composer" > DEBIAN/control && \
180+
echo "Version: ${VERSION}" >> DEBIAN/control && \
181+
echo "Section: utils" >> DEBIAN/control && \
182+
echo "Priority: optional" >> DEBIAN/control && \
183+
echo "Architecture: ${ARCH}" >> DEBIAN/control && \
184+
echo "Maintainer: Intel Edge Software Team <edge.platform@intel.com>" >> DEBIAN/control && \
185+
echo "Depends: bash, coreutils" >> DEBIAN/control && \
186+
echo "Description: OS Image Composer (OIC)" >> DEBIAN/control && \
187+
echo " OIC enables users to compose custom bootable OS images based on a" >> DEBIAN/control && \
188+
echo " user-provided template that specifies package lists, configurations," >> DEBIAN/control && \
189+
echo " and output formats for supported distributions." >> DEBIAN/control
190+
191+
# Build the debian package
192+
RUN dpkg-deb --build . os-image-composer_${VERSION}_${ARCH}.deb
193+
194+
# Save the debian package artifact to dist/ directory
195+
SAVE ARTIFACT os-image-composer_${VERSION}_${ARCH}.deb AS LOCAL dist/os-image-composer_${VERSION}_${ARCH}.deb

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,72 @@ earthly +build
3636
earthly +build --version=1.0.0
3737
```
3838

39+
### Install via Debian Package (Ubuntu/Debian)
40+
41+
For Ubuntu and Debian systems, you can build and install OS Image Composer as a Debian package. This method provides a cleaner installation with proper package management.
42+
43+
#### Build the Debian Package
44+
45+
Use the Earthly `+deb` target to create a `.deb` package:
46+
47+
```bash
48+
# Build with default parameters (version 1.0.0, amd64)
49+
earthly +deb
50+
51+
# Build with custom version and architecture
52+
earthly +deb --VERSION=1.2.0 --ARCH=amd64
53+
54+
# Build for ARM64
55+
earthly +deb --VERSION=1.0.0 --ARCH=arm64
56+
```
57+
58+
The package will be created in the `dist/` directory as `os-image-composer_<VERSION>_<ARCH>.deb`.
59+
60+
#### Install the Package
61+
62+
```bash
63+
# Install using apt (recommended - automatically resolves dependencies)
64+
sudo apt install ./dist/os-image-composer_1.0.0_amd64.deb
65+
66+
# Or using dpkg
67+
sudo dpkg -i dist/os-image-composer_1.0.0_amd64.deb
68+
sudo apt-get install -f # Fix any missing dependencies if needed
69+
```
70+
71+
#### Verify Installation
72+
73+
```bash
74+
# Check if package is installed
75+
dpkg -l | grep os-image-composer
76+
77+
# View installed files
78+
dpkg -L os-image-composer
79+
80+
# Verify the binary works
81+
os-image-composer version
82+
```
83+
84+
#### Package Contents
85+
86+
The Debian package installs the following files:
87+
88+
* **Binary:** `/usr/local/bin/os-image-composer` - Main executable
89+
* **Configuration:** `/etc/os-image-composer/` - Default configuration and OS variant configs
90+
* **Examples:** `/usr/share/os-image-composer/examples/` - Sample image templates
91+
* **Documentation:** `/usr/share/doc/os-image-composer/` - README, LICENSE, and CLI specification
92+
93+
After installation via the Debian package, you can use `os-image-composer` directly from any directory, and reference the example templates from `/usr/share/os-image-composer/examples/`.
94+
95+
#### Uninstall the Package
96+
97+
```bash
98+
# Remove package (keeps configuration files)
99+
sudo dpkg -r os-image-composer
100+
101+
# Remove package and configuration files
102+
sudo dpkg --purge os-image-composer
103+
```
104+
39105
### Install the Prerequisites for Composing an Image
40106

41107
Before you compose an operating system image with the OS Image Composer tool, follow the [instructions to install two prerequisites](./docs/tutorial/prerequisite.md):

0 commit comments

Comments
 (0)