#!/bin/bash app_name="nodejs-lts" tmp_dir="/tmp/${app_name}_tmp" version="20.18.1" release="v${version}" pkg_arch="x64" deb_arch="amd64" if [ "$1" == "arm" ]; then pkg_arch="arm64" deb_arch="arm64" fi deb_url="http://mirrors.ustc.edu.cn/node/latest-v20.x/node-${release}-linux-${pkg_arch}.tar.xz" # 创建临时目录, 用于下载官方包 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 "解包完成, 复制到待打包目录..." 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/" 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 Priority: optional Depends: libc6 (>= 2.28), libgcc1 (>= 1:3.4), libstdc++6 (>= 5.2), python3-minimal, ca-certificates Breaks: nodejs, nodejs-current, npm Replaces: nodejs, nodejs-current, 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 "打包完成 :)"