Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ed3825d

Browse files
alessio-peruginicmaglie
andauthored
Build and distribuite deb packages (#2926)
--------- Co-authored-by: Cristian Maglie <c.maglie@arduino.cc>
1 parent f0d04a9 commit ed3825d

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

‎DistTasks.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ tasks:
7676
-p "{{.BUILD_PLATFORM}}"
7777
7878
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
79+
- task: build_deb
80+
vars:
81+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
82+
ARCH: "i386"
7983

8084
vars:
8185
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd32"
@@ -97,6 +101,10 @@ tasks:
97101
-p "{{.BUILD_PLATFORM}}"
98102
99103
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
104+
- task: build_deb
105+
vars:
106+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
107+
ARCH: "amd64"
100108

101109
vars:
102110
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_amd64"
@@ -118,6 +126,10 @@ tasks:
118126
-p "{{.BUILD_PLATFORM}}"
119127
120128
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
129+
- task: build_deb
130+
vars:
131+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
132+
ARCH: "armhf"
121133

122134
vars:
123135
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_7"
@@ -139,6 +151,10 @@ tasks:
139151
-p "{{.BUILD_PLATFORM}}"
140152
141153
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
154+
- task: build_deb
155+
vars:
156+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
157+
ARCH: "armel"
142158

143159
vars:
144160
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_6"
@@ -160,6 +176,10 @@ tasks:
160176
-p "{{.BUILD_PLATFORM}}"
161177
162178
tar cz -C {{.PLATFORM_DIR}} {{.PROJECT_NAME}} -C ../.. LICENSE.txt -f {{.PACKAGE_NAME}}
179+
- task: build_deb
180+
vars:
181+
GO_BINARY: "{{.DIST_DIR}}/{{.PLATFORM_DIR}}/{{.PROJECT_NAME}}"
182+
ARCH: "arm64"
163183

164184
vars:
165185
PLATFORM_DIR: "{{.PROJECT_NAME}}_linux_arm_64"
@@ -231,3 +251,19 @@ tasks:
231251
cmds:
232252
- mkdir --parents {{.DIST_DIR}}
233253
- cp ./internal/cli/configuration/configuration.schema.json {{.DIST_DIR}}/{{.PROJECT_NAME}}_{{.VERSION}}_configuration.schema.json
254+
255+
build_deb:
256+
desc: Builds the deb package
257+
internal: true
258+
cmds:
259+
- |
260+
docker build \
261+
--build-arg BINARY_NAME={{.PROJECT_NAME}} \
262+
--build-arg DEB_NAME={{.PROJECT_NAME}} \
263+
--build-arg VERSION={{ .VERSION }} \
264+
--build-arg ARCH={{ .ARCH }} \
265+
--build-arg GO_BINARY={{ .GO_BINARY }} \
266+
--output=./dist \
267+
-f debian/Dockerfile .
268+
vars:
269+
VERSION: "{{if .TAG}}{{.VERSION}}{{else}}v0.0.0-{{.VERSION}}{{end}}"

‎debian/Dockerfile‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM debian:bookworm AS debian
2+
3+
ARG VERSION
4+
RUN test -n "${VERSION}" || (echo "Error: VERSION is not set" && exit 1)
5+
6+
ARG REVISION="1"
7+
ARG ARCH
8+
RUN test -n "${ARCH}" || (echo "Error: ARCH is not set" && exit 1)
9+
10+
ARG DEB_NAME
11+
RUN test -n "${DEB_NAME}" || (echo "Error: DEB_NAME is not set" && exit 1)
12+
13+
ARG BINARY_NAME
14+
RUN test -n "${BINARY_NAME}" || (echo "Error: BINARY_NAME is not set" && exit 1)
15+
16+
RUN apt-get update && apt-get install -y sed
17+
18+
ARG GO_BINARY
19+
20+
COPY ./debian/${DEB_NAME} /${DEB_NAME}/
21+
COPY ./${GO_BINARY} /${DEB_NAME}/usr/bin/${BINARY_NAME}
22+
COPY ./debian/${DEB_NAME}/DEBIAN/copyright /${DEB_NAME}/usr/share/doc/copyright
23+
24+
# Go application are tagged with `v` prefix, this remove the first v if present
25+
RUN export VERSION=$(echo "${VERSION}" | sed -e "s/^v\(.*\)/1円/") && \
26+
sed -i "s/\$ARCH/${ARCH}/" /${DEB_NAME}/DEBIAN/control && \
27+
sed -i "s/\$VERSION/${VERSION}/" /${DEB_NAME}/DEBIAN/control && \
28+
dpkg-deb --build --root-owner-group /${DEB_NAME} &&\
29+
mv /${DEB_NAME}.deb "/${DEB_NAME}_${VERSION}-${REVISION}_${ARCH}.deb"
30+
31+
FROM scratch
32+
33+
COPY --from=debian /*.deb /

‎debian/arduino-cli/DEBIAN/control‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Package: arduino-cli
2+
Version: $VERSION
3+
Architecture: $ARCH
4+
Maintainer: arduino <support@arduino.cc>
5+
Description: Arduino CLI

‎debian/arduino-cli/DEBIAN/copyright‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Source: https://github.com/arduino/arduino-cli
3+
Upstream-Name: arduino-cli
4+
5+
Files:
6+
*
7+
Copyright: Copyright 2020-2025 ARDUINO SA (http://www.arduino.cc/)
8+
License: GPL-3+ with exception
9+
This software is released under the GNU General Public License version 3,
10+
which covers the main part of arduino-cli.
11+
The terms of this license can be found at:
12+
https://www.gnu.org/licenses/gpl-3.0.en.html
13+
.
14+
You can be released from the requirements of the above licenses by purchasing
15+
a commercial license. Buying such a license is mandatory if you want to
16+
modify or otherwise use the software for commercial activities involving the
17+
Arduino software without disclosing the source code of your own applications.
18+
To purchase a commercial license, send an email to license@arduino.cc.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /