mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/docker-easyconnect/docker-easyconnect.git
synced 2026-09-20 08:03:33 +08:00
Support non-amd64 deb package of EasyConnect
Since non-amd64 deb packages of EasyConnect are proved to exist (https://github.com/Hagb/docker-easyconnect/issues/25#issuecomment-1233369467), the deb package should not be assume to be amd64 and architecture specific code should be rewritten: - Add EC_HOST build argument to tell Dockerfile the architecture of EasyConnect package - Whether to install cross toolchain and qemu-user and which package should be install, is determined by EC_HOST and the local architecture now, more specifically by build-scripts/get-echost-names.sh (no longer hard-code amd64 cross toolchain) - fake-hwaddr.so should follow the architecture of the EC deb, so fake-hwaddr/Makefile uses CC envirnoment variable instead of hard-coded x86_64-linux-gnu-gcc as c compiler now - qemu_args is removed now. It was used to pass LD_PRELOAD to foreign binaries under qemu-user, but now we pass LD_PRELOAD to the qemu wrapper and wrapper will pass the LD_PRELOAD to the simulated binaries
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
ARG ANDROID_PATCH BUILD_ENV=local MIRROR_URL=http://ftp.cn.debian.org/debian/
|
||||
ARG ANDROID_PATCH BUILD_ENV=local MIRROR_URL=http://ftp.cn.debian.org/debian/ EC_HOST
|
||||
|
||||
COPY ["./build-scripts/config-apt.sh", "./build-scripts/add-qemu.sh", "/tmp/build-scripts/"]
|
||||
COPY ["./build-scripts/config-apt.sh", "./build-scripts/get-echost-names.sh", "./build-scripts/add-qemu.sh", \
|
||||
"/tmp/build-scripts/"]
|
||||
|
||||
RUN . /tmp/build-scripts/config-apt.sh && \
|
||||
. /tmp/build-scripts/get-echost-names.sh && \
|
||||
. /tmp/build-scripts/add-qemu.sh && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends --no-install-suggests \
|
||||
libgtk2.0-0 libx11-xcb1 libxtst6 libnss3 libasound2 libdbus-glib-1-2 iptables xclip\
|
||||
dante-server tigervnc-standalone-server tigervnc-tools psmisc flwm x11-utils \
|
||||
busybox libssl-dev iproute2 tinyproxy-bin libxss1 libgconf-2-4 ca-certificates \
|
||||
$extra_pkg && \
|
||||
$qemu_pkgs && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN groupadd -r socks && useradd -r -g socks socks
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
FROM debian:bookworm-slim AS build
|
||||
|
||||
ARG ANDROID_PATCH BUILD_ENV=local MIRROR_URL=http://ftp.cn.debian.org/debian/
|
||||
ARG ANDROID_PATCH BUILD_ENV=local MIRROR_URL=http://ftp.cn.debian.org/debian/ EC_HOST
|
||||
|
||||
COPY ["./build-scripts/config-apt.sh", "./build-scripts/add-qemu.sh", "/tmp/build-scripts/"]
|
||||
COPY ["./build-scripts/config-apt.sh", "./build-scripts/get-echost-names.sh", "/tmp/build-scripts/"]
|
||||
|
||||
RUN . /tmp/build-scripts/config-apt.sh && \
|
||||
. /tmp/build-scripts/add-qemu.sh && \
|
||||
gcc=gcc && if [ "$(dpkg --print-architecture)" != "amd64" ]; then \
|
||||
dpkg --add-architecture amd64 && gcc=gcc-x86-64-linux-gnu ; \
|
||||
fi && \
|
||||
. /tmp/build-scripts/get-echost-names.sh && \
|
||||
case "$(dpkg --print-architecture)" in \
|
||||
amd64 | i386 | arm64 ) go=golang-go ;; \
|
||||
* ) go=gccgo-go ;; \
|
||||
esac && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends --no-install-suggests ca-certificates \
|
||||
gcc $gcc libc6-dev:amd64 make busybox automake libssl-dev $go
|
||||
busybox libssl-dev automake $go $ecgccpkg build-essential
|
||||
|
||||
RUN mkdir results && cd results && mkdir fake-hwaddr tinyproxy-ws novnc
|
||||
|
||||
COPY fake-hwaddr /tmp/src/fake-hwaddr/
|
||||
|
||||
RUN cd /tmp/src/fake-hwaddr && make && install -D fake-hwaddr.so /results/fake-hwaddr/usr/local/lib/fake-hwaddr.so
|
||||
RUN . /tmp/build-scripts/get-echost-names.sh && \
|
||||
cd /tmp/src/fake-hwaddr && CC=${ec_cc} make clean all && install -D fake-hwaddr.so /results/fake-hwaddr/usr/local/lib/fake-hwaddr.so
|
||||
|
||||
# https://github.com/tinyproxy/tinyproxy/pull/211#issue-382736027
|
||||
ARG TINYPROXY_COMMIT=991e47d8ebd4b12710828b2b486535e4c25ba26c
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
ARG ANDROID_PATCH BUILD_ENV=local MIRROR_URL=http://ftp.cn.debian.org/debian/
|
||||
ARG ANDROID_PATCH BUILD_ENV=local MIRROR_URL=http://ftp.cn.debian.org/debian/ EC_HOST
|
||||
|
||||
COPY ["./build-scripts/config-apt.sh", "./build-scripts/add-qemu.sh", "/tmp/build-scripts/"]
|
||||
COPY ["./build-scripts/config-apt.sh", "./build-scripts/get-echost-names.sh", "./build-scripts/add-qemu.sh", \
|
||||
"/tmp/build-scripts/"]
|
||||
|
||||
RUN . /tmp/build-scripts/config-apt.sh && \
|
||||
. /tmp/build-scripts/get-echost-names.sh && \
|
||||
. /tmp/build-scripts/add-qemu.sh && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends --no-install-suggests iptables \
|
||||
libstdc++6:amd64 dante-server busybox iproute2 tinyproxy-bin ca-certificates ${extra_pkg} && \
|
||||
dante-server busybox iproute2 tinyproxy-bin ca-certificates ${qemu_pkgs} && \
|
||||
for command in ps kill killall; do ln -s "$(which busybox)" /usr/local/bin/"${command}" || exit 1 ; done && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
@@ -23,10 +25,8 @@ RUN EC_DIR=/usr/share/sangfor/EasyConnect/resources && cd /tmp && \
|
||||
bash -c "mkdir -p ${EC_DIR}/{bin,lib64,shell,logs}/" && \
|
||||
bash -c "cp easyconn/${EC_DIR}/bin/{CSClient,easyconn,ECAgent,svpnservice,ca.crt,cert.crt} \
|
||||
/${EC_DIR}/bin/" && \
|
||||
if [ "$(dpkg --print-architecture)" != "amd64" ]; then \
|
||||
extra_amd64_bins=easyconn /tmp/build-scripts/mk-qemu-wrapper.sh ; \
|
||||
fi && \
|
||||
bash -c "chmod +xs ${EC_DIR}/bin/{CSClient,ECAgent,svpnservice}*" && \
|
||||
bash -c "chmod +xs ${EC_DIR}/bin/{CSClient,ECAgent,svpnservice}" && \
|
||||
extra_bins=easyconn . /tmp/build-scripts/mk-qemu-wrapper.sh && \
|
||||
bash -c "cp easyconn/${EC_DIR}/lib64/lib{nspr4,nss3,nssutil3,plc4,plds4,smime3}.so \
|
||||
/${EC_DIR}/lib64/" && \
|
||||
cp easyconn/${EC_DIR}/shell/* \
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
FROM debian:bookworm-slim
|
||||
|
||||
ARG ANDROID_PATCH BUILD_ENV=local MIRROR_URL=http://ftp.cn.debian.org/debian/
|
||||
ARG ANDROID_PATCH BUILD_ENV=local MIRROR_URL=http://ftp.cn.debian.org/debian/ EC_HOST
|
||||
|
||||
COPY ["./build-scripts/config-apt.sh", "./build-scripts/add-qemu.sh", "/tmp/build-scripts/"]
|
||||
COPY ["./build-scripts/config-apt.sh", "./build-scripts/get-echost-names.sh", "./build-scripts/add-qemu.sh", \
|
||||
"/tmp/build-scripts/"]
|
||||
|
||||
RUN . /tmp/build-scripts/config-apt.sh && \
|
||||
. /tmp/build-scripts/get-echost-names.sh && \
|
||||
. /tmp/build-scripts/add-qemu.sh && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends --no-install-suggests $extra_pkg ca-certificates \
|
||||
apt-get install -y --no-install-recommends --no-install-suggests $qemu_pkgs ca-certificates \
|
||||
libgtk2.0-0 libx11-xcb1 libxtst6 libnss3 libasound2 libdbus-glib-1-2 iptables \
|
||||
dante-server psmisc libxaw7 xclip busybox libssl-dev iproute2 tinyproxy-bin libxss1 libgconf-2-4 && \
|
||||
cd /tmp && apt download x11-utils && dpkg -x x11-utils_*.deb x11-utils && \
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
if [ "$(dpkg --print-architecture)" != "amd64" ]; then
|
||||
dpkg --add-architecture amd64 && extra_pkg="qemu-user libc6:amd64 libstdc++6:amd64"
|
||||
if is_echost_foreign; then
|
||||
dpkg --add-architecture $EC_HOST && qemu_pkgs="qemu-user libc6:$EC_HOST libstdc++6:$EC_HOST"
|
||||
fi
|
||||
|
||||
@@ -11,5 +11,4 @@ if [ "${BUILD_ENV}" = "local" ]; then
|
||||
fi
|
||||
else
|
||||
echo "Warning: The BUILD_ENV build argument has been deprecated and will be removed. Please use MIRROR_URL instead." >&2
|
||||
fi &&
|
||||
extra_apk=""
|
||||
fi
|
||||
|
||||
37
build-scripts/get-echost-names.sh
Normal file
37
build-scripts/get-echost-names.sh
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/bin/sh
|
||||
if [ -z "$EC_HOST" -o "$(dpkg --print-architecture)" = "$EC_HOST" ]; then
|
||||
ecgccpkg=build-essential
|
||||
ecprefix=
|
||||
ec_cc=gcc
|
||||
is_echost_foreign=
|
||||
is_echost_foreign() { false; }
|
||||
else
|
||||
case "$EC_HOST" in
|
||||
i386 )
|
||||
ecqemu=qemu-i386
|
||||
ecgccpkg=crossbuild-essential-i386
|
||||
ecprefix=i386-linux-gnu ;;
|
||||
amd64 )
|
||||
ecqemu=qemu-x86_64
|
||||
ecgccpkg=crossbuild-essential-amd64
|
||||
ecprefix=x86_64-linux-gnu ;;
|
||||
armhf )
|
||||
ecqemu=qemu-arm
|
||||
ecgccpkg=crossbuild-essential-armhf
|
||||
ecprefix=arm-linux-gnueabihf ;;
|
||||
arm64 )
|
||||
ecqemu=qemu-aarch64
|
||||
ecgccpkg=crossbuild-essential-arm64
|
||||
ecprefix=aarch64-linux-gnu ;;
|
||||
mips64el )
|
||||
ecqemu=qemu-mips64el
|
||||
ecgccpkg=crossbuild-essential-mips64el
|
||||
ecprefix=mips64el-linux-gnuabi64 ;;
|
||||
* )
|
||||
echo "Unsupported platform ${EC_HOST}" >&2
|
||||
false ;;
|
||||
esac &&
|
||||
ec_cc=${ecprefix}-gcc &&
|
||||
is_echost_foreign=1 &&
|
||||
is_echost_foreign() { true; }
|
||||
fi
|
||||
@@ -1,12 +1,12 @@
|
||||
#!/bin/bash
|
||||
cd /tmp &&
|
||||
. ./build-scripts/get-echost-names.sh &&
|
||||
busybox wget "${EC_URL}" -O EasyConnect.deb &&
|
||||
if [ "$(dpkg --print-architecture)" != "amd64" ]; then
|
||||
if is_echost_foreign; then
|
||||
dpkg-deb -R EasyConnect.deb / &&
|
||||
/DEBIAN/postinst &&
|
||||
rm -r /DEBIAN &&
|
||||
extra_amd64_bins=EasyMonitor ./build-scripts/mk-qemu-wrapper.sh &&
|
||||
chmod +s /usr/share/sangfor/EasyConnect/resources/bin/{CSClient,ECAgent,svpnservice}*
|
||||
extra_bins=EasyMonitor ./build-scripts/mk-qemu-wrapper.sh
|
||||
else
|
||||
dpkg -i EasyConnect.deb
|
||||
fi &&
|
||||
@@ -16,7 +16,7 @@ rm -f /usr/share/sangfor/EasyConnect/resources/conf/easy_connect.json &&
|
||||
mv /usr/share/sangfor/EasyConnect/resources/conf/ /usr/share/sangfor/EasyConnect/resources/conf_backup &&
|
||||
ln -s /root/conf /usr/share/sangfor/EasyConnect/resources/conf &&
|
||||
|
||||
if [ "$(dpkg --print-architecture)" == "amd64" -a ! -z "${USE_EC_ELECTRON}" ]; then
|
||||
if ! is_echost_foreign && [ ! -z "${USE_EC_ELECTRON}" ] ; then
|
||||
exit 0
|
||||
fi &&
|
||||
|
||||
@@ -27,7 +27,6 @@ declare -A ELECTRON_URLS &&
|
||||
ELECTRON_URLS=(
|
||||
[amd64]=https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-linux-x64.zip
|
||||
[i386]=https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-linux-ia32.zip
|
||||
[armel]=https://github.com/electron/electron/releases/download/v1.7.16/electron-v1.7.16-linux-armv7l.zip
|
||||
[armhf]=https://github.com/electron/electron/releases/download/v1.7.16/electron-v1.7.16-linux-armv7l.zip
|
||||
[arm64]=https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-linux-arm64.zip
|
||||
[mips64el]=https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-linux-mips64el.zip
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#!/bin/bash
|
||||
for exec in CSClient ECAgent svpnservice $extra_amd64_bins; do
|
||||
#!/bin/sh
|
||||
. /tmp/build-scripts/get-echost-names.sh &&
|
||||
{
|
||||
! is_echost_foreign ||
|
||||
for exec in CSClient ECAgent svpnservice $extra_bins; do
|
||||
exec_path=/usr/share/sangfor/EasyConnect/resources/bin/$exec &&
|
||||
mkdir -p /usr/local/libexec/qemu-hack/ &&
|
||||
qemu_path=/usr/local/libexec/qemu-hack/$exec &&
|
||||
@@ -7,9 +10,14 @@ for exec in CSClient ECAgent svpnservice $extra_amd64_bins; do
|
||||
mv ${exec_path} ${exec_path}-origin &&
|
||||
|
||||
# 一个让 qemu 产生的进程名字和原生运行时名字一致的 hack(便于 killall 杀进程):使 qemu 的文件名和被模拟程序文件名一致
|
||||
ln -s /usr/bin/qemu-x86_64 ${qemu_path} &&
|
||||
ln -s /usr/bin/${ecqemu} ${qemu_path} &&
|
||||
|
||||
# 将原可执行文件用 qemu 封装起来
|
||||
printf '%s\n%s\n' '#!/bin/sh' "exec ${qemu_path} \${qemu_args} ${exec_path}-origin "'"$@"' > ${exec_path} &&
|
||||
chmod +x ${exec_path} ${exec_path}-origin || exit 1
|
||||
printf '%s\n%s' \
|
||||
'#!/bin/sh' \
|
||||
"LD_PRELOAD= exec ${qemu_path} -E LD_PRELOAD=\"\${LD_PRELOAD}\" ${exec_path}-origin \"\$@\"" > ${exec_path} &&
|
||||
chown --reference=${exec_path}-origin ${exec_path} &&
|
||||
chmod --reference=${exec_path}-origin ${exec_path} ||
|
||||
exit 1
|
||||
done
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
## 构建参数
|
||||
|
||||
- `EC_URL`(仅适用于图形界面版): EasyConnect 的 deb 包下载地址,各版本的下载地址可见于 [../ec\_urls/](../ec_urls/)。
|
||||
- `EC_HOST`: EasyConnect deb 包的架构,默认为空表示 deb 包架构与容器运行的架构一致;以 Debian 包管理器的架构名可准,可选项为:`aarch64`、`amd64`、`armel`、`armhf`、`i386`、`misp64el`。
|
||||
- `ELECTRON_URL`(仅适用于图形界面版): [electron](https://github.com/electron/electron/releases) 的下载地址,用于在非 amd64 架构中将 EasyConnect 前端自带的 electron 替换成可原生执行的 electron(使用 qemu 时原生 electron 可以减小翻译开销;来自 EasyConnect 的 electron 在 Debian bookworm 上有段错误的现象),有一些注意事项:
|
||||
|
||||
- `armel`、`armhf`、`arm64`、`mips64el`、`amd64`、`i386` 架构无需设定该参数,构建脚本中已经预设(有特殊需要可以使用该参数覆盖预设值)
|
||||
@@ -24,6 +25,7 @@
|
||||
|
||||
### `Dockerfile.build` 构建参数
|
||||
|
||||
- `EC_HOST`: EasyConnect deb 包的架构,同上文
|
||||
- `MIRROR_URL`: Debian 镜像站,同上文
|
||||
- `TINYPROXY_COMMIT`: 构建支持 websocket 的 [tinyproxy](https://github.com/tinyproxy/tinyproxy) 的 commit.
|
||||
- `NOVNC_METHOD`: 提供 noVNC 服务的方式,默认为 `min-size`,可选选项有
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
#!/bin/bash
|
||||
fake-hwaddr-run() { "$@" ; }
|
||||
qemu_args=""
|
||||
if [ -n "$FAKE_HWADDR" ]; then
|
||||
if [ "$(dpkg --print-architecture)" = "amd64" ]; then
|
||||
fake-hwaddr-run() { LD_PRELOAD=/usr/local/lib/fake-hwaddr.so "$@" ; }
|
||||
else
|
||||
fake-hwaddr-run() { qemu_args="-E LD_PRELOAD=/usr/local/lib/fake-hwaddr.so" "$@" ; }
|
||||
fi
|
||||
fi
|
||||
[ -z "$_EC_CLI" ] && /usr/share/sangfor/EasyConnect/resources/bin/EasyMonitor
|
||||
|
||||
@@ -42,12 +37,12 @@ do
|
||||
} &
|
||||
|
||||
# 下面这行代码启动 EasyConnect 的前端。
|
||||
fake-hwaddr-run /usr/share/sangfor/EasyConnect/EasyConnect --enable-transparent-visuals --disable-gpu
|
||||
/usr/share/sangfor/EasyConnect/EasyConnect --enable-transparent-visuals --disable-gpu
|
||||
else
|
||||
fake-hwaddr-run /usr/share/sangfor/EasyConnect/resources/bin/ECAgent &
|
||||
sleep 1
|
||||
fake-hwaddr-run easyconn login -t autologin
|
||||
pidof svpnservice > /dev/null || fake-hwaddr-run bash -c "exec easyconn login $CLI_OPTS"
|
||||
pidof svpnservice > /dev/null || bash -c "exec easyconn login $CLI_OPTS"
|
||||
# # 重启一下 tinyproxy
|
||||
# service tinyproxy restart
|
||||
while pidof svpnservice > /dev/null ; do
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
fake-hwaddr.so: fake-hwaddr.c
|
||||
x86_64-linux-gnu-gcc --shared -o fake-hwaddr.so fake-hwaddr.c -ldl -fPIC
|
||||
.PHONY: all clean
|
||||
|
||||
all: fake-hwaddr.so
|
||||
|
||||
fake-hwaddr.so: fake-hwaddr.c
|
||||
${CC} --shared -o fake-hwaddr.so fake-hwaddr.c -ldl -fPIC
|
||||
|
||||
clean:
|
||||
-rm fake-hwaddr.so
|
||||
|
||||
Reference in New Issue
Block a user