From 267db84837ff1ae9c78d2eab664393f1cc3ba185 Mon Sep 17 00:00:00 2001 From: meteyou Date: Fri, 26 May 2023 07:00:53 +0000 Subject: [PATCH 01/17] docs(changelog): update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbbcd9a61..3810531fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 From 332109ae2fa928d3728cb388ddea4e121f9977e4 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 26 May 2023 20:24:36 +0200 Subject: [PATCH 02/17] fix: fix error in udev-fix.sh (#228) --- patches/udev-fix.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/patches/udev-fix.sh b/patches/udev-fix.sh index 01c1cb56b..2084d9756 100755 --- a/patches/udev-fix.sh +++ b/patches/udev-fix.sh @@ -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" @@ -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 } From ba3d5824c6cf05e0c557c40348da75098015f16d Mon Sep 17 00:00:00 2001 From: Rogerio Goncalves Date: Thu, 1 Jun 2023 12:12:00 +0100 Subject: [PATCH 03/17] docs: fix broken README link to the docs (#231) --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1eccb7e80..cf070d152 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ Learn more about: ## How to install MainsailOS ? -You can find detailed instructions in our [documentation](https://docs.mainsail.xyz/setup/mainsail-os). +You can find detailed instructions in our [documentation](https://docs-os.mainsail.xyz). -We recommend the installation via [Raspberry Pi Imager](https://docs.mainsail.xyz/setup/mainsailos/pi-imager). +We recommend the installation via [Raspberry Pi Imager](https://docs-os.mainsail.xyz/getting-started/raspberry-pi-os-based). ## How to get help? @@ -34,9 +34,9 @@ Also see the [FAQ](#faq) section. Here a list of included and preinstalled Software: -- [Klipper (3D Printer Firmware)](https://github.com/KevinOConnor/klipper) +- [Klipper (3D Printer Firmware)](https://github.com/Klipper3d/klipper) - [Moonraker (API Web Server for Klipper)](https://github.com/Arksine/moonraker) -- [Mainsail (Web interface for Klipper/Moonraker)](https://github.com/meteyou/mainsail) +- [Mainsail (Web interface for Klipper/Moonraker)](https://github.com/mainsail-crew/mainsail) - [Crowsnest (Webcam streaming)](https://github.com/mainsail-crew/crowsnest) - [Sonar (Keepalive daemon)](https://github.com/mainsail-crew/sonar) - [Nginx (Webserver & Proxy)](https://nginx.org/en/) From 417ed1f1d8ebd5950931dca2b5a04ef412e67035 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Mon, 7 Aug 2023 17:22:43 +0200 Subject: [PATCH 04/17] chore: update download urls for armbian & orangepi (#233) Signed-off-by: Stefan Dej --- config/armbian/orangepi3lts | 4 ++-- config/armbian/orangepi4lts | 4 ++-- config/orangepi/orangepi_zero2 | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/armbian/orangepi3lts b/config/armbian/orangepi3lts index 46ea21610..8fd06d0a1 100644 --- a/config/armbian/orangepi3lts +++ b/config/armbian/orangepi3lts @@ -5,8 +5,8 @@ BASE_ARCH="arm64" # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts_bullseye.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi3_lts_bullseye.img.xz" # export Variables export BASE_ARCH diff --git a/config/armbian/orangepi4lts b/config/armbian/orangepi4lts index f68c354df..5b0a312c8 100644 --- a/config/armbian/orangepi4lts +++ b/config/armbian/orangepi4lts @@ -5,8 +5,8 @@ BASE_ARCH="arm64" # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/armbian-orangepi4_lts_bullseye.img.xz" # export Variables export BASE_ARCH diff --git a/config/orangepi/orangepi_zero2 b/config/orangepi/orangepi_zero2 index 1ad1c1d18..c149d83f2 100644 --- a/config/orangepi/orangepi_zero2 +++ b/config/orangepi/orangepi_zero2 @@ -5,8 +5,8 @@ BASE_ARCH="arm64" # Image source -DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2.img.xz.sha256" -DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2.img.xz" +DOWNLOAD_URL_CHECKSUM="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2_bullseye.img.xz.sha256" +DOWNLOAD_URL_IMAGE="${DOWNLOAD_BASE_URL}/orangepi-orangepi_zero2_bullseye.img.xz" # export Variables export BASE_ARCH From 7084fd807b4ccf40cef9335e0bed263f018d2e00 Mon Sep 17 00:00:00 2001 From: Stefan Dej Date: Fri, 11 Aug 2023 18:27:06 +0200 Subject: [PATCH 05/17] fix: add crowsnest log path & pkglist link in postrename script (#235) * fix: add crowsnest log path to postrename script Signed-off-by: Stefan Dej * fix: fix crowsnest pkglist sym link in postrename Signed-off-by: Stefan Dej --------- Signed-off-by: Stefan Dej --- .../postrename/filesystem/root/postrename | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/modules/postrename/filesystem/root/postrename b/src/modules/postrename/filesystem/root/postrename index ea43dc156..4aa394ef8 100644 --- a/src/modules/postrename/filesystem/root/postrename +++ b/src/modules/postrename/filesystem/root/postrename @@ -64,7 +64,6 @@ change_www_root() { " } - ### change username in service files change_service_user() { ### Filter nginx service first! @@ -119,6 +118,13 @@ patch_polkit_rules() { fi } +patch_cn_logpath() { + bash -c " + sed -i 's|/home/pi/printer_data/logs/crowsnest.log|/home/${DEFAULT_USER}/printer_data/logs/crowsnest.log|g' \ + /home/${DEFAULT_USER}/printer_data/config/crowsnest.conf + " +} + patch_cn_logrotate() { if [[ -f "/etc/logrotate.d/crowsnest" ]]; then sed -i 's/pi/'"${DEFAULT_USER}"'/g' "/etc/logrotate.d/crowsnest" @@ -160,6 +166,13 @@ fix_mainsailcfg_links() { ln -sf "${src_dir}/mainsail.cfg" "${config_dir}/mainsail.cfg" } +fix_cn_links() { + local tools_dir + tools_dir="/home/${DEFAULT_USER}/crowsnest/tools/" + sudo -u "${DEFAULT_USER}" \ + ln -sf "${tools_dir}/libs/pkglist-rpi.sh" "${tools_dir}/pkglist.sh" +} + main() { local cmdltxt cmdltxt="/boot/cmdline.txt" @@ -205,6 +218,10 @@ echo -e "${WHITE}Trying to relocate venv's ...${NOC}[${GRE}OK${NOC}]" echo -e "${WHITE}Patching moonraker's polkit rules ...${NOC}" patch_polkit_rules echo -e "${WHITE}Patching moonraker's polkit rules ...${NOC}[${GRE}OK${NOC}]" +## patch crownsnest log path +echo -en "${WHITE}Patching crowsnest logpath ...${NOC}\r" +patch_cn_logpath +echo -e "${WHITE}Patching crowsnest logpath ...${NOC}[${GRE}OK${NOC}]" ## patch crowsnest logrotate echo -e "${WHITE}Patching crowsnest logrotate ...${NOC}" patch_cn_logrotate @@ -214,6 +231,7 @@ echo -en "${WHITE}Fix broken symlinks ...${NOC}\r" fix_broken_links fix_timelapse_links fix_mainsailcfg_links +fix_cn_links echo -e "${WHITE}Fix broken symlinks ...${NOC}[${GRE}OK${NOC}]" ## do a short break sleep 2 From f02179d75749a163d74ecc9bf20deefe3fdbb3d1 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Sun, 17 Sep 2023 11:20:33 +0200 Subject: [PATCH 06/17] fix: fix typo in tools_dir var, Line171 (#237) Signed-off-by: Stephan Wendel --- src/modules/postrename/filesystem/root/postrename | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/postrename/filesystem/root/postrename b/src/modules/postrename/filesystem/root/postrename index 4aa394ef8..76474dd41 100644 --- a/src/modules/postrename/filesystem/root/postrename +++ b/src/modules/postrename/filesystem/root/postrename @@ -168,7 +168,7 @@ fix_mainsailcfg_links() { fix_cn_links() { local tools_dir - tools_dir="/home/${DEFAULT_USER}/crowsnest/tools/" + tools_dir="/home/${DEFAULT_USER}/crowsnest/tools" sudo -u "${DEFAULT_USER}" \ ln -sf "${tools_dir}/libs/pkglist-rpi.sh" "${tools_dir}/pkglist.sh" } From 55b253e959572ac9722c21c5902b18e531089e2b Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 29 Sep 2023 19:31:29 +0200 Subject: [PATCH 07/17] fix: fix wifi connectivity (#240) * fix: reenable package upgrades Signed-off-by: Stephan Wendel * fix: fix missing packages for network_configurator Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel --- config/armbian/default | 2 +- src/modules/armbian_net/config | 1 + src/modules/armbian_net/start_chroot_script | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/config/armbian/default b/config/armbian/default index f05c136fa..bd7d28436 100644 --- a/config/armbian/default +++ b/config/armbian/default @@ -23,7 +23,7 @@ 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,udev_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" +MODULES="base,pkgupgrade,udev_fix,armbian(armbian_net,mainsailos,klipper,is_req_preinstall,moonraker,mainsail,timelapse,crowsnest,sonar)" # export Variables export DOWNLOAD_BASE_URL diff --git a/src/modules/armbian_net/config b/src/modules/armbian_net/config index d9a9ffa1e..d2b005768 100644 --- a/src/modules/armbian_net/config +++ b/src/modules/armbian_net/config @@ -14,3 +14,4 @@ [[ -n "$ARMBIAN_NET_FIRSTRUN_FILE" ]] || ARMBIAN_NET_FIRSTRUN_FILE="/boot/armbian_first_run.txt.template" [[ -n "$ARMBIAN_NET_FIRSTRUN_SCRIPT" ]] || ARMBIAN_NET_FIRSTRUN_SCRIPT="/usr/lib/armbian/armbian-firstrun-config" [[ -n "$ARMBIAN_NET_NC_PATH" ]] || ARMBIAN_NET_NC_PATH="/usr/local/bin/network-configurator" +[[ -n "$ARMBIAN_NET_DEPS" ]] || ARMBIAN_NET_DEPS="net-tools" diff --git a/src/modules/armbian_net/start_chroot_script b/src/modules/armbian_net/start_chroot_script index 997425bd5..7a3a152f0 100644 --- a/src/modules/armbian_net/start_chroot_script +++ b/src/modules/armbian_net/start_chroot_script @@ -28,6 +28,11 @@ install_cleanup_trap unpack filesystem/root / root ## END +## Step 1.1: Install Depedencies +### Needed to patch 'network_configurator' +# shellcheck disable=SC2086 +check_install_pkgs ${ARMBIAN_NET_DEPS} + ## Step 2: remove original template if [[ -f "${ARMBIAN_NET_FIRSTRUN_FILE}" ]]; then sudo rm -rf "${ARMBIAN_NET_FIRSTRUN_FILE}" From 485541641b11b8fdb4e6c7b7fceb67eac47e7e83 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Mon, 2 Oct 2023 19:16:15 +0200 Subject: [PATCH 08/17] fix: fix armbian-release file error (#241) To get mainsail release shown in moonraker we need that 'hacky' solution --------- Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 34 ++++------------------ src/modules/mainsailos/start_chroot_script | 17 +++++++++-- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 65b90ac90..5ce9874b4 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -73,38 +73,16 @@ if [[ -f "/root/.not_logged_in_yet" ]]; then fi ## END Step 4 -## Step 5: Move armbian-release to display mainsailos-release -### Substep 1: Move armbian-release - if [[ -f "/etc/armbian-release" ]]; then - echo_green "Armbian release file found! moving to: 'armbian-release-info.txt'" - mv /etc/armbian-release /etc/armbian-release-info.txt - else - echo_red "Armbian release file not found! [SKIPPED]" - fi -### END Substep 1 -### Substep 2: patch Armbian scripts to new file location - echo_green "Patching armbian scripts (release file path) ..." - pushd "/usr/lib/armbian" &> /dev/null || exit 1 - files=() - while IFS='' read -r line; do - files+=("${line}") - done < <(grep -R "/etc/armbian-release" -- * | cut -d":" -f1) - for f in "${files[@]}"; do - sed -i "s|/etc/armbian-release|/etc/armbian-release-info.txt|g" "${f}" - done - popd &> /dev/null || exit 1 -## END Step 5 - -## Step 6: Patch dynamic motd +## Step 5: Patch dynamic motd echo_green "Patch dynamic motd ..." unpack /filesystem/root / chmod +x /etc/update-motd.d/* if [[ -f "/etc/default/armbian-motd" ]]; then sed -i 's/MOTD_DISABLE=""/MOTD_DISABLE="header"/' /etc/default/armbian-motd fi -## END Step 6 +## END Step 5 -## Step 7: Enable SPI interface by default +## Step 6: Enable SPI interface by default echo_green "Enable SPI interface on Orange Pi SBC's ..." ### Substep 1: Copy default config to backup file @@ -129,9 +107,9 @@ echo "spi-dev" >> "${ARMBIAN_MODULES_FILE}" ### END Substep 3 echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" -## END Step 7 +## END Step 6 -## Step 8: Remove unattended-upgrades +## Step 7: Remove unattended-upgrades echo_green "Remove 'unattended-upgrades' service ..." sudo apt-get remove --purge --yes unattended-upgrades -## END Step 8 +## END Step 7 diff --git a/src/modules/mainsailos/start_chroot_script b/src/modules/mainsailos/start_chroot_script index 1f9a192f5..89b426a17 100644 --- a/src/modules/mainsailos/start_chroot_script +++ b/src/modules/mainsailos/start_chroot_script @@ -33,8 +33,21 @@ function get_parent { echo "${DIST_NAME} release ${DIST_VERSION} ($(get_parent))" > /etc/"${DIST_NAME,,}"-release ## END Step 1 -## Step 2: Install CANBoot Dependency +## Step 2: Fake release file +### NOTE: Turns out that the 'distro' python package, +### which is used by moonraker, uses the first file after sorting. +### Therefore we need a hacky solution, because armbian relies, on upgrades +### on the original armbian-release file. +### To get around that, we simple symlink mainsailos-release to +### aaaa-release, which is directly read by moonraker. +if [[ -f "/etc/armbian-release" ]]; then + echo_green "Apply release file workaround ..." + ln -s /etc/"${DIST_NAME,,}"-release /etc/aaaa-release +fi +## END Step 2 + +## Step 3: Install CANBoot Dependency apt-get update --allow-releaseinfo-change # shellcheck disable=SC2086 check_install_pkgs ${MAINSAILOS_DEPS} -## END Step 2 +## END Step 3 From be13745d17780c85baa43d59a40dca565dd9f5b0 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:10:44 +0200 Subject: [PATCH 09/17] fix: fix error autologin on serial tty (#242) * fix: fix autologin on serial tty This fixes issue that after connection to a serial console it trys to autologin with user 'orangepi', which does not exist in our images Signed-off-by: Stephan Wendel * feat: add workaround for orangepi images Apply release file workaround for OrangePI based images. Signed-off-by: Stephan Wendel --- src/modules/mainsailos/start_chroot_script | 9 +++- src/modules/orangepi/config | 3 ++ src/modules/orangepi/end_chroot_script | 24 +++-------- src/modules/orangepi/start_chroot_script | 50 ++++++++++++++++------ 4 files changed, 53 insertions(+), 33 deletions(-) diff --git a/src/modules/mainsailos/start_chroot_script b/src/modules/mainsailos/start_chroot_script index 89b426a17..97e7d3494 100644 --- a/src/modules/mainsailos/start_chroot_script +++ b/src/modules/mainsailos/start_chroot_script @@ -40,8 +40,15 @@ echo "${DIST_NAME} release ${DIST_VERSION} ($(get_parent))" > /etc/"${DIST_NAME, ### on the original armbian-release file. ### To get around that, we simple symlink mainsailos-release to ### aaaa-release, which is directly read by moonraker. +### Substep 1: Do for armbian releases if [[ -f "/etc/armbian-release" ]]; then - echo_green "Apply release file workaround ..." + echo_green "Apply release file workaround (armbian based image) ..." + ln -s /etc/"${DIST_NAME,,}"-release /etc/aaaa-release +fi +### END Substep 1 +### Substep 2: Apply same for OrangePI bsed Images +if [[ -f "/etc/orangepi-release" ]]; then + echo_green "Apply release file workaround (orangepi based image) ..." ln -s /etc/"${DIST_NAME,,}"-release /etc/aaaa-release fi ## END Step 2 diff --git a/src/modules/orangepi/config b/src/modules/orangepi/config index 6196ce5f7..dab971308 100644 --- a/src/modules/orangepi/config +++ b/src/modules/orangepi/config @@ -23,6 +23,9 @@ bash-completion" [[ -n "$ORANGEPI_ADD_OVERLAYS_OPIZ2" ]] || ORANGEPI_ADD_OVERLAYS_OPIZ2="i2c3 uart5 spi-spidev" [[ -n "$ORANGEPI_ADD_OVERLAYS_OPIZ2_PARAMS" ]] || ORANGEPI_ADD_OVERLAYS_OPIZ2_PARAMS="param_spidev_spi_bus=1 param_spidev_spi_cs=1" +## Disable Autologin on gettys +[[ -n "$ORANGEPI_DISABLE_GETTY_AUTOLOGIN" ]] || ORANGEPI_DISABLE_GETTY_AUTOLOGIN="1" + ### EXPERIMENTAL: Install orangepi-config from source git repo [[ -n "$ORANGEPI_INSTALL_OPI_CONFIG" ]] || ORANGEPI_INSTALL_OPI_CONFIG="true" [[ -n "$ORANGEPI_OPI_CONFIG_URL" ]] || ORANGEPI_OPI_CONFIG_URL="https://raw.githubusercontent.com/orangepi-xunlong/orangepi-build/next/external/cache/sources/orangepi-config/" diff --git a/src/modules/orangepi/end_chroot_script b/src/modules/orangepi/end_chroot_script index 1a872a189..8ae4e7609 100644 --- a/src/modules/orangepi/end_chroot_script +++ b/src/modules/orangepi/end_chroot_script @@ -18,27 +18,15 @@ source /common.sh install_cleanup_trap ## Clean up -## Step 1: Remove autologin and lock root account -if [ -f "/etc/systemd/system/getty@.service.d/override.conf" ]; then - rm -f /etc/systemd/system/getty@.service.d/override.conf -fi -## END - -## Step 2: Disable autologin on serial console -if [ -f "/etc/systemd/system/serial-getty@.service.d/override.conf" ]; then - sed -i 's/--autologin root //' /etc/systemd/system/serial-getty@.service.d/override.conf -fi -## END - -## Step 3: Delete root passwd +## Step 1: Delete root passwd (disables root login) ### Deleting root passwd doesn't let you unlock the account sudo passwd -d root -## END +## END Step 1 -## Step 4: Lock root account +## Step 2: Lock root account (disables root login) sudo passwd -l root -## END +## END Step 2 -## Step 5: Remove passwdless sudo +## Step 3: Remove passwdless sudo sed -i '/'"${BASE_USER}"' ALL=(ALL:ALL) NOPASSWD:ALL/d' /etc/sudoers -## END +## END Step 3 diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index cb2596e55..32e18bf50 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -35,6 +35,10 @@ is_board_type() { echo "${board}" } +get_gettyconf_dirs() { + find "${1}" -type d -name "*getty@*" +} + # Base User groups # Shameless "stolen" from # https://github.com/guysoft/CustomPiOS/blob/devel/src/variants/armbian/pre_chroot_script @@ -85,25 +89,16 @@ if [ -f "/root/.not_logged_in_yet" ]; then fi ## END Step 4 -## Step 5: Move armbian-release to display mainsailos-release -if [[ -f "/etc/orangepi-release" ]]; then - echo_green "OrangePi release file found! moving to: 'orangepi-release-info.txt'" - mv /etc/orangepi-release /etc/orangepi-release-info.txt -else - echo_red "OrangePi release file not found! [SKIPPED]" -fi -## END Step 5 - -## Step 6: Patch dynamic motd +## Step 5: Patch dynamic motd echo_green "Patch dynamic motd ..." unpack /filesystem/root / chmod +x /etc/update-motd.d/* if [ -f "/etc/default/orangepi-motd" ]; then sed -i 's/^MOTD_DISABLE=""/MOTD_DISABLE="header tips"/' /etc/default/orangepi-motd fi -## END Step 6 +## END Step 5 -## Step 7: Enable SPI interface by default +## Step 6: Enable SPI interface by default echo_green "Enable interfaces on Orange Pi SBC's ..." ### Substep 1: Copy default config to backup file @@ -136,9 +131,9 @@ fi echo "spi-dev" >> "${ORANGEPI_MODULES_FILE}" echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" -## END Step 7 +## END Step 6 -## Step 8: Install orangepi-config from git source repository +## Step 7: Install orangepi-config from git source repository if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then echo_green "Install orangepi-config from git sources ..." @@ -191,4 +186,31 @@ if [[ "${ORANGEPI_INSTALL_OPI_CONFIG}" == "true" ]]; then else echo_red "WARN: orangepi-config install not configured ... [SKIPPED]" fi +## END Step 7 + +## Step 8: Fix tty and serial-tty autologin +### NOTE: Since OrangePI OS uses for its getty override.conf files +### the location of '/lib/systemd/system/[serial-]getty@.service.d' +### instead the appropriate location in etc, we have to fix that. +if [[ "${ORANGEPI_DISABLE_GETTY_AUTOLOGIN}" = "1" ]]; then + echo_green "Disable 'getty' autologin ..." + + ### Substep 1: copy '/lib/systemd/system/[serial-]getty@.service.d' + for dir in $(get_gettyconf_dirs /usr/lib/systemd/system); do + cp -R "${dir}" /etc/systemd/system + done + ### End Substep 1 + + ### Substep 2: Modify 'override.conf', delete autologin + for conf in $(get_gettyconf_dirs /etc/systemd/system); do + if [[ -f "${conf}/override.conf" ]]; then + echo_green "Found '${conf}/override.conf', trying to modify ..." + sed -i 's/--autologin orangepi //' "${conf}/override.conf" + else + echo_green "No '${conf}/override.conf' found, modifying skipped!" + fi + done + ### END Substep 2 + echo_green "Disable 'getty' autologin ... DONE!" +fi ## END Step 8 From c24e95b8d701b7a3a08d91d4666bcb9beb249758 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 20 Oct 2023 17:06:16 +0200 Subject: [PATCH 10/17] fix: fix 'is_board_type' function (#243) Since we applied PR #241 and #242, this function always doesnt give the right value, which leads to unwanted behaviour in enabling SPI during build. As we no longer rename the release file, we have to use its original location in '/etc/armbian-release' ( Or '/etc/orangepi-release' if Opi Image is used ) Signed-off-by: Stephan Wendel --- src/modules/armbian/start_chroot_script | 2 +- src/modules/orangepi/start_chroot_script | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 5ce9874b4..8a8235846 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -21,7 +21,7 @@ install_cleanup_trap is_board_type() { local board releasefile board="" - releasefile="/etc/armbian-release-info.txt" + releasefile="/etc/armbian-release" if [[ -f "${releasefile}" ]]; then board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" fi diff --git a/src/modules/orangepi/start_chroot_script b/src/modules/orangepi/start_chroot_script index 32e18bf50..7e5d05544 100644 --- a/src/modules/orangepi/start_chroot_script +++ b/src/modules/orangepi/start_chroot_script @@ -28,7 +28,7 @@ install_cleanup_trap is_board_type() { local board releasefile board="" - releasefile="/etc/orangepi-release-info.txt" + releasefile="/etc/orangepi-release" if [[ -f "${releasefile}" ]]; then board="$(grep "BOARD=" "${releasefile}" | cut -d'=' -f2)" fi From 660b0badb9d48fc7e3f16495e493500110bc3dba Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 20 Oct 2023 17:07:59 +0200 Subject: [PATCH 11/17] fix: fix Torrent and Checksum download URLs (#244) After Bullseye images moved to 'oldstable' branch, we need to alter the URLs to 'legacy' images and checksums Signed-off-by: Stephan Wendel --- config/raspberry/rpi32 | 9 +++++++-- config/raspberry/rpi64 | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/config/raspberry/rpi32 b/config/raspberry/rpi32 index f01873e19..ab7d9f6d4 100644 --- a/config/raspberry/rpi32 +++ b/config/raspberry/rpi32 @@ -4,8 +4,13 @@ # Declare Variables before exporting. # See https://www.shellcheck.net/wiki/SC2155 -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 diff --git a/config/raspberry/rpi64 b/config/raspberry/rpi64 index e58c6a460..7cee4dd60 100644 --- a/config/raspberry/rpi64 +++ b/config/raspberry/rpi64 @@ -6,9 +6,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 From 9cb55a72871dac1703da7b51c9e5f4dec41945e8 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:50:20 +0200 Subject: [PATCH 12/17] feat: add BananaPi M2 Zero (#247) * feat: add bananapi m2 zero Adding new SBC BananaPi M2 Zero Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel --- config/armbian/bananapim2zero | 12 ++++++++ src/modules/armbian/config | 6 ++++ src/modules/armbian/start_chroot_script | 38 +++++++++++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 config/armbian/bananapim2zero diff --git a/config/armbian/bananapim2zero b/config/armbian/bananapim2zero new file mode 100644 index 000000000..e22a42b26 --- /dev/null +++ b/config/armbian/bananapim2zero @@ -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 diff --git a/src/modules/armbian/config b/src/modules/armbian/config index c36fa8a01..87896f775 100644 --- a/src/modules/armbian/config +++ b/src/modules/armbian/config @@ -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" diff --git a/src/modules/armbian/start_chroot_script b/src/modules/armbian/start_chroot_script index 8a8235846..7a3f6a0f7 100644 --- a/src/modules/armbian/start_chroot_script +++ b/src/modules/armbian/start_chroot_script @@ -113,3 +113,41 @@ echo_green "Enable SPI interface on Orange Pi SBC's ... DONE!" echo_green "Remove 'unattended-upgrades' service ..." sudo apt-get remove --purge --yes unattended-upgrades ## END Step 7 + +## Step 8: Disable OTG serial console on "bananapim2zero" +if [[ "$(is_board_type)" == "bananapim2zero" ]] \ +&& [[ "${ARMBIAN_CONFIG_BPI2ZERO_OTG_SERIAL}" == "true" ]]; then + echo_green "Disable OTG Serial console for 'bananapim2zero' SBC's ..." + if [[ ! -d /etc/modprobe.d ]]; then + mkdir -p /etc/modprobe.d + fi + if [[ -d /etc/modprobe.d ]]; then + echo "blacklist serial_g" >> /etc/modprobe.d/blacklist.conf + fi + echo_green "Disable OTG Serial console for 'bananapim2zero' SBC's ... [DONE]" +fi +## END Step 8 + +## Step 9: Enable spi and/or UART3 on BananaPi M2 Zero +### Enable both +if [[ "$(is_board_type)" == "bananapim2zero" ]] \ +&& [[ "${ARMBIAN_CONFIG_BPI2ZERO_ENABLE_UART3}" == "true" ]] \ +&& [[ "${ARMBIAN_CONFIG_BPI2ZERO_ENABLE_SPI}" == "true" ]]; then + echo_green "Enable UART3 and SPI for 'bananapim2zero' SBC ..." + echo "overlays=uart3 spi-spidev" >> "${ARMBIAN_CONFIG_TXT_FILE}" +fi +### UART3 only +if [[ "$(is_board_type)" == "bananapim2zero" ]] \ +&& [[ "${ARMBIAN_CONFIG_BPI2ZERO_ENABLE_UART3}" == "true" ]] \ +&& [[ "${ARMBIAN_CONFIG_BPI2ZERO_ENABLE_SPI}" != "true" ]]; then + echo_green "Enable UART3 for 'bananapim2zero' SBC ..." + echo "overlays=uart3" >> "${ARMBIAN_CONFIG_TXT_FILE}" +fi +### SPI only +if [[ "$(is_board_type)" == "bananapim2zero" ]] \ +&& [[ "${ARMBIAN_CONFIG_BPI2ZERO_ENABLE_UART3}" == "true" ]] \ +&& [[ "${ARMBIAN_CONFIG_BPI2ZERO_ENABLE_SPI}" != "true" ]]; then + echo_green "Enable SPI for 'bananapim2zero' SBC ..." + echo "overlays=uart3" >> "${ARMBIAN_CONFIG_TXT_FILE}" +fi +## END Step 9 From c8521b2c2c67bd8a8437c9817ee7ea94447394a0 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:52:04 +0200 Subject: [PATCH 13/17] fix: removing 'klippy' alias (#246) Seems the used alias, which is uneccessary at all, leads to a failing build in some configurations. This should fix #245 Signed-off-by: Stephan Wendel --- .../klipper/filesystem/root/etc/systemd/system/klipper.service | 1 - 1 file changed, 1 deletion(-) diff --git a/src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service b/src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service index 78664b95b..5efb6e36b 100644 --- a/src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service +++ b/src/modules/klipper/filesystem/root/etc/systemd/system/klipper.service @@ -6,7 +6,6 @@ Before=moonraker.service Wants=udev.target [Install] -Alias=klippy WantedBy=multi-user.target [Service] From 6c95a7bb4075d7cac01fa4c63088da5189d26714 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Wed, 25 Oct 2023 16:28:11 +0200 Subject: [PATCH 14/17] feat: adds kiauh module for homebrewed images (#184) * feat: adds kiauh module for homebrewed images This allows forks to add kiauh to their Image with ease. Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel --- src/modules/kiauh/config | 21 +++++++++ src/modules/kiauh/start_chroot_script | 45 +++++++++++++++++++ .../postrename/filesystem/root/postrename | 13 ++++++ 3 files changed, 79 insertions(+) create mode 100644 src/modules/kiauh/config create mode 100644 src/modules/kiauh/start_chroot_script diff --git a/src/modules/kiauh/config b/src/modules/kiauh/config new file mode 100644 index 000000000..d1d86ae37 --- /dev/null +++ b/src/modules/kiauh/config @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +#### KIAUH Install Module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2022 - till today +#### https://github.com/mainsail-crew/MainsailOS +#### +#### This File is distributed under GPLv3 +#### + +#### All Credits to th33xitus for his great tool +#### https://github.com/th33xitus/kiauh + +# shellcheck disable=all + +# KIAUH repo +[[ -n "$KIAUH_REPO_SHIP" ]] || KIAUH_REPO_SHIP="https://github.com/th33xitus/kiauh.git" +[[ -n "$KIAUH_REPO_BRANCH" ]] || KIAUH_REPO_BRANCH="master" + +# Add to $PATH ? (1: yes, 0: no) +[[ -n "$KIAUH_ADD_TO_PATH" ]] || KIAUH_ADD_TO_PATH="1" diff --git a/src/modules/kiauh/start_chroot_script b/src/modules/kiauh/start_chroot_script new file mode 100644 index 000000000..742acc3d7 --- /dev/null +++ b/src/modules/kiauh/start_chroot_script @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +#### KIAUH Install Module +#### +#### Written by Stephan Wendel aka KwadFan +#### Copyright 2022 - till today +#### +#### This File is distributed under GPLv3 +#### + +#### All Credits to th33xitus for his great tool +#### https://github.com/th33xitus/kiauh + +# shellcheck enable=requires-variable-braces + +# Error handling +set -Ee + +# shellcheck disable=SC1091 +source /common.sh +install_cleanup_trap + + +echo_green "Installing sonar ..." + +## Step 1: Force apt update +apt-get update --allow-releaseinfo-change + +## Step 2: Make sure 'git' is installed! +check_install_pkgs git + +## Step 3: Move to Home Dir as WorkingDirectoy +pushd "/home/${BASE_USER}" &> /dev/null || exit 1 + +## Step 4: clone KIAUH repo +echo_green "Clone KIAUH repository ..." +gitclone KIAUH_REPO kiauh + +## Step 5: Link kiauh.sh in /usr/local/bin as kiauh +if [[ ${KIAUH_ADD_TO_PATH} = "1" ]]; then + echo_green "Add kiauh to PATH ..." + sudo ln -s "/home/${BASE_USER}/kiauh/kiauh.sh" "/usr/local/bin/kiauh" +fi + +## Finish +echo_green "Installing KIAUH ... DONE!" diff --git a/src/modules/postrename/filesystem/root/postrename b/src/modules/postrename/filesystem/root/postrename index 76474dd41..0cef0f1f9 100644 --- a/src/modules/postrename/filesystem/root/postrename +++ b/src/modules/postrename/filesystem/root/postrename @@ -166,6 +166,15 @@ fix_mainsailcfg_links() { ln -sf "${src_dir}/mainsail.cfg" "${config_dir}/mainsail.cfg" } +# Optional if kiauh module is used +fix_kiauh_links() { + local src_dir target_dir + src_dir="/home/${DEFAULT_USER}/kiauh" + target_dir="/usr/local/bin" + ln -sf "${src_dir}/kiauh.sh" "${target_dir}/kiauh" +} + + fix_cn_links() { local tools_dir tools_dir="/home/${DEFAULT_USER}/crowsnest/tools" @@ -231,6 +240,10 @@ echo -en "${WHITE}Fix broken symlinks ...${NOC}\r" fix_broken_links fix_timelapse_links fix_mainsailcfg_links +# Optional if kiauh module is used +if [[ -d "/home/${DEFAULT_USER}/kiauh" ]]; then + fix_kiauh_links +fi fix_cn_links echo -e "${WHITE}Fix broken symlinks ...${NOC}[${GRE}OK${NOC}]" ## do a short break From 9fa81ddbd13cbc0c91c12b7f496779654b48f858 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Thu, 2 Nov 2023 21:32:41 +0100 Subject: [PATCH 15/17] chore: update .gitignore (#254) Ignore .vscode directory Signed-off-by: Stephan Wendel --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 290773cbb..518c37d66 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ src/image/** # Ignore build.log src/build.log + +# Ignore vscode settings +.vscode +.vscode/** From b4e2b3dfb387276ce73171b5feadb600e89fe98d Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 3 Nov 2023 07:10:41 +0100 Subject: [PATCH 16/17] chore(build): add new matrix workflow (#253) * chore(build): add new matrix workflow This adds a new behavior of buildcheck and release workflow. The previous generated array for the matrix step, will now be generated from `setup_matrix.py`, this script reads `.github/workflow_config.yml` and generates the array according to it's setup. This allows an easy to maintain entrypoint to choose which SBC will be build on test builds and releases. It also includes version bump from `action/checkout@v3` to `action/checkout@v4` Signed-off-by: Stephan Wendel --------- Signed-off-by: Stephan Wendel --- .github/scripts/setup_matrix.py | 94 +++++++++++++++++++++++++++++++ .github/workflow_config.yml | 39 +++++++++++++ .github/workflows/BuildImages.yml | 12 +++- .github/workflows/Release.yml | 38 +++++++------ 4 files changed, 162 insertions(+), 21 deletions(-) create mode 100644 .github/scripts/setup_matrix.py create mode 100644 .github/workflow_config.yml diff --git a/.github/scripts/setup_matrix.py b/.github/scripts/setup_matrix.py new file mode 100644 index 000000000..9fb4bb1fd --- /dev/null +++ b/.github/scripts/setup_matrix.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python3 +# Generate matrix string from workflow_config.yml +#### +# Written by Stephan Wendel aka KwadFan +# 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() diff --git a/.github/workflow_config.yml b/.github/workflow_config.yml new file mode 100644 index 000000000..292eafac3 --- /dev/null +++ b/.github/workflow_config.yml @@ -0,0 +1,39 @@ +#### Configure workflow matrix +#### +#### Written by Stephan Wendel aka KwadFan +#### 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 diff --git a/.github/workflows/BuildImages.yml b/.github/workflows/BuildImages.yml index 9d8d8019a..c2f6f985b 100644 --- a/.github/workflows/BuildImages.yml +++ b/.github/workflows/BuildImages.yml @@ -9,6 +9,8 @@ on: - "src/build_dist" - "config/**" - ".github/workflows/BuildImages.yml" + - ".github/workflow_config.yml" + - ".github/scripts/setup_matrix.py" tags-ignore: - "**" pull_request: @@ -17,6 +19,8 @@ on: - "src/**" - "config/**" - ".github/workflows/BuildImages.yml" + - ".github/scripts/setup_matrix.py" + - ".github/workflow_config.yml" workflow_dispatch: @@ -32,13 +36,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 diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 1504003f4..7ed3df389 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Clone develop repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: token: ${{ secrets.PAT }} - ref: 'develop' + ref: "develop" - name: Get current version id: current-version @@ -36,9 +36,9 @@ jobs: if: steps.current-version.outputs.version != github.event.inputs.version uses: EndBug/add-and-commit@v9 with: - add: './src/version' + add: "./src/version" default_author: github_actions - message: 'chore: push version number to v${{ github.event.inputs.version }}' + message: "chore: push version number to v${{ github.event.inputs.version }}" push: true update-master-branch: @@ -49,9 +49,9 @@ jobs: - uses: everlytic/branch-merge@1.1.5 with: github_token: ${{ secrets.PAT }} - source_ref: 'develop' - target_branch: 'master' - commit_message_template: '[Automated] Merged {source_ref} into target {target_branch}' + source_ref: "develop" + target_branch: "master" + commit_message_template: "[Automated] Merged {source_ref} into target {target_branch}" release: name: Create Release @@ -62,9 +62,9 @@ jobs: date: ${{ steps.base-name.outputs.date }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: - ref: 'master' + ref: "master" fetch-depth: 0 - name: Get latest tag @@ -85,7 +85,7 @@ jobs: uses: softprops/action-gh-release@v1 with: token: ${{ secrets.GITHUB_TOKEN }} - name: 'MainsailOS ${{ github.event.inputs.version }}' + name: "MainsailOS ${{ github.event.inputs.version }}" tag_name: ${{ github.event.inputs.version }} body: ${{ steps.changelog.outputs.content }} draft: true @@ -106,18 +106,20 @@ jobs: matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: master - 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 ] + needs: [release, matrix] runs-on: ubuntu-latest outputs: base_name: ${{ steps.move-image.outputs.base_name }} @@ -271,7 +273,7 @@ jobs: finish: name: Finish Release - needs: [ release, build ] + needs: [release, build] runs-on: ubuntu-latest steps: - name: Publish Release @@ -283,7 +285,7 @@ jobs: update-rpi-imager: name: Update rpi-imager json - needs: [ release, build, finish ] + needs: [release, build, finish] runs-on: ubuntu-latest steps: - name: Download snipes @@ -345,7 +347,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: 'develop' + ref: "develop" token: ${{ secrets.PAT }} fetch-depth: 0 @@ -369,5 +371,5 @@ jobs: cat CHANGELOG.md - uses: stefanzweifel/git-auto-commit-action@v4 with: - commit_message: 'docs(changelog): update changelog' + commit_message: "docs(changelog): update changelog" file_pattern: CHANGELOG.md From 01a3b7351c1c715ad484b13444b4b5eccc95dda5 Mon Sep 17 00:00:00 2001 From: Stephan Wendel <43513802+KwadFan@users.noreply.github.com> Date: Fri, 3 Nov 2023 08:24:14 +0100 Subject: [PATCH 17/17] feat: add python3-opencv for obico (#248) Signed-off-by: Stephan Wendel --- src/modules/mainsailos/config | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/modules/mainsailos/config b/src/modules/mainsailos/config index 8cb87c0d2..be5aeb8b0 100644 --- a/src/modules/mainsailos/config +++ b/src/modules/mainsailos/config @@ -9,4 +9,8 @@ #### This File is distributed under GPLv3 #### -[ -n "$MAINSAILOS_DEPS" ] || MAINSAILOS_DEPS="python3-serial" +#### NOTE: +#### python3-serial is needed later on for possible CAN adapters +#### python3-opencv is needed for moonraker-obico by obico in version 2.0 + +[ -n "$MAINSAILOS_DEPS" ] || MAINSAILOS_DEPS="python3-serial python3-opencv"