Skip to content

Commit

Permalink
Attempt to merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Dec 9, 2023
2 parents c8a9bb5 + 01a3b73 commit bcf6e64
Show file tree
Hide file tree
Showing 25 changed files with 502 additions and 96 deletions.
94 changes: 94 additions & 0 deletions .github/scripts/setup_matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env python3
# Generate matrix string from workflow_config.yml
####
# Written by Stephan Wendel aka KwadFan <[email protected]>
# Copyright 2023 - till today
# https://github.com/mainsail-crew/MainsailOS
####
# This File is distributed under GPLv3
####

import os
import sys
import yaml

from pathlib import Path
from argparse import ArgumentParser, RawTextHelpFormatter


def main():
# Parse args
parser = ArgumentParser(
description='Returns list for setup matrix',
formatter_class=RawTextHelpFormatter)
parser.add_argument('-c', '--config',
help='Specify the /path/to/configuration/file',
required=True)
parser.add_argument('-g', '--group',
help='Specify group in your configuration file.\
\nFor example \'-g buildtest\'',
required=True)
parser.add_argument('--git',
action='store_true',
help='Push output to git environment variables')
args = parser.parse_args()
# Split Namespaces
config_file, setup_group = args.config, args.group
if args.git:
try:
with open(config_file, 'r') as config:
data = yaml.safe_load(config)
# Check if group is present
if not setup_group in data:
with open(os.environ['GITHUB_STEP_SUMMARY'], 'a') as gitsum:
gitsum_header_msg(gitsum)
gitsum_err_msg(
f"The given group '{setup_group}' doesn't exist!",
gitsum)
sys.exit(1)
else:
with open(os.environ['GITHUB_OUTPUT'], 'a') as gitout:
print(f'matrix={data[setup_group]}', file=gitout)
with open(os.environ['GITHUB_STEP_SUMMARY'], 'a') as gitsum:
gitsum_header_msg(gitsum)
print(f'## Build images for these SBC\'s:', file=gitsum)
for sbc in data[setup_group]:
print(f"- {sbc}", file=gitsum)
except Exception as e:
with open(os.environ['GITHUB_STEP_SUMMARY'], 'a') as gitsum:
gitsum_err_msg(e, gitsum)
sys.exit(1)
else:
try:
# Checks if file exists, else raises error.
with open(config_file, 'r') as config:
data = yaml.safe_load(config)
# Check if group is present
if not setup_group in data:
raise Exception(
f"The given group '{setup_group}' doesn't exist!"
)
else:
print(data[setup_group])
except Exception as e:
err_msg(e)
sys.exit(1)


def err_msg(err):
name = Path(__file__).stem
print(f'{name}: OOOPS, something went wrong!\n{err}')


def gitsum_header_msg(env_var):
print(f'# Setup Matrix:', file=env_var)


def gitsum_err_msg(err, env_var):
gitsum_header_msg(env_var)
print(f'## Error:\n{err}')


# MAIN
if __name__ == "__main__":
main()
39 changes: 39 additions & 0 deletions .github/workflow_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#### Configure workflow matrix
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2023 - till today
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####

#### NOTE: Use entries according to their directory/file structure in 'config'
#### e.g. raspberry/rpi32 armbian/orangepi3lts ...

# Use this categorie to configure behaviour on pushes/pull requests against
# develop branch
# Each entry will be used in setup matrix

buildtest:
# armbian based images
- armbian/bananapim2zero
- armbian/orangepi3lts
- armbian/orangepi4lts
# Orange Pi OS based images
- orangepi/orangepi_zero2
# Raspberry Pi OS based images
- raspberry/rpi32
- raspberry/rpi64

# This is used to setup release build chain.
# Each entry will be used in setup matrix for releases

release:
# armbian based images
- armbian/orangepi3lts
- armbian/orangepi4lts
# Orange Pi OS based images
- orangepi/orangepi_zero2
# Raspberry Pi OS based images
- raspberry/rpi32
- raspberry/rpi64
12 changes: 9 additions & 3 deletions .github/workflows/BuildImages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- "src/build_dist"
- "config/**"
- ".github/workflows/BuildImages.yml"
- ".github/workflow_config.yml"
- ".github/scripts/setup_matrix.py"
tags-ignore:
- "**"
pull_request:
Expand All @@ -16,6 +18,8 @@ on:
- "src/**"
- "config/**"
- ".github/workflows/BuildImages.yml"
- ".github/scripts/setup_matrix.py"
- ".github/workflow_config.yml"

workflow_dispatch:

