4

I'm setting up a GitLab CI script using Ubuntu 17.04 inside docker with almost nothing installed (Docker tag ubuntu:zesty). In the course of the script an apt-get install routine comes to configuring keyboard-configuration which randomly(!) requests a selection of a keyboard layout even though --yes --assume-yes --force-yes is specified:

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:

I don't care about which keyboard is selected, but I guess English (US) could go as a pseudo-standard. Using

  • yes 29 | apt-get ... doesn't work because there's a follow question about the keyboard layout, so that I'd need to use expect which is complicated and I'd like to exclude all easier possibilites.
  • env DEBIAN_FRONTEND=noninteractive and making sure that it's passed to the subprocess still randomly(!) requires input.

Why is this input requested anyway if --force-yes is specified and why does it occur randomly? See https://gitlab.gnome.org/krichter/jhbuild/-/jobs/158 and https://gitlab.com/krichter/jhbuild/-/jobs/34123725 for a failing and succeeding run of the same piece of script code (different servers, but the same relevant line).

Kalle Richter
  • 6,180
  • 21
  • 70
  • 103

1 Answers1

4

Redirect the stdin. Run the command with input from file: command < file. In the file you can put as many new lines as you need with all of the numbers on them. For example, running apt-get install keyboard-configuration <file where file contains:

y
29
<next thing I need to type>
<whatever>
<whatever else>
  • That's an easy solution, thank you. @GitLab users: some CI runners seem to stall for minutes after starting the line starting the dpkg process for keyboard-configuration which makes it very hard to figure out whether the command works/proceeds or not. – Kalle Richter Sep 27 '17 at 21:35
  • 1
    What about using a string instead of a file? – rraallvv Feb 19 '18 at 21:12
  • @rraallvv You can always use apt-get install keyboard-configuration < <( echo "MY INPUT" ) – user140345 Dec 20 '20 at 00:52