Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Legacy] Sync legacy branch with stable #248

Merged
merged 29 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f98a200
contrib: change tabs to spaces
grische Jul 26, 2023
6c18012
Backport changes from v2022.2.1-next3
goligo Mar 30, 2022
4d499a1
Move install_build_dependencies.sh to scripts/
grische Sep 14, 2022
2ce76bd
Add dependencies to README
grische Sep 14, 2022
994a8d0
Fix hardcoded gluon-build path
grische Sep 14, 2022
c1cea0f
Simplify patching and move it into separate script
grische Sep 14, 2022
927ab82
Add Github Action for bash linting
grische Sep 14, 2022
89d1189
Fix in POSIX sh, set flag -E is undefined
grische Sep 14, 2022
cd1fca7
Fix overriding the main git remote by accident
grische Sep 12, 2022
52c7e47
Run output-clean only during build, not before.
grische Sep 14, 2022
d0653ab
contrib: Update render templates
grische Sep 6, 2022
e290988
Format firmware.yml
grische Jul 26, 2023
a15cf7e
Do not build firmware on unrelated changes
grische Sep 18, 2022
15d5a13
Run shellcheck workflow only for shellscripts
grische Sep 18, 2022
02e189d
Add building instructions with Docker
grische May 21, 2022
f143e2c
Adding signing key for grische
grische Oct 9, 2022
f4ead38
Add --tags to git fetch to make sure all Gluon tags are included
goligo Oct 25, 2022
98eb1aa
Get rid of ::set-ouput as it is deprecated
goligo Oct 27, 2022
d10851a
Build without easimon/maximize-build-space
goligo Oct 27, 2022
d230408
Add sign.sh from Gluon
grische Feb 5, 2023
c51034f
Put target list into a separate file
goligo Jan 18, 2023
ca37c41
Replace deprecated actions/create-release
grische Feb 5, 2023
c194ccc
Update actions/download-artifact for download-all
grische Feb 5, 2023
acbf1a6
Simplifying Release Creation
grische Feb 5, 2023
bf0d5f7
fix name for download-artifact action
grische May 7, 2023
8f552c2
github: update action-shellcheck to v1.18.1
grische Jul 21, 2023
01b788e
changelog: add reference to Github releases
grische Jul 26, 2023
a99676f
contrib: make genpkglist executable
grische Jul 26, 2023
398acfd
readme: improve Docker instructions
grische Jul 26, 2023
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
83 changes: 40 additions & 43 deletions .github/workflows/firmware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@ on:
tags:
- v*
pull_request:
paths-ignore:
- '**.md'
- '**/CODEOWNERS'
- '.github/ISSUE_TEMPLATE'
- '.github/*.yml'
- 'contrib/sign.sh'

