deb-packs/python3-textual/package.sh

124 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
app_name="python3-textual"
tmp_dir="/tmp/${app_name}_tmp"
version="0.77.0"
release="v${version}"
deb_arch="all"
deb_url="https://github.com/Textualize/textual/archive/refs/tags/${release}.zip"
# 创建临时目录, 用于下载官方包
if [ -d $tmp_dir ]; then
rm -rf $tmp_dir
fi
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/licenses/python3-textual"
mkdir -p "./unpack/usr/lib/python3/dist-packages"
echo "下载官方zip包..."
wget $deb_url -O "${tmp_dir}/${app_name}-${deb_arch}.zip"
unzip "${tmp_dir}/${app_name}-${deb_arch}.zip" -d $tmp_dir
echo "解包完成, 复制到待打包目录..."
mv "${tmp_dir}/textual-${version}/LICENSE" ./unpack/usr/licenses/python3-textual/
mv "${tmp_dir}/textual-${version}/src/textual" ./unpack/usr/lib/python3/dist-packages/
rm -rf $tmp_dir
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: textual
Priority: optional
Maintainer: Yutent <yutent.io@gmail.com>
Installed-Size: ${size[0]}
Depends: python3-markdown-it, python3-rich (>= 10.7.0), python3-typing-extensions, python3:any
Homepage: https://github.com/Textualize/textual
Description: TUI (Text User Interface) framework for Python inspired by modern web development
Textual uses Rich to render rich text, so anything that Rich can render may be
used in Textual.
.
Event handling in Textual is asynchronous (using async and await keywords).
Widgets (UI components) can independently update and communicate with each
other via message passing.
.
Textual has more in common with modern web development than it does with
curses; layout is done with CSS grid and (soon) the theme may be customized
with CSS. Other techniques are borrowed from JS frameworks such as Vue and
React.
""" > DEBIAN/control
echo """
#!/bin/sh
set -e
# Automatically added by dh_python3
if command -v py3compile >/dev/null 2>&1; then
py3compile -p python3-textual
fi
if command -v pypy3compile >/dev/null 2>&1; then
pypy3compile -p python3-textual || 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 python3-textual
else
dpkg -L python3-textual | 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 "打包完成 :)"
一些 开源&闭源 应用的重新打包
Shell 100%