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