2023-09-26 14:33:19 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
app_name="wechat-devtools"
|
|
|
|
tmp_dir="/tmp/${app_name}_tmp"
|
2024-09-29 10:12:26 +08:00
|
|
|
version="1.06.2407120-1"
|
2023-09-26 14:33:19 +08:00
|
|
|
release="v${version}"
|
|
|
|
|
2024-01-09 14:42:03 +08:00
|
|
|
deb_url="https://github.com/msojocs/wechat-web-devtools-linux/releases/download/${release}/io.github.msojocs.wechat-devtools-linux_${version}_amd64.deb"
|
2023-12-28 17:15:45 +08:00
|
|
|
|
|
|
|
# 打包前, 要改启动脚本的变量声明
|
2024-07-15 09:27:08 +08:00
|
|
|
# root_dir="/usr/share/wechat-devtools"
|
2023-09-26 14:33:19 +08:00
|
|
|
|
|
|
|
# 创建临时目录, 用于下载官方包
|
|
|
|
if [ -d $tmp_dir ]; then
|
|
|
|
rm -rf $tmp_dir
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$1" == "" ]; then
|
|
|
|
if [ -d "./unpack" ]; then
|
|
|
|
sudo rm -rf ./unpack
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f "./${app_name}_${version}.deb" ]; then
|
|
|
|
rm "./${app_name}_${version}.deb"
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir $tmp_dir
|
|
|
|
|
|
|
|
# 创建临时待打包目录
|
|
|
|
echo "创建待打包目录..."
|
|
|
|
mkdir -p "./unpack/DEBIAN"
|
|
|
|
mkdir -p "./unpack/usr/bin"
|
2024-07-15 09:27:08 +08:00
|
|
|
mkdir -p "./unpack/usr/share/${app_name}"
|
2023-09-26 14:33:19 +08:00
|
|
|
mkdir -p "./unpack/usr/share/applications"
|
|
|
|
|
|
|
|
source_dir="${tmp_dir}/${app_name}/opt/apps/io.github.msojocs.wechat-devtools-linux"
|
|
|
|
|
|
|
|
|
|
|
|
echo "下载官方原包..."
|
2023-09-26 15:38:59 +08:00
|
|
|
wget $deb_url -O "${tmp_dir}/${app_name}.deb"
|
2023-09-26 14:33:19 +08:00
|
|
|
|
|
|
|
echo "下载完成, 解包中..."
|
|
|
|
dpkg-deb -R "${tmp_dir}/${app_name}.deb" "${tmp_dir}/${app_name}"
|
|
|
|
|
|
|
|
echo "解包完成, 复制到待打包目录..."
|
|
|
|
mv "${source_dir}/files/bin/bin" "./unpack/usr"
|
2024-07-15 09:27:08 +08:00
|
|
|
mv "${source_dir}/files/bin/nwjs" "./unpack/usr/share/${app_name}"
|
|
|
|
mv "${source_dir}/files/bin/package.nw" "./unpack/usr/share/${app_name}"
|
2023-09-26 14:33:19 +08:00
|
|
|
mv "${source_dir}/entries/icons" "./unpack/usr/share"
|
|
|
|
|
2023-09-26 15:38:59 +08:00
|
|
|
for i in ./unpack/usr/share/icons/hicolor/*/*/*; do
|
|
|
|
mv $i ${i/io.github.msojocs.wechat-devtools-linux/wechat-devtools}
|
|
|
|
done
|
|
|
|
|
2024-07-15 09:27:08 +08:00
|
|
|
rm -rf "./unpack/usr/share/${app_name}/package.nw/node_modules/wcc/bin/mac"
|
|
|
|
rm -rf "./unpack/usr/share/${app_name}/package.nw/node_modules/wcc/bin/windows"
|
2023-09-26 14:33:19 +08:00
|
|
|
|
2024-07-15 09:27:08 +08:00
|
|
|
cp "./unpack/usr/share/${app_name}/nwjs/locales/en-US.pak" "$tmp_dir/en-US.pak"
|
|
|
|
cp "./unpack/usr/share/${app_name}/nwjs/locales/en-US.pak.info" "$tmp_dir/en-US.pak.info"
|
|
|
|
cp "./unpack/usr/share/${app_name}/nwjs/locales/zh-CN.pak" "$tmp_dir/zh-CN.pak"
|
|
|
|
cp "./unpack/usr/share/${app_name}/nwjs/locales/zh-CN.pak.info" "$tmp_dir/zh-CN.pak.info"
|
2023-09-26 14:33:19 +08:00
|
|
|
|
2024-07-15 09:27:08 +08:00
|
|
|
rm -rf ./unpack/usr/share/${app_name}/nwjs/locales/*
|
2023-09-26 14:33:19 +08:00
|
|
|
|
2024-07-15 09:27:08 +08:00
|
|
|
cp "$tmp_dir/en-US.pak" "./unpack/usr/share/${app_name}/nwjs/locales/"
|
|
|
|
cp "$tmp_dir/en-US.pak.info" "./unpack/usr/share/${app_name}/nwjs/locales/"
|
|
|
|
cp "$tmp_dir/zh-CN.pak" "./unpack/usr/share/${app_name}/nwjs/locales/"
|
|
|
|
cp "$tmp_dir/zh-CN.pak.info" "./unpack/usr/share/${app_name}/nwjs/locales/"
|
2023-09-26 14:33:19 +08:00
|
|
|
|
|
|
|
rm -rf $tmp_dir
|
|
|
|
|
|
|
|
echo "复制完成, 创建可执行文件及程序桌面入口文件..."
|
|
|
|
|
|
|
|
echo """
|
|
|
|
[Desktop Entry]
|
|
|
|
Name=WeChat Dev Tools
|
|
|
|
Name[zh_CN]=微信开发者工具
|
|
|
|
Comment=The development tools for wechat projects
|
|
|
|
Comment[zh_CN]=提供微信开发相关项目的开发IDE支持
|
|
|
|
Categories=Development;WebDevelopment;IDE;
|
|
|
|
Exec=wechat-devtools
|
|
|
|
Icon=wechat-devtools
|
|
|
|
Type=Application
|
|
|
|
Terminal=false
|
|
|
|
StartupWMClass=wechat-devtools
|
|
|
|
Actions=
|
|
|
|
MimeType=x-scheme-handler/wechatide
|
|
|
|
|
|
|
|
""" > ./unpack/usr/share/applications/wechat-devtools.desktop
|
|
|
|
|
2024-07-09 09:15:03 +08:00
|
|
|
echo "文件复制完成, 手动修改启动脚本的root_dir定义为以下内容..."
|
2024-07-15 09:27:08 +08:00
|
|
|
echo "root_dir=\"/usr/share/wechat-devtools\""
|
2023-09-26 14:33:19 +08:00
|
|
|
|
|
|
|
elif [ "$1" == "pack" ]; then
|
|
|
|
|
2023-09-26 15:38:59 +08:00
|
|
|
echo '计算文件md5中...'
|
|
|
|
|
2023-09-26 14:33:19 +08:00
|
|
|
cd ./unpack
|
|
|
|
|
|
|
|
find usr/ -type f | xargs -I {} md5sum {} > DEBIAN/md5sums
|
|
|
|
IFS=$'\t' read -ra size <<< "$(du -d 0)"
|
|
|
|
|
|
|
|
echo """
|
|
|
|
Package: ${app_name}
|
|
|
|
Version: ${version}
|
|
|
|
Architecture: amd64
|
|
|
|
Maintainer: Yutent <yutent.io@gmail.com>
|
|
|
|
Breaks: io.github.msojocs.wechat-devtools-no-wine
|
|
|
|
Replaces: io.github.msojocs.wechat-devtools-no-wine
|
|
|
|
Installed-Size: ${size[0]}
|
2024-09-05 10:56:37 +08:00
|
|
|
Homepage: https://github.com/msojocs/wechat-web-devtools-linux
|
2024-01-09 14:42:03 +08:00
|
|
|
Section: non-free/development
|
2023-09-26 14:33:19 +08:00
|
|
|
Priority: optional
|
|
|
|
Description: WeChat Devtools For Linux.
|
|
|
|
To help developers develop and debug Weixin Mini Programs more simply and efficiently,
|
|
|
|
Tencent have launched the new Weixin DevTools based on the original Official Account
|
|
|
|
web debugging tools. Therefore, we now have two developer modes (Official Account web
|
|
|
|
debugging) and (Mini Program debugging). This version is unofficial.
|
|
|
|
""" > DEBIAN/control
|
|
|
|
|
|
|
|
|
|
|
|
echo '计算文件md5完成, 打包中...'
|
|
|
|
|
|
|
|
cd ../
|
|
|
|
|
|
|
|
sudo chown -R root:root unpack
|
|
|
|
|
|
|
|
dpkg-deb -b ./unpack "./${app_name}_${version}.deb"
|
|
|
|
|
|
|
|
sudo rm -rf ./unpack
|
|
|
|
echo "打包完成 :)"
|
|
|
|
fi
|