2023-09-26 14:33:19 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
app_name="wechat-devtools"
|
|
|
|
tmp_dir="/tmp/${app_name}_tmp"
|
2023-12-28 17:15:45 +08:00
|
|
|
version="1.06.2308310-3"
|
2023-09-26 14:33:19 +08:00
|
|
|
release="v${version}"
|
|
|
|
|
2023-12-28 17:15:45 +08:00
|
|
|
deb_url="https://github.com/msojocs/wechat-web-devtools-linux/releases/download/${version}/io.github.msojocs.wechat-devtools-linux_${version}_amd64.deb"
|
|
|
|
|
|
|
|
# 打包前, 要改启动脚本的变量声明
|
|
|
|
# root_dir="/usr/lib/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"
|
|
|
|
mkdir -p "./unpack/usr/lib/${app_name}"
|
|
|
|
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"
|
|
|
|
mv "${source_dir}/files/bin/nwjs" "./unpack/usr/lib/${app_name}"
|
|
|
|
mv "${source_dir}/files/bin/package.nw" "./unpack/usr/lib/${app_name}"
|
|
|
|
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
|
|
|
|
|
2023-09-26 14:33:19 +08:00
|
|
|
rm -rf "./unpack/usr/lib/${app_name}/package.nw/node_modules/wcc/bin/mac"
|
|
|
|
rm -rf "./unpack/usr/lib/${app_name}/package.nw/node_modules/wcc/bin/windows"
|
|
|
|
|
|
|
|
cp "./unpack/usr/lib/${app_name}/nwjs/locales/en-US.pak" "$tmp_dir/en-US.pak"
|
|
|
|
cp "./unpack/usr/lib/${app_name}/nwjs/locales/en-US.pak.info" "$tmp_dir/en-US.pak.info"
|
|
|
|
cp "./unpack/usr/lib/${app_name}/nwjs/locales/zh-CN.pak" "$tmp_dir/zh-CN.pak"
|
|
|
|
cp "./unpack/usr/lib/${app_name}/nwjs/locales/zh-CN.pak.info" "$tmp_dir/zh-CN.pak.info"
|
|
|
|
|
|
|
|
rm -rf ./unpack/usr/lib/${app_name}/nwjs/locales/*
|
|
|
|
|
|
|
|
cp "$tmp_dir/en-US.pak" "./unpack/usr/lib/${app_name}/nwjs/locales/"
|
|
|
|
cp "$tmp_dir/en-US.pak.info" "./unpack/usr/lib/${app_name}/nwjs/locales/"
|
|
|
|
cp "$tmp_dir/zh-CN.pak" "./unpack/usr/lib/${app_name}/nwjs/locales/"
|
|
|
|
cp "$tmp_dir/zh-CN.pak.info" "./unpack/usr/lib/${app_name}/nwjs/locales/"
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
echo "文件复制完成, 手动修改启动脚本..."
|
|
|
|
|
|
|
|
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]}
|
|
|
|
Section: development
|
|
|
|
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
|