deb-packs/nodejs/package-current.sh

98 lines
2.4 KiB
Bash
Raw Permalink Normal View History

2023-09-14 15:01:31 +08:00
#!/bin/bash
app_name="nodejs-current"
tmp_dir="/tmp/${app_name}_tmp"
2024-11-30 12:03:59 +08:00
version="23.3.0"
2023-09-14 15:01:31 +08:00
release="v${version}"
pkg_arch="x64"
deb_arch="amd64"
if [ "$1" == "arm" ]; then
pkg_arch="arm64"
deb_arch="arm64"
fi
2024-11-02 18:41:55 +08:00
deb_url="http://mirrors.ustc.edu.cn/node/latest-v23.x/node-${release}-linux-${pkg_arch}.tar.xz"
2023-09-14 15:01:31 +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"
echo "下载官方原包..."
wget $deb_url -O "${tmp_dir}/${app_name}-${pkg_arch}.tar.xz"
echo "下载完成, 解包中..."
tar -xf "${tmp_dir}/${app_name}-${pkg_arch}.tar.xz" -C $tmp_dir
echo "解包完成, 复制到待打包目录..."
2023-09-14 15:12:12 +08:00
mv ${tmp_dir}/node-${release}-linux-${pkg_arch}/bin "./unpack/usr/"
mv ${tmp_dir}/node-${release}-linux-${pkg_arch}/include "./unpack/usr/"
mv ${tmp_dir}/node-${release}-linux-${pkg_arch}/lib "./unpack/usr/"
mv ${tmp_dir}/node-${release}-linux-${pkg_arch}/share "./unpack/usr/"
2023-09-14 15:01:31 +08:00
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}
Section: devlop
Installed-Size: ${size[0]}
Architecture: ${deb_arch}
Maintainer: Yutent <yutent.io@gmail.com>
Priority: optional
Depends: libc6 (>= 2.28), libgcc1 (>= 1:3.4), libstdc++6 (>= 5.2), python3-minimal, ca-certificates
Breaks: nodejs, nodejs-lts, npm
Replaces: nodejs, nodejs-lts, npm
Provides: nodejs, npm
Homepage: https://nodejs.org
Description: Node.js event-based server-side javascript engine
Node.js is similar in design to and influenced by systems like
Ruby's Event Machine or Python's Twisted.
.
It takes the event model a bit further - it presents the event
loop as a language construct instead of as a library.
.
Node.js is bundled with several useful libraries to handle server tasks :
System, Events, Standard I/O, Modules, Timers, Child Processes, POSIX,
HTTP, Multipart Parsing, TCP, DNS, Assert, Path, URL, Query Strings.
""" > DEBIAN/control
echo '计算文件md5完成, 打包中...'
cd ..
sudo chown -R root:root unpack
dpkg-deb -b ./unpack "./${app_name}-${deb_arch}_${version}.deb"
sudo rm -rf ./unpack
echo "打包完成 :)"