Skip to content

Commit

Permalink
feat: use new dist arch
Browse files Browse the repository at this point in the history
  • Loading branch information
EkkoG committed Oct 16, 2024
1 parent 1c1cc7c commit 96630d5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 59 deletions.
22 changes: 19 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

default_modules="add-all-device-to-lan add-feed-key add-feed ib argon base opkg-mirror prefer-ipv6-settings statistics system tools"

LOG() {
# echo when $LOG_ENABLE is not set or set to 1
if [ -z "$LOG_ENABLE" ] || [ "$LOG_ENABLE" == "1" ]; then
echo -e "\033[32m$1\033[0m"
fi

}

echo "Default modules: $default_modules"

final_modules=$default_modules
Expand Down Expand Up @@ -30,12 +38,16 @@ cp -r user_modules_in_container user_modules

all_packages=
# system env by calling env
system_env=$(env)
system_env=""
if [ $USE_SYTEM_ENV ]; then
system_env="$(env)"
fi

deal() {
modules_dir=$1

for module in $final_modules; do
LOG "Processing $module in $modules_dir"

if [ -f "$modules_dir/$module/packages" ]; then
all_packages="$all_packages $(cat $modules_dir/$module/packages)"
Expand All @@ -55,8 +67,12 @@ deal() {
for file in $(find "$modules_dir/$module/files/etc/uci-defaults" -type f); do
echo "$all_env" | while IFS= read -r env; do
env_name="$(echo "$env" | cut -d '=' -f 1)"
env_value="${!env_name}"
sed -e "s|\$$env_name|$env_value|g" -i $file
echo "env_name: $env_name"
if [ ! -z "$env_name" ]; then
env_value="${!env_name}"
LOG "Replacing $env_name with $env_value in $file"
sed -e "s|\$$env_name|$env_value|g" -i $file
fi
done
done
fi
Expand Down
59 changes: 4 additions & 55 deletions modules/add-feed-base/base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,13 @@ else
fi

PACKAGES_ARCH=$(cat .config | grep CONFIG_TARGET_ARCH_PACKAGES | awk -F '=' '{print $2}' | sed 's/"//g')
OPENWRT_VERSION=$(cat ./include/version.mk | grep 'VERSION_NUMBER:=$(if' | awk -F ',' '{print $3}' | awk -F ')' '{print $1}')
BIG_VERSION=$(echo $OPENWRT_VERSION | awk -F '.' '{print $1"."$2}')

echo "PACKAGES_ARCH: $PACKAGES_ARCH OPENWRT_VERSION: $OPENWRT_VERSION BIG_VERSION: $BIG_VERSION"
DISTRIB_ARCH=$PACKAGES_ARCH
DISTRIB_RELEASE=$OPENWRT_VERSION
add_packages() {
echo "try add $1"

all_supported=$(curl https://sourceforge.net/projects/ekko-openwrt-dist/files/$1/ | grep -e "<th.*files/$1" | grep -o 'href="/projects[^"]*"' | sed 's/href="//' | sed 's/"$//' | awk -F/ '{print $6}')
echo "All supported version: "
echo "$all_supported"

version=$(echo "$DISTRIB_RELEASE" | awk -F- '{print $1}')
echo "Current version: $version"

# get the first two version number
big_version=$(echo "$version" | awk -F. '{print $1"."$2}')

if [ "$1" == "luci" ]; then
supported=$(echo "$all_supported" | grep "$big_version")
feed_version="$DISTRIB_RELEASE"
else
supported=$(echo "$all_supported" | grep $DISTRIB_ARCH | grep $big_version)
feed_version="$DISTRIB_ARCH-v$DISTRIB_RELEASE"
fi

echo "Supported version: "
echo "$supported"

if [ -z "$supported" ]; then
echo "Your device is not supported"
exit 1
fi

full_support=0
for i in $supported; do
if [ "$i" = "$feed_version" ]; then
full_support=1
break
fi
done

if [ "$full_support" = "0" ]; then
echo "Your device is not fully supported"
echo "Find the latest version that supports your device"

# 过滤掉 rc 和 SNAPSHOT 版本, 不用 grep
final_release=$(echo "$supported" | grep -v "\-rc" | grep -v "SNAPSHOT" | tail -n 1)
if [ -z "$final_release" ]; then
echo "No final release found, use the latest rc version"
feed_version=$(echo "$supported" | grep "\-rc" | tail -n 1)
else
feed_version=$final_release
fi
dist_path="$1/$PACKAGES_ARCH"
if [ $1 = luci ]; then
dist_path="luci"
fi
echo "Feed version: $feed_version"
EKKOG_FEED="src/gz ekkog_$1 https://ghproxy.imciel.com/https://downloads.sourceforge.net/project/ekko-openwrt-dist/$1/$feed_version"
EKKOG_FEED="src/gz ekkog_$1 https://ghproxy.imciel.com/https://downloads.sourceforge.net/project/ekko-openwrt-dist/$dist_path"
mkdir -p files/etc/opkg/
echo "$EKKOG_FEED" >> files/etc/opkg/customfeeds.conf
# 添加软件源到第一行
Expand Down
2 changes: 1 addition & 1 deletion modules/openclash/post-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ wget --user-agent='clash' $CLASH_CONFIG_URL -O files/etc/openclash/config/config

. ./modules/add-feed-base/base.sh

add_packages "clash"
add_packages "mihomo"

0 comments on commit 96630d5

Please sign in to comment.