Ubuntu26.04 (Resolute) 适配定制网易云 2.0.4 deb 打包方案

上次分享出《ubuntu22.04安装网易云音乐》,后来我在Ubuntu26.04上也能正常安装,不过会出现一些Bug,比如偶尔会卡着出现兼容性问题。这个是网友修改版 2.0.4 的网易云音乐 deb(官方已经关闭下载链接),但是包的信息很完整。

Ubuntu26.04 已废弃 libappindicator3-1、全面 openssl3、GTK 新版,原 deb 的Recommends: libappindicator3-1会造成 apt 告警,先解包改配置再打包,打包出来的包22.04/24.04/26.04 全系列 amd64 通用

本次记录在Ubuntu26.04上通过对这个deb安装包,进行二次修改去掉废弃的依赖,实现自己打包自己使用。当然也可以分享给大家测试使用。


1. 安装打包依赖

sudo apt update
sudo apt install fakeroot dpkg-dev -y

2.一键解包(提取所有文件)

netease-cloud-music_2.0.4_amd64.deb 就是下载回来的包,大小 101M,我将对它进行修改二次打包。

# 创建工作目录
mkdir -p ~/ncm-build
cd ~/ncm-build

# 把你的deb复制过来
cp /data/soft/netease-cloud-music_2.0.4_amd64.deb ./

# 解包文件内容到 ncm-package
dpkg-deb -x netease-cloud-music_2.0.4_amd64.deb ncm-package

# 解包控制信息(control、postinst、postrm 等)
dpkg-deb --control netease-cloud-music_2.0.4_amd64.deb ncm-package/DEBIAN

现在结构:

ncm-package/
├── DEBIAN/        # 控制脚本
├── opt/
└── usr/

详细的信息自己可对比前后变化。

3. 编写 DEBIAN/control(deb 核心配置)

cat ~/ncm_build/build/DEBIAN/control 

Package: netease-cloud-music
Version: 2.0.4
Architecture: amd64
Maintainer: Netease
Installed-Size: 290671
Depends: libgtk-3-0, libnotify4, libnss3, libxss1, libxtst6, xdg-utils, libatspi2.0-0, libuuid1, libsecret-1-0
Section: sound
Priority: optional
Homepage: https://music.163.com
Description: Netease Cloud Music for Linux
 Official Netease Cloud Music client for Ubuntu/Debian
  • Depends:运行依赖,缺啥后续补充,简化可只留核心库

4.安装后执行脚本 postinst(解决权限 / 快捷更新)

cat ~/ncm_build/build/DEBIAN/postinst 

#!/bin/bash

if type update-alternatives 2>/dev/null >&1; then
    # Remove previous link if it doesn't use update-alternatives
    if [ -L '/usr/bin/netease-cloud-music' -a -e '/usr/bin/netease-cloud-music' -a "`readlink '/usr/bin/netease-cloud-music'`" != '/etc/alternatives/netease-cloud-music' ]; then
        rm -f '/usr/bin/netease-cloud-music'
    fi
    update-alternatives --install '/usr/bin/netease-cloud-music' 'netease-cloud-music' '/opt/netease-cloud-music/netease-cloud-music' 100 || ln -sf '/opt/netease-cloud-music/netease-cloud-music' '/usr/bin/netease-cloud-music'
else
    ln -sf '/opt/netease-cloud-music/netease-cloud-music' '/usr/bin/netease-cloud-music'
fi

# Check if user namespaces are supported by the kernel and working with a quick test:
if ! { [[ -L /proc/self/ns/user ]] && unshare --user true; }; then
    # Use SUID chrome-sandbox only on systems without user namespaces:
    chmod 4755 '/opt/netease-cloud-music/chrome-sandbox' || true
else
    chmod 0755 '/opt/netease-cloud-music/chrome-sandbox' || true
fi

if hash update-mime-database 2>/dev/null; then
    update-mime-database /usr/share/mime || true
fi

if hash update-desktop-database 2>/dev/null; then
    update-desktop-database /usr/share/applications || true
fi

# Install apparmor profile. (Ubuntu 24+)
# First check if the version of AppArmor running on the device supports our profile.
# This is in order to keep backwards compatibility with Ubuntu 22.04 which does not support abi/4.0.
# In that case, we just skip installing the profile since the app runs fine without it on 22.04.
#
# Those apparmor_parser flags are akin to performing a dry run of loading a profile.
# https://wiki.debian.org/AppArmor/HowToUse#Dumping_profiles
#
# Unfortunately, at the moment AppArmor doesn't have a good story for backwards compatibility.
# https://askubuntu.com/questions/1517272/writing-a-backwards-compatible-apparmor-profile
if apparmor_status --enabled > /dev/null 2>&1; then
  APPARMOR_PROFILE_SOURCE='/opt/netease-cloud-music/resources/apparmor-profile'
  APPARMOR_PROFILE_TARGET='/etc/apparmor.d/netease-cloud-music'
  if apparmor_parser --skip-kernel-load --debug "$APPARMOR_PROFILE_SOURCE" > /dev/null 2>&1; then
    cp -f "$APPARMOR_PROFILE_SOURCE" "$APPARMOR_PROFILE_TARGET"

    # Updating the current AppArmor profile is not possible and probably not meaningful in a chroot'ed environment.
    # Use cases are for example environments where images for clients are maintained.
    # There, AppArmor might correctly be installed, but live updating makes no sense.
    if ! { [ -x '/usr/bin/ischroot' ] && /usr/bin/ischroot; } && hash apparmor_parser 2>/dev/null; then
      # Extra flags taken from dh_apparmor:
      # > By using '-W -T' we ensure that any abstraction updates are also pulled in.
      # https://wiki.debian.org/AppArmor/Contribute/FirstTimeProfileImport
      apparmor_parser --replace --write-cache --skip-read-cache "$APPARMOR_PROFILE_TARGET"
    fi
  else
    echo "Skipping the installation of the AppArmor profile as this version of AppArmor does not seem to support the bundled profile"
  fi
fi

postinst脚本添加执行权限:

chmod 755 ~/ncm_build/build/DEBIAN/postinst

其它的都没有做修改,因为它都跟官方之前的包保留着。

5. 打包生成 deb

cd ~/ncm_build
fakeroot dpkg-deb -b build netease-cloud-music_2.0.4_amd64_ubuntu2604.deb

生成好的包:netease-cloud-music_2.0.4_amd64_ubuntu2604.deb,大小84M

在 Ubuntu 26.04 安装(任意一台同架构电脑都能用)

sudo dpkg -i netease-cloud-music_2.0.4_amd64_ubuntu2604.deb
sudo apt -f install -y    #缺少依赖包,可执行它安装

大家喜欢也可以自己去打包一个试试,有问题可以留言交流哦。

本文首发于 58Linux技术博客,专注Ubuntu桌面使用、Linux服务器运维与网站搭建实战。

发表评论

粤ICP备10052831号 | © 2026 58Linux 技术笔记. All Rights Reserved. | 联系我们 | 关于本站
本站内容开放共享,仅供学习交流 | 专注 Ubuntu & Linux 实战教程
Built with GeneratePress