0 Star 2 Fork 0

yg125 / amlogic-s9xxx-armbian

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
action.yml 11.49 KB
Copy Edit Raw Blame History
ophub authored 2024-05-22 21:03 . Adjust file check
name: "Rebuild Armbian and Kernel"
author: "https://github.com/ophub/amlogic-s9xxx-armbian"
description: "Support Amlogic, Rockchip and Allwinner boxes."
inputs:
# Select build target
build_target:
description: "Select build target: armbian / kernel"
required: false
default: "armbian"
# For build armbian -----
armbian_path:
description: "Set Armbian file path."
required: false
default: "build/output/images/*.img"
armbian_board:
description: "Set device Board."
required: false
default: "all"
kernel_repo:
description: "Set kernel repository."
required: false
default: "ophub/kernel"
kernel_usage:
description: "Set the tags of the stable kernel."
required: false
default: "stable"
armbian_kernel:
description: "Set kernel version."
required: false
default: "6.1.y_5.15.y"
auto_kernel:
description: "Auto use the latest kernel."
required: false
default: "true"
armbian_fstype:
description: "Set armbian rootfs type: ext4 / btrfs"
required: false
default: "ext4"
armbian_size:
description: "Set armbian rootfs size(Unit: MiB)."
required: false
default: ""
builder_name:
description: "Set Armbian builder signature."
required: false
default: ""
# For compile kernel -----
kernel_source:
description: "Select the kernel source code"
required: false
default: "unifreq"
kernel_version:
description: "Select kernel version"
required: false
default: "6.1.y_5.15.y"
kernel_auto:
description: "Auto use the latest kernel"
required: false
default: "true"
kernel_package:
description: "Select compile package list"
required: false
default: "all"
kernel_sign:
description: "Set the kernel custom signature"
required: false
default: "-ophub"
kernel_toolchain:
description: "Select the compilation toolchain"
required: false
default: "clang"
kernel_config:
description: "Set the path of kernel .config"
required: false
default: "false"
kernel_patch:
description: "Set the directory for kernel patches"
required: false
default: "false"
auto_patch:
description: "Set whether to use kernel patches"
required: false
default: "false"
compress_format:
description: "Set the initrd compression format"
required: false
default: "xz"
runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${GITHUB_ACTION_PATH}
echo -e "Current running path: [ ${PWD} ]"
build_target="${{ inputs.build_target }}"
[[ -z "${build_target}" ]] && build_target="armbian"
if [[ "${build_target}" == "armbian" ]]; then
cd ${GITHUB_ACTION_PATH}
echo -e "Start rebuilding Armbian..."
armbian_file="${{ inputs.armbian_path }}"
armbian_filename="${armbian_file##*/}"
armbian_filepath="build/output/images"
echo -e "Get armbian file input parameters: [ ${armbian_file} ]"
[[ -z "${armbian_file}" ]] && echo -e "The [ armbian_path ] variable must be specified." && exit 1
[[ -d "${armbian_filepath}" ]] || mkdir -p ${armbian_filepath}
if [[ "${armbian_file}" == http* ]]; then
echo -e "Download file: [ ${armbian_file} ]"
curl -fsSL "${armbian_file}" -o "${armbian_filepath}/${armbian_filename}"
else
if [[ -z "$(ls ${armbian_filepath}/${armbian_filename} 2>/dev/null)" ]]; then
echo -e "Copy files: [ ${armbian_file} ]"
cp -vf ${GITHUB_WORKSPACE}/${armbian_file} ${armbian_filepath} 2>/dev/null
else
echo -e "The [ ${armbian_filepath}/${armbian_filename} ] file already exists, skipping."
fi
fi
sync
echo -e "About the [ ${armbian_filepath} ] directory: \n$(ls -l ${armbian_filepath} 2>/dev/null)"
cd ${armbian_filepath}
echo -e "Check the Armbian file format..."
down_file="$(ls -l *.img* 2>/dev/null | grep "^-" | awk '{print $9}' | sort -u | head -n 1)"
if [[ -n "${down_file}" ]]; then
echo -e "Selected Armbian file: [ ${down_file} ]"
else
echo -e "The Armbian file is invalid."
exit 1
fi
[[ "${down_file:0-7}" == ".img.gz" ]] && gzip -df ${down_file} 2>/dev/null && sync
[[ "${down_file:0-7}" == ".img.xz" ]] && xz -d ${down_file} 2>/dev/null && sync
[[ "${down_file:0-4}" == ".zip" ]] && unzip -o ${down_file} 2>/dev/null && sync
echo -e "Armbian file: \n$(ls -l *.img 2>/dev/null)"
echo -e "Check the armbian file name (-trunk_)..."
image_file="$(ls *.img 2>/dev/null | head -n 1)"
if [[ "${image_file}" =~ "-trunk_" ]]; then
echo -e "The armbian file name is correct."
else
echo -e "Modify Armbian filename..."
image_version="$(echo ${image_file} | grep -oE '[2-9][0-9]\.[0-9]{1,2}\.[0-9]{1,2}' | head -n 1)"
image_kernel="$(echo ${image_file} | grep -oE '[5-9]\.[0-9]{1,2}\.[0-9]{1,3}' | head -n 1)"
image_save_name="Armbian_${image_version}-trunk_${image_kernel}.img"
rm -f ${image_save_name}
mv -f ${image_file} ${image_save_name}
echo -e "Renamed Armbian file: [ ${image_save_name} ]"
fi
cd ${GITHUB_ACTION_PATH}
echo -e "Start to rebuild armbian..."
make_command=""
[[ -n "${{ inputs.armbian_board }}" ]] && make_command="${make_command} -b ${{ inputs.armbian_board }}"
[[ -n "${{ inputs.kernel_repo }}" ]] && make_command="${make_command} -r ${{ inputs.kernel_repo }}"
[[ -n "${{ inputs.kernel_usage }}" ]] && make_command="${make_command} -u ${{ inputs.kernel_usage }}"
[[ -n "${{ inputs.armbian_kernel }}" ]] && make_command="${make_command} -k ${{ inputs.armbian_kernel }}"
[[ -n "${{ inputs.auto_kernel }}" ]] && make_command="${make_command} -a ${{ inputs.auto_kernel }}"
[[ -n "${{ inputs.armbian_fstype }}" ]] && make_command="${make_command} -t ${{ inputs.armbian_fstype }}"
[[ -n "${{ inputs.armbian_size }}" ]] && make_command="${make_command} -s ${{ inputs.armbian_size }}"
[[ -n "${{ inputs.builder_name }}" ]] && make_command="${make_command} -n ${{ inputs.builder_name }}"
sudo ./rebuild ${make_command}
cd ${GITHUB_ACTION_PATH}/${armbian_filepath}
# Compress Armbian image file
pigz -qf *.img || gzip -qf *.img
# Generate a sha256sum verification file for each Armbian image file
for file in *; do [[ -f "${file}" ]] && sha256sum "${file}" >"${file}.sha" 2>/dev/null; done
rm -f *.sha.sha 2>/dev/null
sync && sleep 3
cd ${GITHUB_ACTION_PATH}
echo -e "Output environment variables."
echo "PACKAGED_OUTPUTPATH=${PWD}/${armbian_filepath}" >> ${GITHUB_ENV}
echo "PACKAGED_OUTPUTDATE=$(date +"%m.%d.%H%M")" >> ${GITHUB_ENV}
echo "PACKAGED_STATUS=success" >> ${GITHUB_ENV}
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${armbian_filepath}"
echo -e "PACKAGED_OUTPUTDATE: $(date +"%m.%d.%H%M")"
echo -e "PACKAGED_STATUS: success"
echo -e "PACKAGED_OUTPUTPATH files list: \n$(ls -l ${PWD}/${armbian_filepath} 2>/dev/null)"
elif [[ "${build_target}" == "kernel" ]]; then
cd ${GITHUB_ACTION_PATH}
echo -e "Start compile kernel..."
config_filepath="compile-kernel/tools/config"
kernel_outpath="compile-kernel/output"
[[ -d "${config_filepath}" ]] || mkdir -p ${config_filepath}
if [[ -n "${{ inputs.kernel_config }}" && "${{ inputs.kernel_config }}" != "false" ]]; then
if [[ "$(ls ${GITHUB_WORKSPACE}/${{ inputs.kernel_config }}/config-* -l 2>/dev/null | grep "^-" | wc -l)" -ne "0" ]]; then
echo -e "Use a custom kernel compilation template..."
rm -f ${config_filepath}/* 2>/dev/null && sync
cp -vf ${GITHUB_WORKSPACE}/${{ inputs.kernel_config }}/config-* ${config_filepath}/ 2>/dev/null && sync
echo -e "List of Kernel Custom Compilation Configuration Templates: \n$(ls -l ${config_filepath})"
else
echo -e "The custom kernel compilation template path is invalid, continue to use the default template."
fi
else
echo -e "Use the default kernel compilation template."
fi
custom_kernel_patch="compile-kernel/tools/patch"
[[ -d "${custom_kernel_patch}" ]] || mkdir -p ${custom_kernel_patch}
if [[ -n "${{ inputs.kernel_patch }}" && "${{ inputs.kernel_patch }}" != "false" ]]; then
if [[ -d "${GITHUB_WORKSPACE}/${{ inputs.kernel_patch }}" ]]; then
echo -e "Use custom kernel patches..."
rm -rf ${custom_kernel_patch}/* 2>/dev/null && sync
cp -vrf ${GITHUB_WORKSPACE}/${{ inputs.kernel_patch }}/* -t ${custom_kernel_patch} && sync
echo -e "Directory of custom kernel patches: \n$(ls -l ${custom_kernel_patch})"
else
echo -e "Invalid custom kernel patch directory, skipping."
fi
else
echo -e "No custom kernel patches available."
fi
make_command=""
[[ -n "${{ inputs.kernel_source }}" ]] && make_command="${make_command} -r ${{ inputs.kernel_source }}"
[[ -n "${{ inputs.kernel_version }}" ]] && make_command="${make_command} -k ${{ inputs.kernel_version }}"
[[ -n "${{ inputs.kernel_auto }}" ]] && make_command="${make_command} -a ${{ inputs.kernel_auto }}"
[[ -n "${{ inputs.kernel_package }}" ]] && make_command="${make_command} -m ${{ inputs.kernel_package }}"
[[ -n "${{ inputs.auto_patch }}" ]] && make_command="${make_command} -p ${{ inputs.auto_patch }}"
[[ -n "${{ inputs.kernel_sign }}" ]] && make_command="${make_command} -n ${{ inputs.kernel_sign }}"
[[ -n "${{ inputs.kernel_toolchain }}" ]] && make_command="${make_command} -t ${{ inputs.kernel_toolchain }}"
[[ -n "${{ inputs.compress_format }}" ]] && make_command="${make_command} -c ${{ inputs.compress_format }}"
sudo ./recompile ${make_command}
cd ${GITHUB_ACTION_PATH}
output_tags="$(ls -l ${PWD}/${kernel_outpath}/*.tar.gz | awk '{print $9}' | grep -oE '[1-9][0-9]{0,2}\.[0-9]{1,3}\.[0-9]+' | xargs | tr "[ ]" "_")"
echo -e "Output environment variables."
echo "PACKAGED_OUTPUTTAGS=${output_tags}" >> ${GITHUB_ENV}
echo "PACKAGED_OUTPUTPATH=${PWD}/${kernel_outpath}" >> ${GITHUB_ENV}
echo "PACKAGED_OUTPUTDATE=$(date +"%m.%d.%H%M")" >> ${GITHUB_ENV}
echo "PACKAGED_STATUS=success" >> ${GITHUB_ENV}
echo -e "PACKAGED_OUTPUTTAGS: ${output_tags}"
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${kernel_outpath}"
echo -e "PACKAGED_OUTPUTDATE: $(date +"%m.%d.%H%M")"
echo -e "PACKAGED_STATUS: success"
echo -e "PACKAGED_OUTPUTPATH files list: \n$(ls -l ${PWD}/${kernel_outpath} 2>/dev/null)"
else
echo -e "Please select a build target: armbian / kernel"
exit 1
fi
branding:
icon: "terminal"
color: "gray-dark"
1
https://gitee.com/yg125/amlogic-s9xxx-armbian.git
git@gitee.com:yg125/amlogic-s9xxx-armbian.git
yg125
amlogic-s9xxx-armbian
amlogic-s9xxx-armbian
main

Search