Skip to content

Nilabsent Zapret firmware MI-3G TEST! #21

Nilabsent Zapret firmware MI-3G TEST!

Nilabsent Zapret firmware MI-3G TEST! #21

Workflow file for this run

name: Nilabsent Zapret firmware MI-3G TEST!
on:
workflow_dispatch:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
container: registry.gitlab.com/hadzhioglu/padavan-ng
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v6
- name: Get variables
run: |
sed -i 's|\\r$||g' variables build_nilabsent_MI-3G.config
. <(cat variables build_nilabsent_MI-3G.config)
PADAVAN_THEMES="${PADAVAN_THEMES[*]}"
for v in "${!PADAVAN_@}" "${!CONFIG_@}" "${!ZAPRET_@}"; do
echo "$v=${!v}" >> "$GITHUB_ENV"
done
- name: Set up build tools
run: |
apt update
apt install --no-install-recommends -y \
autoconf automake autopoint cmake \
bison build-essential flex gawk \
gettext git gperf libtool libtool-bin \
pkg-config fakeroot kmod cpio doxygen \
texinfo help2man libncurses5-dev \
zlib1g-dev libsqlite3-dev gcc-multilib \
curl dos2unix unzip wget locales xxd libltdl-dev \
libgmp3-dev libmpfr-dev libarchive-tools libblkid-dev
- name: Update locales
run: |
locale-gen --no-purge en_US.UTF-8 ru_RU.UTF-8
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
- name: Download sources and toolchain
run: |
git config --global --add safe.directory '*'
git clone -b "$PADAVAN_BRANCH" "$PADAVAN_REPO" padavan-ng-hadzhioglu
git -C padavan-ng-hadzhioglu checkout "$PADAVAN_COMMIT"
ARCH=""
case "$PADAVAN_TOOLCHAIN_URL" in
*.tzst|*.tar.zst) ARCH="--zstd" ;;
*.txz|*.tar.xz) ARCH="--xz" ;;
esac
wget -qO- "$PADAVAN_TOOLCHAIN_URL" | tar -C padavan-ng-hadzhioglu $ARCH -xf - || :
- name: Build toolchain if missing
if: false
run: |
if [[ ! -f padavan-ng-hadzhioglu/toolchain/out/mipsel-linux-uclibc/sysroot/lib/libuClibc-*.so ]]; then
cd padavan-ng-hadzhioglu/toolchain
./clean_sources.sh
./build_toolchain.sh
else
echo "Toolchain already present, skip build_toolchain.sh"
fi
#==================================================================
- name: Replace nfqws from nilabsent/padavan-ng
if: env.ZAPRET_REPLACE_NFQWS == '1'
run: |
set -e
cd padavan-ng-hadzhioglu/trunk/user
echo "=== Replacing nfqws directory from nilabsent/padavan-ng ==="
rm -rf nfqws
mkdir -p nfqws
# Скачиваем архив только каталога nfqws и распаковываем
curl -fsSL "https://github.com/nilabsent/padavan-ng/archive/refs/heads/master.tar.gz" -o /tmp/padavan-ng-nilabsent.tar.gz
tar -xzf /tmp/padavan-ng-nilabsent.tar.gz -C /tmp
# Копируем весь каталог trunk/user/nfqws как есть
cp -a /tmp/padavan-ng-master/trunk/user/nfqws/. nfqws/
echo "=== nfqws structure check ==="
[[ -f nfqws/Makefile ]] || { echo "Makefile missing in nfqws"; exit 1; }
[[ -f nfqws/config/exclude.list ]] || { echo "exclude.list missing in nfqws"; exit 1; }
[[ -f nfqws/zapret-72.12.tar.gz ]] || { echo "zapret-72.12.tar.gz missing in nfqws"; exit 1; }
ls -R nfqws
- name: Replace nfqws2 from nilabsent/padavan-ng
if: env.ZAPRET_REPLACE_NFQWS2 == '1'
run: |
set -e
cd padavan-ng-hadzhioglu/trunk/user
echo "=== Replacing nfqws2 directory from nilabsent/padavan-ng ==="
rm -rf nfqws2
mkdir -p nfqws2
# Используем тот же архив (если хочется, можно вынести скачивание в отдельный шаг)
# curl -fsSL "https://github.com/nilabsent/padavan-ng/archive/refs/heads/master.tar.gz" -o /tmp/padavan-ng-nilabsent.tar.gz
# tar -xzf /tmp/padavan-ng-nilabsent.tar.gz -C /tmp
cp -a /tmp/padavan-ng-master/trunk/user/nfqws2/. nfqws2/
echo "=== nfqws2 structure check ==="
[[ -f nfqws2/Makefile ]] || { echo "Makefile missing in nfqws2"; exit 1; }
[[ -f nfqws2/config/exclude.list ]] || { echo "exclude.list missing in nfqws2"; exit 1; }
[[ -f nfqws2/zapret2-0.9.4.5.tar.gz ]] || { echo "zapret2-0.9.4.5.tar.gz missing in nfqws2"; exit 1; }
ls -R nfqws2
# ================================================================
- name: Patch user/Makefile to add nfqws2
run: |
set -e
cd padavan-ng-hadzhioglu/trunk/user
mf="Makefile"
echo "=== Patching user/Makefile to add nfqws2 ==="
echo "=== Before patch (NFQWS lines, with numbers) ==="
nl -ba "$mf" | grep 'CONFIG_FIRMWARE_INCLUDE_NFQWS' || echo "no NFQWS lines before patch"
tmp="$(mktemp)"
matched=0
while IFS= read -r line; do
case "$line" in
*'CONFIG_FIRMWARE_INCLUDE_NFQWS'*)
echo "MATCHED LINE WITH CONFIG_FIRMWARE_INCLUDE_NFQWS, PATCHING" >&2
echo 'dir_$(CONFIG_FIRMWARE_INCLUDE_NFQWS)+= nfqws' >> "$tmp"
echo 'dir_$(CONFIG_FIRMWARE_INCLUDE_NFQWS2)+= nfqws2' >> "$tmp"
matched=1
;;
*)
echo "$line" >> "$tmp"
;;
esac
done < "$mf"
mv "$tmp" "$mf"
echo "=== After patch (NFQWS lines, with numbers) ==="
nl -ba "$mf" | grep 'CONFIG_FIRMWARE_INCLUDE_NFQWS' || echo "no NFQWS lines after patch"
echo "=== Full user/Makefile after patch ==="
cat "$mf"
echo "=== Verifying patch ==="
if [ "$matched" -ne 1 ]; then
echo "ERROR: line with CONFIG_FIRMWARE_INCLUDE_NFQWS not found, aborting build"
exit 1
fi
if ! grep -q 'dir_$(CONFIG_FIRMWARE_INCLUDE_NFQWS2)+= nfqws2' "$mf"; then
echo "ERROR: nfqws2 line not found in $mf, aborting build"
exit 1
fi
#============================================================================
- name: Install themes
run: |
if [[ -n "$PADAVAN_THEMES" ]]; then
git clone --depth 1 -b "$PADAVAN_THEMES_BRANCH" "$PADAVAN_THEMES_REPO" themes
cp -r themes/common-theme themes/jquery.js padavan-ng-hadzhioglu/trunk/user/www/n56u_ribbon_fixed
for theme in $PADAVAN_THEMES; do
echo "Installing $theme theme"
cp -r "themes/$theme-theme" padavan-ng-hadzhioglu/trunk/user/www/n56u_ribbon_fixed
done
fi
- name: Run custom pre-build script
run: '[[ -f pre-build.sh ]] && . pre-build.sh || :'
- name: Build firmware
if: false
run: |
cp build_nilabsent_MI-3G.config padavan-ng-hadzhioglu/trunk/.config
cd padavan-ng-hadzhioglu/trunk
./clear_tree.sh
./build_firmware.sh
FW_FILE_NAME="$(find images -type f -regextype posix-extended -iregex '.*\\.\\(trx\\|bin\\)$' -printf '%T@\\t%f\\n' | sort -V | tail -1 | cut -f2)"
if [[ -z "$FW_FILE_NAME" ]]; then
echo "Firmware image not found in images/"
exit 1
fi
echo "FW_FILE_NAME=$FW_FILE_NAME" >> "$GITHUB_ENV"
- name: Build firmware
run: |
cp build_nilabsent_MI-3G.config padavan-ng-hadzhioglu/trunk/.config
cd padavan-ng-hadzhioglu/trunk
./clear_tree.sh
./build_firmware.sh
# Берём самый свежий .trx или .bin
FW_FILE_NAME="$(ls -1t images/*.trx images/*.bin 2>/dev/null | head -n1 | xargs -n1 basename || true)"
if [[ -z "$FW_FILE_NAME" ]]; then
echo "Firmware image not found in images/"
ls -al images || echo "images dir missing"
exit 1
fi
echo "Found firmware: $FW_FILE_NAME"
echo "FW_FILE_NAME=$FW_FILE_NAME" >> "$GITHUB_ENV"
echo "=== Check nfqws2 in romfs ==="
find padavan-ng-hadzhioglu/trunk/romfs -maxdepth 4 -type f -iname 'nfqws2*' -o -iname 'zapret2*' || true
- name: Run custom post-build script
run: '[[ -f post-build.sh ]] && . post-build.sh || :'
- name: Prepare artifacts
run: |
cp "padavan-ng-hadzhioglu/trunk/images/$FW_FILE_NAME" .
echo "BUILD_TIMESTAMP=$(date '+%Y.%m.%d_%H.%M.%S')" >> "$GITHUB_ENV"
- name: Upload artifacts
uses: actions/upload-artifact@v5
with:
name: padavan-ng-hadzhioglu_${{ env.CONFIG_VENDOR }}_${{ env.CONFIG_FIRMWARE_PRODUCT_ID }}_${{ env.BUILD_TIMESTAMP }}
retention-days: 7
path: |
${{ env.FW_FILE_NAME }}
build_nilabsent_MI-3G.config
- name: Check firmware size
run: |
partitions="padavan-ng-hadzhioglu/trunk/configs/boards/$CONFIG_VENDOR/$CONFIG_FIRMWARE_PRODUCT_ID/partitions.config"
if [[ ! -f "$partitions" ]]; then
echo "Partitions config not found: $partitions"
exit 1
fi
max_fw_size="$(awk '/Firmware/ { getline; getline; sub(",", ""); num=strtonum($2); if (num>0) print num; }' "$partitions")"
if [[ -z "$max_fw_size" ]]; then
echo "Cannot extract max firmware size from $partitions"
exit 1
fi
fw_size="$(stat -c %s "$FW_FILE_NAME")"
if (( fw_size > max_fw_size )); then
fw_size_fmtd="$(numfmt --grouping "$fw_size") bytes"
max_fw_size_fmtd="$(numfmt --grouping "$max_fw_size") bytes"
echo "Firmware size ($fw_size_fmtd) exceeds max size ($max_fw_size_fmtd) for your target device"
exit 1
fi