1 |
commit: f3299dffb18d26fe500bc59a59a8bc591b2dcf78 |
2 |
Author: Jason Miller <aidenn0 <AT> geocities <DOT> com> |
3 |
AuthorDate: Wed Jun 22 23:12:10 2016 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 23 19:05:06 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=f3299dff |
7 |
|
8 |
gen_initramfs: fix little-endian problem with hostid |
9 |
|
10 |
gen_initramfs.sh | 14 +++++++++++++- |
11 |
1 file changed, 13 insertions(+), 1 deletion(-) |
12 |
|
13 |
diff --git a/gen_initramfs.sh b/gen_initramfs.sh |
14 |
index f113373..1fd5d2a 100755 |
15 |
--- a/gen_initramfs.sh |
16 |
+++ b/gen_initramfs.sh |
17 |
@@ -110,7 +110,19 @@ append_base_layout() { |
18 |
date -u '+%Y%m%d-%H%M%S' > ${TEMP}/initramfs-base-temp/etc/build_date |
19 |
echo "Genkernel $GK_V" > ${TEMP}/initramfs-base-temp/etc/build_id |
20 |
|
21 |
- printf "$(hostid | sed 's/\([0-9A-F]\{2\}\)/\\x\1/gI')" > ${TEMP}/initramfs-base-temp/etc/hostid |
22 |
+ # The ZFS tools want the hostid in order to find the right pool. |
23 |
+ # Assume the initramfs we're building is for this system, so copy |
24 |
+ # our current hostid into it. |
25 |
+ # We also have to deal with binary+endianness here: glibc's gethostid |
26 |
+ # expects the value to be in binary using the native endianness. But |
27 |
+ # the coreutils hostid program doesn't show it in the right form. |
28 |
+ local hostid |
29 |
+ if file -L "${TEMP}/initramfs-base-temp/bin/sh" | grep -q 'MSB executable'; then |
30 |
+ hostid="$(hostid)" |
31 |
+ else |
32 |
+ hostid="$(hostid | sed -E 's/(..)(..)(..)(..)/\4\3\2\1/')" |
33 |
+ fi |
34 |
+ printf "$(echo "${hostid}" | sed 's/\([0-9A-F]\{2\}\)/\\x\1/gI')" > ${TEMP}/initramfs-base-temp/etc/hostid |
35 |
|
36 |
mkdir -p "${TEMP}/initramfs-base-temp/etc/mdev/helpers" |
37 |
install -m 644 -t "${TEMP}/initramfs-base-temp/etc" /usr/share/genkernel/mdev/mdev.conf |