我正在使用 Ubuntu 17.04 在 Docker 中设置 GitLab CI 脚本,几乎没有安装任何东西(Docker 标签ubuntu:zesty
)。在脚本的过程中,apt-get install
会进行一个配置例程,即使指定了keyboard-configuration
,也会随机(!)请求选择键盘布局:--yes --assume-yes --force-yes
Setting up keyboard-configuration (1.142ubuntu5) ...
debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
Configuring keyboard-configuration
----------------------------------
The layout of keyboards varies per country, with some countries having multiple
common layouts. Please select the country of origin for the keyboard of this
computer.
1. Afghani 48. Iraqi
2. Albanian 49. Irish
3. Amharic 50. Italian
4. Arabic 51. Japanese
5. Arabic (Morocco) 52. Japanese (PC-98xx Series)
6. Arabic (Syria) 53. Kazakh
7. Armenian 54. Khmer (Cambodia)
8. Azerbaijani 55. Korean
9. Bambara 56. Kyrgyz
10. Bangla 57. Lao
11. Belarusian 58. Latvian
12. Belgian 59. Lithuanian
13. Bosnian 60. Macedonian
14. Braille 61. Maltese
15. Bulgarian 62. Maori
16. Burmese 63. Moldavian
17. Chinese 64. Mongolian
18. Croatian 65. Montenegrin
19. Czech 66. Nepali
20. Danish 67. Norwegian
21. Dhivehi 68. Persian
22. Dutch 69. Polish
23. Dzongkha 70. Portuguese
24. English (Cameroon) 71. Portuguese (Brazil)
25. English (Ghana) 72. Romanian
26. English (Nigeria) 73. Russian
27. English (South Africa) 74. Serbian
28. English (UK) 75. Sinhala (phonetic)
29. English (US) 76. Slovak
30. Esperanto 77. Slovenian
31. Estonian 78. Spanish
32. Faroese 79. Spanish (Latin American)
33. Filipino 80. Swahili (Kenya)
34. Finnish 81. Swahili (Tanzania)
35. French 82. Swedish
36. French (Canada) 83. Switzerland
37. French (Democratic Republic of the Congo) 84. Taiwanese
38. French (Guinea) 85. Tajik
39. French (Togo) 86. Thai
40. Georgian 87. Tswana
41. German 88. Turkish
42. German (Austria) 89. Turkmen
43. Greek 90. Ukrainian
44. Hebrew 91. Urdu (Pakistan)
45. Hungarian 92. Uzbek
46. Icelandic 93. Vietnamese
47. Indian 94. Wolof
Country of origin for the keyboard:
我不在乎选择哪个键盘,但我想English (US)
可以作为伪标准。使用
yes 29 | apt-get ...
不起作用,因为有一个关于键盘布局的后续问题,所以我需要使用expect
复杂的,而且我想排除所有更简单的可能性。env DEBIAN_FRONTEND=noninteractive
并确保它仍然随机地传递给子进程(!)需要输入。
--force-yes
如果指定了,为什么还是会请求此输入,并且为什么它会随机发生?请参阅https://gitlab.gnome.org/krichter/jhbuild/-/jobs/158和https://gitlab.com/krichter/jhbuild/-/jobs/34123725对于同一段脚本代码(不同的服务器,但相同的相关行)的失败和成功运行。
答案1
重定向stdin
。使用来自文件的输入运行命令:command < file
。在文件中,您可以根据需要添加任意数量的新行,并在其上添加所有数字。例如,运行apt-get install keyboard-configuration <file
文件包含的内容:
y
29
<next thing I need to type>
<whatever>
<whatever else>