update: flatpak

This commit is contained in:
msojocs 2022-04-06 23:34:18 +08:00
parent b00dfb3ef7
commit 9f7fd4ed39
5 changed files with 223 additions and 177 deletions

41
.github/workflows/flatpak-verify.yml vendored Normal file
View File

@ -0,0 +1,41 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build Packages
on:
release:
types: [published]
push:
tags:
- v*
branches: [ master, dev]
pull_request:
branches: [ master ]
# # Allows you to run this workflow manually from the Actions tab
# workflow_dispatch:
jobs:
flatpak:
name: "Flatpak"
runs-on: ubuntu-latest
container:
image: bilelmoussaoui/flatpak-github-actions:freedesktop-21.08
options: --privileged
strategy:
matrix:
arch: [x86_64]
# Don't fail the whole workflow if one architecture fails
fail-fast: false
steps:
- uses: actions/checkout@v2
# Docker is required by the docker/setup-qemu-action which enables emulation
- name: Install deps
run: |
dnf -y install docker
- uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v4
with:
bundle: wechat-devtools.flatpak
manifest-path: io.github.msojocs.wechat-devtools.yml
cache-key: flatpak-builder-${{ github.sha }}
arch: ${{ matrix.arch }}

View File

@ -0,0 +1,181 @@
app-id: io.github.msojocs.wechat-devtools
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
sdk-extensions:
- org.freedesktop.Sdk.Extension.node12
command: startup
finish-args:
# X11 + XShm access
- --share=ipc
- --socket=x11
# Wayland access
- --socket=wayland
# Needs to talk to the network:
- --share=network
# Needs to save files locally
- --filesystem=host
- --metadata=X-DConf=migrate-path=/org/gnome/dictionary/
modules:
- name: nwjs
buildsystem: simple
sources:
- type: archive
url: http://npmmirror.com/mirrors/nwjs/v0.53.1/nwjs-sdk-v0.53.1-linux-x64.tar.gz
md5: b6f49803c51d0abacca2d1e566c7fe19
build-commands:
- ls -l
- mkdir -p /app/opt/nwjs
- mv * /app/opt/nwjs
- name: package.nw
buildsystem: simple
sources:
- type: archive
url: https://servicewechat.com/wxa-dev-logic/download_redirect?type=x64&from=mpwiki&download_version=1052203070&version_type=1
md5: 2785d569b88d72a8e238d438d92faf44
archive-type: 7z
path: code
strip-components: 0
dest-filename: wechat_devtools.7z
build-commands:
- ls -l
- mv code/package.nw /app/opt/package.nw
- name: nodejs
buildsystem: simple
build-options:
prepend-path: /app/opt/nodejs/bin
build-args:
- --share=network
sources:
- type: archive
url: https://npmmirror.com/mirrors/node/v16.1.0/node-v16.1.0-linux-x64.tar.gz
md5: 2280bfbbf29981fd5adce334f40146ff
build-commands:
- ls -l
- mkdir -p /app/opt/nodejs
- mv * /app/opt/nodejs
- npm config set registry https://registry.npmmirror.com # 注册模块镜像
- npm config set disturl https://npmmirror.com/dist # node-gyp 编译依赖的 node 源码镜像
- npm install -g npm@8.6.0
- npm --version
- npm -g install nw-gyp node-gyp
- name: library
buildsystem: simple
build-commands:
- for file in *.deb; do ar p $file data.tar.xz | tar -xJ; done;
post-install:
- rm -rf usr/share/{doc,man}
- cp -dr usr/* $FLATPAK_DEST/
# - cp -dr lib/* $FLATPAK_DEST/lib
# - cp -dr opt/* $FLATPAK_DEST/
sources:
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libkrb5-dev_1.18.3-6+deb11u1_amd64.deb
sha256: d3a4a4705329c51d7a9843a72f87421938eeeef8548b3f2d46ce83f0862f9311
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/krb5-multidev_1.18.3-6+deb11u1_amd64.deb
sha256: b8bbee0879e6041ebbf58f62e1a526cc25225d67c140d5593b1341cc31388351
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libkrb5-3_1.18.3-6+deb11u1_amd64.deb
sha256: afb9dced3fcbdbc439a166eaa217dbfd485585842f12ce4587123009618e8bfe
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libk5crypto3_1.18.3-6+deb11u1_amd64.deb
sha256: 4a010fc69322b6be9e141a76593f46e6588c968ee3b7cf79a3b8b7efda9aeeba
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libgssapi-krb5-2_1.18.3-6+deb11u1_amd64.deb
sha256: 2ab853cbd0494c06fa694906c6eeea4df79720f461c76d080eb21a3e98f44115
- name: build
buildsystem: simple
build-options:
ldflags: -L/app/lib/x86_64-linux-gnu
prepend-path: /app/opt/nodejs/bin:/usr/lib/sdk/node12/bin
build-args:
- --share=network
prepend-ld-library-path: /app/lib/x86_64-linux-gnu
env:
NO_WINE: true
sources:
# - type: git
# branch: dev
# url: https://github.com/msojocs/wechat-web-devtools-linux.git
- type: dir
path: tools
dest: tools
- type: dir
path: compiler
dest: compiler
build-commands:
- env
- echo $PATH
- ln -s /app/opt/package.nw package.nw
- cd package.nw && ls -l
- python --version
- python3 --version
- python2 --version
- node --version
- tools/fix-package-name.js
- tools/fix-selection-copy-node
- tools/fix-cli.sh
- tools/fix-core.sh
- tools/fix-menu.sh
- tools/fix-other.sh
- tools/rebuild-node-modules.sh 0.53.1
# - ls -l
- name: library
buildsystem: simple
build-commands:
- for file in *.deb; do ar p $file data.tar.xz | tar -xJ; done;
post-install:
- rm -rf usr/share/{doc,man}
- cp -dr usr/* $FLATPAK_DEST/
- cp -dr lib/* $FLATPAK_DEST/lib
# - cp -dr opt/* $FLATPAK_DEST/
sources:
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libgssapi-krb5-2_1.18.3-6+deb11u1_amd64.deb
sha256: 2ab853cbd0494c06fa694906c6eeea4df79720f461c76d080eb21a3e98f44115
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libkrb5-3_1.18.3-6+deb11u1_amd64.deb
sha256: afb9dced3fcbdbc439a166eaa217dbfd485585842f12ce4587123009618e8bfe
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libk5crypto3_1.18.3-6+deb11u1_amd64.deb
sha256: 4a010fc69322b6be9e141a76593f46e6588c968ee3b7cf79a3b8b7efda9aeeba
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libkrb5support0_1.18.3-6+deb11u1_amd64.deb
sha256: 1f19908dbd37bd2ba9b3b3c9eb6ab8bee9a72f72745e6887f5366bb5fece654b
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/keyutils/libkeyutils1_1.6.1-2_amd64.deb
sha256: f01060b434d8cad3c58d5811d2082389f11b3db8152657d6c22c1d298953f2a5
- name: clean
buildsystem: simple
build-commands:
- cp /app/opt/nodejs/bin/node /app/opt/nwjs
- cd /app/opt/nwjs && ln -s node node.exe
- rm -rf /app/opt/nodejs
- name: startup
buildsystem: simple
build-commands:
- sed -i 's/Icon=dir\/res\/icons\/wechat-devtools.svg/Icon=io.github.msojocs.wechat_devtools/' template.desktop
- sed -i 's/Exec=dir\/bin\/wechat-devtools/Exec=startup/' template.desktop
post-install:
- install -Dm755 wechat-devtools /app/opt/bin/wechat-devtools
- install -Dm755 startup.sh /app/bin/startup
- install -Dm644 template.desktop /app/share/applications/io.github.msojocs.wechat-devtools.desktop
- install -Dm644 wechat-devtools.svg /app/share/icons/hicolor/scalable/apps/io.github.msojocs.wechat-devtools.svg
sources:
- type: file
path: bin/wechat-devtools
- type: file
path: res/flatpak/startup.sh
- type: file
path: res/template.desktop
- type: file
path: res/icons/wechat-devtools.svg

View File

@ -1,83 +0,0 @@
app-id: io.github.msojocs.wechat-devtools
runtime: org.freedesktop.Platform
runtime-version: '21.08'
sdk: org.freedesktop.Sdk
command: startup
finish-args:
# X11 + XShm access
- --share=ipc
- --socket=x11
# Wayland access
- --socket=wayland
# Needs to talk to the network:
- --share=network
# Needs to save files locally
- --filesystem=host
- --metadata=X-DConf=migrate-path=/org/gnome/dictionary/
modules:
- name: nwjs
buildsystem: simple
sources:
- type: dir
# url: https://npm.taobao.org/mirrors/nwjs/v0.53.1/nwjs-sdk-v0.53.1-linux-x64.tar.gz
# md5: b6f49803c51d0abacca2d1e566c7fe19
path: nwjs
build-commands:
- ls -l
- rm package.nw
- mkdir -p /app/opt/nwjs
- cp -r . /app/opt/nwjs
- name: package.nw
buildsystem: simple
sources:
- type: dir
# url: https://npm.taobao.org/mirrors/nwjs/v0.53.1/nwjs-sdk-v0.53.1-linux-x64.tar.gz
# md5: b6f49803c51d0abacca2d1e566c7fe19
path: package.nw
build-commands:
- ls -l
- mkdir -p /app/opt/package.nw
- cp -r . /app/opt/package.nw
- name: wechat-devtools
buildsystem: simple
build-commands:
- install -Dm755 wechat-devtools /app/opt/bin/wechat-devtools
- install -Dm755 startup.sh /app/bin/startup
- install -Dm644 io.github.msojocs.wechat_devtools.desktop /app/share/applications/io.github.msojocs.wechat-devtools.desktop
- install -Dm644 io.github.msojocs.wechat_devtools.svg /app/share/icons/hicolor/scalable/apps/io.github.msojocs.wechat-devtools.svg
- ar p libgssapi-krb5-2_1.18.3-6+deb11u1_amd64.deb data.tar.xz | tar -xJ
- ar p libkrb5-3_1.18.3-6+deb11u1_amd64.deb data.tar.xz | tar -xJ
- ar p libk5crypto3_1.18.3-6+deb11u1_amd64.deb data.tar.xz | tar -xJ
- ar p libkrb5support0_1.18.3-6+deb11u1_amd64.deb data.tar.xz | tar -xJ
- ar p libkeyutils1_1.6.1-2_amd64.deb data.tar.xz | tar -xJ
- ls -l
post-install:
- rm -rf usr/share/{doc,man}
- cp -dr usr/* $FLATPAK_DEST/
- cp -dr lib/* $FLATPAK_DEST/lib
# - cp -dr opt/* $FLATPAK_DEST/
sources:
- type: file
path: bin/wechat-devtools
- type: file
path: startup.sh
- type: file
path: io.github.msojocs.wechat_devtools.desktop
- type: file
path: io.github.msojocs.wechat_devtools.svg
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libgssapi-krb5-2_1.18.3-6+deb11u1_amd64.deb
sha256: 2ab853cbd0494c06fa694906c6eeea4df79720f461c76d080eb21a3e98f44115
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libkrb5-3_1.18.3-6+deb11u1_amd64.deb
sha256: afb9dced3fcbdbc439a166eaa217dbfd485585842f12ce4587123009618e8bfe
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libk5crypto3_1.18.3-6+deb11u1_amd64.deb
sha256: 4a010fc69322b6be9e141a76593f46e6588c968ee3b7cf79a3b8b7efda9aeeba
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/krb5/libkrb5support0_1.18.3-6+deb11u1_amd64.deb
sha256: 1f19908dbd37bd2ba9b3b3c9eb6ab8bee9a72f72745e6887f5366bb5fece654b
- type: file
url: http://ftp.cn.debian.org/debian/pool/main/k/keyutils/libkeyutils1_1.6.1-2_amd64.deb
sha256: f01060b434d8cad3c58d5811d2082389f11b3db8152657d6c22c1d298953f2a5

View File

@ -1,93 +0,0 @@
#!/bin/bash
set -e
notice() {
echo -e "\033[36m $1 \033[0m "
}
fail() {
echo -e "\033[41;37m 失败 \033[0m $1"
}
root_dir=$(cd `dirname $0`/.. && pwd -P)
DEVTOOLS_VERSION=$( cat "$root_dir/package.nw/package.json" | grep -m 1 -Eo "\"[0-9]{1}\.[0-9]{2}\.[0-9]+" )
DEVTOOLS_VERSION="${DEVTOOLS_VERSION//\"/}"
echo $BUILD_VERSION
if [ -n "$1" ];then
export BUILD_VERSION=$1
fi
if [ -z "$BUILD_VERSION" ];then
export BUILD_VERSION='continuous'
fi
if [ "$BUILD_VERSION" == "continuous" ];then
export BUILD_VERSION="v${DEVTOOLS_VERSION}-continuous"
fi
notice "检查版本号 -> $BUILD_VERSION"
INPUT_VERSION=$( echo $BUILD_VERSION | sed 's/v//' | sed 's/-.*//' )
if [[ "$INPUT_VERSION" != "$DEVTOOLS_VERSION" ]];then
fail "传入版本号与实际版本号不一致!"
exit 1
fi
############ 准备构建deb包所需的文件及结构 ################
package_name="io.github.msojocs.wechat-devtools"
if [[ $NO_WINE == 'true' ]];then
BUILD_MARK='no_wine'
package_name="${package_name}-no-wine"
else
BUILD_MARK='wine'
NAME_SUFFIX=" (wine)"
package_name="${package_name}-wine"
fi
echo "root_dir: $root_dir"
tmp_dir="$root_dir/tmp"
build_dir="$root_dir/tmp/$package_name"
base_dir="$build_dir/opt/apps/$package_name"
# Remove any previous build
rm -rf $build_dir
# Make usr and icons dirs
notice "Make Dirs"
mkdir -p $base_dir/{entries,files}
mkdir -p $base_dir/entries/{applications,icons/hicolor/scalable/apps/,mime,plugins,services}
mkdir -p $base_dir/files/{bin/bin,doc,lib}
notice "COPY Files"
cp -r "$root_dir/res/deepin"/* $build_dir
mv "$build_dir/opt/apps/io.github.msojocs.wechat-devtools"/* $base_dir
rm -r "$build_dir/opt/apps/io.github.msojocs.wechat-devtools"
sed -i "s/BUILD_VERSION/${BUILD_VERSION//v/}/" "$build_dir/debian/control" "$base_dir/info"
sed -i "s/io.github.msojocs.wechat-devtools/$package_name/g" "$base_dir/info" "$build_dir/debian/control"
\cp -rf "$root_dir/bin/wechat-devtools" "$base_dir/files/bin/bin/wechat-devtools"
# desktop
\cp -rf "$root_dir/res/template.desktop" "$base_dir/entries/applications/$package_name.desktop"
sed -i "s#Icon=dir/res/icons/wechat-devtools.svg#Icon=$package_name#" "$base_dir/entries/applications/$package_name.desktop"
sed -i "s#dir#/opt/apps/$package_name/files/bin#" "$base_dir/entries/applications/$package_name.desktop"
sed -i "s/WeChat Dev Tools/WeChat Dev Tools$NAME_SUFFIX/g" "$base_dir/info" "$base_dir/entries/applications/$package_name.desktop"
sed -i "s/微信开发者工具/微信开发者工具$NAME_SUFFIX/g" "$base_dir/entries/applications/$package_name.desktop"
\cp -rf "$root_dir/res/icons/wechat-devtools.svg" "$base_dir/entries/icons/hicolor/scalable/apps/$package_name.svg"
# 主体文件
cp -r "$root_dir/package.nw" "$base_dir/files/bin/package.nw"
cp -r "$root_dir/nwjs" "$base_dir/files/bin/nwjs"
if [ -f "$root_dir/node/bin/node" ];then
rm -rf "$base_dir/files/bin/nwjs"/{node,node.exe}
cp "$root_dir/node/bin/node" "$base_dir/files/bin/nwjs/node"
cd "$base_dir/files/bin/nwjs/" && ln -s "node" "node.exe"
fi
# chown -R root:root "$base_dir"
notice "BUILD DEB Package"
cd "$build_dir"
ls -l "$build_dir"
mkdir -p "$root_dir/tmp/build"
if [[ ! $NO_WINE -eq 'true' ]];then
echo "Depends: wine, wine-binfmt" >> "$build_dir/debian/control"
fi
# dpkg-deb -b . "$root_dir/tmp/build/WeChat_Dev_Tools_${BUILD_VERSION}_amd64_${BUILD_MARK}_deepin.deb"
debuild

View File

@ -68,6 +68,6 @@ EOF
# flatpak-builder build-dir io.github.msojocs.wechat-devtools.yml --force-clean
flatpak-builder build-dir io.github.msojocs.wechat-devtools.yml --install --force-clean --user
flatpak-builder build-dir io.github.msojocs.wechat-devtools.yml --force-clean --install --user
flatpak run io.github.msojocs.wechat-devtools