2023-05-22 12:24:59 +08:00
|
|
|
#!/bin/bash
|
2023-05-22 13:51:48 +08:00
|
|
|
|
|
|
|
app_name="bun"
|
2023-08-02 18:02:08 +08:00
|
|
|
tmp_dir="/tmp/${app_name}_tmp"
|
2023-09-11 15:05:37 +08:00
|
|
|
version="1.0.0"
|
2023-08-02 18:02:08 +08:00
|
|
|
release="v${version}"
|
2023-09-11 16:03:00 +08:00
|
|
|
pkg_arch="x64"
|
|
|
|
deb_arch="amd64"
|
2023-05-22 13:51:48 +08:00
|
|
|
|
2023-09-11 16:03:00 +08:00
|
|
|
if [ "$1" == "arm" ]; then
|
|
|
|
pkg_arch="aarch64"
|
|
|
|
deb_arch="arm64"
|
|
|
|
fi
|
|
|
|
echo $1
|
|
|
|
echo $pkg_arch, $deb_arch
|
|
|
|
# exit 0
|
|
|
|
|
|
|
|
deb_url="https://github.com/oven-sh/bun/releases/download/bun-${release}/bun-linux-${pkg_arch}.zip"
|
2023-05-22 13:51:48 +08:00
|
|
|
|
|
|
|
# 创建临时目录, 用于下载官方包
|
|
|
|
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/bin"
|
|
|
|
|
|
|
|
echo "下载官方原包..."
|
2023-09-11 16:03:00 +08:00
|
|
|
wget $deb_url -O "${tmp_dir}/bun-linux-${pkg_arch}.zip"
|
2023-05-22 13:51:48 +08:00
|
|
|
|
|
|
|
|
|
|
|
echo "下载完成, 解包中..."
|
2023-09-11 16:03:00 +08:00
|
|
|
unzip "${tmp_dir}/bun-linux-${pkg_arch}.zip" -d $tmp_dir
|
2023-05-22 13:51:48 +08:00
|
|
|
|
|
|
|
echo "解包完成, 复制到待打包目录..."
|
2023-09-11 16:03:00 +08:00
|
|
|
mv ${tmp_dir}/bun-linux-${pkg_arch}/* "./unpack/usr/bin/"
|
2023-05-22 13:51:48 +08:00
|
|
|
|
|
|
|
rm -rf $tmp_dir
|
|
|
|
|
|
|
|
echo "复制完成, 计算文件md5..."
|
|
|
|
|
|
|
|
cd ./unpack
|
|
|
|
|
|
|
|
find usr/ -type f | xargs md5sum > DEBIAN/md5sums
|
|
|
|
|
2023-05-22 14:10:49 +08:00
|
|
|
IFS=$'\t' read -ra size <<< "$(du -d 0)"
|
|
|
|
|
2023-05-22 13:51:48 +08:00
|
|
|
echo """
|
2023-08-02 18:02:08 +08:00
|
|
|
Package: ${app_name}
|
2023-05-22 13:51:48 +08:00
|
|
|
Version: ${version}
|
|
|
|
Section: devlop
|
2023-05-22 14:10:49 +08:00
|
|
|
Installed-Size: ${size[0]}
|
2023-09-11 16:03:00 +08:00
|
|
|
Architecture: ${deb_arch}
|
2023-05-22 13:51:48 +08:00
|
|
|
Maintainer: Yutent <yutent.io@gmail.com>
|
|
|
|
Priority: optional
|
|
|
|
Homepage: https://bun.sh/
|
|
|
|
Description: Incredibly fast JavaScript runtime.
|
2023-09-11 16:03:00 +08:00
|
|
|
Incredibly fast JavaScript runtime, bundler, transpiler and package manager - all in one.
|
2023-05-22 13:51:48 +08:00
|
|
|
|
|
|
|
""" > DEBIAN/control
|
|
|
|
|
|
|
|
echo '计算文件md5完成, 打包中...'
|
|
|
|
|
|
|
|
cd ..
|
|
|
|
sudo chown -R root:root unpack
|
|
|
|
|
|
|
|
dpkg-deb -b ./unpack "./${app_name}_${version}.deb"
|
|
|
|
|
2023-07-28 22:59:50 +08:00
|
|
|
echo "打包完成 :)"
|