jobs:
generate_target_matrix:
runs-on: ubuntu-latest
outputs:
target_json: ${{ steps.set_target.outputs.target }}
steps:
- name: Set target matrix
id: set_target
shell: bash
run: |
target_list="[\"ar71xx-generic\", \"ar71xx-tiny\", \"ar71xx-nand\", \"ath79-generic\", \"brcm2708-bcm2708\", \"brcm2708-bcm2709\", \"ipq40xx-generic\", \"ipq806x-generic\", \"lantiq-xrx200\", \"lantiq-xway\", \"mpc85xx-generic\", \"mpc85xx-p1020\", \"ramips-mt7620\", \"ramips-mt7621\", \"ramips-mt76x8\", \"ramips-rt305x\", \"sunxi-cortexa7\", \"x86-generic\", \"x86-geode\", \"x86-legacy\", \"x86-64\", \"ar71xx-mikrotik\", \"brcm2708-bcm2710\", \"mvebu-cortexa9\"]"
echo ::set-output name=target::{\"target\": $(echo $target_list)}\"
- name: Checkout
uses: actions/checkout@v3
- name: Set target matrix
id: set_target
shell: bash
run: |
target_list=$(cat targets | jq -Rsc '.[:-1] | split("\n")')
echo "target={\"target\": $(echo $target_list)}" >> $GITHUB_OUTPUT

build_firmware:
needs: generate_target_matrix
Expand All @@ -27,19 +35,24 @@ jobs:
matrix: ${{ fromJson(needs.generate_target_matrix.outputs.target_json) }}
runs-on: ubuntu-latest
steps:
- name: Maximize build space
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Install build dependencies
run: |
sudo -E ./install_build_dependencies.sh
sudo -E ./scripts/install_build_dependencies.sh
- name: build target ${{ matrix.target }}
id: compile
run: |
git checkout -b patched ${GITHUB_SHA}
make BROKEN=1 GLUON_TARGETS=${{ matrix.target }} V=s
echo "::set-output name=status::success"
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware ${{ matrix.target }}
uses: actions/upload-artifact@master
if: steps.compile.outputs.status == 'success'
Expand All @@ -51,42 +64,26 @@ jobs:
runs-on: ubuntu-latest
needs: build_firmware
if: github.event_name != 'pull_request'
outputs:
output1: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Display structure of artifacts
run: ls -R
- name: Create tar.gz files
run: |
set -x
for output in *_output; do
tar zcvf "${output}.tar.gz" "${output}"
done
- name: Create Release & Upload Release Assets
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
# Note: If there is no release name specified, releases created in
# the GitHub UI do not trigger a failure and are modified instead.
draft: false
prerelease: false

upload_release:
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.generate_target_matrix.outputs.target_json) }}
runs-on: ubuntu-latest
needs: [ create_release, generate_target_matrix ]
if: github.event_name != 'pull_request'
steps:
- name: Download Artifact ${{ matrix.target }}
uses: actions/download-artifact@v2
with:
name: ${{ matrix.target }}_output
path: ${{ matrix.target }}_output
- name: Create ${{ matrix.target }}_output.tar.gz
run: tar zcvf ${{ matrix.target }}_output.tar.gz ${{ matrix.target }}_output
- name: Upload Release Asset ${{ matrix.target }}
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.output1 }}
asset_path: ./${{ matrix.target }}_output.tar.gz
asset_name: ${{ matrix.target }}_output.tar.gz
asset_content_type: application/gzip
# Note: Release notes are only auto-generated if the release was
# created by the Github Action and was not created in the Github UI.
generate_release_notes: true
files: |
./*_output.tar.gz
28 changes: 28 additions & 0 deletions .github/workflows/shellcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Shell Linting

on: # yamllint disable-line rule:truthy
workflow_dispatch:
push:
branches:
- stable
- next
paths:
- '**.sh'
pull_request:
paths:
- '**.sh'

jobs:
shellcheck:
name: runner / shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: shellcheck
# Make sure the action is pinned to a commit, as all reviewdog repos
# have hundreds of contributors with write access (breaks easy/often)
uses: reviewdog/action-shellcheck@50e5e1e2284575f23a1e409d9c0804cdfc4f6e31 # v1.18.1
with:
filter_mode: "file"
fail_on_error: true
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Freifunk München Firmware Changelog

## Newer versions
Detailed changelog for versions v2022.5.1 and above can be found here:
https://github.com/freifunkMUC/site-ffm/releases

## v2022.2.1
- Fix bug in wireguard package which was causing high CPU load if no WAN was available

Expand Down
4 changes: 4 additions & 0 deletions Dockerfile_build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM ubuntu:20.04

ADD ./scripts/install_build_dependencies.sh /
RUN /install_build_dependencies.sh
74 changes: 20 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,10 @@ GLUON_BUILD_DIR := gluon-build
GLUON_GIT_URL := https://github.com/freifunk-gluon/gluon.git
GLUON_GIT_REF := v2021.1.2

PATCH_DIR := ${GLUON_BUILD_DIR}/site/patches
PATCH_DIR := ./patches
SECRET_KEY_FILE ?= ${HOME}/.gluon-secret-key

GLUON_TARGETS ?= \
ar71xx-generic \
ar71xx-mikrotik \
ar71xx-nand \
ar71xx-tiny \
ath79-generic \
brcm2708-bcm2708 \
brcm2708-bcm2709 \
brcm2708-bcm2710 \
ipq40xx-generic \
ipq806x-generic \
lantiq-xrx200 \
lantiq-xway \
mpc85xx-generic \
mpc85cc-p1020 \
mvebu-cortexa9 \
ramips-mt7620 \
ramips-mt7621 \
ramips-mt76x8 \
ramips-rt305x \
sunxi-cortexa7 \
x86-64 \
x86-generic \
x86-geode \
x86-legacy

GLUON_TARGETS ?= $(shell cat targets | tr '\n' ' ')
GLUON_AUTOUPDATER_BRANCH := stable

ifneq (,$(shell git describe --exact-match --tags 2>/dev/null))
Expand Down Expand Up @@ -60,7 +35,7 @@ info:
@echo '# Building release ${GLUON_RELEASE} for branch ${GLUON_AUTOUPDATER_BRANCH}'
@echo

build: gluon-prepare
build: gluon-prepare output-clean
for target in ${GLUON_TARGETS}; do \
echo ""Building target $$target""; \
${GLUON_MAKE} download all GLUON_TARGET="$$target"; \
Expand All @@ -76,36 +51,27 @@ sign: manifest
${GLUON_BUILD_DIR}/contrib/sign.sh ${SECRET_KEY_FILE} output/images/sysupgrade/${GLUON_AUTOUPDATER_BRANCH}.manifest

${GLUON_BUILD_DIR}:
git clone ${GLUON_GIT_URL} ${GLUON_BUILD_DIR}

gluon-prepare: output-clean ${GLUON_BUILD_DIR}
cd ${GLUON_BUILD_DIR} \
&& git remote set-url origin ${GLUON_GIT_URL} \
&& git fetch origin \
&& rm -rf packages \
&& git checkout -q --force ${GLUON_GIT_REF} \
&& git clean -fd;
ln -sfT .. ${GLUON_BUILD_DIR}/site
mkdir -p ${GLUON_BUILD_DIR}

# Note: "|" means "order only", e.g. "do not care about folder timestamps"
# https://www.gnu.org/savannah-checkouts/gnu/make/manual/html_node/Prerequisite-Types.html
${GLUON_BUILD_DIR}/.git: | ${GLUON_BUILD_DIR}
git init ${GLUON_BUILD_DIR}
cd ${GLUON_BUILD_DIR} && git remote add origin ${GLUON_GIT_URL}

gluon-update: | ${GLUON_BUILD_DIR}/.git
cd ${GLUON_BUILD_DIR} && git fetch --tags origin ${GLUON_GIT_REF}
cd ${GLUON_BUILD_DIR} && git reset --hard FETCH_HEAD
cd ${GLUON_BUILD_DIR} && git clean -ffdx packages/ # double -f -f required to remove sub-repositories
cd ${GLUON_BUILD_DIR} && git clean -fd

gluon-prepare: gluon-update
make gluon-patch
ln -sfT .. ${GLUON_BUILD_DIR}/site
${GLUON_MAKE} update

gluon-patch:
echo "Applying Patches ..."
(cd ${GLUON_BUILD_DIR})
if [ `git branch --list patched` ]; then \
(git branch -D patched) \
fi
(cd ${GLUON_BUILD_DIR}; git checkout -B patching)
if [ -d "gluon-build/site/patches" -a "gluon-build/site/patches/*.patch" ]; then \
(cd ${GLUON_BUILD_DIR}; git apply --ignore-space-change --ignore-whitespace --whitespace=nowarn --verbose site/patches/*.patch) || ( \
cd ${GLUON_BUILD_DIR}; \
git clean -fd; \
git checkout -B patched; \
git branch -D patching; \
exit 1 \
) \
fi
(cd ${GLUON_BUILD_DIR}; git branch -M patched)
scripts/apply_patches.sh ${GLUON_BUILD_DIR} ${PATCH_DIR}

gluon-clean:
rm -rf ${GLUON_BUILD_DIR}
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
![Build ffmuc firmware](https://github.com/freifunkMUC/site-ffm/workflows/Build%20ffmuc%20firmware/badge.svg)

## Dependencies

* git
* GNU make
* GNU patch
* [Upstream Gluon dependencies](https://gluon.readthedocs.io/en/latest/user/getting_started.html#dependencies)

For convenience, you can find a script to install those dependencies on an Ubuntu-based distribution:\
[install_build_dependencies.sh](scripts/install_build_dependencies.sh)

## Building

Check out this repository and execute `make`, i.e. like this:
Expand All @@ -11,6 +21,27 @@ git checkout -b patched && git checkout stable
make
```

### Containerised building

As the CI is using Ubuntu, only the Ubuntu dependencies are being tracked. To simplify building on other distros, containerised building is also possible:
```sh
docker build -t site-ffm-stable -f Dockerfile_build .
```
This will build the build Docker image. With the following export, the Makefile will then use the repo for building but will run inside an Ubuntu container.\
**Note**: If the working directory is a git worktree, add a volume mount for the main git folder.
```sh
mkdir -p gluon-build output
docker run --rm -v $(pwd):/site-ffm:ro -v $(pwd)/gluon-build:/site-ffm/gluon-build:rw -v $(pwd)/output:/site-ffm/output:rw -w /site-ffm -u $UID site-ffm-stable make
```

#### Example
Full command for a [lantiq-xrx200](https://github.com/freifunk-gluon/gluon/blob/v2022.1/targets/lantiq-xrx200) build:

```sh
mkdir -p logs gluon-build output
docker run --rm -v $(pwd):/site-ffm:ro -v $(pwd)/gluon-build:/site-ffm/gluon-build:rw -v $(pwd)/output:/site-ffm/output:rw -w /site-ffm -u $UID site-ffm-stable make V=s GLUON_TARGETS=lantiq-xrx200 |& tee logs/build_lantiq-xrx200_$(date --iso=s).log
```

## Further Resources

This firmware is based on [Gluon](https://gluon.readthedocs.io/en/v2021.1/).
Expand Down
Loading