mirror of
https://github.com/asdlokj1qpi233/subconverter.git
synced 2025-10-26 10:52:21 +00:00
Fix build error
This commit is contained in:
8
.github/workflows/docker.yml
vendored
8
.github/workflows/docker.yml
vendored
@@ -179,7 +179,7 @@ jobs:
|
|||||||
tags: tindy2013/subconverter:latest
|
tags: tindy2013/subconverter:latest
|
||||||
build-args: |
|
build-args: |
|
||||||
SHA=${{ steps.vars.outputs.sha_short }}
|
SHA=${{ steps.vars.outputs.sha_short }}
|
||||||
THREADS=2
|
THREADS=4
|
||||||
outputs: type=image,push=true
|
outputs: type=image,push=true
|
||||||
|
|
||||||
- name: Replace tag without `v`
|
- name: Replace tag without `v`
|
||||||
@@ -200,7 +200,7 @@ jobs:
|
|||||||
context: scripts/
|
context: scripts/
|
||||||
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
|
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
|
||||||
build-args: |
|
build-args: |
|
||||||
THREADS=2
|
THREADS=4
|
||||||
outputs: type=image,push=true
|
outputs: type=image,push=true
|
||||||
|
|
||||||
- name: Save digest
|
- name: Save digest
|
||||||
@@ -252,7 +252,7 @@ jobs:
|
|||||||
tags: tindy2013/subconverter:latest
|
tags: tindy2013/subconverter:latest
|
||||||
build-args: |
|
build-args: |
|
||||||
SHA=${{ steps.vars.outputs.sha_short }}
|
SHA=${{ steps.vars.outputs.sha_short }}
|
||||||
THREADS=2
|
THREADS=4
|
||||||
outputs: type=image,push=true
|
outputs: type=image,push=true
|
||||||
|
|
||||||
- name: Replace tag without `v`
|
- name: Replace tag without `v`
|
||||||
@@ -273,7 +273,7 @@ jobs:
|
|||||||
context: scripts/
|
context: scripts/
|
||||||
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
|
tags: tindy2013/subconverter:${{steps.version.outputs.result}}
|
||||||
build-args: |
|
build-args: |
|
||||||
THREADS=2
|
THREADS=4
|
||||||
outputs: type=image,push=true
|
outputs: type=image,push=true
|
||||||
|
|
||||||
- name: Save digest
|
- name: Save digest
|
||||||
|
|||||||
@@ -495,6 +495,7 @@ T unwrap_free(JSContext * ctx, JSValue val)
|
|||||||
template <class Tuple, std::size_t... I>
|
template <class Tuple, std::size_t... I>
|
||||||
Tuple unwrap_args_impl(JSContext * ctx, JSValueConst * argv, std::index_sequence<I...>)
|
Tuple unwrap_args_impl(JSContext * ctx, JSValueConst * argv, std::index_sequence<I...>)
|
||||||
{
|
{
|
||||||
|
(void)ctx;
|
||||||
return Tuple{js_traits<std::decay_t<std::tuple_element_t<I, Tuple>>>::unwrap(ctx, argv[I])...};
|
return Tuple{js_traits<std::decay_t<std::tuple_element_t<I, Tuple>>>::unwrap(ctx, argv[I])...};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1207,12 +1208,12 @@ public:
|
|||||||
|
|
||||||
JSModuleDef * m;
|
JSModuleDef * m;
|
||||||
JSContext * ctx;
|
JSContext * ctx;
|
||||||
const char * name;
|
/*const char * name;*/
|
||||||
|
|
||||||
using nvp = std::pair<const char *, Value>;
|
using nvp = std::pair<const char *, Value>;
|
||||||
std::vector<nvp> exports;
|
std::vector<nvp> exports;
|
||||||
public:
|
public:
|
||||||
Module(JSContext * ctx, const char * name) : ctx(ctx), name(name)
|
Module(JSContext * ctx, const char * name) : ctx(ctx)/*, name(name)*/
|
||||||
{
|
{
|
||||||
m = JS_NewCModule(ctx, name, [](JSContext * ctx, JSModuleDef * m) noexcept {
|
m = JS_NewCModule(ctx, name, [](JSContext * ctx, JSModuleDef * m) noexcept {
|
||||||
auto& context = Context::get(ctx);
|
auto& context = Context::get(ctx);
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
FROM alpine:3.16
|
FROM alpine:3.16 AS builder
|
||||||
LABEL maintainer "tindy.it@gmail.com"
|
LABEL maintainer="tindy.it@gmail.com"
|
||||||
ARG THREADS="4"
|
ARG THREADS="4"
|
||||||
ARG SHA=""
|
ARG SHA=""
|
||||||
|
|
||||||
# build minimized
|
# build minimized
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
RUN apk add --no-cache --virtual .build-tools git g++ build-base linux-headers cmake python3 && \
|
RUN set -xe && \
|
||||||
|
apk add --no-cache --virtual .build-tools git g++ build-base linux-headers cmake python3 && \
|
||||||
apk add --no-cache --virtual .build-deps curl-dev rapidjson-dev libevent-dev pcre2-dev yaml-cpp-dev && \
|
apk add --no-cache --virtual .build-deps curl-dev rapidjson-dev libevent-dev pcre2-dev yaml-cpp-dev && \
|
||||||
git clone https://github.com/ftk/quickjspp --depth=1 && \
|
git clone https://github.com/ftk/quickjspp --depth=1 && \
|
||||||
cd quickjspp && \
|
cd quickjspp && \
|
||||||
@@ -29,7 +30,7 @@ RUN apk add --no-cache --virtual .build-tools git g++ build-base linux-headers c
|
|||||||
install -d /usr/include/date/ && \
|
install -d /usr/include/date/ && \
|
||||||
install -m644 libcron/externals/date/include/date/* /usr/include/date/ && \
|
install -m644 libcron/externals/date/include/date/* /usr/include/date/ && \
|
||||||
cd .. && \
|
cd .. && \
|
||||||
git clone https://github.com/ToruNiina/toml11 --depth=1 && \
|
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1 && \
|
||||||
cd toml11 && \
|
cd toml11 && \
|
||||||
cmake -DCMAKE_CXX_STANDARD=11 . && \
|
cmake -DCMAKE_CXX_STANDARD=11 . && \
|
||||||
make install -j $THREADS && \
|
make install -j $THREADS && \
|
||||||
@@ -41,14 +42,19 @@ RUN apk add --no-cache --virtual .build-tools git g++ build-base linux-headers c
|
|||||||
python3 -m pip install gitpython && \
|
python3 -m pip install gitpython && \
|
||||||
python3 scripts/update_rules.py -c scripts/rules_config.conf && \
|
python3 scripts/update_rules.py -c scripts/rules_config.conf && \
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release . && \
|
cmake -DCMAKE_BUILD_TYPE=Release . && \
|
||||||
make -j $THREADS && \
|
make -j $THREADS
|
||||||
mv subconverter /usr/bin && \
|
|
||||||
mv base ../ && \
|
# build final image
|
||||||
cd .. && \
|
FROM alpine:3.16
|
||||||
rm -rf subconverter quickjspp libcron toml11 /usr/lib/lib*.a /usr/include/* /usr/local/include/lib*.a /usr/local/include/* && \
|
LABEL maintainer="tindy.it@gmail.com"
|
||||||
apk add --no-cache --virtual subconverter-deps pcre2 libcurl yaml-cpp libevent && \
|
|
||||||
apk del .build-tools .build-deps
|
RUN apk add --no-cache --virtual subconverter-deps pcre2 libcurl yaml-cpp libevent
|
||||||
|
|
||||||
|
COPY --from=builder /subconverter/subconverter /usr/bin/
|
||||||
|
COPY --from=builder /subconverter/base /base/
|
||||||
|
|
||||||
# set entry
|
# set entry
|
||||||
WORKDIR /base
|
WORKDIR /base
|
||||||
CMD subconverter
|
CMD subconverter
|
||||||
|
|
||||||
|
EXPOSE 25500/tcp
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ cd ..
|
|||||||
git clone https://github.com/jbeder/yaml-cpp --depth=1
|
git clone https://github.com/jbeder/yaml-cpp --depth=1
|
||||||
cd yaml-cpp
|
cd yaml-cpp
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOOLS=OFF . > /dev/null
|
cmake -DCMAKE_BUILD_TYPE=Release -DYAML_CPP_BUILD_TESTS=OFF -DYAML_CPP_BUILD_TOOLS=OFF . > /dev/null
|
||||||
make install -j2 > /dev/null
|
make install -j3 > /dev/null
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
git clone https://github.com/ftk/quickjspp --depth=1
|
git clone https://github.com/ftk/quickjspp --depth=1
|
||||||
cd quickjspp
|
cd quickjspp
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||||
make quickjs -j2
|
make quickjs -j3 > /dev/null
|
||||||
install -d /usr/lib/quickjs/
|
install -d /usr/lib/quickjs/
|
||||||
install -m644 quickjs/libquickjs.a /usr/lib/quickjs/
|
install -m644 quickjs/libquickjs.a /usr/lib/quickjs/
|
||||||
install -d /usr/include/quickjs/
|
install -d /usr/include/quickjs/
|
||||||
@@ -31,10 +31,10 @@ git clone https://github.com/PerMalmberg/libcron --depth=1
|
|||||||
cd libcron
|
cd libcron
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||||
make libcron install -j2
|
make libcron install -j3
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
git clone https://github.com/ToruNiina/toml11 --depth=1
|
git clone https://github.com/ToruNiina/toml11 --branch="v3.7.1" --depth=1
|
||||||
cd toml11
|
cd toml11
|
||||||
cmake -DCMAKE_CXX_STANDARD=11 .
|
cmake -DCMAKE_CXX_STANDARD=11 .
|
||||||
make install -j4
|
make install -j4
|
||||||
@@ -42,8 +42,9 @@ cd ..
|
|||||||
|
|
||||||
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig
|
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||||
make -j2
|
make -j3
|
||||||
rm subconverter
|
rm subconverter
|
||||||
|
# shellcheck disable=SC2046
|
||||||
g++ -o base/subconverter $(find CMakeFiles/subconverter.dir/src/ -name "*.o") -static -lpcre2-8 -levent -lyaml-cpp -L/usr/lib64 -lcurl -lmbedtls -lmbedcrypto -lmbedx509 -lz -l:quickjs/libquickjs.a -llibcron -O3 -s
|
g++ -o base/subconverter $(find CMakeFiles/subconverter.dir/src/ -name "*.o") -static -lpcre2-8 -levent -lyaml-cpp -L/usr/lib64 -lcurl -lmbedtls -lmbedcrypto -lmbedx509 -lz -l:quickjs/libquickjs.a -llibcron -O3 -s
|
||||||
|
|
||||||
python3 -m ensurepip
|
python3 -m ensurepip
|
||||||
|
|||||||
@@ -1,66 +1,78 @@
|
|||||||
import configparser, shutil, glob, os, random, string
|
import argparse
|
||||||
import stat, logging, argparse
|
import configparser
|
||||||
from git import InvalidGitRepositoryError, repo as GitRepo
|
import glob
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import shutil
|
||||||
|
import stat
|
||||||
|
from git import InvalidGitRepositoryError, Repo
|
||||||
|
|
||||||
|
|
||||||
def del_rw(action, name: str, exc):
|
def del_rw(action, name: str, exc):
|
||||||
os.chmod(name, stat.S_IWRITE)
|
os.chmod(name, stat.S_IWRITE)
|
||||||
os.remove(name)
|
os.remove(name)
|
||||||
|
|
||||||
|
|
||||||
def open_repo(path: str):
|
def open_repo(path: str):
|
||||||
if os.path.exists(repo_path) == False: return None
|
if not os.path.exists(path):
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
return GitRepo.Repo(path)
|
return Repo(path)
|
||||||
except InvalidGitRepositoryError:
|
except InvalidGitRepositoryError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
|
||||||
parser.add_argument("-c", "--config", default="rules_config.conf")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
def update_rules(repo_path, save_path, commit, matches, keep_tree):
|
||||||
config.read(args.config)
|
os.makedirs(save_path, exist_ok=True)
|
||||||
logging.basicConfig(format="%(asctime)s %(message)s", level=logging.DEBUG)
|
for pattern in matches:
|
||||||
|
files = glob.glob(os.path.join(repo_path, pattern), recursive=True)
|
||||||
|
for file in files:
|
||||||
|
if os.path.isdir(file):
|
||||||
|
continue
|
||||||
|
file_rel_path, file_name = os.path.split(os.path.relpath(file, repo_path))
|
||||||
|
if keep_tree:
|
||||||
|
file_dest_dir = os.path.join(save_path, file_rel_path)
|
||||||
|
os.makedirs(file_dest_dir, exist_ok=True)
|
||||||
|
file_dest_path = os.path.join(file_dest_dir, file_name)
|
||||||
|
else:
|
||||||
|
file_dest_path = os.path.join(save_path, file_name)
|
||||||
|
shutil.copy2(file, file_dest_path)
|
||||||
|
logging.info(f"copied {file} to {file_dest_path}")
|
||||||
|
|
||||||
for section in config.sections():
|
def main():
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("-c", "--config", default="rules_config.conf")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(args.config)
|
||||||
|
logging.basicConfig(format="%(asctime)s %(message)s", level=logging.DEBUG)
|
||||||
|
|
||||||
|
for section in config.sections():
|
||||||
repo = config.get(section, "name", fallback=section)
|
repo = config.get(section, "name", fallback=section)
|
||||||
url = config.get(section, "url")
|
url = config.get(section, "url")
|
||||||
commit = config.get(section, "checkout")
|
commit = config.get(section, "checkout")
|
||||||
matches = config.get(section, "match").split("|")
|
matches = config.get(section, "match").split("|")
|
||||||
save_path = config.get(section, "dest", fallback="base/rules/{}".format(repo))
|
save_path = config.get(section, "dest", fallback=f"base/rules/{repo}")
|
||||||
keep_tree = config.getboolean(section, "keep_tree", fallback=True)
|
keep_tree = config.getboolean(section, "keep_tree", fallback=True)
|
||||||
|
|
||||||
logging.info("reading files from url {} with commit {} and matches {}, save to {} keep_tree {}".format(url, commit, matches, save_path, keep_tree))
|
logging.info(f"reading files from url {url} with commit {commit} and matches {matches}, save to {save_path} keep_tree {keep_tree}")
|
||||||
|
|
||||||
# ran_str = ''.join(random.sample(string.ascii_letters + string.digits, 16))
|
|
||||||
repo_path = os.path.join("./tmp/repo/", repo)
|
repo_path = os.path.join("./tmp/repo/", repo)
|
||||||
|
|
||||||
r = open_repo(repo_path)
|
r = open_repo(repo_path)
|
||||||
if r != None:
|
if r is None:
|
||||||
logging.info("repo {} exists, checking out...".format(repo_path))
|
logging.info(f"cloning {url} to {repo_path}")
|
||||||
r.git.checkout(commit)
|
r = Repo.clone_from(url, repo_path)
|
||||||
else:
|
else:
|
||||||
logging.info("repo {} not exist, cloning...".format(repo_path))
|
logging.info(f"pulling changes for {repo} from {url}")
|
||||||
shutil.rmtree(repo_path, ignore_errors=True)
|
r.remotes.origin.pull()
|
||||||
os.makedirs(repo_path, exist_ok=True)
|
|
||||||
r = GitRepo.Repo.clone_from(url, repo_path)
|
|
||||||
r.git.checkout(commit)
|
r.git.checkout(commit)
|
||||||
|
update_rules(repo_path, save_path, commit, matches, keep_tree)
|
||||||
|
|
||||||
os.makedirs(save_path, exist_ok=True)
|
shutil.rmtree("./tmp", ignore_errors=True)
|
||||||
|
|
||||||
for pattern in matches:
|
|
||||||
files = glob.glob("{}/{}".format(repo_path, pattern), recursive=True)
|
|
||||||
for file in files:
|
|
||||||
if os.path.isdir(file): continue
|
|
||||||
|
|
||||||
(file_rel_path, file_name) = os.path.split(file.removeprefix(repo_path))
|
if __name__ == "__main__":
|
||||||
if keep_tree:
|
main()
|
||||||
file_dest_dir = "{}{}".format(save_path, file_rel_path)
|
|
||||||
file_dest_path = "{}/{}".format(file_dest_dir, file_name)
|
|
||||||
os.makedirs(file_dest_dir, exist_ok=True)
|
|
||||||
else:
|
|
||||||
file_dest_path = "{}{}".format(save_path, file_name)
|
|
||||||
|
|
||||||
shutil.copyfile(file, file_dest_path)
|
|
||||||
logging.info("copied {} to {}".format(file, file_dest_path))
|
|
||||||
|
|
||||||
shutil.rmtree("./tmp", onerror=del_rw)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user