Skip to content
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
73 changes: 73 additions & 0 deletions .github/workflows/deb_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build debian package for Linux ADI-scripts

on:
push:
branches:
- kuiper2.0
- '20[1-9][0-9]_R[1-9]'
pull_request:
branches:
- kuiper2.0
- '20[1-9][0-9]_R[1-9]'
env:
APP_NAME: linux_image_ADI-scripts

jobs:
build_debian_package:
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout code repository
uses: actions/checkout@v6
with:
path: ${{env.APP_NAME}}
- name: Get version from file
run: |
VERSION=$(cat "${{env.APP_NAME}}/packaging/VERSION" 2>/dev/null | tr -d '[:space:]')
# Regex to match semantic versioning (from semver.org)
# Regex will match valid version number https://regex101.com/r/K8FvXg/1
regex='^((0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)))*))?(\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?)$'
if ! [[ "$VERSION" =~ $regex ]]; then
echo "WARNING: Invalid or missing version '$VERSION', falling back to 0.0.1"
VERSION="0.0.1"
fi
echo "VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y build-essential devscripts debhelper gettext
- name: Build debian package
run: |
"${{env.APP_NAME}}/packaging/build-adi-scripts-deb.sh" "${{github.head_ref}}" "${{env.VERSION}}" "${{env.APP_NAME}}"
- name: Upload debian artifacts to github
if: success() && env.PACKAGE_NAME != ''
uses: actions/upload-artifact@v7
with:
name: ${{env.PACKAGE_NAME}}-${{env.VERSION}}-ubuntu
path: |
${{env.PACKAGE_NAME}}_*.deb
${{env.PACKAGE_NAME}}*.dsc
${{env.PACKAGE_NAME}}*.debian.tar.xz
${{env.PACKAGE_NAME}}*.orig.tar.gz
if-no-files-found: error
- name: Authenticate with Cloudsmith via OIDC
if: success() && github.event_name == 'push' && env.PACKAGE_NAME != ''
uses: cloudsmith-io/cloudsmith-cli-action@v2.0.2
with:
oidc-namespace: adi
oidc-service-slug: ${{ secrets.CLOUDSMITH_SERVICE_SLUG }}

- name: Upload debian package to Cloudsmith
if: success() && env.CLOUDSMITH_API_KEY != ''
run: |
pip install cloudsmith-cli
for f in ${{env.PACKAGE_NAME}}*.dsc ${{env.PACKAGE_NAME}}*.orig.tar.gz ${{env.PACKAGE_NAME}}*.debian.tar.xz; do
[ -f "$f" ] || continue
cloudsmith push raw -SW --republish adi/kuiper-internal "$f"
done
cloudsmith push deb -SW --republish "adi/kuiper-internal/debian/trixie" ${{env.PACKAGE_NAME}}_*.deb




76 changes: 76 additions & 0 deletions packaging/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# ADI Scripts Debian Package Builder

