forked from eclipse/mraa
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
809c3d6
commit c73fc23
Showing
26 changed files
with
448 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM debian:bullseye | ||
|
||
RUN dpkg --add-architecture arm64 && \ | ||
apt-get update && \ | ||
apt-get full-upgrade --no-install-recommends -y \ | ||
build-essential crossbuild-essential-arm64 git \ | ||
cmake debhelper devscripts lintian swig python3-dev:arm64 libjson-c-dev:arm64 && \ | ||
adduser --gecos runner --disabled-password runner && \ | ||
rm -rf /var/lib/apt/lists/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
shopt -s nullglob | ||
|
||
build() { | ||
local SCRIPT_DIR="$(dirname "$(realpath "$0")")" | ||
|
||
local NATIVE_BUILD="false" | ||
local CONTAINER_BACKEND="podman" | ||
local CONTAINER_REGISTRY="" | ||
local NO_CONTAINER_UPDATE="false" | ||
local CONTAINER_SHELL="false" | ||
|
||
if ! $NATIVE_BUILD | ||
then | ||
if [[ "$(basename "$CONTAINER_BACKEND")" == "docker" ]] && "$CONTAINER_BACKEND" -v | grep -q podman | ||
then | ||
echo "'$CONTAINER_BACKEND' backend is selected, but the functionality is actually provided by 'podman' backend. Updating accordingly..." | ||
CONTAINER_BACKEND="$(command -v podman)" | ||
fi | ||
|
||
local CONTAINER_IMAGE="$($CONTAINER_BACKEND image ls "-qf=reference=${CONTAINER_REGISTRY}mraa:master")" | ||
local CONTAINER_EXIT_CODE=0 | ||
|
||
if ! $NO_CONTAINER_UPDATE | ||
then | ||
if [[ -z $CONTAINER_REGISTRY ]] | ||
then | ||
$CONTAINER_BACKEND build --force-rm -t "${CONTAINER_REGISTRY}mraa:master" "$SCRIPT_DIR" | ||
else | ||
$CONTAINER_BACKEND pull "${CONTAINER_REGISTRY}mraa:master" | ||
fi | ||
fi | ||
|
||
if [[ $CONTAINER_IMAGE != "$($CONTAINER_BACKEND image ls "-qf=reference=${CONTAINER_REGISTRY}mraa:master")" ]] | ||
then | ||
$CONTAINER_BACKEND container rm mraa &>/dev/null || true | ||
$CONTAINER_BACKEND image rm "${CONTAINER_REGISTRY}mraa:builder" &>/dev/null || true | ||
fi | ||
|
||
CONTAINER_BUILDER="$($CONTAINER_BACKEND image ls "-qf=reference=${CONTAINER_REGISTRY}mraa:builder")" | ||
if [[ -z $CONTAINER_BUILDER ]] | ||
then | ||
$CONTAINER_BACKEND tag "${CONTAINER_REGISTRY}mraa:master" "${CONTAINER_REGISTRY}mraa:builder" | ||
fi | ||
|
||
CONTAINER_OPTIONS=( "--name" "mraa" ) | ||
CONTAINER_OPTIONS+=( "--workdir" "$PWD" ) | ||
CONTAINER_OPTIONS+=( "--mount" "type=bind,source=$PWD,destination=$PWD" ) | ||
CONTAINER_OPTIONS+=( "--mount" "type=bind,source=$(realpath $SCRIPT_DIR/../../..),destination=$(realpath $SCRIPT_DIR/../../..)" ) | ||
if [[ -t 0 ]] | ||
then | ||
CONTAINER_OPTIONS+=( "-it" ) | ||
fi | ||
if [[ "$PWD" != "$SCRIPT_DIR" ]] | ||
then | ||
CONTAINER_OPTIONS+=( "--mount" "type=bind,source=$SCRIPT_DIR,destination=$SCRIPT_DIR" ) | ||
fi | ||
$CONTAINER_BACKEND container kill mraa &>/dev/null || true | ||
$CONTAINER_BACKEND container rm mraa &>/dev/null || true | ||
if [[ "$(basename "$CONTAINER_BACKEND")" == "podman" ]] | ||
then | ||
CONTAINER_OPTIONS+=( "--user" "root" ) | ||
if $CONTAINER_SHELL | ||
then | ||
if ! $CONTAINER_BACKEND run "${CONTAINER_OPTIONS[@]}" "${CONTAINER_REGISTRY}mraa:builder" bash | ||
then | ||
CONTAINER_EXIT_CODE="$($CONTAINER_BACKEND inspect mraa --format='{{.State.ExitCode}}')" | ||
fi | ||
else | ||
if ! $CONTAINER_BACKEND run "${CONTAINER_OPTIONS[@]}" "${CONTAINER_REGISTRY}mraa:builder" make deb | ||
then | ||
CONTAINER_EXIT_CODE="$($CONTAINER_BACKEND inspect mraa --format='{{.State.ExitCode}}')" | ||
fi | ||
$CONTAINER_BACKEND container rm mraa | ||
fi | ||
else | ||
local CONTAINER_SUDO="sed -i -E \"s/^(runner):(x?):([0-9]+):([0-9]+):(.*):(.*):(.*)$/\1:\2:$(id -u):$(id -g):\5:\6:\7/\" /etc/passwd && sudo -u runner" | ||
if $CONTAINER_SHELL | ||
then | ||
if ! $CONTAINER_BACKEND run "${CONTAINER_OPTIONS[@]}" "${CONTAINER_REGISTRY}mraa:builder" bash -c "$CONTAINER_SUDO -i" | ||
then | ||
CONTAINER_EXIT_CODE="$($CONTAINER_BACKEND inspect mraa --format='{{.State.ExitCode}}')" | ||
fi | ||
else | ||
if ! $CONTAINER_BACKEND run "${CONTAINER_OPTIONS[@]}" "${CONTAINER_REGISTRY}mraa:builder" bash -c "$CONTAINER_SUDO make deb" | ||
then | ||
CONTAINER_EXIT_CODE="$($CONTAINER_BACKEND inspect mraa --format='{{.State.ExitCode}}')" | ||
fi | ||
$CONTAINER_BACKEND container rm mraa | ||
fi | ||
fi | ||
return $CONTAINER_EXIT_CODE | ||
fi | ||
} | ||
|
||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: 2 | ||
updates: | ||
# Maintain dependencies for GitHub Actions | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "daily" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Build & Release | ||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
- name: Test | ||
run: | | ||
make test | ||
- name: Build | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get build-dep --no-install-recommends -y . | ||
make all | ||
sudo apt install -y binfmt-support qemu-user-static | ||
.github/container/build-deb | ||
- name: Workaround actions/upload-artifact#176 | ||
run: | | ||
echo "artifacts_path=$(realpath ..)" >> $GITHUB_ENV | ||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ github.event.repository.name }} | ||
path: | | ||
${{ env.artifacts_path }}/*.deb | ||
release: | ||
runs-on: ubuntu-latest | ||
needs: build | ||
if: ${{ github.event_name != 'pull_request' && github.ref_name == 'master' }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
fetch-depth: 0 | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ github.event.repository.name }} | ||
- name: Check if the latest version is releasable | ||
run: | | ||
version="$(dpkg-parsechangelog -S Version)" | ||
echo "version=$version" >> $GITHUB_ENV | ||
echo "changes<<EOF" >> $GITHUB_ENV | ||
echo '```' >> $GITHUB_ENV | ||
echo "$(dpkg-parsechangelog -S Changes)" >> $GITHUB_ENV | ||
echo '```' >> $GITHUB_ENV | ||
echo "EOF" >> $GITHUB_ENV | ||
if [[ -n "$(git tag -l "$version")" ]] | ||
then | ||
echo "distro=UNRELEASED" >> $GITHUB_ENV | ||
else | ||
echo "distro=$(dpkg-parsechangelog -S Distribution)" >> $GITHUB_ENV | ||
fi | ||
echo "$version" > VERSION | ||
if [[ -f pkg.conf.template ]] | ||
then | ||
sed "s/VERSION/$(dpkg-parsechangelog -S Version)/g" pkg.conf.template > pkg.conf | ||
fi | ||
- name: Release | ||
if: env.distro != 'UNRELEASED' | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ env.version }} | ||
body_path: README.md | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
target_commitish: master | ||
draft: false | ||
fail_on_unmatched_files: true | ||
files: | | ||
*.deb | ||
VERSION | ||
- name: Append changelog | ||
if: env.distro != 'UNRELEASED' | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
tag_name: ${{ env.version }} | ||
body: | | ||
## Changelog for ${{ env.version }} | ||
${{ env.changes }} | ||
append_body: true | ||
- name: Update Test repos | ||
if: env.distro != 'UNRELEASED' | ||
uses: radxa-repo/update-repo-action@main | ||
with: | ||
test-repo: true | ||
token: ${{ secrets.RADXA_APT_TEST_REPO_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
PROJECT ?= mraa | ||
PREFIX ?= /usr | ||
BINDIR ?= $(PREFIX)/bin | ||
LIBDIR ?= $(PREFIX)/lib | ||
MANDIR ?= $(PREFIX)/share/man | ||
|
||
.PHONY: all | ||
all: build | ||
|
||
# | ||
# Test | ||
# | ||
.PHONY: test | ||
test: | ||
|
||
# | ||
# Build | ||
# | ||
.PHONY: build | ||
build: build-doc | ||
|
||
SRC-DOC := . | ||
DOCS := $(SRC-DOC)/SOURCE | ||
.PHONY: build-doc | ||
build-doc: $(DOCS) | ||
|
||
$(SRC-DOC): | ||
mkdir -p $(SRC-DOC) | ||
|
||
.PHONY: $(SRC-DOC)/SOURCE | ||
$(SRC-DOC)/SOURCE: $(SRC-DOC) | ||
echo -e "git clone $(shell git remote get-url origin)\ngit checkout $(shell git rev-parse HEAD)" > "$@" | ||
|
||
# | ||
# Clean | ||
# | ||
.PHONY: distclean | ||
distclean: clean | ||
|
||
.PHONY: clean | ||
clean: clean-doc clean-deb | ||
|
||
.PHONY: clean-doc | ||
clean-doc: | ||
rm -rf $(DOCS) | ||
|
||
.PHONY: clean-deb | ||
clean-deb: | ||
rm -rf obj-aarch64-linux-gnu debian/.debhelper debian/libmraa*/ debian/mraa-*/ debian/python3-mraa/ debian/tmp/ debian/debhelper-build-stamp debian/files debian/*.debhelper.log debian/*.*.debhelper debian/*.substvars | ||
|
||
# | ||
# Release | ||
# | ||
.PHONY: dch | ||
dch: debian/changelog | ||
gbp dch --debian-branch=master | ||
|
||
.PHONY: deb | ||
deb: debian | ||
debuild --no-lintian --lintian-hook "lintian --fail-on error,warning --suppress-tags bad-distribution-in-changes-file -- %p_%v_*.changes" --no-sign -b -aarm64 -Pcross |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/.debhelper | ||
/debhelper-build-stamp | ||
/files | ||
/libmraa*/ | ||
/mraa-*/ | ||
/python3-mraa/ | ||
/tmp/ | ||
/*.debhelper.log | ||
/*.debhelper | ||
/*.substvars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mraa (2.2.0-1) stable; urgency=medium | ||
|
||
* Initial release | ||
|
||
-- "Radxa Computer Co., Ltd" <[email protected]> Thu, 27 Jul 2023 18:54:14 +0800 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
Source: mraa | ||
Maintainer: "Radxa Computer Co., Ltd" <[email protected]> | ||
Section: misc | ||
Priority: optional | ||
Standards-Version: 4.6.0 | ||
Build-Depends: cmake (>= 3.15), | ||
debhelper (>=12~), | ||
devscripts, | ||
lintian, | ||
swig, | ||
python3-dev, | ||
libjson-c-dev | ||
|
||
Package: libmraa2 | ||
Architecture: any | ||
Section: libs | ||
Priority: optional | ||
Depends: ${shlibs:Depends}, | ||
${misc:Depends}, | ||
Homepage: http://iotdk.intel.com/docs/master/mraa/ | ||
Description: userspace I/O library (runtime) | ||
mraa (libmraa) is library for interacting with userspace I/O on GNU/Linux | ||
platforms. The library abstracts platform quirks away from the end user. | ||
Currently interfaces supported include GPIO/PWM/I2C/SPI. | ||
. | ||
This package contains the library used at runtime. | ||
|
||
Package: libmraa-dev | ||
Architecture: any | ||
Section: libdevel | ||
Priority: optional | ||
Depends: libmraa2 (= ${binary:Version}), | ||
${misc:Depends} | ||
Homepage: http://iotdk.intel.com/docs/master/mraa/ | ||
Description: userspace I/O library (development) | ||
mraa (libmraa) is library for interacting with userspace I/O on GNU/Linux | ||
platforms. The library abstracts platform quirks away from the end user. | ||
Currently interfaces supported include GPIO/PWM/I2C/SPI. | ||
. | ||
This package contains the library development files. | ||
|
||
Package: mraa-examples | ||
Architecture: all | ||
Section: doc | ||
Priority: optional | ||
Homepage: http://iotdk.intel.com/docs/master/mraa/ | ||
Description: examples for mraa | ||
mraa (libmraa) is library for interacting with userspace I/O on GNU/Linux | ||
platforms. The library abstracts platform quirks away from the end user. | ||
Currently interfaces supported include GPIO/PWM/I2C/SPI. | ||
. | ||
This package contains mraa examples. | ||
|
||
Package: mraa-tools | ||
Architecture: any | ||
Depends: libmraa2, | ||
${shlibs:Depends}, | ||
${misc:Depends}, | ||
Section: utils | ||
Priority: optional | ||
Homepage: http://iotdk.intel.com/docs/master/mraa/ | ||
Description: userspace I/O tools (GPIO/I2C) | ||
mraa (libmraa) is library for interacting with userspace I/O on GNU/Linux | ||
platforms. The library abstracts platform quirks away from the end user. | ||
Currently interfaces supported include GPIO/PWM/I2C/SPI. | ||
. | ||
This package contains mraa GPIO tool. | ||
|
||
Package: python3-mraa | ||
Architecture: any | ||
Depends: libmraa2, | ||
python3, | ||
${shlibs:Depends}, | ||
${misc:Depends}, | ||
Section: python | ||
Priority: optional | ||
Homepage: http://iotdk.intel.com/docs/master/mraa/ | ||
Description: Python 3 binding for mraa | ||
mraa (libmraa) is library for interacting with userspace I/O on GNU/Linux | ||
platforms. The library abstracts platform quirks away from the end user. | ||
Currently interfaces supported include GPIO/PWM/I2C/SPI. | ||
. | ||
This package contains mraa Python 3 binding. |
Oops, something went wrong.