101 lines
2.3 KiB
Bash
101 lines
2.3 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
app_name="pyinstaller"
|
||
|
tmp_dir="/tmp/${app_name}_tmp"
|
||
|
version="6.11.1"
|
||
|
release="v${version}"
|
||
|
deb_arch="amd64"
|
||
|
tmp_dir="/data/docker/${app_name}"
|
||
|
|
||
|
|
||
|
|
||
|
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/lib/python3/dist-packages"
|
||
|
|
||
|
|
||
|
echo "复制编译好的文件到待打包目录..."
|
||
|
cp -r "${tmp_dir}/usr/local/bin" "./unpack/usr/"
|
||
|
cp -r "${tmp_dir}/usr/local/lib/python3.11/dist-packages/PyInstaller" "./unpack/usr/lib/python3/dist-packages/"
|
||
|
|
||
|
|
||
|
echo "复制完成, 计算文件md5..."
|
||
|
|
||
|
cd ./unpack
|
||
|
|
||
|
find usr/ -type f | xargs md5sum > DEBIAN/md5sums
|
||
|
|
||
|
IFS=$'\t' read -ra size <<< "$(du -d 0)"
|
||
|
|
||
|
echo """
|
||
|
Package: ${app_name}
|
||
|
Version: ${version}
|
||
|
Architecture: ${deb_arch}
|
||
|
Section: python
|
||
|
Source: pyinstaller
|
||
|
Priority: optional
|
||
|
Maintainer: Yutent <yutent.io@gmail.com>
|
||
|
Installed-Size: ${size[0]}
|
||
|
Depends: python3:any, python3-altgraph, python3-packaging, python3-setuptools, binutils
|
||
|
Homepage: https://github.com/pyinstaller/pyinstaller
|
||
|
Description: Freeze (package) Python programs into stand-alone executables
|
||
|
PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules.
|
||
|
|
||
|
""" > DEBIAN/control
|
||
|
|
||
|
echo """
|
||
|
#!/bin/sh
|
||
|
set -e
|
||
|
|
||
|
# Automatically added by dh_python3
|
||
|
if command -v py3compile >/dev/null 2>&1; then
|
||
|
py3compile -p pyinstaller
|
||
|
fi
|
||
|
if command -v pypy3compile >/dev/null 2>&1; then
|
||
|
pypy3compile -p pyinstaller || true
|
||
|
fi
|
||
|
|
||
|
# End automatically added section
|
||
|
|
||
|
""" > DEBIAN/postinst
|
||
|
|
||
|
echo """
|
||
|
#!/bin/sh
|
||
|
set -e
|
||
|
|
||
|
# Automatically added by dh_python3
|
||
|
if command -v py3clean >/dev/null 2>&1; then
|
||
|
py3clean -p pyinstaller
|
||
|
else
|
||
|
dpkg -L pyinstaller | sed -En -e '/^(.*)\/(.+)\.py$/s,,rm "\1/__pycache__/\2".*,e'
|
||
|
find /usr/lib/python3/dist-packages/ -type d -name __pycache__ -empty -print0 | xargs --null --no-run-if-empty rmdir
|
||
|
fi
|
||
|
|
||
|
# End automatically added section
|
||
|
|
||
|
""" > DEBIAN/prerm
|
||
|
|
||
|
chmod +x ./DEBIAN/postinst
|
||
|
chmod +x ./DEBIAN/prerm
|
||
|
|
||
|
echo '计算文件md5完成, 打包中...'
|
||
|
|
||
|
cd ..
|
||
|
sudo chown -R root:root unpack
|
||
|
|
||
|
dpkg-deb -b ./unpack "./${app_name}-${deb_arch}_${version}.deb"
|
||
|
|
||
|
sudo rm -rf ./unpack
|
||
|
echo "打包完成 :)"
|