This directory contains the infrastructure to build Debian packages for the [linux_image_ADI-scripts](https://github.com/analogdevicesinc/linux_image_ADI-scripts) repository using debhelper.

## Overview

The build system:
1. Builds it using `make`
2. Creates a `.deb` package with debhelper
3. Generates source package files (`.orig.tar.gz`, `.debian.tar.xz`, `.dsc`)

## Prerequisites

```bash
sudo apt-get install debhelper devscripts build-essential wget gettext
git clone https://github.com/analogdevicesinc/linux_image_ADI-scripts.git
git checkout kuiper2.0
```

**Note:** This package depends on the `gt` (USB Gadget Tool) package. You should build and install the gt package separately before using the USB gadget functionality.

## Usage

### Building the Package

The script should be run from the parent folder of the entire git repository and call the script

```bash
linux_image_ADI-scripts/packaging/build-adi-scripts-deb.sh [branch] [version] [clone_dir]
```

Parameters:
- `branch`: Branch or tag name (default: `kuiper2.0`) (used for changelog only)
- `version`: Package version (default: `1.0.0`)
- `clone_dir`: Directory where the repository is cloned (default: `linux_image_ADI-scripts`)

### Example

```bash
# Build from kuiper2.0 branch with default version
./build-adi-scripts-deb.sh

# Build from specific branch with custom version
./build-adi-scripts-deb.sh main 1.5

# Build from specific branch with custom version and clone directory
./build-adi-scripts-deb.sh main 1.5 /path/to/linux_image_ADI-scripts
```

## Output Files

The build process generates:
- `adi-scripts_<version>.orig.tar.gz` - Upstream source tarball
- `adi-scripts_<version>-1.debian.tar.xz` - Debian packaging files
- `adi-scripts_<version>-1.dsc` - Debian source package descriptor
- `adi-scripts_<version>-1_all.deb` - Binary package (architecture-independent)

## Package Contents

The package installs:
- Shell scripts to `/usr/bin/`
- Systemd service files to `/etc/systemd/system/`
- Python scripts to `/usr/share/systemd/`
- Configuration files for lightdm, USB gadget, etc.

The following systemd services are enabled on installation:
- `adi-power.service` - Power management service
- `fan-control.service` - Fan control service
- `fix-display-port.service` - DisplayPort fix service

## Notes

- The package is architecture-independent (`all`) as it contains only shell scripts
- Uses upstream Makefile with `make install DESTDIR=... PREFIX=/usr`
- Systemd services are enabled during package installation via postinst script
- The build process creates both binary and source packages automatically
1 change: 1 addition & 0 deletions packaging/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0
60 changes: 60 additions & 0 deletions packaging/build-adi-scripts-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash -e

# Script that generates ADI scripts .deb package and source files using debhelper
# As a prerequire, the repository should be checked out before running this script


RELEASE=${1:-kuiper2.0} # Default to kuiper2.0 branch
VERSION=${2:-1.0.0} # Default to version 1.0.0
UPSTREAM_DIR=${3:-linux_image_ADI-scripts} # Default to linux_image_ADI-scripts

# Package metadata
PACKAGE="adi-scripts"

# Set variable for github workflows
[ -n "$GITHUB_ENV" ] && echo "PACKAGE_NAME=$PACKAGE" >> $GITHUB_ENV

WORK_DIR="${PACKAGE}-${VERSION}"

# Rename extracted directory to match Debian conventions
cp -a ${UPSTREAM_DIR} ${WORK_DIR}

# Create the orig tarball with exclusions
echo "Creating source tarball with exclusions..."
tar czf ${PACKAGE}_${VERSION}.orig.tar.gz \
--exclude='.git' \
${WORK_DIR}

# Substitute variables in templates
cd ${WORK_DIR}

# Copy debian directory into the extracted source tree
cp -r packaging/debian .

# Export all variables for envsubst and debian/rules
export VERSION PACKAGE RELEASE
export DATE=$(date -R)

# Create changelog entry
CHANGELOG_ENTRY="Build from ${RELEASE} branch"
export CHANGELOG_ENTRY

# Substitute templates
envsubst < debian/control.template > debian/control
envsubst < debian/changelog.template > debian/changelog

# Remove template files
rm debian/*.template

# Build package using debhelper (builds both binary and source packages)
echo "Building packages..."
dpkg-buildpackage -us -uc

cd ..

echo ""
echo "Build complete! Generated files:"
echo " - ${PACKAGE}_${VERSION}.orig.tar.gz (upstream source)"
echo " - ${PACKAGE}_${VERSION}-1.debian.tar.xz (debian files)"
echo " - ${PACKAGE}_${VERSION}-1.dsc (source descriptor)"
echo " - ${PACKAGE}_${VERSION}-1_all.deb (binary package)"
5 changes: 5 additions & 0 deletions packaging/debian/changelog.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
${PACKAGE} (${VERSION}-1) stable; urgency=medium

* ${CHANGELOG_ENTRY}

-- Engineerzone <https://ez.analog.com/sw-interface-tools> ${DATE}
13 changes: 13 additions & 0 deletions packaging/debian/control.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Source: ${PACKAGE}
Section: utils
Priority: optional
Maintainer: Engineerzone <https://ez.analog.com/sw-interface-tools>
Build-Depends: debhelper-compat (= 13)
Standards-Version: 4.6.2
Homepage: https://github.com/analogdevicesinc/linux_image_ADI-scripts

Package: ${PACKAGE}
Architecture: all
Depends: ${shlibs:Depends}, ${misc:Depends}, bash, wget, systemd, gt (>= 1.0)
Description: ADI Linux system configuration and test scripts
This package contains shell scripts for configuring and testing Analog Devices hardware on Linux systems, including power management, USB gadget configuration, and various device test scripts.
34 changes: 34 additions & 0 deletions packaging/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: linux_image_ADI-scripts
Upstream-Contact: Analog Devices, Inc.
Source: https://github.com/analogdevicesinc/linux_image_ADI-scripts

Files: *
Copyright: 2018, Analog Devices Inc.
License: BSD-3-Clause

License: BSD-3-Clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19 changes: 19 additions & 0 deletions packaging/debian/postinst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash -e

if [ "$1" = "configure" ]; then
if command -v systemctl >/dev/null 2>&1; then
systemctl enable adi-power.service || true
systemctl enable fan-control.service || true
systemctl enable fix-display-port.service || true
systemctl enable gt.service || true
systemctl enable gt-start.service || true
systemctl enable gt.target || true
systemctl enable iiod_ffs.service || true
systemctl enable iiod_context_attr.service || true
systemctl enable dev-iio_ffs.mount || true

systemctl daemon-reload || true
fi
fi

exit 0
29 changes: 29 additions & 0 deletions packaging/debian/postrm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash -e

if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
if command -v systemctl >/dev/null 2>&1; then
systemctl disable adi-power.service 2>/dev/null || true
systemctl disable fan-control.service 2>/dev/null || true
systemctl disable fix-display-port.service 2>/dev/null || true
systemctl disable gt.service 2>/dev/null || true
systemctl disable gt-start.service 2>/dev/null || true
systemctl disable gt.target 2>/dev/null || true
systemctl disable iiod_ffs.service 2>/dev/null || true
systemctl disable iiod_context_attr.service 2>/dev/null || true
systemctl disable dev-iio_ffs.mount 2>/dev/null || true

systemctl stop adi-power.service 2>/dev/null || true
systemctl stop fan-control.service 2>/dev/null || true
systemctl stop fix-display-port.service 2>/dev/null || true
systemctl stop gt.service 2>/dev/null || true
systemctl stop gt-start.service 2>/dev/null || true
systemctl stop gt.target 2>/dev/null || true
systemctl stop iiod_ffs.service 2>/dev/null || true
systemctl stop iiod_context_attr.service 2>/dev/null || true
systemctl stop dev-iio_ffs.mount 2>/dev/null || true

systemctl daemon-reload || true
fi
fi

exit 0
29 changes: 29 additions & 0 deletions packaging/debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/make -f

PACKAGE ?= adi-scripts

export DH_VERBOSE = 1

%:
dh $@

override_dh_auto_clean:
# Nothing to clean - no build artifacts
:

override_dh_auto_configure:
# No configuration needed
:

override_dh_auto_build:
# Nothing to build - shell scripts only
:

override_dh_auto_install:
# Use upstream Makefile with DESTDIR and PREFIX support
# Makefile installs all files: scripts, services, USB gadget files, configs
$(MAKE) install DESTDIR=$(CURDIR)/debian/$(PACKAGE) PREFIX=/usr

override_dh_auto_test:
# Skip tests
:
1 change: 1 addition & 0 deletions packaging/debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
Loading