|
1 | 1 | #!/bin/bash |
| 2 | +set -euo pipefail |
2 | 3 | clear |
3 | 4 |
|
| 5 | +sed_in_place() { |
| 6 | + if sed --version >/dev/null 2>&1; then |
| 7 | + sed -i "$@" |
| 8 | + else |
| 9 | + sed -i '' "$@" |
| 10 | + fi |
| 11 | +} |
| 12 | + |
| 13 | +resolve_profiles_url() { |
| 14 | + local release_repo |
| 15 | + local version_number |
| 16 | + |
| 17 | + release_repo="$(sed -n 's#^VERSION_REPO:=.*,\(https://downloads\.openwrt\.org/releases/[^)]*\)).*$#\1#p' include/version.mk | tail -n 1)" |
| 18 | + |
| 19 | + if [ -z "$release_repo" ]; then |
| 20 | + version_number="$(sed -n 's#^VERSION_NUMBER:=.*,\([^)]*\)).*$#\1#p' include/version.mk | tail -n 1)" |
| 21 | + if [ -n "$version_number" ]; then |
| 22 | + release_repo="https://downloads.openwrt.org/releases/$version_number" |
| 23 | + fi |
| 24 | + fi |
| 25 | + |
| 26 | + if [ -z "$release_repo" ]; then |
| 27 | + echo "[TARGET] Failed to resolve OpenWrt release repo from include/version.mk" >&2 |
| 28 | + return 1 |
| 29 | + fi |
| 30 | + |
| 31 | + printf '%s/targets/mediatek/filogic/profiles.json\n' "${release_repo%/}" |
| 32 | +} |
| 33 | + |
4 | 34 | # 使用特定的优化 |
5 | | -sed -i 's,-mcpu=generic,-march=armv8-a+crc+crypto,g' include/target.mk |
| 35 | +sed_in_place 's,-mcpu=generic,-march=armv8-a+crc+crypto,g' include/target.mk |
6 | 36 |
|
7 | 37 | #Vermagic |
8 | | -latest_version="$(curl -s https://github.com/openwrt/openwrt/tags | grep -Eo "v[0-9\\.]+\\-*r*c*[0-9]*.tar.gz" | grep 'v24.10' | sed -n 1p | sed 's/v//g' | sed 's/.tar.gz//g')" |
9 | | -wget https://downloads.openwrt.org/releases/${latest_version}/targets/mediatek/filogic/profiles.json |
10 | | -jq -r '.linux_kernel.vermagic' profiles.json >.vermagic |
11 | | -sed -i -e 's/^\(.\).*vermagic$/\1cp $(TOPDIR)\/.vermagic $(LINUX_DIR)\/.vermagic/' include/kernel-defaults.mk |
| 38 | +profiles_url="$(resolve_profiles_url)" |
| 39 | +echo "[TARGET] Downloading vermagic from $profiles_url" |
| 40 | +wget -O profiles.json "$profiles_url" |
| 41 | +jq -er '.linux_kernel.vermagic' profiles.json > .vermagic |
| 42 | +sed_in_place -e 's/^\(.\).*vermagic$/\1cp $(TOPDIR)\/.vermagic $(LINUX_DIR)\/.vermagic/' include/kernel-defaults.mk |
12 | 43 |
|
13 | 44 | # 预配置一些插件 |
14 | 45 | cp -rf ../PATCH/files ./files |
15 | 46 |
|
16 | | -find ./ -name *.orig | xargs rm -f |
17 | | -find ./ -name *.rej | xargs rm -f |
| 47 | +find ./ -name '*.orig' -delete |
| 48 | +find ./ -name '*.rej' -delete |
18 | 49 |
|
19 | 50 | #exit 0 |
0 commit comments