diff --git a/misc/packaging/acrn-hypervisor.postinst b/misc/packaging/acrn-hypervisor.postinst index 2068636a9..decd71c21 100644 --- a/misc/packaging/acrn-hypervisor.postinst +++ b/misc/packaging/acrn-hypervisor.postinst @@ -1,46 +1,72 @@ #!/bin/bash -#* Copyright (c) 2020 Intel Corporation All rights reserved. +#* Copyright (c) 2020 Intel Corporation SPDX-License-Identifier: BSD-3-Clause # postinst script for acrn-hypervisor +# please NOTE !!! scenario_info/board_info changed by python scripts, so do not add content there!!! +# please NOTE !!! scenario_info/board_info please add in release.json if needed !!! set -e echo "please choose , ," -echo "Scenario is -> - 1. industry - 2. hybrid - 3. logical_partition" -read num +scenario_info=(industry hybrid logical_partition ) -if [[ $num -eq 1 ]] -then - echo "Scenario is industry" - SCENARIO="industry" -elif [[ $num -eq 2 ]] -then - echo "Scenario is hybrid" - SCENARIO="hybrid" +board_info=(nuc7i7dnb whl-ipc-i5 ) -elif [[ $num -eq 3 ]] -then - echo "Scenario is logical_partition" - SCENARIO="logical_partition" -fi +echo "Scenario is ->" -echo "Board is -> - 1. nuc7i7dnb - 2. whl-ipc-i5" -read num2 +scenario_num=${#scenario_info[@]} + +for ((i=0;i" +board_num=${#board_info[@]} + +for ((i=0;i" echo $ACRNBIN -echo "disk type is -> - 1. nvme - 2. sda" -read num3 +echo "disk type is ->" -if [[ $num3 -eq 1 ]] -then - echo "disk type is nvme" - type="nvme" -elif [[ $num3 -eq 2 ]] -then - echo "disk type is sda" - type="sda" -fi +disk_info=(nvme sda) +disk_num=${#disk_info[@]} +for ((i=0;i , ,"\n') + + end = lines.index('echo "Scenario is ->"\n') + + del lines[(start+1):(end-1)] + + lines.insert(start+1,"\nscenario_info=(%s)\n"%scenario_info) + lines.insert(start+2,"\nboard_info=(%s)\n"%board_info) + with open("acrn-hypervisor.postinst", "w") as f: + for line in lines: + f.write(line) + f.close() listcontrol=['Package: acrn-package\n','version: %s \n'% datetime.date.today(),'Section: free \n','Priority: optional \n','Architecture: amd64 \n','Installed-Size: 66666 \n','Maintainer: Intel\n','Description: %s \n' % acrn_info,'\n'] @@ -222,24 +318,34 @@ def create_acrn_deb(): if target == 'boot': continue if os.path.exists(target): - os.system('cp %s %s' % (source,target)) + add_cmd_list(cmd_list, 'cp %s %s' % (source,target), cur_dir) else: - os.system('mkdir -p %s' % target) - os.system('cp %s %s' % (source,target)) + add_cmd_list(cmd_list, 'mkdir -p %s' % target, cur_dir) + add_cmd_list(cmd_list, 'cp %s %s' % (source,target), cur_dir) - os.system('cp -r usr acrn_release_deb') - os.system('rm -rf usr') + add_cmd_list(cmd_list, 'mkdir -p %s' % target, cur_dir) + add_cmd_list(cmd_list, 'cp %s %s' % (source,target), cur_dir) - os.system('mkdir -p acrn_release_deb/boot') - cmd = "cp acrn_release_img/acrn.* acrn_release_deb/boot" - os.system(cmd) + add_cmd_list(cmd_list, 'cp -r usr acrn_release_deb', cur_dir) + add_cmd_list(cmd_list, 'rm -rf usr', cur_dir) + add_cmd_list(cmd_list, 'mkdir -p acrn_release_deb/boot', cur_dir) - os.system('cp acrn-hypervisor.postinst acrn_release_deb/DEBIAN/postinst' ) - os.system('chmod +x acrn_release_deb/DEBIAN/postinst') - os.system('sed -i \'s/\r//\' acrn_release_deb/DEBIAN/postinst') - os.system('dpkg -b acrn_release_deb acrn_deb_package.deb ') + for filename in glob.glob(r'acrn_release_img/acrn.*'): + add_cmd_list(cmd_list, 'cp %s acrn_release_deb/boot' % filename, cur_dir) + + add_cmd_list(cmd_list, 'cp acrn-hypervisor.postinst acrn_release_deb/DEBIAN/postinst', cur_dir) + add_cmd_list(cmd_list, 'chmod +x acrn_release_deb/DEBIAN/postinst', cur_dir) + add_cmd_list(cmd_list, 'sed -i \'s/\r//\' acrn_release_deb/DEBIAN/postinst', cur_dir) + + add_cmd_list(cmd_list, 'cp acrn-hypervisor.preinst acrn_release_deb/DEBIAN/preinst', cur_dir) + add_cmd_list(cmd_list, 'chmod +x acrn_release_deb/DEBIAN/preinst', cur_dir) + add_cmd_list(cmd_list, 'sed -i \'s/\r//\' acrn_release_deb/DEBIAN/preinst', cur_dir) + + add_cmd_list(cmd_list, 'dpkg -b acrn_release_deb acrn_deb_package.deb ', cur_dir) + run_cmd_list(cmd_list) + return @@ -274,5 +380,9 @@ def install_process(): print('start install install_acrn_kernel_deb') install_acrn_kernel_deb() + if load_dict['auto_reboot'] == 'true': + print('start reboot') + os.system("sudo reboot") + if __name__ == "__main__": install_process() diff --git a/misc/packaging/release.json b/misc/packaging/release.json index ec0df81fb..1e2531f2c 100644 --- a/misc/packaging/release.json +++ b/misc/packaging/release.json @@ -1,68 +1,64 @@ { - "//":"Configuration for packaging ACRN and Ubuntu for simple installation", + "//":"release ubuntu as sos verion", + "install_package":"true", + "gcc_version":"7.3.0", + "binutils":"2.27", + "//":"acrn-hypervisor config", + "build_acrn":"true", + "sync_acrn_code":"true", + "acrn_repo":"https://github.com/projectacrn/acrn-hypervisor.git", + "release_version":"remotes/origin/release_2.1", + "acrn_deb_package":"true", + "install_acrn_deb":"false", + "build_cmd": + { + "build_method": + { + "use_xml":"true", + "use_sourcecode":"true" + }, + "scenario": + { + "industry":"true", + "hybrid":"true", + "logical_partition":"true" - "//":"if true, the script will first install all needed apps and libraries and verify gcc and binutils versions ", - "install_package":"true", - "gcc_version":"7.3.0", - "binutils":"2.27", + }, + "board": + { + "nuc7i7dnb":"true", + "whl-ipc-i5":"true" + }, + "release":"0" + }, + "acrn_patch": + { + "patch_need":"false", + "patch_dir":"acrn_additional_patch", + "patch_list": + { + "0001-xxxxxxxx.patch": "true", + "0002-xxxxxxxx.patch": "true" + } - "//":"acrn-hypervisor config -------------------------------------", + }, + "//":"kernel config", + "build_acrn_kernel":"true", + "sync_acrn_kernel_code":"true", + "kernel_patch": + { + "patch_need":"false", + "patch_dir":"kernel_additional_patch", + "patch_list": + { + "0001_xxxxxxxx.patch": "true" + } - "//":"if true, uses make to build ACRN from source for the scenarios and boards specified by build_cmd below", - "build_acrn":"true", - - "//":"if true, (and build_acrn is true) clone a local copy of the specified release version of the ACRN hypervisor repo", - "//":"if false, assume the repo's local copy is OK", - "sync_acrn_code":"true", - "acrn_repo":"https://github.com/projectacrn/acrn-hypervisor.git", - "release_version":"remotes/origin/release_2.0", - - "//":"if true, build the acrn_deb_package.deb with the ACRN hypervisor and tools", - "//":"(if build_acrn is false, the package contents won't be recompiled before packaging)", - "acrn_deb_package":"true", - - "//":"if true, install the acrn_deb package locally after it's built", - "//":"(normally the package is copied to the target and installed there, so default is false)", - "install_acrn_deb":"false", - - "//":"This is the list of scenario and board combinations that will be built into the package", - "//":"(each scenario for each board) use release=0 for debug build, and 1 for production build", - "build_cmd": - { - "scenario": - { - "industry":"true", - "hybrid":"true", - "logical_partition":"true" - }, - "board": - { - "nuc7i7dnb":"true", - "whl-ipc-i5":"true" - }, - "release":"0" - }, - - "//":"kernel config ----------------------------------------------", - - "//":"if true, uses make to build the ACRN-patched kernel from source", - "build_acrn_kernel":"true", - - "//":"if true, (and build_acrn_kernel is true) clone a local copy of the specified release version of the ACRN kernel repo", - "//":"if false, assume the repo's local copy is OK", - "sync_acrn_kernel_code":"true", - "kernel_release_version":"remotes/origin/release_2.0", - "sos_kernel_repo":"https://github.com/projectacrn/acrn-kernel.git", - - "//":"if true, build the acrn_kernel_deb_package.deb with the ACRN kernel", - "//":"(if build_acrn_kernel is false, the package contents won't be recompiled before packaging)", - "acrn_kernel_deb_package":"true", - - "//":"if true, install the acrn_kernel_deb package locally after it's built", - "//":"(normally the package is copied to the target and installed there, so default is false)", - "install_acrn_kernel_deb":"false", - - "//":"misc -------------------------------------------------------", - - "auto_reboot":"false" + }, + "kernel_release_version":"remotes/origin/release_2.1", + "sos_kernel_repo":"https://github.com/projectacrn/acrn-kernel.git", + "acrn_kernel_deb_package":"true", + "install_acrn_kernel_deb":"false", + "//":"misc", + "auto_reboot":"false" }