Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: chromeos-postinst

Issue 2742009: Modify postinstall to avoid x86-specific dependencies. (Closed) Base URL: http://src.chromium.org/git/installer.git
Patch Set: Rebase Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/sh -e 1 #!/bin/sh -e
2 2
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # This script is called after an AutoUpdate or USB install. The first argument 7 # This script is called after an AutoUpdate or USB install. The first argument
8 # is the partition where the new rootfs is installed or empty. If non-empty 8 # is the partition where the new rootfs is installed or empty. If non-empty
9 # the rootfs should be updated w/ the new bootloader config. If empty, the 9 # the rootfs should be updated w/ the new bootloader config. If empty, the
10 # rootfs is mounted-read only and should not be updated. 10 # rootfs is mounted-read only and should not be updated.
11 11
12 # Update /boot/extlinux.conf. 12 # Update /boot/extlinux.conf.
13 INSTALL_ROOT=`dirname "$0"` 13 INSTALL_ROOT=`dirname "$0"`
14 INSTALL_DEV="$1" 14 INSTALL_DEV="$1"
15 POSTCOMMIT="$2" 15 POSTCOMMIT="$2"
16 # Find whole disk device. 16 # Find whole disk device.
17 ROOT_DEV=${INSTALL_DEV%%[0-9]*} 17 ROOT_DEV=$(get_block_dev_from_partition_dev ${INSTALL_DEV})
18 NEW_PART_NUM=${INSTALL_DEV##*/*[a-z]} 18 NEW_PART_NUM=${INSTALL_DEV##*/*[a-z]}
19 19
20 case ${NEW_PART_NUM} in 20 case ${NEW_PART_NUM} in
21 "3" ) 21 "3" )
22 BOOT_SLOT="A" 22 BOOT_SLOT="A"
23 ;; 23 ;;
24 "5" ) 24 "5" )
25 BOOT_SLOT="B" 25 BOOT_SLOT="B"
26 ;; 26 ;;
27 * ) 27 * )
28 # Not a valid boot location. 28 # Not a valid boot location.
29 echo "Not a valid target parition number: ${NEW_PART_NUM}" 29 echo "Not a valid target parition number: ${NEW_PART_NUM}"
30 exit 1 30 exit 1
31 ;; 31 ;;
32 esac 32 esac
33 33
34 if [ "$POSTCOMMIT" != "--postcommit" ]; then 34 if [ "$POSTCOMMIT" != "--postcommit" ]; then
35 # Pre-commit. Returning an error here will prevent ever booting into the 35 # Pre-commit. Returning an error here will prevent ever booting into the
36 # installed system. 36 # installed system.
37 37
38 echo "Postinst running" 38 echo "Postinst running"
39 echo " Set boot target to ${INSTALL_DEV}: \ 39 echo " Set boot target to ${INSTALL_DEV}: \
40 Partition ${NEW_PART_NUM}, Slot ${BOOT_SLOT}" 40 Partition ${NEW_PART_NUM}, Slot ${BOOT_SLOT}"
41 41
42 echo "Updating /boot/extlinux.conf target" 42 if [ -f /boot/extlinux.conf ]; then
43 # If the mount-point is read-write, update the bootloader 43 echo "Updating /boot/extlinux.conf target"
44 # Only update extlinux.conf if $1 is non-empty 44 # If the mount-point is read-write, update the bootloader
45 if [ -n "$INSTALL_DEV" ]; then 45 # Only update extlinux.conf if $1 is non-empty
46 # Set default label to chromeos-hd. 46 if [ -n "$INSTALL_DEV" ]; then
47 sed -i 's/^DEFAULT .*/DEFAULT chromeos-hd/' \ 47 # Set default label to chromeos-hd.
48 "$INSTALL_ROOT"/boot/extlinux.conf || true 48 sed -i 's/^DEFAULT .*/DEFAULT chromeos-hd/' \
49 sed -i "{ s:HDROOT:$INSTALL_DEV: }" \ 49 "$INSTALL_ROOT"/boot/extlinux.conf || true
50 "$INSTALL_ROOT"/boot/extlinux.conf || true 50 sed -i "{ s:HDROOT:$INSTALL_DEV: }" \
51 "$INSTALL_ROOT"/boot/extlinux.conf || true
52 fi
51 fi 53 fi
52 54
55
53 echo "Updating grub target for EFI BIOS" 56 echo "Updating grub target for EFI BIOS"
54 # Set up grub.cfg 57 # Set up grub.cfg
55 ${INSTALL_ROOT}/usr/sbin/chromeos-setimage ${BOOT_SLOT} \ 58 ${INSTALL_ROOT}/usr/sbin/chromeos-setimage ${BOOT_SLOT} \
56 --dst=${ROOT_DEV} --run_as_root 59 --dst=${ROOT_DEV} --run_as_root
57 60
58 # Set up gpt boot selection for legacy devices. 61 # Set up gpt boot selection for legacy devices.
59 # flush linux caches; seems to be necessary 62 # flush linux caches; seems to be necessary
60 sync 63 sync
61 echo 3 > /proc/sys/vm/drop_caches 64 echo 3 > /proc/sys/vm/drop_caches
62 65
66
63 echo "Updating gpt PMBR target for legacy BIOS" 67 echo "Updating gpt PMBR target for legacy BIOS"
64 # Configure the PMBR to boot the new image. 68 # Configure the PMBR to boot the new image.
65 # 69 #
66 # IMPORTANT NOTE: postinst is run by the previoulsy installed image 70 # IMPORTANT NOTE: postinst is run by the previoulsy installed image
67 # rather than the new image. So changes here need to be backwards compatible 71 # rather than the new image. So changes here need to be backwards compatible
68 # with the old image's gpt binaries. 72 # with the old image's gpt binaries.
69 # 73 #
70 if [ -x /usr/bin/cgpt ]; then 74 if [ -x /usr/bin/cgpt ]; then
71 cgpt boot -i $NEW_PART_NUM ${ROOT_DEV} 2>&1 75 cgpt boot -i $NEW_PART_NUM ${ROOT_DEV} 2>&1
72 else 76 else
73 # The old gpt tool requires a -b arg to specify the PMBR bootcode. We don't 77 # The old gpt tool requires a -b arg to specify the PMBR bootcode. We don't
74 # want to change the code, so we have to extract it, then put it back. 78 # want to change the code, so we have to extract it, then put it back.
75 dd if=${ROOT_DEV} bs=512 count=1 of=/tmp/oldpmbr.bin 79 dd if=${ROOT_DEV} bs=512 count=1 of=/tmp/oldpmbr.bin
76 gpt -S boot -i $NEW_PART_NUM -b /tmp/oldpmbr.bin ${ROOT_DEV} 2>&1 80 gpt -S boot -i $NEW_PART_NUM -b /tmp/oldpmbr.bin ${ROOT_DEV} 2>&1
77 fi 81 fi
78 else 82 else
79 # Post-commit. At this point an unexpected reboot may boot the installed 83 # Post-commit. At this point an unexpected reboot may boot the installed
80 # system, but returning an error here will cause the updater to try to 84 # system, but returning an error here will cause the updater to try to
81 # not boot the installed system, instead keeping the existing system. 85 # not boot the installed system, instead keeping the existing system.
82 echo -n # this is a noop, required for 'sh' 86 echo -n # this is a noop, required for 'sh'
83 fi 87 fi
84 88
85 89
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698