feat:snap

This commit is contained in:
msojocs 2022-04-17 18:07:11 +08:00
parent 484f25b953
commit c9a5f824a8
10 changed files with 242 additions and 36 deletions

3
.gitignore vendored
View File

@ -18,4 +18,5 @@ temp.sh
# flatpak
.flatpak-builder
build-dir
__pycache__
__pycache__
*.txt

View File

@ -1,14 +0,0 @@
#!/bin/bash
xhost +
docker run \
-t -i --rm \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
-v $HOME/.Xauthority:/root/.Xauthority \
-e DISPLAY=unix:0.0 \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
--privileged \
wechat-devtools /opt/wechat/devtools/bin/docker-entrypoint

27
bin/wechat-devtools-snap Normal file
View File

@ -0,0 +1,27 @@
#!/bin/bash
echo "SNAP 启动"
root_dir=$(cd `dirname $0`/.. && pwd -P)
echo "root_dir: $root_dir"
ls -l "$root_dir"
export WECHAT_DEVTOOLS_DIR="$root_dir/nwjs"
export APPDATA="$SNAP_USER_DATA/.config/wechat_devtools"
export PATH="$root_dir/wine:$root_dir/node/bin:$root_dir/nwjs:$PATH"
export USERPROFILE=$SNAP_USER_DATA
ls -l /usr/lib/x86_64-linux-gnu
ls -l /usr/lib
echo -e "\033[46;37m环境变量: \033[0m"
env
# LANG=zh_CN.UTF-8 exec "$DIR"/../nwjs/nw --load-extension="$DIR"/../nwjs/package.nw/js/ideplugin "$@"
EXTENSION1="--load-extension=$SNAP/package.nw/js/ideplugin"
EXTENSION2="--load-extension=$SNAP_USER_DATA/.config/wechat_devtools/WeappPlugin"
INSPECTOR1="--custom-devtools-frontend=file://$SNAP/package.nw/js/ideplugin/inspector" # 要加file://指明为本地文件路径
INSPECTOR2="--custom-devtools-frontend=file://$SNAP_USER_DATA/.config/wechat_devtools/WeappPlugin/inspector/"
USERDATADIR="$SNAP_USER_DATA/.config/wechat_devtools"
# "$@"参数
LANG=zh_CN.UTF-8
"$SNAP/nw" $EXTENSION2 $INSPECTOR1 "$@"

View File

@ -0,0 +1,15 @@
#!/bin/bash
# 由于var目录空间大小不够故修改multipass镜像的存储位置
# https://github.com/canonical/multipass/pull/1789#issuecomment-704991752
# as root
snap stop multipass
snap connect multipass:removable-media # for /mnt /media https://snapcraft.io/docs/removable-media-interface
snap connect multipass:all-home # for /home/* https://snapcraft.io/docs/home-interface
mkdir -p /mnt/disk2/multipass
mkdir /etc/systemd/system/snap.multipass.multipassd.service.d/
tee /etc/systemd/system/snap.multipass.multipassd.service.d/override.conf <<EOF
[Service]
Environment=MULTIPASS_STORAGE=/mnt/disk2/multipass
EOF
systemctl daemon-reload
snap start multipass

View File

@ -0,0 +1,3 @@
[Desktop Entry]
Name=WeChat Dev Tools
Exec=env APPDATA=${SNAP_USER_DATA} USERPROFILE=~ ${SNAP}/nw --load-extension=${SNAP}/package.nw/js/ideplugin --custom-devtools-frontend=file://${SNAP}/package.nw/js/ideplugin/inspector %U

159
snap/snapcraft.yaml Normal file
View File

