Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
blocktrron committed Jul 25, 2024
0 parents commit db42d45
Show file tree
Hide file tree
Showing 8 changed files with 288 additions and 0 deletions.
161 changes: 161 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Build package
on: [ push, pull_request]
jobs:
build-meta:
name: build-meta
runs-on: ubuntu-24.04
outputs:
build-meta-output: >-
${{ steps.build-metadata.outputs.build-meta-output }}
firmware-version: >-
${{ steps.build-metadata.outputs.firmware-version }}
create-release: >-
${{ steps.build-metadata.outputs.create-release }}
sdk-name:
${{ steps.build-metadata.outputs.sdk-name }}
sdk-url:
${{ steps.build-metadata.outputs.sdk-url }}
imagebuilder-name:
${{ steps.build-metadata.outputs.imagebuilder-name }}
imagebuilder-url:
${{ steps.build-metadata.outputs.imagebuilder-url }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
- name: Determine Version
id: build-metadata
run: bash $GITHUB_WORKSPACE/contrib/get-version.sh
- name: Create Artifact of build-meta
uses: actions/upload-artifact@v4
with:
name: build-meta
path: ${{ steps.build-metadata.outputs.build-meta-output }}
build-packages:
name: build-packages
runs-on: ubuntu-24.04
needs: build-meta
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-tags: true
fetch-depth: 0
submodules: true
- name: Install dependencies
run: |
$GITHUB_WORKSPACE/contrib/install-deps.sh
- name: Download SDK
run: |
curl -o /tmp/openwrt-sdk.tar.xz ${{ needs.build-meta.outputs.sdk-url }}
- name: Extract SDK
run: |
tar -xf /tmp/openwrt-sdk.tar.xz -C /tmp
ls /tmp
mv /tmp/${{ needs.build-meta.outputs.sdk-name }} /tmp/openwrt-sdk
- name: Create feeds.conf
run: |
cp /tmp/openwrt-sdk/feeds.conf.default /tmp/openwrt-sdk/feeds.conf
echo "src-link oobfw $GITHUB_WORKSPACE/openwrt" >> /tmp/openwrt-sdk/feeds.conf
echo "src-link oobpkgs $GITHUB_WORKSPACE/packages" >> /tmp/openwrt-sdk/feeds.conf
cat /tmp/openwrt-sdk/feeds.conf
- name: Init SDK
run: |
cd /tmp/openwrt-sdk
echo "# CONFIG_SIGNED_PACKAGES is not set" > /tmp/openwrt-sdk/.config
echo CONFIG_FFDA_OOB_FIRMWARE_VERSION=\"${{ needs.build-meta.outputs.firmware-version }}0\" >> /tmp/openwrt-sdk/.config
make defconfig
cat .config
cd /tmp/openwrt-sdk
./scripts/feeds update -a
./scripts/feeds install -a
- name: Build packages
run: |
cd /tmp/openwrt-sdk
cat .config
make package/ffda-oob-firmware/compile V=s -j4
make package/index
- name: Show binary output directory structure
run: |
tree /tmp/openwrt-sdk/bin
- name: Upload oobfw packages
uses: actions/upload-artifact@v4
with:
name: packages-oobfw
path: /tmp/openwrt-sdk/bin/packages/mips_24kc/oobfw
- name: Upload oobpkgs packages
uses: actions/upload-artifact@v4
with:
name: packages-oobpkgs
path: /tmp/openwrt-sdk/bin/packages/mips_24kc/oobpkgs
build-firmware:
name: build-firmware
runs-on: ubuntu-24.04
needs: [build-packages, build-meta]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: /tmp/packages
- name: Show binary output directory structure
run: |
tree /tmp/packages
- name: Install dependencies
run: |
$GITHUB_WORKSPACE/contrib/install-deps.sh
- name: Download Imagebuilder
run: |
curl -o /tmp/openwrt-imagebuilder.tar.xz ${{ needs.build-meta.outputs.imagebuilder-url }}
- name: Extract Imagebuilder
run: |
tar -xf /tmp/openwrt-imagebuilder.tar.xz -C /tmp
mv /tmp/${{ needs.build-meta.outputs.imagebuilder-name }} /tmp/openwrt-imagebuilder
- name: Link repositories
run: |
sed -i '/^option check_signature/d' /tmp/openwrt-imagebuilder/repositories.conf
echo "src oobfw file:///tmp/packages/packages-oobfw" >> /tmp/openwrt-imagebuilder/repositories.conf
echo "src oobpkgs file:///tmp/packages/packages-oobpkgs" >> /tmp/openwrt-imagebuilder/repositories.conf
cat /tmp/openwrt-imagebuilder/repositories.conf
- name: Build images
run: |
cd /tmp/openwrt-imagebuilder
$GITHUB_WORKSPACE/contrib/build-image.sh
- name: Upload firmware images
uses: actions/upload-artifact@v4
with:
name: firmware-images
path: /tmp/openwrt-imagebuilder/bin/targets/ath79/nand
create-release:
name: create-release
runs-on: ubuntu-24.04
permissions:
contents: write
needs: [build-packages, build-firmware, build-meta]
if: ${{ needs.build-meta.outputs.create-release == '1' }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: /tmp/artifacts
- name: Show binary output directory structure
run: |
tree /tmp/artifacts
- name:
run: |
mkdir -p /tmp/artifacts-upload
cp /tmp/artifacts/firmware-images/*.bin /tmp/artifacts-upload
cp /tmp/artifacts/firmware-images/*.img /tmp/artifacts-upload
cp /tmp/artifacts/packages-oobfw/*.ipk /tmp/artifacts-upload
cp /tmp/artifacts/packages-oobpkgs/*.ipk /tmp/artifacts-upload
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
body: ${{ github.ref_name }}
files: |
/tmp/artifacts-upload/*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "packages"]
path = packages
url = https://github.com/freifunk-darmstadt/ffda-oob-state-reporter.git
5 changes: 5 additions & 0 deletions contrib/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

EXTRA_PKGS="kmod-usb-serial-pl2303 kmod-usb-serial-cp210x kmod-usb-serial-ftdi luci luci-proto-qmi picocom gl-puli-mcu kmod-usb-serial-option qmi-utils ffda-oob-firmware"

make image PROFILE="glinet_gl-xe300" PACKAGES="$EXTRA_PKGS"
69 changes: 69 additions & 0 deletions contrib/get-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash


BASE_VERSION="1.0.0"

# Name of SDK
SDK_NAME="openwrt-sdk-23.05.4-ath79-nand_gcc-12.3.0_musl.Linux-x86_64"

# Name of Imagebuilder
IMAGEBUILDER_NAME="openwrt-imagebuilder-23.05.4-ath79-nand.Linux-x86_64"

# URLs
SDK_URL="https://downloads.openwrt.org/releases/23.05.4/targets/ath79/nand/${SDK_NAME}.tar.xz"
IMAGEBUILDER_URL="http://downloads.openwrt.org/releases/23.05.4/targets/ath79/nand/${IMAGEBUILDER_NAME}.tar.xz"

# Get Git short hash for repo at $SCRIPT_DIR
GIT_SHORT_HASH="$(git -C "$SCRIPT_DIR" rev-parse --short HEAD)"

# Get date of last Git commit for repo at $SCRIPT_DIR
GIT_COMMIT_DATE="$(git -C "$SCRIPT_DIR" log -1 --format=%cd --date=format:'%Y%m%d')"

# Get latest Git tag for repo at $SCRIPT_DIR
GIT_LATEST_TAG="$(git describe --tags --abbrev=0)"

# Use the base version as the version prefix
VERSION_PREFIX="$BASE_VERSION"

# Use the latest tag as the version prefix if it exists
if [ -n "$GIT_LATEST_TAG" ]; then
# If there is a tag, use it as the version prefix
VERSION_PREFIX="$GIT_LATEST_TAG"
fi

# Don't create a release by default
CREATE_RELEASE="0"

# Check if this was a push of a tag
if [ "$GITHUB_EVENT_NAME" = "push" ] && [ "$GITHUB_REF_TYPE" = "branch" ]; then
VERSION="$VERSION_PREFIX-$GIT_SHORT_HASH-$GIT_COMMIT_DATE"
elif [ "$GITHUB_EVENT_NAME" = "push" ] && [ "$GITHUB_REF_TYPE" = "tag" ]; then
# If this was a push of a tag, use the tag as the version
VERSION="$VERSION_PREFIX"
CREATE_RELEASE="1"
else
# Error out, unsupported
exit 1
fi

# Write build-meta to dedicated file before appending GITHUB_OUTPUT.
# This way, we can create an artifact for our build-meta to eventually upload to a release.
BUILD_META_TMP_DIR="$(mktemp -d)"
BUILD_META_OUTPUT="$BUILD_META_TMP_DIR/build-meta.txt"

echo "firmware-version=$VERSION" > "$BUILD_META_OUTPUT"
echo "create-release=$CREATE_RELEASE" >> "$BUILD_META_OUTPUT"
echo "build-meta-output=$BUILD_META_TMP_DIR" >> "$BUILD_META_OUTPUT"
echo "sdk-name=$SDK_NAME" >> "$BUILD_META_OUTPUT"
echo "sdk-url=$SDK_URL" >> "$BUILD_META_OUTPUT"
echo "imagebuilder-name=$IMAGEBUILDER_NAME" >> "$BUILD_META_OUTPUT"
echo "imagebuilder-url=$IMAGEBUILDER_URL" >> "$BUILD_META_OUTPUT"


# Copy over to GITHUB_OUTPUT
cat "$BUILD_META_OUTPUT" >> "$GITHUB_OUTPUT"

# Display Output so we can conveniently check it from CI log viewer
cat "$GITHUB_OUTPUT"

exit 0
4 changes: 4 additions & 0 deletions contrib/install-deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

sudo apt-get -y update
sudo apt-get -y install tree curl build-essential clang flex bison g++ gawk gcc-multilib g++-multilib gettext git libncurses5-dev libssl-dev python3-setuptools rsync swig unzip zlib1g-dev file wget
40 changes: 40 additions & 0 deletions openwrt/oob-packages/ffda-oob-firmware/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=ffda-oob-firmware
PKG_VERSION:=1

PKG_CONFIG_DEPENDS := CONFIG_FFDA_OOB_FIRMWARE_VERSION

include $(INCLUDE_DIR)/package.mk

define Build/Prepare
endef

define Build/Configure
endef

define Build/Compile
endef

define Package/ffda-oob-firmware
TITLE:=Base files of FFDA OOB Firmware
DEPENDS:=+ffda-oob-state-reporter
endef

define Package/ffda-oob-firmware/config
config FFDA_OOB_FIRMWARE_VERSION
string "Gluon version number"
depends on PACKAGE_ffda-oob-firmware
default ""
endef

define Package/ffda-oob-firmware/install
$(Gluon/Build/Install)

$(INSTALL_DIR) $(1)/lib/ffda-oob-firmware $(1)/usr/bin
echo '$(call qstrip,$(CONFIG_FFDA_OOB_FIRMWARE_VERSION))' > $(1)/lib/ffda-oob-firmware/firmware-version

$(INSTALL_BIN) ./files/ffda-oob-ntp.sh $(1)/usr/bin/ffda-oob-ntp
endef

$(eval $(call BuildPackage,ffda-oob-firmware))
5 changes: 5 additions & 0 deletions openwrt/oob-packages/ffda-oob-firmware/files/ffda-oob-ntp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

ntpd -n -q -p time.windows.com || exit 1

date "+%s" > /tmp/ntp_last_sync
1 change: 1 addition & 0 deletions packages
Submodule packages added at 2e66cb

0 comments on commit db42d45

Please sign in to comment.