-
Notifications
You must be signed in to change notification settings - Fork 1
/
ql_diy
59 lines (57 loc) · 2.97 KB
/
ql_diy
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
#!/usr/bin/env bash
hx=`ls $REPO_FLODER/bin/targets/*/*/*toolchain* 2>/dev/null | sed "s/openwrt/$IMG_NAME/g" 2>/dev/null`
xx=`ls $REPO_FLODER/bin/targets/*/*/*imagebuil* 2>/dev/null | sed "s/openwrt/$IMG_NAME/g" 2>/dev/null`
up_github() {
echo "上传到github"
export AUTH="Authorization: token $GITHUB_TOKEN"
export cache_path='github.com/repos/hong0980/OpenWrt-Cache/releases'
export cache_repo_id='84581161'
while true; do
ret=$(curl -sH "$AUTH" "https://api.$cache_path/tags/cache")
echo $ret | jq -r '.assets[] | select(.name == "${hx##*/}").id' | xargs -n1 -i curl -X DELETE -H "$AUTH" "https://api.$cache_path/assets/{}"
echo $ret | jq -r '.assets[] | select(.name == "${xx##*/}").id' | xargs -n1 -i curl -X DELETE -H "$AUTH" "https://api.$cache_path/assets/{}"
echo $ret | jq -r '.assets[] | select(.name | contains ("'$IMG_NAME'.img")).id' | xargs -n1 -i curl -X DELETE -H "$AUTH" "https://api.$cache_path/assets/{}"
ls output | parallel --wc 'while true; do curl -T {} -H "$AUTH" -H "Content-Type: application/octet-stream" "https://uploads.$cache_path/$cache_repo_id/assets?name={}" && break || true; done'
set +e
for i in {1..5}; do
curl -sL --fail https://github.com/hong0980/Actions-OpenWrt/releases/download/$SOURCE_NAME-Cache/$IMG_NAME.img.zst.0$i || break
done | zstdmt -d -o /dev/null
if [ $? -eq 0 ]; then
break
fi
done
set -e
}
grep -q "$CACHE_NAME-cache" xa || {
echo "打包cache"
[[ -n $hx ]] && (cp -v `find $REPO_FLODER/bin/targets/ -type f -name "*toolchain*"` output/${hx##*/} || true)
[[ -n $xx ]] && (cp -v `find $REPO_FLODER/bin/targets/ -type f -name "*imagebuil*"` output/${xx##*/} || true)
pushd $REPO_FLODER || pushd openwrt
[[ -d ".ccache" ]] && (ccache=".ccache"; ls -alh .ccache)
tar -I zstdmt -cf ../output/$CACHE_NAME-cache.tzst staging_dir/host* staging_dir/tool* $ccache || \
tar --zstd -cf ../output/$CACHE_NAME-cache.tar.zst staging_dir/host* staging_dir/tool* $ccache
du -h --max-depth=1 ./ --exclude=staging_dir
du -h --max-depth=1 ./staging_dir
popd
ls -lh output
if [[ $(du -m "output/${CACHE_NAME}*" | cut -f1) -ge 300 ]]; then
echo "OUTPUT_RELEASE=true" >>$GITHUB_ENV
fi
}
# [[ "$TARGET_DEVICE" =~ r[1-9] && "$SOURCE_NAME" =~ coolsnowwolf ]] && {
# [[ $REPO_FLODER ]] && cd $REPO_FLODER || cd openwrt
# cp -fv $(find build_dir -type f -name 'motorcomm.c') ../output
# cp -fv $(find dl -name 'u-boot-202*' -o -name 'linux-5.[0-9][0-9]*' -o -name '*rockchip*') ../output
# tar -zcf ../output/rockchip.tar.gz target/linux/rockchip
# echo "OUTPUT_RELEASE=true" >>$GITHUB_ENV
# }
[[ "$REPO_BRANCH" = "openwrt-23.05" && "$TARGET_DEVICE" = "r1-plus-lts" ]] && {
cd $REPO_FLODER || cd openwrt
# build_dir/target-aarch64_generic_musl/linux-rockchip_armv8/linux-5.15.114/drivers/net/phy/Makefile
cp -fv build_dir/*/linux*/linux*/drivers/net/phy/Kconfig ../output
cp -fv build_dir/*/linux*/linux*/drivers/net/phy/Makefile ../output
echo "OUTPUT_RELEASE=true" >>$GITHUB_ENV
}
# up_github || true
echo "SAVE_CACHE=''" >>$GITHUB_ENV
# export -p