Commit db72eab3 authored by iv's avatar iv

nayuos: Add script to modify the image after build (create two images:...

nayuos: Add script to modify the image after build (create two images: Chromium and Nayu) + script dir.
parent 2667eb96
#!/bin/sh
#XXX: should not depend on the host's sh ^
# Download sources using the "repo" command
DL_LOG={{ instance_log_dir }}/cros_sources_dl.log
echo "getting Chromium OS sources..." >> $DL_LOG
{{ depot_tools_export_path_cmd }}
cd {{ cros_location }}
repo init -u https://chromium.googlesource.com/chromiumos/manifest.git -b {{ branch }} >> $DL_LOG
repo sync >> $DL_LOG
# Build
{{ depot_tools_export_path_cmd }}
cd {{ cros_location }}
IMAGE_LOCATION={{ board }}.img
BUILD_LOG={{ instance_log_dir }}/cros_build.log
echo "building packages for a {{ board }}-flavoured Chromium OS..." >> $BUILD_LOG \
&& cros_sdk -- ./build_packages --board={{ board }} >> $BUILD_LOG \
&& echo "building image for a {{ board }}-flavoured Chromium OS..." >> $BUILD_LOG \
&& cros_sdk -- ./build_image --board={{ board }} >> $BUILD_LOG \
&& echo "removing old image if any and creating image file {{ board }}.img..." >> $BUILD_LOG \
&& cros_sdk -- rm -f $IMAGE_LOCATION \
&& cros_sdk -- touch $IMAGE_LOCATION \
&& cros_sdk -- cros flash --board={{ board }} file://$IMAGE_LOCATION >> $BUILD_LOG
[buildout] [buildout]
parts = parts =
parameters parameters
modify-image-script
template-full-build-script template-full-build-script
# eggs given by software.cfg # eggs given by software.cfg
...@@ -39,11 +40,12 @@ log = ${buildout:directory}/var/log ...@@ -39,11 +40,12 @@ log = ${buildout:directory}/var/log
run = ${buildout:directory}/etc/run run = ${buildout:directory}/etc/run
cros_location = ${buildout:directory}/parts/chromiumos cros_location = ${buildout:directory}/parts/chromiumos
[template-full-build-script] [template-full-build-script]
# create the instance.cfg file in the buildout directory # create the instance.cfg file in the buildout directory
# (use jinja for templating) # (use jinja for templating)
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
template = {{ script_dir }}/cros_full_build.sh.in template = {{ scripts_dir }}/cros_full_build.sh.in
rendered = ${directory:run}/cros_full_build.sh rendered = ${directory:run}/cros_full_build.sh
# md5sum = # md5sum =
mode = 0770 mode = 0770
...@@ -53,4 +55,19 @@ context = ...@@ -53,4 +55,19 @@ context =
key cros_location directory:cros_location key cros_location directory:cros_location
key depot_tools_export_path_cmd depot-tools:export-path key depot_tools_export_path_cmd depot-tools:export-path
key branch parameters:configuration.branch key branch parameters:configuration.branch
key board parameters:configuration.board key boards_list parameters:configuration.boards
\ No newline at end of file
[modify-image-script]
# create the script that will modify the image after the build
recipe = slapos.recipe.template:jinja2
template = {{ scripts_dir }}/modify_image.sh.in
rendered = ${directory:cros_location}/src/scripts/modify_image.sh
mode = 0770
commands = sudo rm /tmp/m/etc/init/openssh-server.conf
sudo install -d /tmp/m/var/run/net/
&& sudo sh -c "printf '127.0.0.1 localhost\n::1 localhost' > /tmp/m/var/run/net/hosts" \
&& sudo rm /tmp/m/etc/hosts \
&& sudo ln -s /tmp/m/etc/hosts /var/run/net/hosts
context =
key board parameters:configuration.boards
key commands :commands
\ No newline at end of file
#!/bin/bash
#XXX: should not depend on the host's bash ^
#################mo####### Download of sources using the "repo" command ########################
DL_LOG={{ instance_log_dir }}/cros_sources_dl.log
echo "getting Chromium OS sources..." >> $DL_LOG
{{ depot_tools_export_path_cmd }}
cd {{ cros_location }}
repo init -u https://chromium.googlesource.com/chromiumos/manifest.git -b {{ branch }} >> $DL_LOG
repo sync >> $DL_LOG
######################################## Build ##############################################
BOARDS="{{ boards_list }}"
for board in ${BOARDS}; do
echo ${board}
if [ ${board} == daisy ]; then
echo "daisy board: accepting license for Mali drivers..."
cros_sdk -- sudo sh -c "cp /etc/make.conf.user /etc/make.conf.user.save"
cros_sdk -- sudo sh -c "echo 'ACCEPT_LICENSE=\"*\"' >> /etc/make.conf.user"
fi
{{ depot_tools_export_path_cmd }}
cd {{ cros_location }}
IMAGE_LOCATION=${board}.chromiumos.img
NAYU_IMAGE_LOCATION=${board}.nayuos.img
BUILD_LOG={{ instance_log_dir }}/cros_build.log
# preparing packages (for chroot and image)
echo "building packages for a ${board}-flavoured Chromium OS..." >> $BUILD_LOG
cros_sdk -- ./build_packages --board=${board} >> $BUILD_LOG
# Chromium original dev image
echo "building image for a ${board}-flavoured Chromium OS..." >> $BUILD_LOG
cros_sdk -- ./build_image --board=${board} >> $BUILD_LOG \
&& echo "removing old image if any and creating image file $IMAGE_LOCATION..." >> $BUILD_LOG \
&& cros_sdk -- rm -f $IMAGE_LOCATION && cros_sdk -- touch $IMAGE_LOCATION \
&& cros_sdk -- cros flash --board=${board} file://$IMAGE_LOCATION >> $BUILD_LOG
# NayuOS
echo "rebuilding image with noenable_rootfs_verification and modifying image" >> $BUILD_LOG
cros_sdk -- ./build_image --board=${board} --noenable_rootfs_verification >> $BUILD_LOG \
&& cros_sdk -- ./modify_image.sh ${board} \
&& echo "modifying image, removing old image if any and creating image file $NAYU_IMAGE_LOCATION..." >> $BUILD_LOG \
&& cros_sdk -- rm -f $NAYU_IMAGE_LOCATION && cros_sdk -- touch $NAYU_IMAGE_LOCATION \
&& cros_sdk -- cros flash --board=${board} file://$NAYU_IMAGE_LOCATION >> $BUILD_LOG
if [ ${board} == daisy ]; then
echo "daisy board: removing accepted license for the next builds..."
cros_sdk -- sudo sh -c "cp /etc/make.conf.user.save /etc/make.conf.user"
fi
done
exit 0
\ No newline at end of file
#! /bin/bash
# will modify all the images produced after running the script for the given board
BOARD=$1
./mount_gpt_image.sh -f $( ./get_latest_image.sh --board=${BOARD} )
{{ commands }}
./mount_gpt_image.sh -f $( ./get_latest_image.sh --board=${BOARD} ) -u
\ No newline at end of file
...@@ -35,13 +35,14 @@ command = sudo -V ...@@ -35,13 +35,14 @@ command = sudo -V
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/instance.cfg template = ${:_profile_base_location_}/instance.cfg
rendered = ${buildout:directory}/instance.cfg rendered = ${buildout:directory}/instance.cfg
md5sum = 0b1a50348c080b280f95dab1817e1033 md5sum = fc963e19bb083726bca7e38224c0edfa
mode = 0644 mode = 0644
scripts_dir = ${:_profile_base_location_}/scripts
context = context =
# for access to the eggs from the instance # for access to the eggs from the instance
key eggs_directory buildout:eggs-directory key eggs_directory buildout:eggs-directory
key develop_eggs_directory buildout:develop-eggs-directory key develop_eggs_directory buildout:develop-eggs-directory
key script_dir :_profile_base_location_ key scripts_dir :scripts_dir
[install-eggs-for-the-instance] [install-eggs-for-the-instance]
# after installation of the eggs, the recipes # after installation of the eggs, the recipes
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment