Skip to content

Build and distribuite deb packages #2926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
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
36 changes: 36 additions & 0 deletions DistTasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ tasks:
-p "{{.BUILD_PLATFORM}}"

tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
- task: build_deb
vars:
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
ARCH: "i386"

vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd32"
Expand All @@ -97,6 +101,10 @@ tasks:
-p "{{.BUILD_PLATFORM}}"

tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
- task: build_deb
vars:
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
ARCH: "amd64"

vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd64"
Expand All @@ -118,6 +126,10 @@ tasks:
-p "{{.BUILD_PLATFORM}}"

tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
- task: build_deb
vars:
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
ARCH: "armhf"

vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_7"
Expand All @@ -139,6 +151,10 @@ tasks:
-p "{{.BUILD_PLATFORM}}"

tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
- task: build_deb
vars:
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
ARCH: "armel"

vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
Expand All @@ -160,6 +176,10 @@ tasks:
-p "{{.BUILD_PLATFORM}}"

tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
- task: build_deb
vars:
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
ARCH: "arm64"

vars:
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_64"
Expand Down Expand Up @@ -231,3 +251,19 @@ tasks:
cmds:
- mkdir --parents {{.DIST_DIR}}
- cp ./internal/cli/configuration/configuration.schema.json {{.DIST_DIR}}/{{.PROJECT_NAME}}_{{.VERSION}}_configuration.schema.json

build_deb:
desc: Builds the deb package
internal: true
cmds:
- |
docker build \
--build-arg BINARY_NAME={{.PROJECT_NAME}} \
--build-arg DEB_NAME={{.PROJECT_NAME}} \
--build-arg VERSION={{ .VERSION }} \
--build-arg ARCH={{ .ARCH }} \
--build-arg GO_BINARY={{ .GO_BINARY }} \
--output=./dist \
-f debian/Dockerfile .
vars:
VERSION: "{{if .TAG}}{{.VERSION}}{{else}}v0.0.0-{{.VERSION}}{{end}}"
33 changes: 33 additions & 0 deletions debian/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
FROM debian:bookworm AS debian

ARG VERSION
RUN test -n "${VERSION}" || (echo "Error: VERSION is not set" && exit 1)

ARG REVISION="1"
ARG ARCH
RUN test -n "${ARCH}" || (echo "Error: ARCH is not set" && exit 1)

ARG DEB_NAME
RUN test -n "${DEB_NAME}" || (echo "Error: DEB_NAME is not set" && exit 1)

ARG BINARY_NAME
RUN test -n "${BINARY_NAME}" || (echo "Error: BINARY_NAME is not set" && exit 1)

RUN apt-get update && apt-get install -y sed

ARG GO_BINARY

COPY ./debian/${DEB_NAME} /${DEB_NAME}/
COPY ./${GO_BINARY} /${DEB_NAME}/usr/bin/${BINARY_NAME}
COPY ./debian/${DEB_NAME}/DEBIAN/copyright /${DEB_NAME}/usr/share/doc/copyright

# Go application are tagged with `v` prefix, this remove the first v if present
RUN export VERSION=$(echo "${VERSION}" | sed -e "s/^v\(.*\)/\1/") && \
sed -i "s/\$ARCH/${ARCH}/" /${DEB_NAME}/DEBIAN/control && \
sed -i "s/\$VERSION/${VERSION}/" /${DEB_NAME}/DEBIAN/control && \
dpkg-deb --build --root-owner-group /${DEB_NAME} &&\
mv /${DEB_NAME}.deb "/${DEB_NAME}_${VERSION}-${REVISION}_${ARCH}.deb"

FROM scratch

COPY --from=debian /*.deb /
5 changes: 5 additions & 0 deletions debian/arduino-cli/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Package: arduino-cli
Version: $VERSION
Architecture: $ARCH
Maintainer: arduino <support@arduino.cc>
Description: Arduino CLI
18 changes: 18 additions & 0 deletions debian/arduino-cli/DEBIAN/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://github.com/arduino/arduino-cli
Upstream-Name: arduino-cli

Files:
*
Copyright: Copyright 2020-2025 ARDUINO SA (http://www.arduino.cc/)
License: GPL-3+ with exception
This software is released under the GNU General Public License version 3,
which covers the main part of arduino-cli.
The terms of this license can be found at:
https://www.gnu.org/licenses/gpl-3.0.en.html
.
You can be released from the requirements of the above licenses by purchasing
a commercial license. Buying such a license is mandatory if you want to
modify or otherwise use the software for commercial activities involving the
Arduino software without disclosing the source code of your own applications.
To purchase a commercial license, send an email to license@arduino.cc.