@ -0,0 +1,159 @@
name: wechat-devtools # you probably want to 'snapcraft register <name>'
base: core18 # the base snap is the execution environment for this snap
version: '0.1' # just for humans, typically '1.2+git' or '1.3.2'
summary: WeChat Devtools for Linux # 79 char long summary
description: |
WeChat Devtools for Linux.
grade: stable # must be 'stable' to release into candidate/stable channels
confinement: strict # use 'strict' once you have the right plugs and slots
architectures:
- build-on: [amd64]
run-on: [amd64]
# pull
# build
# stage
# prime
# snap
# /root/parts/my-part/src/nw
parts:
# compiler:
# plugin: nil
# source: https://download.fastgit.org/msojocs/wechat-devtools-linux/releases/download/v0.6/compiler.tar.xz
node-js:
plugin: dump
source: https://npmmirror.com/mirrors/node/v16.4.2/node-v16.4.2-linux-x64.tar.gz
# source: './cache/node-v16.4.2-linux-x64.tar.gz'
organize:
"*": nodejs/
stage:
- nodejs/*
devtools:
plugin: dump
source: https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=1052203070&version_type=1
# source: ./cache/wechat_devtools_1.05.2201240_x64.exe
source-type: 7z
source-subdir: ./code
build-environment:
- PATH: "$SNAPCRAFT_STAGE/nodejs/bin:$PATH"
- NW_VERSION: 0.55.0
# - NW_PACKAGE_DIR: "$SNAPCRAFT_PART_BUILD/code/package.nw"
# - srcdir: "$SNAPCRAFT_PROJECT_DIR"
build-packages:
- python2.7
- libxkbfile-dev
- pkg-config
- libkrb5-dev
- gcc
- g++
- make
- openssl
- libssh2-1-dev
override-build: |
env
echo "3"
ls -l $SNAPCRAFT_STAGE
ls -l $SNAPCRAFT_PROJECT_DIR
# 执行构建脚本
chmod -R 755 $SNAPCRAFT_PART_BUILD/code/package.nw
npm install node-gyp nw-gyp -g --registry=https://registry.npm.taobao.org
node-gyp install --registry=https://registry.npm.taobao.org
cp -r "${SNAPCRAFT_PROJECT_DIR}/tools" "$SNAPCRAFT_PART_BUILD/code/tools"
cp -r "${SNAPCRAFT_PROJECT_DIR}/compiler" "$SNAPCRAFT_PART_BUILD/code/compiler"
for script in fix-package-name.js fix-cli.sh fix-core.sh fix-other.sh; do
echo -e "\e[1;34mrun ${script}\e[0m"
"${SNAPCRAFT_PART_BUILD}/code/tools/${script}"
done
# 构建模块
"${SNAPCRAFT_PART_BUILD}/code/tools/rebuild-node-modules.sh" $NW_VERSION
rm -rf "${SNAPCRAFT_PART_BUILD}/code/tools"
snapcraftctl build
stage-packages:
- libxkbfile1
- git-core
override-prime: |
snapcraftctl prime
rm -rf node node.exe
cp "$SNAPCRAFT_PRIME/nodejs/bin/node" "$SNAPCRAFT_PRIME/node"
ln -s "node" "node.exe"
after:
- node-js
# - compiler
# - desktop-gnome-platform
nw-js:
plugin: dump
source: https://npmmirror.com/mirrors/nwjs/v0.55.0/nwjs-sdk-v0.55.0-linux-x64.tar.gz
# source: ./cache/nwjs-sdk-v0.55.0-linux-x64.tar.gz
stage-packages:
- libnss3
- libnspr4
run-script:
plugin: nil
override-build: |
snapcraftctl build
cp "${SNAPCRAFT_PROJECT_DIR}/bin/wechat-devtools-snap" "$SNAPCRAFT_PART_INSTALL/wechat-devtools-snap"
stage:
- wechat-devtools-snap
zzz:
plugin: nil
# source: https://npmmirror.com/mirrors/nwjs/v0.53.1/nwjs-sdk-v0.53.1-linux-x64.tar.gz
override-stage: |
echo "6"
env
ls -l $SNAPCRAFT_STAGE
apps:
wechat-devtools:
# autostart: wechat-devtools.desktop
command: desktop-launch $SNAP/wechat-devtools-snap
environment:
WECHAT_DEVTOOLS_DIR: $SNAP/nwjs
APPDATA: "$SNAP_USER_DATA/wechat_devtools"
PATH: "$SNAP/node/bin:$SNAP/nwjs:$PATH"
USERPROFILE: $SNAP_USER_DATA
GIT_EXEC_PATH: $SNAP/usr/lib/git-core
extensions:
- gnome-3-34
plugs:
- desktop
- desktop-legacy
- opengl
- mount-observe
- x11
- wayland
- network
- network-bind
- gsettings
- browser-support
- password-manager-service
plugs:
gtk-3-themes:
interface: content
target: $SNAP/data-dir/themes
default-provider: gtk-common-themes
icon-themes:
interface: content
target: $SNAP/data-dir/icons
default-provider: gtk-common-themes
sound-themes:
interface: content
target: $SNAP/data-dir/sounds
default-provider: gtk-common-themes
# platform_snap:
# interface: content
# target: $SNAP/gnome-platform
# default-provider: gnome-3-34-1804

9
test/nw-gyp.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
root_dir=$(cd `dirname $0`/.. && pwd -P)
NW_VERSION=0.53.0
ln -s $( which python2 ) "$root_dir/tmp/python"
export PATH="$root_dir/tmp:$PATH"
export all_proxy="sock5://127.0.0.1:7890"
cd /mnt/disk1/GitHub/wechat-devtools-linux/node_modules/node-pty
nw-gyp rebuild --arch=x64 "--target=$NW_VERSION" --dist-url=https://registry.npmmirror.com/-/binary/nwjs

6
test/snap.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
cd "/mnt/disk1/GitHub/wechat-devtools-linux"
snapcraft #--http-proxy="http://192.168.249.236:7890" --https-proxy="http://192.168.249.236:7890"
snap install wechat-devtools_0.1_amd64.snap --devmode
wechat-devtools

View File

@ -21,10 +21,10 @@ exit
echo "$@ $0 $1 $2"
root_dir=$(cd `dirname $0`/.. && pwd -P)
export PATH="$root_dir/node/bin:$PATH"
PY_VERSION=`python -V 2>&1|awk '{print $2}'|awk -F '.' '{print $1}'`
echo $PY_VERSION
if [ "$PY_VERSION" == "Python 3.10.1" ]; then
echo ok
fi
cd $root_dir/tmp
export HTTPS_PROXY="http://127.0.0.1:7890"
# npm uninstall vscode-ripgrep
# npm install vscode-ripgrep
cd $root_dir/tmp/node_modules/vscode-ripgrep
rm -rf bin /tmp/vscode-ripgrep-cache-1.13.2/ripgrep-v13.0.0-4-x86_64-unknown-linux-musl.tar.gz
npm run postinstall

View File

@ -27,15 +27,15 @@ hash nw-gyp 2>/dev/null || {
}
# 代理处理
echo "尝试取消所有代理"
unset http_proxy
unset HTTP_PROXY
unset https_proxy
unset HTTPS_PROXY
unset socket_proxy
unset SOCKET_PROXY
unset all_proxy
unset ALL_PROXY
# echo "尝试取消所有代理"
# unset http_proxy
# unset HTTP_PROXY
# unset https_proxy
# unset HTTPS_PROXY
# unset socket_proxy
# unset SOCKET_PROXY
# unset all_proxy
# unset ALL_PROXY
echo -e "\033[42;37m ######## 版本信息 $(date '+%Y-%m-%d %H:%M:%S') ########\033[0m"
echo "NW VERSION: $NW_VERSION"
@ -80,10 +80,10 @@ export JOBS=$max_thread
spdlog@0.11.1 \
trash \
vscode-oniguruma \
vscode-ripgrep \
@vscode/ripgrep \
nodegit \
--registry=http://registry.npmmirror.com \
--nodegit_binary_host_mirror=http://npmmirror.com/mirrors/nodegit/v0.27.0/) # reinstall modules
--registry=https://registry.npmmirror.com \
--nodegit_binary_host_mirror=https://npmmirror.com/mirrors/nodegit/v0.27.0/ ) # reinstall modules
# rebuild
cd "$package_dir/node_modules_tmp/node_modules/node-pty" && nw-gyp rebuild --arch=x64 "--target=$NW_VERSION" --dist-url=https://registry.npmmirror.com/-/binary/nwjs
@ -105,14 +105,14 @@ cd "$package_dir/node_modules_tmp/node_modules/spdlog" && nw-gyp rebuild --arch=
(cd "${package_dir}/node_modules_tmp/node_modules" && find -name ".deps" | xargs -I{} rm -rf {} && find -name "obj.target" | xargs -I{} rm -rf {} && find -name "*.a" -delete && find -name "*.lib" -delete && find -name "*.mk" -delete)
(cd "${package_dir}/node_modules_tmp/node_modules" && find -name "*.node" | xargs -I{} \cp -rf {} ${package_dir}/node_modules/{})
cd "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep" && \
cd "${package_dir}/node_modules_tmp/node_modules/@vscode/ripgrep" && \
sed -i 's/api.github.com/wechat-devtools.jiyecafe.workers.dev/' lib/download.js && \
sed -i "s/ const release/ downloadOpts.headers.upstream = 'api.github.com';const release/" lib/download.js && \
sed -i "s/ return download/ opts.headers.upstream = 'objects.githubusercontent.com';return download/" lib/download.js && \
sed -i 's/response.headers.location,/response.headers.location.replace("objects.githubusercontent.com", "wechat-devtools.jiyecafe.workers.dev"),/' lib/download.js && \
npm run postinstall
mkdir -p "${package_dir}/node_modules/vscode-ripgrep/bin"
\cp -fr "${package_dir}/node_modules_tmp/node_modules/vscode-ripgrep/bin/rg" "${package_dir}/node_modules/vscode-ripgrep/bin/rg"
\cp -fr "${package_dir}/node_modules_tmp/node_modules/@vscode/ripgrep/bin/rg" "${package_dir}/node_modules/vscode-ripgrep/bin/rg"
(cd "${package_dir}/node_modules" && find -name ".deps" | xargs -I{} rm -rf {} && find -name "obj.target" | xargs -I{} rm -rf {} && find -name "*.a" -delete && find -name "*.lib" -delete && find -name "*.mk" -delete && find -name "*Makefile" -delete && find -name "*gyp*" -delete)
rm -rf "${package_dir}/node_modules_tmp"