From d3f52afe2f1902b606c95d86a1f902a5a2267b00 Mon Sep 17 00:00:00 2001 From: Daijiro Fukuda Date: Fri, 26 Sep 2025 14:56:28 +0900 Subject: [PATCH] Add support for .deb packages for ubuntu-noble-amd64 (#32) Fix GH-35 --------- Co-authored-by: otegami Co-authored-by: Sutou Kouhei --- .github/workflows/package.yaml | 148 +++++++++++++++++++++ .github/workflows/release.yaml | 4 +- .gitignore | 14 +- Rakefile | 28 ++++ helper.rb | 21 +++ packages/Rakefile | 71 ++++++++++ packages/apt/test.sh | 28 ++++ packages/apt/ubuntu-noble/Dockerfile | 33 +++++ packages/debian/changelog | 0 packages/debian/control | 67 ++++++++++ packages/debian/copyright | 41 ++++++ packages/debian/libopenarm-can-dev.install | 18 +++ packages/debian/libopenarm-can1.install | 15 +++ packages/debian/openarm-can-utils.install | 17 +++ packages/debian/rules | 27 ++++ packages/debian/source/format | 1 + packages/debian/upstream/metadata | 18 +++ 17 files changed, 547 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/package.yaml create mode 100644 Rakefile create mode 100644 helper.rb create mode 100644 packages/Rakefile create mode 100755 packages/apt/test.sh create mode 100644 packages/apt/ubuntu-noble/Dockerfile create mode 100644 packages/debian/changelog create mode 100644 packages/debian/control create mode 100644 packages/debian/copyright create mode 100644 packages/debian/libopenarm-can-dev.install create mode 100644 packages/debian/libopenarm-can1.install create mode 100644 packages/debian/openarm-can-utils.install create mode 100755 packages/debian/rules create mode 100644 packages/debian/source/format create mode 100644 packages/debian/upstream/metadata diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml new file mode 100644 index 0000000..db7b8fd --- /dev/null +++ b/.github/workflows/package.yaml @@ -0,0 +1,148 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Package +on: + push: + branches: + - '**' + - '!dependabot/**' + tags: + - '**' + pull_request: +concurrency: + group: ${{ github.head_ref || github.sha }}-${{ github.workflow }} + cancel-in-progress: true +jobs: + source: + name: Source + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v5 + - name: Create source archive + run: | + rake dist + - uses: actions/upload-artifact@v4 + with: + name: source + path: | + openarm-can-*.tar.gz + build: + name: Build + needs: source + strategy: + fail-fast: false + matrix: + id: + - ubuntu-noble-amd64 + env: + APACHE_ARROW_REPOSITORY: ${{ github.workspace }}/apache-arrow + # condition && true-case || false-case + # == + # condition ? true-case : false-case + runs-on: >- + ${{ (contains(matrix.id, 'arm64') || + contains(matrix.id, 'aarch64')) && 'ubuntu-24.04-arm' || + 'ubuntu-latest' }} + timeout-minutes: 10 + steps: + - uses: actions/checkout@v5 + with: + submodules: recursive + - uses: actions/checkout@v5 + with: + path: apache-arrow + repository: apache/arrow + - name: Prepare environment variables + run: | + id=${{ matrix.id }} + # ubuntu-noble-amd64 -> ubuntu-noble + os_version=${id%-*} + # ubuntu-noble -> ubuntu + os=${os_version%-*} + # ubuntu-noble -> noble + version=${os_version##*-} + # ubuntu-noble-amd64 -> amd64 + architecture=${id##*-} + + if [ "${os}" = "debian" ] || [ "${os}" = "ubuntu" ]; then + TASK_NAMESPACE=apt + if [ "${architecture}" = "amd64" ]; then + echo "APT_TARGETS=${os_version}" >> "${GITHUB_ENV}" + TEST_DOCKER_IMAGE="${os}:${version}" + else + echo "APT_TARGETS=${id}" >> "${GITHUB_ENV}" + TEST_DOCKER_IMAGE="arm64v8/${os}:${version}" + fi + else + TASK_NAMESPACE=yum + # amazon-linux -> amazonlinux + docker_os=${os/-/} + if [ "${architecture}" = "x86_64" ]; then + echo "YUM_TARGETS=${os_version}" >> "${GITHUB_ENV}" + TEST_DOCKER_IMAGE="${docker_os}:${version}" + else + echo "YUM_TARGETS=${id}" >> "${GITHUB_ENV}" + TEST_DOCKER_IMAGE="arm64v8/${docker_os}:${version}" + fi + fi + echo "ARCHITECTURE=${architecture}" >> ${GITHUB_ENV} + echo "TASK_NAMESPACE=${TASK_NAMESPACE}" >> ${GITHUB_ENV} + echo "TEST_DOCKER_IMAGE=${TEST_DOCKER_IMAGE}" >> ${GITHUB_ENV} + - name: Install dependencies + run: | + sudo apt update -o="APT::Acquire::Retries=3" + sudo apt install -y -V -o="APT::Acquire::Retries=3" \ + devscripts \ + ruby + - uses: actions/download-artifact@v5 + with: + name: source + - name: Update version + if: github.ref_type != 'tag' + run: | + cd packages + rake version:update + - name: Login to GitHub Container registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build with docker + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + cd packages + rake docker:pull || : + rake ${TASK_NAMESPACE}:build BUILD_DIR=build + if [ "${TASK_NAMESPACE}" = "yum" ] && [ "${ARCHITECTURE}" != "x86_64" ]; then + # Remove SRPMs from non x86_64 artifacts + rm -rf ${TASK_NAMESPACE}/repositories/*/*/source + fi + - name: Push the built Docker image + continue-on-error: true + run: | + cd packages + rake docker:push + + # Test + - name: Test + run: | + docker run \ + --rm \ + --volume ${PWD}:/host:ro \ + ${TEST_DOCKER_IMAGE} \ + /host/packages/${TASK_NAMESPACE}/test.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ab468e0..65684d5 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -29,9 +29,7 @@ jobs: - uses: actions/checkout@v4 - name: Create source archive run: | - git archive ${GITHUB_REF_NAME} \ - --prefix openarm-can-${GITHUB_REF_NAME}/ \ - --output openarm-can-${GITHUB_REF_NAME}.tar.gz + rake dist VERSION=${GITHUB_REF_NAME} sha256sum \ openarm-can-${GITHUB_REF_NAME}.tar.gz > \ openarm-can-${GITHUB_REF_NAME}.tar.gz.sha256 diff --git a/.gitignore b/.gitignore index 0ea0e06..9cc7ff3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,16 @@ # limitations under the License. /.vscode -/build \ No newline at end of file +/build +/openarm-can-*.tar.gz +/packages/apt/build.sh +/packages/apt/build/ +/packages/apt/env.sh +/packages/apt/repositories/ +/packages/apt/tmp/ +/packages/openarm-can-*.tar.gz +/packages/yum/build.sh +/packages/yum/build/ +/packages/yum/env.sh +/packages/yum/repositories/ +/packages/yum/tmp/ diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..5c92b5e --- /dev/null +++ b/Rakefile @@ -0,0 +1,28 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require_relative "helper" + +version = ENV["VERSION"] || Helper.detect_version + +archive_base_name = "openarm-can-#{version}" +archive_tar_gz = "#{archive_base_name}.tar.gz" +file archive_tar_gz do + sh("git", "archive", "HEAD", + "--prefix", "#{archive_base_name}/", + "--output", archive_tar_gz) +end + +desc "Create #{archive_tar_gz}" +task :dist => archive_tar_gz diff --git a/helper.rb b/helper.rb new file mode 100644 index 0000000..20799d0 --- /dev/null +++ b/helper.rb @@ -0,0 +1,21 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module Helper + module_function + def detect_version + cmakelists = File.join(__dir__, "CMakeLists.txt") + File.read(cmakelists)[/^project\(.+ VERSION (.+?)\)/, 1] + end +end diff --git a/packages/Rakefile b/packages/Rakefile new file mode 100644 index 0000000..107ac44 --- /dev/null +++ b/packages/Rakefile @@ -0,0 +1,71 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +require "time" + +apache_arrow_repository = ENV["APACHE_ARROW_REPOSITORY"] +if apache_arrow_repository.nil? + raise "Specify APACHE_ARROW_REPOSITORY environment variable" +end +require "#{apache_arrow_repository}/dev/tasks/linux-packages/package-task" + +require_relative "../helper" + +class OpenArmCANPackageTask < PackageTask + def initialize + super("openarm-can", detect_version, detect_release_time) + end + + private + def detect_version + Helper.detect_version + end + + def detect_release_time + release_time_env = ENV["RELEASE_TIME"] + if release_time_env + Time.parse(release_time_env).utc + else + Time.now.utc + end + end + + def enable_yum? + false + end + + def define_archive_task + file @archive_name do + if File.exist?("../#{@archive_name}") + ln_s("../#{@archive_name}", + @archive_name) + else + download("https://github.com/#{github_repository}/" + + "releases/download/#{@version}/#{@archive_name}", + @archive_name) + end + end + end + + def github_repository + "enactic/openarm_can" + end + + def docker_image(os, architecture) + "ghcr.io/#{github_repository.gsub(/"_"/, "-")}-package:#{super}" + end +end + +task = OpenArmCANPackageTask.new +task.define diff --git a/packages/apt/test.sh b/packages/apt/test.sh new file mode 100755 index 0000000..aa29d90 --- /dev/null +++ b/packages/apt/test.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -exu + +apt update +apt install -V -y curl lsb-release + +distribution=$(lsb_release --short --id | tr '[:upper:]' '[:lower:]') +code_name=$(lsb_release --codename --short) +architecture=$(dpkg --print-architecture) + +repositories_dir=/host/packages/apt/repositories +apt install -V -y \ + "${repositories_dir}"/"${distribution}"/pool/"${code_name}"/*/*/*/*_"${architecture}".deb diff --git a/packages/apt/ubuntu-noble/Dockerfile b/packages/apt/ubuntu-noble/Dockerfile new file mode 100644 index 0000000..9476427 --- /dev/null +++ b/packages/apt/ubuntu-noble/Dockerfile @@ -0,0 +1,33 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:noble + +RUN \ + echo "debconf debconf/frontend select Noninteractive" | \ + debconf-set-selections + +ARG DEBUG + +RUN \ + quiet=$([ "${DEBUG}" = "yes" ] || echo "-qq") && \ + apt update ${quiet} && \ + apt install -y -V ${quiet} \ + build-essential \ + ccache \ + cmake \ + debhelper \ + devscripts \ + ninja-build && \ + apt clean diff --git a/packages/debian/changelog b/packages/debian/changelog new file mode 100644 index 0000000..e69de29 diff --git a/packages/debian/control b/packages/debian/control new file mode 100644 index 0000000..9374c3b --- /dev/null +++ b/packages/debian/control @@ -0,0 +1,67 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Source: openarm-can +Section: libs +Priority: optional +Maintainer: "Enactic, Inc." +Rules-Requires-Root: no +Build-Depends: + cmake, + debhelper-compat (= 13), +Standards-Version: 4.6.0 +Homepage: https://docs.openarm.dev/ +Vcs-Browser: https://github.com/enactic/openarm_can +Vcs-Git: https://github.com/enactic/openarm_can.git + +Package: libopenarm-can-dev +Section: libdevel +Architecture: any +Multi-Arch: same +Depends: + ${misc:Depends}, + libopenarm-can1 (= ${binary:Version}), +Description: Development files to use OpenArm CAN as a library + OpenArm CAN Library is a communication bridge between high-level + OpenArm control applications and low-level motor protocols. + It abstracts CAN bus communication via SocketCAN interface. + . + This package provides header files to use OpenArm CAN as a library. + +Package: libopenarm-can1 +Architecture: any +Multi-Arch: same +Depends: + ${misc:Depends}, + ${shlibs:Depends}, +Description: CAN communication library for OpenArm robotic hardware + OpenArm CAN Library is a communication bridge between high-level + OpenArm control applications and low-level motor protocols. + It abstracts CAN bus communication via SocketCAN interface. + +Package: openarm-can-utils +Architecture: any +Depends: + ${misc:Depends}, + ${shlibs:Depends}, + can-utils, + iproute2, + python3, +Description: Utility tools for OpenArm CAN configuration + OpenArm CAN Library is a communication bridge between high-level + OpenArm control applications and low-level motor protocols. + It abstracts CAN bus communication via Linux SocketCAN interface. + . + This package provides utility scripts for CAN interface setup, + motor diagnostics, and configuration tools. diff --git a/packages/debian/copyright b/packages/debian/copyright new file mode 100644 index 0000000..4e1638f --- /dev/null +++ b/packages/debian/copyright @@ -0,0 +1,41 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Source: https://github.com/enactic/openarm_can/releases +Upstream-Name: OpenArm CAN +Upstream-Contact: "Enactic, Inc." + +Files: + * +Copyright: + 2025 Enactic, Inc. +License: Apache-2.0 + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + . + http://www.apache.org/licenses/LICENSE-2.0 + . + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + . + On Debian systems, the full text of the Apache Software License version 2 can + be found in the file `/usr/share/common-licenses/Apache-2.0'. diff --git a/packages/debian/libopenarm-can-dev.install b/packages/debian/libopenarm-can-dev.install new file mode 100644 index 0000000..ddb040f --- /dev/null +++ b/packages/debian/libopenarm-can-dev.install @@ -0,0 +1,18 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +usr/include/* +usr/lib/*/lib*.so +usr/lib/*/pkgconfig/* +usr/lib/*/cmake/OpenArmCAN/* diff --git a/packages/debian/libopenarm-can1.install b/packages/debian/libopenarm-can1.install new file mode 100644 index 0000000..e21f647 --- /dev/null +++ b/packages/debian/libopenarm-can1.install @@ -0,0 +1,15 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +usr/lib/*/lib*.so.* diff --git a/packages/debian/openarm-can-utils.install b/packages/debian/openarm-can-utils.install new file mode 100644 index 0000000..9793dd1 --- /dev/null +++ b/packages/debian/openarm-can-utils.install @@ -0,0 +1,17 @@ +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +setup/configure_socketcan.sh usr/libexec/openarm-can +setup/set_zero.sh usr/libexec/openarm-can +setup/change_baudrate.py usr/libexec/openarm-can diff --git a/packages/debian/rules b/packages/debian/rules new file mode 100755 index 0000000..099d1b2 --- /dev/null +++ b/packages/debian/rules @@ -0,0 +1,27 @@ +#!/usr/bin/make -f +# +# Copyright 2025 Enactic, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +%: + dh $@ + +override_dh_auto_configure: + dh_auto_configure \ + --buildsystem=cmake+ninja \ + -- \ + -DBUILD_SHARED_LIBS=ON \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo diff --git a/packages/debian/source/format b/packages/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/packages/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/packages/debian/upstream/metadata b/packages/debian/upstream/metadata new file mode 100644 index 0000000..7412935 --- /dev/null +++ b/packages/debian/upstream/metadata @@ -0,0 +1,18 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Bug-Database: https://github.com/enactic/openarm_can/issues +Bug-Submit: https://github.com/enactic/openarm_can/issues/new +Changelog: https://github.com/enactic/openarm_can/blob/main/packages/debian/changelog +Documentation: https://docs.openarm.dev/software/can/ +Repository-Browse: https://github.com/enactic/openarm_can +Repository: https://github.com/enactic/openarm_can.git