mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-26 02:42:25 +00:00
Merge remote-tracking branch 'fork/master' into dev
# Conflicts: # .github/workflows/build.yml # .github/workflows/docker.yml # .gitignore # base/pref.example.toml # base/snippets/emoji.toml # base/snippets/emoji.txt # scripts/build.macos.release.sh # scripts/build.windows.release.sh # scripts/rules_config.conf # src/generator/config/subexport.cpp # src/handler/interfaces.cpp # src/handler/settings.cpp # src/parser/config/proxy.h # src/parser/subparser.cpp # src/parser/subparser.h # src/utils/map_extra.h # src/version.h
This commit is contained in:
@@ -30,7 +30,7 @@ RUN set -xe && \
|
||||
install -d /usr/include/date/ && \
|
||||
install -m644 libcron/externals/date/include/date/* /usr/include/date/ && \
|
||||
cd .. && \
|
||||
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1 && \
|
||||
git clone https://github.com/ToruNiina/toml11 --branch="v4.3.0" --depth=1 && \
|
||||
cd toml11 && \
|
||||
cmake -DCMAKE_CXX_STANDARD=11 . && \
|
||||
make install -j $THREADS && \
|
||||
@@ -53,6 +53,10 @@ RUN apk add --no-cache --virtual subconverter-deps pcre2 libcurl yaml-cpp
|
||||
COPY --from=builder /subconverter/subconverter /usr/bin/
|
||||
COPY --from=builder /subconverter/base /base/
|
||||
|
||||
ENV TZ=Africa/Abidjan
|
||||
RUN ln -sf /usr/share/zoneinfo/$TZ /etc/localtime
|
||||
RUN echo $TZ > /etc/timezone
|
||||
|
||||
# set entry
|
||||
WORKDIR /base
|
||||
CMD subconverter
|
||||
|
||||
@@ -4,7 +4,7 @@ set -xe
|
||||
apk add gcc g++ build-base linux-headers cmake make autoconf automake libtool python2 python3
|
||||
apk add mbedtls-dev mbedtls-static zlib-dev rapidjson-dev zlib-static pcre2-dev
|
||||
|
||||
git clone https://github.com/curl/curl --depth=1 --branch curl-8_4_0
|
||||
git clone https://github.com/curl/curl --depth=1 --branch curl-8_6_0
|
||||
cd curl
|
||||
cmake -DCURL_USE_MBEDTLS=ON -DHTTP_ONLY=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DCMAKE_USE_LIBSSH2=OFF -DBUILD_CURL_EXE=OFF . > /dev/null
|
||||
make install -j2 > /dev/null
|
||||
@@ -34,7 +34,7 @@ cmake -DCMAKE_BUILD_TYPE=Release .
|
||||
make libcron install -j3
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1
|
||||
git clone https://github.com/ToruNiina/toml11 --branch="v4.3.0" --depth=1
|
||||
cd toml11
|
||||
cmake -DCMAKE_CXX_STANDARD=11 .
|
||||
make install -j4
|
||||
|
||||
@@ -41,7 +41,7 @@ sudo install -d /usr/local/include/date/
|
||||
sudo install -m644 libcron/externals/date/include/date/* /usr/local/include/date/
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1
|
||||
git clone https://github.com/ToruNiina/toml11 --branch="v4.3.0" --depth=1
|
||||
cd toml11
|
||||
cmake -DCMAKE_CXX_STANDARD=11 .
|
||||
sudo make install -j6 > /dev/null
|
||||
@@ -63,4 +63,4 @@ chmod +r ./*
|
||||
cd ..
|
||||
mv base subconverter
|
||||
|
||||
set +xe
|
||||
set +xe
|
||||
|
||||
@@ -1,33 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -xe
|
||||
|
||||
# 获取系统架构
|
||||
ARCH=$(uname -m)
|
||||
|
||||
if [ "$ARCH" == "x86_64" ]; then
|
||||
TOOLCHAIN="mingw-w64-x86_64"
|
||||
else
|
||||
TOOLCHAIN="mingw-w64-i686"
|
||||
fi
|
||||
|
||||
pacman -S --needed --noconfirm base-devel ${TOOLCHAIN}-toolchain ${TOOLCHAIN}-cmake ${TOOLCHAIN}-nghttp2 ${TOOLCHAIN}-openssl
|
||||
|
||||
git clone https://github.com/curl/curl --depth=1 --branch curl-8_8_0
|
||||
git clone https://github.com/curl/curl --depth=1 --branch curl-8_6_0
|
||||
cd curl
|
||||
cmake -DCMAKE_BUILD_TYPE=Release \
|
||||
-DCURL_USE_LIBSSH2=OFF \
|
||||
-DHTTP_ONLY=ON \
|
||||
-DCURL_USE_SCHANNEL=ON \
|
||||
-DBUILD_SHARED_LIBS=OFF \
|
||||
-DBUILD_CURL_EXE=OFF \
|
||||
-DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" \
|
||||
-G "Unix Makefiles" \
|
||||
-DHAVE_LIBIDN2=OFF \
|
||||
-DCURL_USE_LIBPSL=OFF \
|
||||
-DCURL_STATICLIB=ON \
|
||||
-DCURL_DISABLE_SOCKETPAIR=ON \
|
||||
-DCURL_DISABLE_NONBLOCKING=ON .
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DCURL_USE_LIBSSH2=OFF -DHTTP_ONLY=ON -DCURL_USE_SCHANNEL=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CURL_EXE=OFF -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" -G "Unix Makefiles" -DHAVE_LIBIDN2=OFF -DCURL_USE_LIBPSL=OFF .
|
||||
make install -j4
|
||||
cd ..
|
||||
|
||||
@@ -62,7 +38,7 @@ cmake -DRAPIDJSON_BUILD_DOC=OFF -DRAPIDJSON_BUILD_EXAMPLES=OFF -DRAPIDJSON_BUILD
|
||||
make install -j4
|
||||
cd ..
|
||||
|
||||
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1
|
||||
git clone https://github.com/ToruNiina/toml11 --branch "v4.3.0" --depth=1
|
||||
cd toml11
|
||||
cmake -DCMAKE_INSTALL_PREFIX="$MINGW_PREFIX" -G "Unix Makefiles" -DCMAKE_CXX_STANDARD=11 .
|
||||
make install -j4
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
[ACL4SSR]
|
||||
name=ACL4SSR
|
||||
url=https://github.com/ACL4SSR/ACL4SSR
|
||||
checkout=1dc5c92b0c8ceaaecbc66530c309961f53e52c8c
|
||||
branch=master
|
||||
match=Clash/*.list|Clash/Ruleset/**
|
||||
|
||||
[ACL4SSR_config]
|
||||
name=ACL4SSR
|
||||
url=https://github.com/ACL4SSR/ACL4SSR
|
||||
checkout=1dc5c92b0c8ceaaecbc66530c309961f53e52c8c
|
||||
branch=master
|
||||
match=Clash/config/**
|
||||
dest=base/config/
|
||||
keep_tree=false
|
||||
|
||||
[DivineEngine]
|
||||
url=https://github.com/asdlokj1qpi233/Profiles.git
|
||||
checkout=f6302d855192bd8d0be08319dff3e58ae7c2bd4e
|
||||
match=Surge/Ruleset/**
|
||||
|
||||
[NobyDa]
|
||||
url=https://github.com/NobyDa/Script
|
||||
checkout=ae4c12f23de8078e02c373c9969b19af28257fcb
|
||||
branch=master
|
||||
match=Surge/*.list
|
||||
|
||||
[lhie1]
|
||||
url=https://github.com/dler-io/Rules
|
||||
branch=main
|
||||
match=Surge/Surge 3/Provider/**
|
||||
|
||||
@@ -22,10 +22,13 @@ def open_repo(path: str):
|
||||
return None
|
||||
|
||||
|
||||
def update_rules(repo_path, save_path, commit, matches, keep_tree):
|
||||
def update_rules(repo_path: str, save_path: str, matches: list[str], keep_tree: bool):
|
||||
os.makedirs(save_path, exist_ok=True)
|
||||
for pattern in matches:
|
||||
files = glob.glob(os.path.join(repo_path, pattern), recursive=True)
|
||||
if len(files) == 0:
|
||||
logging.warn(f"no files found for pattern {pattern}")
|
||||
continue
|
||||
for file in files:
|
||||
if os.path.isdir(file):
|
||||
continue
|
||||
@@ -51,12 +54,13 @@ def main():
|
||||
for section in config.sections():
|
||||
repo = config.get(section, "name", fallback=section)
|
||||
url = config.get(section, "url")
|
||||
commit = config.get(section, "checkout")
|
||||
commit = config.get(section, "commit", fallback=None)
|
||||
branch = config.get(section, "branch", fallback=None)
|
||||
matches = config.get(section, "match").split("|")
|
||||
save_path = config.get(section, "dest", fallback=f"base/rules/{repo}")
|
||||
keep_tree = config.getboolean(section, "keep_tree", fallback=True)
|
||||
|
||||
logging.info(f"reading files from url {url} with commit {commit} and matches {matches}, save to {save_path} keep_tree {keep_tree}")
|
||||
logging.info(f"reading files from url {url}, matches {matches}, save to {save_path} keep_tree {keep_tree}")
|
||||
|
||||
repo_path = os.path.join("./tmp/repo/", repo)
|
||||
|
||||
@@ -67,8 +71,21 @@ def main():
|
||||
else:
|
||||
logging.info(f"repo {repo_path} exists")
|
||||
|
||||
r.git.checkout(commit)
|
||||
update_rules(repo_path, save_path, commit, matches, keep_tree)
|
||||
try:
|
||||
if commit is not None:
|
||||
logging.info(f"checking out to commit {commit}")
|
||||
r.git.checkout(commit)
|
||||
elif branch is not None:
|
||||
logging.info(f"checking out to branch {branch}")
|
||||
r.git.checkout(branch)
|
||||
else:
|
||||
logging.info(f"checking out to default branch")
|
||||
r.active_branch.checkout()
|
||||
except Exception as e:
|
||||
logging.error(f"checkout failed {e}")
|
||||
continue
|
||||
|
||||
update_rules(repo_path, save_path, matches, keep_tree)
|
||||
|
||||
shutil.rmtree("./tmp", ignore_errors=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user