Skip to content

Commit 0918b7e

Browse files
committed
fix chromeos-installer
1 parent 473adf7 commit 0918b7e

9 files changed

Lines changed: 306 additions & 369 deletions

File tree

chromeos-base/chromeos-installer/chromeos-installer.bashrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ unset -f cros_pre_src_prepare_openfyde_patches
55

66
cros_post_src_install_rock5b_openfyde_flash_spi() {
77
exeinto /usr/sbin
8-
doexe ${ROCK5B_OPENFYDE_BASE_BASHRC_FILEPATH}/flash_spi.sh
8+
doexe ${ROCK5B_OPENFYDE_BASHRC_FILEPATH}/flash_spi.sh
9+
doexe ${ROCK5B_OPENFYDE_BASHRC_FILEPATH}/copy_kernel.sh
910
}
1011

1112
cros_pre_src_prepare_rock5b_openfyde_patches() {
12-
eapply -p2 ${ROCK5B_OPENFYDE_BASE_BASHRC_FILEPATH}/install.patch
13-
eapply -p2 ${ROCK5B_OPENFYDE_BASE_BASHRC_FILEPATH}/postinst.patch
13+
eapply -p1 ${ROCK5B_OPENFYDE_BASHRC_FILEPATH}/rock5b.patch
1414
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
#
3+
disk_dev=$1
4+
EFI_NUM=12
5+
6+
help() {
7+
echo "$0 [root_partition_num] [disk_dev]"
8+
}
9+
10+
die() {
11+
echo $@
12+
help
13+
exit 1
14+
}
15+
16+
remove_old_kernel() {
17+
local efi_mnt=$1
18+
19+
rm -f "${efi_mnt}/boot/Image"
20+
rm -rf "${efi_mnt}/boot/rockchip"
21+
}
22+
23+
copy_kernel_to() {
24+
local efi_mnt=$1
25+
26+
[ -f /mnt/stateful_partition/fyde/Env.txt ] && \
27+
cp /mnt/stateful_partition/fyde/Env.txt "${efi_mnt}/boot/"
28+
cp /boot/boot.scr.uimg ${efi_mnt}/boot/
29+
}
30+
31+
main() {
32+
local disk_dev=$1
33+
[ -z "${disk_dev}" ] && disk_dev=$(rootdev -d)
34+
35+
local tmpdir=$(mktemp -d)
36+
local efi_dev=""
37+
38+
if [[ $disk_dev =~ [a-z]$ ]]; then
39+
efi_dev=${disk_dev}${EFI_NUM}
40+
else
41+
efi_dev=${disk_dev}p${EFI_NUM}
42+
fi
43+
44+
mount $efi_dev $tmpdir || die "error mounting efi"
45+
remove_old_kernel $tmpdir || die "error removing old kernel"
46+
copy_kernel_to $tmpdir || die "error copy new kernel"
47+
48+
umount $tmpdir
49+
rmdir $tmpdir
50+
}
51+
52+
main $@

chromeos-base/chromeos-installer/files/install.patch

Lines changed: 0 additions & 21 deletions
This file was deleted.

chromeos-base/chromeos-installer/files/postinst.patch

Lines changed: 0 additions & 58 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
Index: installer/chromeos-install
2+
===================================================================
3+
--- installer.orig/chromeos-install
4+
+++ installer/chromeos-install
5+
@@ -722,6 +722,7 @@ install_stateful() {
6+
var_overlay/db/pkg
7+
var_overlay/lib/portage
8+
dev_image
9+
+ fyde
10+
"
11+
12+
local rootfs_dlc="${ROOT}/opt/google/dlc"
13+
@@ -1026,6 +1027,8 @@ do_post_install() {
14+
fi
15+
local dst_rootfs_dev=""
16+
17+
+ FLAGS_skip_postinstall="${FLAGS_FALSE}"
18+
+ echo "Ignoring --skip_postinstall"
19+
# Now run the postinstall script on one new rootfs. Note that even though
20+
# we're passing the new destination partition number as an arg, the postinst
21+
# script had better not try to access it, for the reasons we just gave.
22+
Index: installer/chromeos-postinst
23+
===================================================================
24+
--- installer.orig/chromeos-postinst
25+
+++ installer/chromeos-postinst
26+
@@ -58,6 +58,32 @@ get_android_version() {
27+
echo ${version#*=}
28+
}
29+
30+
+get_mtd_dev()
31+
+{
32+
+ echo '/dev/mtdblock0'
33+
+}
34+
+
35+
+get_boot_type()
36+
+{
37+
+ cat /mnt/stateful_partition/fyde/Env.txt \
38+
+ | grep -o '^[^#]*' | grep 'overlays=' | grep -q 'ssd-sata'
39+
+
40+
+ if [ "$?" -eq "0" ]; then
41+
+ echo 'SATA'
42+
+ return 0
43+
+ fi
44+
+
45+
+ cat /mnt/stateful_partition/fyde/Env.txt \
46+
+ | grep -o '^[^#]*' | grep 'fdtfile=' | grep -q 'rk3588s-orangepi-5b'
47+
+
48+
+ if [ "$?" -eq "0" ]; then
49+
+ echo 'EMMC'
50+
+ else
51+
+ echo 'NVME'
52+
+ fi
53+
+}
54+
+
55+
+
56+
main() {
57+
local target_disk=$(get_disk_dev)
58+
local target_part_num=$(get_part_num)
59+
@@ -80,6 +106,9 @@ main() {
60+
fi
61+
62+
local install_dev="$1"
63+
+
64+
+ chroot . /usr/sbin/flash_spi.sh "$(get_mtd_dev)" "$(get_boot_type)"
65+
+ chroot . /usr/sbin/copy_kernel.sh "$target_disk"
66+
shift
67+
chroot . /usr/bin/cros_installer --type="postinst" \
68+
--install_dev="${install_dev}" --install_dir="/" "$@"

0 commit comments

Comments
 (0)