Skip to content

Commit

Permalink
Merge branch 'develop' into chore/bookworm
Browse files Browse the repository at this point in the history
  • Loading branch information
KwadFan committed Feb 11, 2024
2 parents e8f4533 + 257f28d commit 75aacd5
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 17 deletions.
20 changes: 10 additions & 10 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: 'MainsailOS/build'
author: 'Stefan Dej'
description: 'Build MainsailOS images'
name: "MainsailOS/build"
author: "Stefan Dej"
description: "Build MainsailOS images"
inputs:
config:
description: 'Board config name'
description: "Board config name"
required: true
custompios-repository:
description: 'Repository for CustomPiOS'
description: "Repository for CustomPiOS"
required: false
default: 'guysoft/CustomPiOS'
default: "guysoft/CustomPiOS"
custompios-ref:
description: 'Branch / Tag / SHA to checkout CustomPiOS'
description: "Branch / Tag / SHA to checkout CustomPiOS"
required: false
default: 'devel'
default: "devel"
outputs:
type:
description: SBC type (raspberry/armbian/...)
Expand All @@ -22,7 +22,7 @@ outputs:
value: ${{ steps.config.outputs.SBC }}

runs:
using: 'composite'
using: "composite"
steps:
- name: Install Dependencies
shell: bash
Expand Down Expand Up @@ -87,7 +87,7 @@ runs:
- name: Cache Base Source Image
id: cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: repository/src/image/*.img.xz
key: base-image-${{ steps.checksum.outputs.CHECKSUM }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflow_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ buildtest:
# Raspberry Pi OS based images
- raspberry/rpi32
- raspberry/rpi64
# rpi 64 with KS
- raspberry/rpi64-ks

# This is used to setup release build chain.
# Each entry will be used in setup matrix for releases
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/BuildImages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Build MainsailOS
on:
push:
branches:
- "master"
- "develop"
paths:
- "src/modules/**"
Expand Down Expand Up @@ -81,7 +80,7 @@ jobs:
- name: Upload failed Logfile
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failed-${{ steps.move-image.outputs.image }}.log
path: repository/src/build.log
Expand All @@ -100,19 +99,19 @@ jobs:
sha256sum ${{ steps.move-image.outputs.image }}.img.xz > ${{ steps.move-image.outputs.image }}.img.xz.sha256
- name: Upload Compressed Image
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.move-image.outputs.image }}.img.xz
path: ${{ steps.move-image.outputs.image }}.img.xz

- name: Upload Compressed Image Checksum
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.move-image.outputs.image }}.img.xz.sha256
path: ${{ steps.move-image.outputs.image }}.img.xz.sha256

- name: Upload Image Checksum
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.move-image.outputs.image }}.img.sha256
path: ${{ steps.move-image.outputs.image }}.img.sha256
2 changes: 1 addition & 1 deletion .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:

- name: Upload failed Logfile
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: failed-${{ steps.move-image.outputs.image }}.log
path: repository/src/build.log
Expand Down
31 changes: 31 additions & 0 deletions config/raspberry/rpi64-ks
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Shebang for better file detection

# Declare Variables before exporting.
# See https://www.shellcheck.net/wiki/SC2155

BASE_ARCH="arm64"

# 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"


# Changed modules
# shellcheck disable=SC2034
MODULES="base,pkgupgrade,udev_fix,mainsailos(net,piconfig,klipper,is_req_preinstall,moonraker,timelapse,mainsail,klipperscreen,crowsnest,sonar,password-for-sudo),postrename"


# export variables
export BASE_ARCH
export DOWNLOAD_URL_CHECKSUM
export DOWNLOAD_URL_IMAGE

### JSON sniplet Setup
### NOTE: Please see all config files for setup variables!!!
# shellcheck disable=SC2034
JSON_SUPPORTED_SBC="pi3-64bit pi4-64bit"
13 changes: 13 additions & 0 deletions src/modules/klipperscreen/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
#Shebang for better file detection
#### KlipperScreen install module
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2024 - till today
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####

[ -n "$KLIPPERSCREEN_REPO_SHIP" ] || KLIPPERSCREEN_REPO_SHIP=https://github.com/KlipperScreen/KlipperScreen.git
[ -n "$KLIPPERSCREEN_REPO_BRANCH" ] || KLIPPERSCREEN_REPO_BRANCH=master
9 changes: 9 additions & 0 deletions src/modules/klipperscreen/filesystem/tmp/ks_update_entry.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

[update_manager KlipperScreen]
type: git_repo
path: ~/KlipperScreen
origin: https://github.com/KlipperScreen/KlipperScreen.git
virtualenv: ~/.KlipperScreen-env
requirements: scripts/KlipperScreen-requirements.txt
system_dependencies: scripts/system-dependencies.json
managed_services: KlipperScreen
64 changes: 64 additions & 0 deletions src/modules/klipperscreen/start_chroot_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
#### KlipperScreen install module
####
#### Written by Stephan Wendel aka KwadFan <[email protected]>
#### Copyright 2024 - till today
#### https://github.com/mainsail-crew/MainsailOS
####
#### This File is distributed under GPLv3
####
# shellcheck enable=require-variable-braces

# Source error handling, leave this in place
set -Ee

# Source CustomPIOS common.sh
# shellcheck disable=SC1091
source /common.sh
install_cleanup_trap

# Module only Variables
KS_BUILD_INSTALL_SH="/home/${BASE_USER}/KlipperScreen/scripts/KlipperScreen-install.sh"
KS_MOONRAKER_CONF_PATH="/home/${BASE_USER}/printer_data/config/moonraker.conf"

echo_green "Installing KlipperScreen and enable KlipperScreen Service ..."

## Force apt update
apt-get update
## Make sure 'git' is installed!
check_install_pkgs git

## Step 1: Move to Home Dir as WorkingDirectoy
pushd "/home/${BASE_USER}" &> /dev/null || exit 1

## Step 2: clone KlipperScreen repo
gitclone KLIPPERSCREEN_REPO KlipperScreen

## Step 3: Move to KlipperScreen as working directory
pushd "/home/${BASE_USER}/KlipperScreen" &> /dev/null || exit 1

## Step 4: Run KlipperScreen install routine
echo_green "Launch KlipperScreen install routine ..."
sudo -u "${BASE_USER}" "${KS_BUILD_INSTALL_SH}"

## Step 5: Update moonraker.conf
if [[ -f "${KS_MOONRAKER_CONF_PATH}" ]]; then
echo_green "Copying temporary file ..."
unpack /filesystem/tmp /tmp root
cat /tmp/ks_update_entry.txt >> "${KS_MOONRAKER_CONF_PATH}"
else
echo_red "File moonraker.conf not found ... [SKIPPED]"
fi

## Step 6: Leave KlipperScreen
popd &> /dev/null || exit 1

## Step 7: leave home dir
popd &> /dev/null || exit 1

## Step 8: Enable service
echo_green "Enable KlipperScreen.service ..."
systemctl_if_exists enable KlipperScreen.service

## Finish
echo_green "Installing KlipperScreen and enable KlipperScreen Service ... DONE!"
20 changes: 19 additions & 1 deletion src/modules/postrename/filesystem/root/postrename
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ SERVICES=(moonraker klipper nginx sonar crowsnest)
SYSTEMD_DIR="/etc/systemd/system"
DEFAULT_USER="$(grep "1000" /etc/passwd | awk -F ':' '{print $1}')"

### KlipperScreen workaround
KS_INSTALLED="$(find /home/"${DEFAULT_USER}" -name "KlipperScreen" | wc -l)"
if [[ "${KS_INSTALLED}" = "1" ]]; then
SERVICES+=(KlipperScreen)
fi

## Helper funcs
### Mangle services
Expand Down Expand Up @@ -90,6 +95,11 @@ relocate_venv() {
local -a venvs
venvs=(klippy-env moonraker-env)

### KlipperScreen workaround
if [[ "${KS_INSTALLED}" = "1" ]]; then
venvs+=(.KlipperScreen-env)
fi

for venv in "${venvs[@]}"; do
# Move venv
# delete pycache (*.pyc files)
Expand All @@ -116,6 +126,15 @@ patch_polkit_rules() {
if [[ -f "${polkit_legacy_dir}/10-moonraker.pkla" ]]; then
sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_legacy_dir}/10-moonraker.pkla"
fi
if [[ -f "${polkit_dir}/KlipperScreen.rules" ]]; then
sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_dir}/KlipperScreen.rules"
fi
if [[ -f "${polkit_usr_dir}/KlipperScreen.rules" ]]; then
sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_usr_dir}/KlipperScreen.rules"
fi
if [[ -f "${polkit_legacy_dir}/20-klipperscreen.pkla" ]]; then
sed -i 's/pi/'"${DEFAULT_USER}"'/g' "${polkit_legacy_dir}/20-klipperscreen.pkla"
fi
}

patch_cn_logpath() {
Expand Down Expand Up @@ -174,7 +193,6 @@ fix_kiauh_links() {
ln -sf "${src_dir}/kiauh.sh" "${target_dir}/kiauh"
}


fix_cn_links() {
local tools_dir
tools_dir="/home/${DEFAULT_USER}/crowsnest/tools"
Expand Down

0 comments on commit 75aacd5

Please sign in to comment.