-
Notifications
You must be signed in to change notification settings - Fork 604
Expand file tree
/
Copy pathaction.yml
More file actions
173 lines (158 loc) · 6.72 KB
/
Copy pathaction.yml
File metadata and controls
173 lines (158 loc) · 6.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: "Make Fnnas"
author: "https://github.com/ophub/fnnas"
description: "Support Amlogic, Rockchip and Allwinner boxes."
inputs:
# Select build target
build_target:
description: "Select build target: fnnas / kernel"
required: false
default: "fnnas"
# For build fnnas -----
fnnas_path:
description: "Set fnnas arm64 file path."
required: false
default: ""
fnnas_board:
description: "Select device board."
required: false
default: "all"
kernel_repo:
description: "Select kernel repository."
required: false
default: "ophub/fnnas"
fnnas_kernel:
description: "Select kernel version."
required: false
default: "6.1.y_6.12.y"
auto_kernel:
description: "Auto use the latest kernel."
required: false
default: "true"
fnnas_size:
description: "Set the rootfs size(Unit: MiB)."
required: false
default: ""
rootfs_expand:
description: "Set rootfs expansion size(Unit: GiB)."
required: false
default: ""
builder_name:
description: "Set fnnas builder signature."
required: false
default: ""
# For compile kernel -----
debs_repo:
description: "Set fnnas debs repository."
required: false
default: "ophub/fnnas"
debs_install:
description: "Install kernel debs files."
required: false
default: "none"
dtbs_install:
description: "Install kernel dtbs files."
required: false
default: "true"
dtbs_version:
description: "Set kernel dtbs version."
required: false
default: "6.12.y"
runs:
using: "composite"
steps:
- shell: bash
run: |
cd ${{ github.action_path }}
echo -e "FnNAS Actions working directory: [ ${PWD} ]"
# Get build target
build_target="${{ inputs.build_target }}"
[[ -z "${build_target}" ]] && build_target="fnnas"
# Get fnnas file input parameters, set work directory
fnnas_filename="${{ inputs.fnnas_path }}"
fnnas_savefile="${fnnas_filename##*/}"
fnnas_savepath="fnnas-arm64"
fnnas_outpath="fnnas/out"
echo -e "FnNAS rootfs input file: [ ${fnnas_filename} ]"
[[ -z "${fnnas_filename}" ]] && echo -e "Error: The [ fnnas_path ] parameter is required but not provided." && exit 1
[[ -d "${fnnas_savepath}" ]] || mkdir -p ${fnnas_savepath}
[[ -d "${fnnas_outpath}" ]] || mkdir -p ${fnnas_outpath}
# Download or copy fnnas file
if [[ "${fnnas_filename}" =~ ^http ]]; then
echo -e "Downloading FnNAS rootfs file: [ ${fnnas_filename} ]"
curl -fsSL "${fnnas_filename}" -o "${fnnas_savepath}/${fnnas_savefile}"
else
if [[ -z "$(ls ${fnnas_savepath}/${fnnas_savefile} 2>/dev/null)" ]]; then
echo -e "Copying FnNAS rootfs file from local path: [ ${fnnas_filename} ]"
if [[ "${fnnas_filename}" =~ ^/ ]]; then
cp -vf ${fnnas_filename} ${fnnas_savepath}/ || true
else
cp -vf ${{ github.workspace }}/${fnnas_filename} ${fnnas_savepath}/ || true
fi
else
echo -e "The [ ${fnnas_savepath}/${fnnas_savefile} ] file already exists, skipping."
fi
fi
sync
echo -e "Contents of [ ${fnnas_savepath} ] directory: \n$(ls -lh ${fnnas_savepath} 2>/dev/null)"
# Verify fnnas file format
cd ${fnnas_savepath}
echo -e "Verifying FnNAS image 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 FnNAS image file: [ ${down_file} ]"
else
echo -e "No valid FnNAS image file (.img) found."
exit 1
fi
# Decompress fnnas file
[[ "${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 "FnNAS image files after decompression: \n$(ls -lh *.img 2>/dev/null)"
# Set builder custom signature
[[ -n "${{ inputs.builder_name }}" ]] && {
builder_name="${{ inputs.builder_name }}"
builder_name="${builder_name// /-}"
}
if [[ "${build_target}" == "fnnas" ]]; then
echo -e "Starting FnNAS system rebuild..."
cd ${{ github.action_path }}
echo -e "Building FnNAS system image..."
make_args=()
[[ -n "${{ inputs.fnnas_board }}" ]] && make_args+=(-b "${{ inputs.fnnas_board }}")
[[ -n "${{ inputs.kernel_repo }}" ]] && make_args+=(-r "${{ inputs.kernel_repo }}")
[[ -n "${{ inputs.fnnas_kernel }}" ]] && make_args+=(-k "${{ inputs.fnnas_kernel }}")
[[ -n "${{ inputs.auto_kernel }}" ]] && make_args+=(-a "${{ inputs.auto_kernel }}")
[[ -n "${{ inputs.fnnas_size }}" ]] && make_args+=(-s "${{ inputs.fnnas_size }}")
[[ -n "${{ inputs.rootfs_expand }}" ]] && make_args+=(-e "${{ inputs.rootfs_expand }}")
[[ -n "${builder_name}" ]] && make_args+=(-n "${builder_name}")
sudo ./renas "${make_args[@]}"
elif [[ "${build_target}" == "kernel" ]]; then
echo -e "Building FnNAS kernel package..."
# Prepare output directory
kernel_outpath="fnnas/out"
[[ -d "${kernel_outpath}" ]] || mkdir -p ${kernel_outpath}
cd ${{ github.action_path }}
make_args=()
[[ -n "${{ inputs.debs_repo }}" ]] && make_args+=(-r "${{ inputs.debs_repo }}")
[[ -n "${{ inputs.debs_install }}" ]] && make_args+=(-e "${{ inputs.debs_install }}")
[[ -n "${{ inputs.dtbs_install }}" ]] && make_args+=(-t "${{ inputs.dtbs_install }}")
[[ -n "${{ inputs.dtbs_version }}" ]] && make_args+=(-k "${{ inputs.dtbs_version }}")
sudo ./rekernel "${make_args[@]}"
else
echo -e "Invalid build target. Please specify: fnnas or kernel."
exit 1
fi
# Output environment variables
cd ${{ github.action_path }}
echo -e "Exporting output environment variables..."
echo "PACKAGED_OUTPUTPATH=${PWD}/${fnnas_outpath}" >> ${GITHUB_ENV}
echo "PACKAGED_OUTPUTDATE=$(date +"%m.%d.%H%M")" >> ${GITHUB_ENV}
echo "PACKAGED_STATUS=success" >> ${GITHUB_ENV}
echo -e "PACKAGED_OUTPUTPATH: ${PWD}/${fnnas_outpath}"
echo -e "PACKAGED_OUTPUTDATE: $(date +"%m.%d.%H%M")"
echo -e "PACKAGED_STATUS: success"
echo -e "Build output files: \n$(ls -lh ${PWD}/${fnnas_outpath}/ 2>/dev/null)"
branding:
icon: "terminal"
color: "gray-dark"