Automatically translate date formats in po files.
[live-boot-grml.git] / initramfs-tools / scripts / live-functions
1
2 . /scripts/functions
3 . /live.vars
4
5 log_wait_msg ()
6 {
7         # Print a message and wait for enter
8         if [ -x /bin/plymouth ] && plymouth --ping
9         then
10                 plymouth message --text="$@"
11                 plymouth watch-keystroke | read nunya
12         fi
13
14         _log_msg "Waiting: ${@} ... \n"
15 }
16
17 really_export ()
18 {
19         STRING="${1}"
20         VALUE="$(eval echo -n \${$STRING})"
21
22         if [ -f /live.vars ] && grep -sq "export ${STRING}" /live.vars
23         then
24                 sed -i -e 's/\('${STRING}'=\).*$/\1'${VALUE}'/' /live.vars
25         else
26                 echo "export ${STRING}=\"${VALUE}\"" >> /live.vars
27         fi
28
29         eval export "${STRING}"="${VALUE}"
30 }
31
32 lang2locale() {
33         langpart="${1%%_*}"
34         if [ "$1" != "C" ]; then
35                 # Match the language code with 3rd field in languagelist
36                 line=$(grep -v "^#" /usr/share/live-boot/languagelist | cut -f1,3,6 -d\; | grep -v ';C$' | grep "^$langpart;")
37                 if [ -n "$line" ]; then
38                         if [ "$(echo "$line" | grep -c '')" -gt 1 ]; then
39                                 # More than one match; try matching the
40                                 # country as well.
41                                 countrypart="${1#*_}"
42                                 if [ "$countrypart" = "$1" ]; then
43                                         countryline="$(echo "$line" | head -n1)"
44                                         echo "${countryline##*;}"
45                                         return
46                                 fi
47                                 countrypart="${countrypart%%[@.]*}"
48                                 countryline="$(echo "$line" | grep ";$countrypart;" | head -n1 || true)"
49                                 if [ "$countryline" ]; then
50                                         echo "${countryline##*;}"
51                                         return
52                                 fi
53                         fi
54                         echo "${line##*;}"
55                 fi
56         else
57                 echo "C"
58         fi
59 }
60
61 # Override maybe_break from scripts/functions
62 maybe_break()
63 {
64         if [ "${break}" = "$1" ]; then
65                 # Call original panic
66                 . /scripts/functions
67                 panic "Spawning shell within the initramfs"
68         fi
69 }
70
71 # Override panic from scripts/functions
72 panic() {
73
74         DEB_1="\033[1;31m .''\`.  \033[0m"
75         DEB_2="\033[1;31m: :'  : \033[0m"
76         DEB_3="\033[1;31m\`. \`'\`  \033[0m"
77         DEB_4="\033[1;31m  \`-    \033[0m"
78
79         LIVELOG="\033[1;37m/boot.log\033[0m"
80         DEBUG="\033[1;37mdebug\033[0m"
81
82         # Reset redirections to avoid buffering
83         exec 1>&6 6>&-
84         exec 2>&7 7>&-
85         kill ${tailpid}
86
87         printf "\n\n"
88         printf "     ${DEB_1}\n"
89         printf "     ${DEB_2}  \033[1;37mBOOT FAILED!\033[0m\n"
90         printf "     ${DEB_3}\n"
91         printf "     ${DEB_4}  This Debian Live image failed to boot.\n\n"
92
93         printf "  Please file a bug against the 'live-boot' package or email the Debian\n"
94         printf "  Live mailing list at <debian-live@lists.debian.org>, making sure to note the\n"
95         printf "  exact version, name and distribution of the image you were attempting to boot.\n\n"
96
97         printf "  The file ${LIVELOG} contains some debugging information but booting with the\n"
98         printf "  ${DEBUG} command-line parameter will greatly increase its verbosity which is\n"
99         printf "  extremely useful when diagnosing issues.\n\n"
100
101         if [ -n "${panic}" ]; then
102                 printf "  live-boot will now restart your system. "
103         else
104                 printf "  live-boot will now start a shell. "
105         fi
106         printf "The error message was:\n\n    "
107
108         # Call original panic
109         . /scripts/functions
110         panic "$@"
111 }