无法在 Ubuntu pyxis 容器中安装 update-notifier-common

Cannot install update-notifier-common in Ubuntu pyxis container

我正在尝试设置一个脚本来初始化我的 Ubuntu pyxis 容器:

#!/usr/bin/env bash

# Python and nano
apt-get update
apt-get install -y software-properties-common python3-pip python3-tk nano

# Fonts
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections  # Automatically accept EULA
echo ttf-mscorefonts-installer msttcorefonts/present-mscorefonts-eula note | debconf-set-selections  # Automatically accept EULA
apt-get install -y msttcorefonts
rm -r ~/.cache/matplotlib 2>/dev/null

# Required python packages
pip3 install joblib matplotlib numpy pillow scikit-learn scipy tqdm

我运行这个脚本用

srun --container-image ubuntu:latest /root/setup_container.sh >~/setup_container.log 2>&1

但是,由于update-notifier-common配置不正确,MS 字体包安装失败。日志文件的关键部分如下(我也上传了整个日志文件here)。

...
Setting up update-notifier-common (3.192.30.9) ...
chown: invalid user: ‘_apt:root’
dpkg: error processing package update-notifier-common (--configure):
installed update-notifier-common package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of ttf-mscorefonts-installer:
ttf-mscorefonts-installer depends on update-notifier-common (>= 0.119ubuntu2); however:
  Package update-notifier-common is not configured yet.

dpkg: error processing package ttf-mscorefonts-installer (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
Errors were encountered while processing:
update-notifier-common
ttf-mscorefonts-installer
W: No sandbox user '_apt' on the system, can not drop privileges
E: Sub-process /usr/bin/dpkg returned an error code (1)
...

由于日志包含有关无效 _apt:root 用户的错误消息,并且我还在日志文件的其他地方收到 No sandbox user 'apt' 警告,因此我尝试创建一个 _apt 用户我自己,但这带来了新的错误:

#!/usr/bin/env bash

# _apt user
adduser _apt --home /nonexistent --system --no-create-home --force-badname
usermod -aG sudo _apt
usermod -aG root _apt

# Python and nano
apt-get update
apt-get install -y software-properties-common python3-pip python3-tk nano

# Fonts
echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections  # Automatically accept EULA
echo ttf-mscorefonts-installer msttcorefonts/present-mscorefonts-eula note | debconf-set-selections  # Automatically accept EULA
apt-get install -y msttcorefonts
rm -r ~/.cache/matplotlib 2>/dev/null

Warning: The home dir /nonexistent you specified can't be accessed: No such file or directory
Allowing use of questionable username.
Adding system user `_apt' (UID 100) ...
Adding new user `_apt' (UID 100) with group `nogroup' ...
Not creating home directory `/nonexistent'.
Reading package lists...
E: Method gave invalid 400 URI Failure message: Could not switch group
E: Method gave invalid 400 URI Failure message: Could not switch group
E: Method http has died unexpectedly!
E: Sub-process http returned an error code (112)
E: Method http has died unexpectedly!
E: Sub-process http returned an error code (112)
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package software-properties-common
E: Unable to locate package python3-pip
E: Unable to locate package python3-tk
E: Unable to locate package nano
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package msttcorefonts
/root/GE/setup_container.sh: line 19: pip3: command not found
/root/GE/setup_container.sh: line 21: pip3: command not found
srun: error: gpu01: task 0: Exited with exit code 127

如何正确安装 update-notifier-common(以及随后的 msttcorefonts)?

我设法通过手动下载和安装 msttcorefonts 软件包解决了这个问题,显然 Ubuntu 存储库中的版本目前已损坏。

apt-get install -y wget
wget http://ftp.de.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.8_all.deb -O ~/msfonts.deb
apt-get install -y ~/msfonts.deb
rm ~/msfonts.deb