mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 14:41:31 +02:00
Changes to use the postinst --esp-part-file flag; postinst fixups removed
Added the flags required for mounted images to the postinst call. Scripts no longer need to fixup postinst hence that code is removed. Review URL: http://codereview.chromium.org/3027012
This commit is contained in:
parent
dd059edd58
commit
e79e88eb0e
@ -27,17 +27,7 @@ import os
|
|||||||
import stat
|
import stat
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
USAGE = "usage: %prog --mounted_dir=directory --for_qemu=[true]"
|
USAGE = "usage: %prog --mounted_dir=directory --enable_tablet=[true]"
|
||||||
|
|
||||||
POST_INST_IN_FILENAME = 'usr/sbin/chromeos-postinst'
|
|
||||||
POST_INST_OUT_FILENAME = 'postinst_vm'
|
|
||||||
XORG_CONF_FILENAME = os.path.join('etc', 'X11', 'xorg.conf')
|
|
||||||
|
|
||||||
EFI_CODE_MARKER_START = r'echo "Updating grub target for EFI BIOS"'
|
|
||||||
EFI_CODE_MARKER_END = \
|
|
||||||
r"""sh "${INSTALL_ROOT}"/usr/sbin/chromeos-firmwareupdate
|
|
||||||
fi
|
|
||||||
else"""
|
|
||||||
|
|
||||||
INPUT_SECTION_MARKER = r'Section "InputDevice"'
|
INPUT_SECTION_MARKER = r'Section "InputDevice"'
|
||||||
SECTION_END_MARKER = r'EndSection'
|
SECTION_END_MARKER = r'EndSection'
|
||||||
@ -46,8 +36,8 @@ MOUSE_SECTION_IDENTIFIERS = []
|
|||||||
MOUSE_SECTION_IDENTIFIERS += ['Identifier "Mouse']
|
MOUSE_SECTION_IDENTIFIERS += ['Identifier "Mouse']
|
||||||
MOUSE_SECTION_IDENTIFIERS += ['Identifier "USBMouse']
|
MOUSE_SECTION_IDENTIFIERS += ['Identifier "USBMouse']
|
||||||
|
|
||||||
REPLACE_USB_MOUSE_PAIR = ('InputDevice "USBMouse" "AlwaysCore"',
|
REPLACE_USB_MOUSE_PAIR = ('InputDevice "USBMouse" "AlwaysCore"', '')
|
||||||
'')
|
XORG_CONF_FILENAME = os.path.join('etc', 'X11', 'xorg.conf')
|
||||||
|
|
||||||
|
|
||||||
TABLET_DEVICE_CONFIG = """
|
TABLET_DEVICE_CONFIG = """
|
||||||
@ -100,47 +90,21 @@ def FixXorgConf(mount_point):
|
|||||||
f.write(xorg_conf)
|
f.write(xorg_conf)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
# Remove the code that does EFI processing from the postinst script
|
|
||||||
def FixPostInst(mount_point):
|
|
||||||
postinst_in = os.path.join(mount_point, POST_INST_IN_FILENAME)
|
|
||||||
f = open(postinst_in, 'r')
|
|
||||||
postinst = f.read()
|
|
||||||
f.close()
|
|
||||||
m1 = postinst.find(EFI_CODE_MARKER_START)
|
|
||||||
m2 = postinst.find(EFI_CODE_MARKER_END)
|
|
||||||
if (m1 == -1) or (m2 == -1) or (m1 > m2):
|
|
||||||
# basic sanity check
|
|
||||||
return
|
|
||||||
m2 += len(EFI_CODE_MARKER_END)
|
|
||||||
postinst = postinst[0:m1] + postinst[m2:]
|
|
||||||
|
|
||||||
# Write the file back out.
|
|
||||||
postinst_out = os.path.join(mount_point, POST_INST_OUT_FILENAME)
|
|
||||||
f = open(postinst_out, 'w')
|
|
||||||
f.write(postinst)
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
# Mark the file read/execute.
|
|
||||||
os.chmod(postinst_out, stat.S_IEXEC | stat.S_IREAD)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = OptionParser(USAGE)
|
parser = OptionParser(USAGE)
|
||||||
parser.add_option('--mounted_dir', dest='mounted_dir',
|
parser.add_option('--mounted_dir', dest='mounted_dir',
|
||||||
help='directory where the Chromium OS image is mounted')
|
help='directory where the Chromium OS image is mounted')
|
||||||
parser.add_option('--for_qemu', dest='for_qemu',
|
parser.add_option('--enable_tablet', dest='enable_tablet',
|
||||||
default="true",
|
default="true",
|
||||||
help='fixup image for qemu')
|
help='fixup image for qemu')
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
if not options.mounted_dir:
|
if not options.mounted_dir:
|
||||||
parser.error("Please specify the mount point for the Chromium OS image");
|
parser.error("Please specify the mount point for the Chromium OS image");
|
||||||
if options.for_qemu not in ('true', 'false'):
|
if options.enable_tablet not in ('true', 'false'):
|
||||||
parser.error("Please specify either true or false for --for_qemu")
|
parser.error("Please specify either true or false for --enable_tablet")
|
||||||
|
|
||||||
FixPostInst(options.mounted_dir)
|
if (options.enable_tablet == 'true'):
|
||||||
if (options.for_qemu == 'true'):
|
|
||||||
FixXorgConf(options.mounted_dir)
|
FixXorgConf(options.mounted_dir)
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,15 +179,15 @@ mkdir -p "${TEMP_MNT}"
|
|||||||
sudo mount -o loop "${TEMP_ROOTFS}" "${TEMP_MNT}"
|
sudo mount -o loop "${TEMP_ROOTFS}" "${TEMP_MNT}"
|
||||||
if [ "${FLAGS_format}" = "qemu" ]; then
|
if [ "${FLAGS_format}" = "qemu" ]; then
|
||||||
sudo python ./fixup_image_for_qemu.py --mounted_dir="${TEMP_MNT}" \
|
sudo python ./fixup_image_for_qemu.py --mounted_dir="${TEMP_MNT}" \
|
||||||
--for_qemu=true
|
--enable_tablet=true
|
||||||
else
|
else
|
||||||
sudo python ./fixup_image_for_qemu.py --mounted_dir="${TEMP_MNT}" \
|
sudo python ./fixup_image_for_qemu.py --mounted_dir="${TEMP_MNT}" \
|
||||||
--for_qemu=false
|
--enable_tablet=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Change this value if the rootfs partition changes
|
# Change this value if the rootfs partition changes
|
||||||
ROOTFS_PARTITION=/dev/sda3
|
ROOTFS_PARTITION=/dev/sda3
|
||||||
sudo "${TEMP_MNT}"/postinst_vm "${ROOTFS_PARTITION}"
|
sudo "${TEMP_MNT}"/postinst "${ROOTFS_PARTITION}" --esp_part_file="${TEMP_ESP}"
|
||||||
trap - INT TERM EXIT
|
trap - INT TERM EXIT
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user