Expand All @@ -31,13 +35,15 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Create Matrix
id: set-matrix
run: |
ARRAY=$(find ${{ github.workspace }}/config -type f -printf '%P\n' | sed '/default/d' | sort | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${ARRAY}" >> $GITHUB_OUTPUT
PY_INT=$(command -v python3)
CONFIG="${{ github.workspace }}/.github/workflow_config.yml"
GROUP="buildtest"
$PY_INT ${{ github.workspace }}/.github/scripts/setup_matrix.py -c $CONFIG -g $GROUP --git
build:
needs: setup
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
name: Push version number
runs-on: ubuntu-latest
steps:
- name: Clone develop repository
uses: actions/checkout@v3
- name: Clone v2.x repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
ref: "v2.x"
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
date: ${{ steps.base-name.outputs.date }}
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: "v2.x"
fetch-depth: 0
Expand Down Expand Up @@ -94,15 +94,17 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: v2.x

- name: Create Matrix
id: set-matrix
run: |
ARRAY=$(find ${{ github.workspace }}/config -type f -printf '%P\n' | sed '/default/d' | sort | jq -R -s -c 'split("\n")[:-1]')
echo "matrix=${ARRAY}" >> $GITHUB_OUTPUT
PY_INT=$(command -v python3)
CONFIG="${{ github.workspace }}/.github/workflow_config.yml"
GROUP="release"
$PY_INT ${{ github.workspace }}/.github/scripts/setup_matrix.py -c $CONFIG -g $GROUP --git
build:
needs: [release, matrix]
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ All notable changes to Mainsail will be documented in this file.
- Load `i2c-dev` modules (#217) | [6846f82](6846f82ff311299928824c8bceb606b1db13a444)
- Fix broken udev package (#224) | [b07d7a1](b07d7a103a2aad81045c26dc7223c26369ee1322)
- Fix udev for version 'rp1+deb11u2' (#226) | [b0343d5](b0343d55ddb9db0126f4fb9759e050d5fbcbb10e)
- Remove legacy cam stack (#227) | [8c65ad7](8c65ad7045bf2ada360b0f1307f599aea73d7d4f)

### Refactor

Expand Down
12 changes: 12 additions & 0 deletions config/armbian/bananapim2zero
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Shebang for better file detection
# shellcheck enable=require-variable-braces

# Image source
DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-bananapi_m2_zero_bullseye.img.xz.sha256"
DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-bananapi_m2_zero_bullseye.img.xz"

# export Variables
export BASE_ARCH
export DOWNLOAD_URL_CHECKSUM
export DOWNLOAD_URL_IMAGE
46 changes: 36 additions & 10 deletions config/armbian/default
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
#!/usr/bin/env bash
# Shebang for better file detection

export BASE_APT_CACHE=no
export OCTOPI_INCLUDE_WIRINGPI=no
export BASE_DISTRO=armbian
export BASE_ROOT_PARTITION=2
export BASE_IMAGE_RESIZEROOT=500
export BASE_IMAGE_RASPBIAN=no
export BASE_IMAGE_ENLARGEROOT=1000
export BASE_ARCH=arm64

export MODULES="base,pkgupgrade(network,piconfig,klipper,node,is_req_preinstall,moonraker,mainsail,crowsnest,ratos(linear_movement_analysis,timelapse,klipperscreen,rpi_mcu,disable-services(hotspot),dfu-util),password-for-sudo),postrename"
# Declare Variables before exporting.
# See https://www.shellcheck.net/wiki/SC2155

# Download Base Url
DOWNLOAD_BASE_URL="https://github.com/mainsail-crew/armbian-builds/releases/latest/download"

# Base User
BASE_ADD_USER="yes"
BASE_USER="pi"
BASE_USER_PASSWORD="armbian"

# Needed while building for non rpi sbc
BASE_DISTRO="armbian"
BASE_IMAGE_RASPBIAN="no"

# partition resizing
BASE_ROOT_PARTITION="2"
BASE_IMAGE_ENLARGEROOT=6500
BASE_IMAGE_RESIZEROOT=600
# Compress not needed due compression done in workflow
BASE_RELEASE_COMPRESS=no
# Modules are valid for 32bit and 64bit images
MODULES="base,pkgupgrade,udev_fix,armbian(armbian_net,mainsailos,klipper,node,is_req_preinstall,moonraker,mainsail,crowsnest,ratos(linear_movement_analysis,timelapse,klipperscreen,rpi_mcu,disable-services(hotspot),dfu-util))"

# export Variables
export DOWNLOAD_BASE_URL
export BASE_ADD_USER
export BASE_USER
export BASE_USER_PASSWORD
export BASE_DISTRO
export BASE_IMAGE_RASPBIAN
export BASE_ROOT_PARTITION
export BASE_IMAGE_ENLARGEROOT
export BASE_IMAGE_RESIZEROOT
export BASE_RELEASE_COMPRESS
export MODULES
9 changes: 7 additions & 2 deletions config/raspberry/rpi32
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env bash
# Shebang for better file detection

DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha256"
DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent"
# Keep for Bookworm template
# DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.sha256"
# DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_armhf_latest.torrent"

# New locations after Bullseye turned into 'oldstable'
DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-10-10/2023-05-03-raspios-bullseye-armhf-lite.img.xz.sha256"
DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.com/raspios_oldstable_lite_armhf/images/raspios_oldstable_lite_armhf-2023-10-10/2023-05-03-raspios-bullseye-armhf-lite.img.xz.torrent"

export DOWNLOAD_URL_CHECKSUM
export DOWNLOAD_URL_IMAGE
8 changes: 6 additions & 2 deletions config/raspberry/rpi64
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@

BASE_ARCH="arm64"

DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256"
DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent"
# Keep for Bookworm template
# DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.sha256"
# DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.org/raspios_lite_arm64_latest.torrent"

# New locations after Bullseye turned into 'oldstable'
DOWNLOAD_URL_CHECKSUM="https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-10-10/2023-05-03-raspios-bullseye-arm64-lite.img.xz.sha256"
DOWNLOAD_URL_IMAGE="https://downloads.raspberrypi.com/raspios_oldstable_lite_arm64/images/raspios_oldstable_lite_arm64-2023-10-10/2023-05-03-raspios-bullseye-arm64-lite.img.xz.torrent"


# export variables
Expand Down
10 changes: 6 additions & 4 deletions patches/udev-fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ set -eo pipefail
### Variables
DEBIAN_FRONTEND="noninteractive"
TITLE="\e[31mMainsailOS Patcher\e[0m - udev rule fix"
UDEV_PKG_VERSION="$(dpkg-query -s udev | grep "Version" | sed 's/Version\: //')"
UDEV_FIX_RAW_RULE_FILE="https://raw.githubusercontent.com/systemd/systemd/main/rules.d/60-serial.rules"
UDEV_FIX_TMP_FILE="/tmp/60-serial.rules"
UDEV_FIX_OUTPUT_FILE="/etc/udev/rules.d/60-serial.rules"
Expand Down Expand Up @@ -74,14 +73,17 @@ print_footer(){
# Patch Funcs

patch_udev(){
if [[ -n "${UDEV_PKG_VERSION}" ]] && [[ "${UDEV_PKG_VERSION}" =~ "deb11u2" ]]; then
echo_red "'udev' version: ${UDEV_PKG_VERSION}, is affected by bug ..."
local udev_pkg_version
udev_pkg_version="$(dpkg-query -s udev | grep "Version" | sed 's/Version\: //')"

if [[ -n "${udev_pkg_version}" ]] && [[ "${udev_pkg_version}" =~ "deb11u2" ]]; then
echo_red "'udev' version: ${udev_pkg_version}, is affected by bug ..."
echo_green "Install patched udev rule from systemd git repository ..."
curl -sSL "${UDEV_FIX_RAW_RULE_FILE}" > "${UDEV_FIX_TMP_FILE}"
sudo cp "${UDEV_FIX_TMP_FILE}" "${UDEV_FIX_OUTPUT_FILE}"
rm -f "${UDEV_FIX_TMP_FILE}"
else
echo_green "'udev' version: ${UDEV_PKG_VERSION}, is NOT affected by bug ... [SKIPPED]"
echo_green "'udev' version: ${udev_pkg_version}, is NOT affected by bug ... [SKIPPED]"
fi
}

Expand Down
6 changes: 6 additions & 0 deletions src/modules/armbian/config
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,9 @@ bash-completion"
[[ -n "$ARMBIAN_CONFIG_TXT_FILE" ]] || ARMBIAN_CONFIG_TXT_FILE="/boot/armbianEnv.txt"
[[ -n "$ARMBIAN_CONFIG_BAK_FILE" ]] || ARMBIAN_CONFIG_BAK_FILE="/boot/armbianEnv.txt.backup"
[[ -n "$ARMBIAN_MODULES_FILE" ]] || ARMBIAN_MODULES_FILE="/etc/modules"

## BananaPi M2 Zero specific
### Disable OTG Serial Interface? (true/false)
[[ -n "$ARMBIAN_CONFIG_BPI2ZERO_OTG_SERIAL" ]] || ARMBIAN_CONFIG_BPI2ZERO_OTG_SERIAL="true"
[[ -n "$ARMBIAN_CONFIG_BPI2ZERO_ENABLE_UART3" ]] || ARMBIAN_CONFIG_BPI2ZERO_ENABLE_UART3="true"
[[ -n "$ARMBIAN_CONFIG_BPI2ZERO_ENABLE_SPI" ]] || ARMBIAN_CONFIG_BPI2ZERO_ENABLE_SPI="true"
Loading

0 comments on commit bcf6e64

Please sign in to comment.