##// END OF EJS Templates
a
Unknown -
r400:2604f8ea96ac
parent child
Show More
@@ -1,100 +1,97
1 1 # This file contains utility functions used by rpi23-gen-image.sh
2 2
3 3 cleanup (){
4 4 set +x
5 5 set +e
6 6
7 7 # Identify and kill all processes still using files
8 8 echo "killing processes using mount point ..."
9 9 fuser -k "${R}"
10 10 sleep 3
11 11 fuser -9 -k -v "${R}"
12 12
13 13 # Clean up temporary .password file
14 14 if [ -r ".password" ] ; then
15 15 shred -zu .password
16 16 fi
17 17
18 18 # Clean up all temporary mount points
19 19 echo "removing temporary mount points ..."
20 20 umount -l "${R}/proc" 2> /dev/null
21 21 umount -l "${R}/sys" 2> /dev/null
22 22 umount -l "${R}/dev/pts" 2> /dev/null
23 23 umount "$BUILDDIR/mount/boot/firmware" 2> /dev/null
24 24 umount "$BUILDDIR/mount" 2> /dev/null
25 25 cryptsetup close "${CRYPTFS_MAPPING}" 2> /dev/null
26 26 losetup -d "$ROOT_LOOP" 2> /dev/null
27 27 losetup -d "$FRMW_LOOP" 2> /dev/null
28 28 trap - 0 1 2 3 6
29 29 }
30 30
31 31 chroot_exec() {
32 32 # Exec command in chroot
33 33 LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot ${R} $*
34 34 }
35 35
36 36 as_nobody() {
37 37 # Exec command as user nobody
38 38 sudo -E -u nobody LANG=C LC_ALL=C $*
39 39 }
40 40
41 41 install_readonly() {
42 42 # Install file with user read-only permissions
43 43 install -o root -g root -m 644 $*
44 44 }
45 45
46 46 install_exec() {
47 47 # Install file with root exec permissions
48 48 install -o root -g root -m 744 $*
49 49 }
50 50
51 51 use_template () {
52 52 # Test if configuration template file exists
53 53 if [ ! -r "./templates/${CONFIG_TEMPLATE}" ] ; then
54 54 echo "error: configuration template ${CONFIG_TEMPLATE} not found"
55 55 exit 1
56 56 fi
57 57
58 58 # Load template configuration parameters
59 59 . "./templates/${CONFIG_TEMPLATE}"
60 60 }
61 61
62 62 chroot_install_cc() {
63 63 # Install c/c++ build environment inside the chroot
64 64 if [ -z "${COMPILER_PACKAGES}" ] ; then
65 65 COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }')
66 66 # Install COMPILER_PACKAGES in chroot
67 67 chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES}
68 68 fi
69 69 }
70 70
71 71 chroot_remove_cc() {
72 72 # Remove c/c++ build environment from the chroot
73 73 if [ ! -z "${COMPILER_PACKAGES}" ] ; then
74 74 chroot_exec apt-get -qq -y --auto-remove purge ${COMPILER_PACKAGES}
75 75 COMPILER_PACKAGES=""
76 76 fi
77 77 }
78 78 #GPL v2.0
79 79 #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh
80 # edited with thir param
81 #start
82 80 set_kernel_config() {
83 # flag as $1, value to set as $2, config must exist at "./.config"
84 local TGT="CONFIG_${1}"
85 local REP="${2//\//\\/}"
86 if grep -q "^${TGT}[^_]" .config; then
87 sed -i "s/^\(${TGT}=.*\|# ${TGT} is not set\)/${TGT}=${REP}/" .config
88 else
89 echo "${TGT}=${2}" >> .config
90 fi
81 # flag as $1, value to set as $2, config must exist at "./.config"
82 local TGT="CONFIG_${1#CONFIG_}"
83 local REP="${2//\//\\/}"
84 if grep -q "^${TGT}[^_]" .config; then
85 sed -i "s/^\(${TGT}=.*\|# ${TGT} is not set\)/${TGT}=${REP}/" .config
86 else
87 echo "${TGT}=${2}" >> .config
88 fi
91 89 }
92 90
93 91 unset_kernel_config() {
94 # unsets flag with the value of $1, config must exist at "./.config"
95 local TGT="CONFIG_${1}"
96 sed -i "s/^${TGT}=.*/# ${TGT} is not set/" .config
92 # unsets flag with the value of $1, config must exist at "./.config"
93 local TGT="CONFIG_${1#CONFIG_}"
94 sed -i "s/^${TGT}=.*/# ${TGT} is not set/" .config
97 95 }
98 96 #
99 #end
100 #
97
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant