我已经为 Linux Mint 14 的用户制作了这个安装后脚本(也可以在 Ubuntu 12.10 上使用),现在我正在为 Linux Mint 15 和 'echo -ne "\n"| 测试它。 sudo add-apt-repository ppa:some-ppa-to-add' 命令在 Linux Mint 15 上不起作用,但在 Mint 14 上仍然有效。我想为新版本的 Linux Mint 更新此脚本。
这是我的安装后脚本的链接:The Minty Developer
Mint 14 的输出如下所示:
$ echo -ne "\n" | sudo add-apt-repository ppa:apt-fast/stable
You are about to add the following PPA to your system:
This PPA contains tested (stable) builds of apt-fast.
More info: https://launchpad.net/~apt-fast/+archive/stable
gpg: keyring `/tmp/tmpddxueh/secring.gpg' created
gpg: requesting key CA8DA16B from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpddxueh/trustdb.gpg: trustdb created
gpg: key CA8DA16B: public key "Launchpad PPA for apt-fast" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
这是 Mint 15 上的输出:
$ echo -ne "\n" | sudo add-apt-repository ppa:apt-fast/stable
You are about to add the following PPA to your system:
This PPA contains tested (stable) builds of apt-fast.
More info: https://launchpad.net/~apt-fast/+archive/stable
就是这样。什么都没发生。 我也测试过只做 echo | ppa:some-ppa-to-add 和它是相同的结果。
任何人都可以帮我弄清楚如何使这行代码/命令起作用,以便可以为那些有兴趣将其用于新系统版本的人更新脚本吗?
谢谢。
最佳答案
您可以使用 add-apt-repository --yes
但您通过回答该问题覆盖了系统范围的安全策略。
你不说用户是谁;如果您的脚本为我这样做,我会很生气,但我不是典型的最终用户。我刚刚看了你的剧本,一般来说它是对话式的。如果它说类似的话
I'm going to add these packages from reasonably trustworthy sources and set them up so they will automatically update, etc., etc.
这样会更有礼貌。
已添加
add-apt-repository
中有一个未记录的功能,它允许您以编程方式覆盖问题:
if (sys.stdin.isatty() and
not "FORCE_ADD_APT_REPOSITORY" in os.environ):
if options.remove:
print(_("Press [ENTER] to continue or ctrl-c to cancel removing it"))
else:
print(_("Press [ENTER] to continue or ctrl-c to cancel adding it"))
sys.stdin.readline()
因此 bash 序列
export FORCE_ADD_APT_REPOSITORY=force
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo add-apt-repository ...
应该停止提问。它仍然会显示噪音
You are about to add the following PPA to your system:
Sublime Text 2 packages - the .deb will automatically download the
latest build from http://www.sublimetext.com/dev or beta from
http://www.sublimetext.com/2 (Adobe Flash Player installer - style).
More info and feedback:
http://www.webupd8.org/2011/03/sublime-text-2-ubuntu-ppa.html
http://www.webupd8.org/2012/03/sublime-text-2-ppa-separate-development.html
More info: https://launchpad.net/~webupd8team/+archive/sublime-text-2
但是那是放在 stdout 上的,所以应该能够发送到 >/dev/null
,错误仍然出现在 stderr 上。
关于linux - 自动化 Enter 按键不适用于 Linux Mint 15,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16869758/