Skip to content

Commit

Permalink
v9.8
Browse files Browse the repository at this point in the history
- CI | Add new build script to master branch, required to trigger builds on GitHub
  • Loading branch information
MichaIng committed Oct 10, 2024
1 parent 31d6a09 commit 89c2dd3
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 0 deletions.
92 changes: 92 additions & 0 deletions .build/software/sprd-bluetooth/build.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/bin/bash
{
if [[ -f '/boot/dietpi/func/dietpi-globals' ]]
then
. /boot/dietpi/func/dietpi-globals || exit 1
else
curl -sSf "https://raw.githubusercontent.com/${G_GITOWNER:-MichaIng}/DietPi/${G_GITBRANCH:-master}/dietpi/func/dietpi-globals" -o /tmp/dietpi-globals || exit 1
# shellcheck disable=SC1091
. /tmp/dietpi-globals || exit 1
G_EXEC_NOHALT=1 G_EXEC rm /tmp/dietpi-globals
fi

G_EXEC mkdir -p sprd-bluetooth/{DEBIAN,usr/bin,lib/systemd/system}

G_EXEC curl -fo sprd-bluetooth/usr/bin/hciattach_opi 'https://raw.githubusercontent.com/orangepi-xunlong/orangepi-build/next/external/packages/blobs/bt/hciattach/hciattach_opi_arm64'
G_EXEC chmod +x sprd-bluetooth/usr/bin/hciattach_opi
cat << '_EOF_' > sprd-bluetooth/lib/systemd/system/sprd-bluetooth.service
[Unit]
Description=Spreadtrum (sprd) Bluetooth support
After=bluetooth.service
[Service]
RemainAfterExit=yes
ExecStart=/usr/bin/hciattach_opi -n -s 1500000 /dev/ttyBT0 sprd
[Install]
WantedBy=multi-user.target
_EOF_

# Control files
# - postinst
cat << '_EOF_' > sprd-bluetooth/DEBIAN/postinst
#!/bin/sh
if [ -d '/run/systemd/system' ]
then
echo 'Configuring sprd-bluetooth systemd service ...'
systemctl unmask sprd-bluetooth
systemctl enable --now sprd-bluetooth
fi
_EOF_

# - prerm
cat << '_EOF_' > sprd-bluetooth/DEBIAN/prerm
#!/bin/sh
if [ "$1" = 'remove' ] && [ -d '/run/systemd/system' ]
then
if [ -f '/lib/systemd/system/sprd-bluetooth.service' ]
then
echo 'Deconfiguring sprd-bluetooth systemd service ...'
systemctl unmask sprd-bluetooth
systemctl disable --now sprd-bluetooth
fi
fi
_EOF_

# - postrm
cat << '_EOF_' > sprd-bluetooth/DEBIAN/postrm
#!/bin/sh
if [ "$1" = 'purge' ]
then
if [ -d '/etc/systemd/system/sprd-bluetooth.service.d' ]
then
echo 'Removing sprd-bluetooth systemd service overrides ...'
rm -Rv /etc/systemd/system/sprd-bluetooth.service.d
fi
fi
_EOF_

# - md5sums
find sprd-bluetooth ! \( -path sprd-bluetooth/DEBIAN -prune \) -type f -exec md5sum {} + | sed 's|sprd-bluetooth/||' > sprd-bluetooth/DEBIAN/md5sums

# - control
cat << _EOF_ > sprd-bluetooth/DEBIAN/control
Package: sprd-bluetooth
Version: 0.0.1
Architecture: arm64
Maintainer: MichaIng <micha@dietpi.com>
Date: $(date -uR)
Installed-Size: $(du -sk sprd-bluetooth | mawk '{print $1}')
Section: admin
Priority: optional
Homepage: https://github.com/RPi-Distro/sprd-bluetooth
Description: System tweaks for the Raspberry Pi, DietPi edition
_EOF_
G_CONFIG_INJECT 'Installed-Size: ' "Installed-Size: $(du -sk sprd-bluetooth | mawk '{print $1}')" sprd-bluetooth/DEBIAN/control

# Build DEB package
G_EXEC_OUTPUT=1 G_EXEC dpkg-deb -b -Zxz -z9 sprd-bluetooth

# Cleanup
G_EXEC rm -R sprd-bluetooth
}
25 changes: 25 additions & 0 deletions .github/workflows/sprd-bluetooth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: sprd-bluetooth
on: workflow_dispatch
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
permissions: {}
jobs:
build:
# https://github.com/actions/runner-images
runs-on: ubuntu-24.04
steps:
- name: Build
run: sudo bash -c "$(curl -sSf "https://raw.githubusercontent.com/$GITHUB_REPOSITORY_OWNER/DietPi/$GITHUB_REF_NAME/.build/software/sprd-bluetooth/build.bash")"
- name: Upload
run: |
# SSH server and client keys
mkdir ~/.ssh
umask 377
echo '${{ secrets.KNOWN_HOSTS }}' > ~/.ssh/known_hosts
echo '${{ secrets.SSH_KEY }}' > ~/.ssh/id_ed25519
# Upload
curl -T sprd-bluetooth.deb --key ~/.ssh/id_ed25519 '${{ secrets.UPLOAD_URL }}all/'
curl 'https://api.cloudflare.com/client/v4/zones/${{ secrets.CF_ZONE }}/purge_cache' -H 'Authorization: Bearer ${{ secrets.CF_TOKEN }}' -H 'Content-Type: application/json' \
--data '{"files":["https://dietpi.com/downloads/binaries/testing/","https://dietpi.com/downloads/binaries/testing/sprd-bluetooth.deb"]}'

0 comments on commit 89c2dd3

Please sign in to comment.