@@ -1,58 +1,58 | |||
|
1 | 1 | # |
|
2 | 2 | # Setup Locales and keyboard settings |
|
3 | 3 | # |
|
4 | 4 | |
|
5 | 5 | # Load utility functions |
|
6 | 6 | . ./functions.sh |
|
7 | 7 | |
|
8 | 8 | # Install and setup timezone |
|
9 | 9 | echo "${TIMEZONE}" > "${ETC_DIR}/timezone" |
|
10 | 10 | chroot_exec dpkg-reconfigure -f noninteractive tzdata |
|
11 | 11 | |
|
12 | 12 | # Install and setup default locale and keyboard configuration |
|
13 | 13 | if [ "$(echo "$APT_INCLUDES" | grep ",locales")" ] ; then |
|
14 | 14 | # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug |
|
15 | 15 | # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957 |
|
16 | 16 | # ... so we have to set locales manually |
|
17 | 17 | if [ "$DEFLOCAL" = "en_US.UTF-8" ] ; then |
|
18 | 18 | chroot_exec echo "locales locales/locales_to_be_generated multiselect ${DEFLOCAL} UTF-8" | debconf-set-selections |
|
19 | 19 | else |
|
20 | 20 | # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale |
|
21 | 21 | chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections |
|
22 | 22 | sed -i "/en_US.UTF-8/s/^#//" "${ETC_DIR}/locale.gen" |
|
23 | 23 | fi |
|
24 | 24 | |
|
25 | 25 | sed -i "/${DEFLOCAL}/s/^#//" "${ETC_DIR}/locale.gen" |
|
26 | 26 | chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections |
|
27 | 27 | chroot_exec locale-gen |
|
28 | 28 | chroot_exec update-locale LANG="${DEFLOCAL}" |
|
29 | 29 | |
|
30 | 30 | # Install and setup default keyboard configuration |
|
31 |
if [ "$XKB_MODEL" != " |
|
|
31 | if [ "$XKB_MODEL" != "" ] ; then | |
|
32 | 32 | sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" "${ETC_DIR}/default/keyboard" |
|
33 | 33 | fi |
|
34 |
if [ "$XKB_LAYOUT" != " |
|
|
34 | if [ "$XKB_LAYOUT" != "" ] ; then | |
|
35 | 35 | sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" "${ETC_DIR}/default/keyboard" |
|
36 | 36 | fi |
|
37 | 37 | if [ "$XKB_VARIANT" != "" ] ; then |
|
38 | 38 | sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" "${ETC_DIR}/default/keyboard" |
|
39 | 39 | fi |
|
40 | 40 | if [ "$XKB_OPTIONS" != "" ] ; then |
|
41 | 41 | sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" "${ETC_DIR}/default/keyboard" |
|
42 | 42 | fi |
|
43 | 43 | chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration |
|
44 | 44 | |
|
45 | 45 | # Install and setup font console |
|
46 | 46 | case "${DEFLOCAL}" in |
|
47 | 47 | *UTF-8) |
|
48 | 48 | sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' "${ETC_DIR}/default/console-setup" |
|
49 | 49 | ;; |
|
50 | 50 | *) |
|
51 | 51 | sed -i 's/^CHARMAP.*/CHARMAP="guess"/' "${ETC_DIR}/default/console-setup" |
|
52 | 52 | ;; |
|
53 | 53 | esac |
|
54 | 54 | chroot_exec dpkg-reconfigure -f noninteractive console-setup |
|
55 | 55 | else # (no locales were installed) |
|
56 | 56 | # Install POSIX default locale |
|
57 | 57 | install_readonly files/locales/locale "${ETC_DIR}/default/locale" |
|
58 | 58 | fi |
@@ -1,97 +1,97 | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | # This file contains utility functions used by rpi23-gen-image.sh |
|
3 | 3 | |
|
4 | 4 | cleanup (){ |
|
5 | 5 | set +x |
|
6 | 6 | set +e |
|
7 | 7 | |
|
8 | 8 | # Identify and kill all processes still using files |
|
9 | 9 | echo "killing processes using mount point ..." |
|
10 | 10 | fuser -k "${R}" |
|
11 | 11 | sleep 3 |
|
12 | 12 | fuser -9 -k -v "${R}" |
|
13 | 13 | |
|
14 | 14 | # Clean up temporary .password file |
|
15 | 15 | if [ -r ".password" ] ; then |
|
16 | 16 | shred -zu .password |
|
17 | 17 | fi |
|
18 | 18 | |
|
19 | 19 | # Clean up all temporary mount points |
|
20 | 20 | echo "removing temporary mount points ..." |
|
21 | 21 | umount -l "${R}/proc" 2> /dev/null |
|
22 | 22 | umount -l "${R}/sys" 2> /dev/null |
|
23 | 23 | umount -l "${R}/dev/pts" 2> /dev/null |
|
24 | 24 | umount "$BUILDDIR/mount/boot/firmware" 2> /dev/null |
|
25 | 25 | umount "$BUILDDIR/mount" 2> /dev/null |
|
26 | 26 | cryptsetup close "${CRYPTFS_MAPPING}" 2> /dev/null |
|
27 | 27 | losetup -d "$ROOT_LOOP" 2> /dev/null |
|
28 | 28 | losetup -d "$FRMW_LOOP" 2> /dev/null |
|
29 | 29 | trap - 0 1 2 3 6 |
|
30 | 30 | } |
|
31 | 31 | |
|
32 | 32 | chroot_exec() { |
|
33 | 33 | # Exec command in chroot |
|
34 | 34 | LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot "${R}" "$@" |
|
35 | 35 | } |
|
36 | 36 | |
|
37 | 37 | as_nobody() { |
|
38 | 38 | # Exec command as user nobody |
|
39 | 39 | sudo -E -u nobody LANG=C LC_ALL=C "$@" |
|
40 | 40 | } |
|
41 | 41 | |
|
42 | 42 | install_readonly() { |
|
43 | 43 | # Install file with user read-only permissions |
|
44 | 44 | install -o root -g root -m 644 "$@" |
|
45 | 45 | } |
|
46 | 46 | |
|
47 | 47 | install_exec() { |
|
48 | 48 | # Install file with root exec permissions |
|
49 | 49 | install -o root -g root -m 744 "$@" |
|
50 | 50 | } |
|
51 | 51 | |
|
52 | 52 | use_template () { |
|
53 | 53 | # Test if configuration template file exists |
|
54 | 54 | if [ ! -r "./templates/${CONFIG_TEMPLATE}" ] ; then |
|
55 | 55 | echo "error: configuration template ${CONFIG_TEMPLATE} not found" |
|
56 | 56 | exit 1 |
|
57 | 57 | fi |
|
58 | 58 | |
|
59 | 59 | # Load template configuration parameters |
|
60 | 60 | . "./templates/${CONFIG_TEMPLATE}" |
|
61 | 61 | } |
|
62 | 62 | |
|
63 | 63 | chroot_install_cc() { |
|
64 | 64 | # Install c/c++ build environment inside the chroot |
|
65 | 65 | if [ -z "${COMPILER_PACKAGES}" ] ; then |
|
66 | 66 | COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }') |
|
67 | 67 | # Install COMPILER_PACKAGES in chroot |
|
68 | 68 | chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install "${COMPILER_PACKAGES}" |
|
69 | 69 | fi |
|
70 | 70 | } |
|
71 | 71 | |
|
72 | 72 | chroot_remove_cc() { |
|
73 | 73 | # Remove c/c++ build environment from the chroot |
|
74 | 74 | if [ -n "${COMPILER_PACKAGES}" ] ; then |
|
75 | 75 | chroot_exec apt-get -qq -y --auto-remove purge "${COMPILER_PACKAGES}" |
|
76 | 76 | COMPILER_PACKAGES="" |
|
77 | 77 | fi |
|
78 | 78 | } |
|
79 | 79 | #GPL v2.0 |
|
80 | 80 | #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh |
|
81 | 81 | set_kernel_config() { |
|
82 | 82 | # flag as $1, value to set as $2, config must exist at "./.config" |
|
83 | 83 | TGT="CONFIG_${1#CONFIG_}" |
|
84 | 84 | REP="${2}" |
|
85 | 85 | if grep -q "^${TGT}[^_]" .config; then |
|
86 | 86 | sed -i "s/^\(${TGT}=.*\|# ${TGT} is not set\)/${TGT}=${REP}/" .config |
|
87 | 87 | else |
|
88 | echo "${TGT}=${2}" >> .config | |
|
88 | echo "${TGT}"="${2}" >> .config | |
|
89 | 89 | fi |
|
90 | 90 | } |
|
91 | 91 | |
|
92 | 92 | unset_kernel_config() { |
|
93 | 93 | # unsets flag with the value of $1, config must exist at "./.config" |
|
94 | 94 | TGT="CONFIG_${1#CONFIG_}" |
|
95 | 95 | sed -i "s/^${TGT}=.*/# ${TGT} is not set/" .config |
|
96 | 96 | } |
|
97 | 97 | # No newline at end of file |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant