mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-01 09:42:10 +00:00
misc:update packaging tool,add pre-check scripts/ add patch function /optimize
Tracked-On: #5022 Signed-off-by: zhanqi <sherry.qi.zhang@intel.com>
This commit is contained in:
parent
54f6a6e221
commit
735619f5c2
@ -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 <scenario> ,<board> ,<disk type>"
|
||||
|
||||
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<scenario_num;i++))
|
||||
|
||||
{
|
||||
let s_num=i+1
|
||||
echo $s_num ${scenario_info[i]};
|
||||
|
||||
}
|
||||
|
||||
|
||||
while :
|
||||
do
|
||||
read num
|
||||
if [ $num = 0 ] || [ $num -gt ${scenario_num} ]; then
|
||||
|
||||
echo "out of scenario scope,please retry"
|
||||
else
|
||||
c=$(($num-1))
|
||||
echo "scenario is" ${scenario_info[c]};
|
||||
SCENARIO="${scenario_info[c]}"
|
||||
break
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
echo "Board is ->"
|
||||
board_num=${#board_info[@]}
|
||||
|
||||
for ((i=0;i<board_num;i++))
|
||||
|
||||
{
|
||||
let b_num=i+1
|
||||
echo $b_num ${board_info[i]};
|
||||
|
||||
}
|
||||
|
||||
|
||||
while :
|
||||
do
|
||||
read num2
|
||||
if [ $num2 = 0 ] || [ $num2 -gt ${board_num} ]; then
|
||||
|
||||
echo "out of board scope,please retry"
|
||||
else
|
||||
c1=$(($num2-1))
|
||||
echo "board is" ${board_info[c1]};
|
||||
BOARD="${board_info[c1]}"
|
||||
break
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
if [[ $num2 -eq 1 ]]
|
||||
then
|
||||
echo "Board is nuc7i7dnb"
|
||||
BOARD="nuc7i7dnb"
|
||||
elif [[ $num2 -eq 2 ]]
|
||||
then
|
||||
echo "Board is whl-ipc-i5"
|
||||
BOARD="whl-ipc-i5"
|
||||
fi
|
||||
|
||||
ACRNBIN="/boot/acrn.${SCENARIO}.${BOARD}.bin"
|
||||
|
||||
@ -48,21 +74,34 @@ echo "Your acrn bin is ->"
|
||||
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<disk_num;i++))
|
||||
|
||||
{
|
||||
let d_num=i+1
|
||||
echo $d_num ${disk_info[i]};
|
||||
|
||||
}
|
||||
|
||||
|
||||
while :
|
||||
do
|
||||
read num3
|
||||
if [ $num3 = 0 ] || [ $num3 -gt ${disk_num} ]; then
|
||||
|
||||
echo "out of disk scope,please retry"
|
||||
else
|
||||
c3=$(($num3-1))
|
||||
echo "disk is" ${disk_info[c3]};
|
||||
type="${disk_info[c3]}"
|
||||
break
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
str=$(blkid |grep ext4 |grep ${type})
|
||||
|
||||
|
76
misc/packaging/acrn-hypervisor.preinst
Normal file
76
misc/packaging/acrn-hypervisor.preinst
Normal file
@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
#* Copyright (c) 2020 Intel Corporation SPDX-License-Identifier: BSD-3-Clause
|
||||
# preinst script for acrn-hypervisor
|
||||
|
||||
acrnnative=$(ls /sys/class/ |grep vhm || true)
|
||||
if [ -z "$acrnnative" ]
|
||||
then
|
||||
echo "You are in ubuntu, let's pre-check whether fit acrn needs"
|
||||
else
|
||||
echo "You are in acrn already, no need pre-check "
|
||||
exit 0
|
||||
fi
|
||||
#check mem/cpu
|
||||
cpunumsexp=4
|
||||
percode=$(lscpu |awk '$1 == "Thread(s)" {print $NF}')
|
||||
cputotal=$(lscpu |awk '$1 == "CPU(s):" {print $NF}')
|
||||
|
||||
|
||||
if [[ $cputotal -eq $cpunumsexp ]]
|
||||
then
|
||||
echo "CPU cores config is ok"
|
||||
|
||||
elif [[ $cputotal -gt $cpunumsexp ]]
|
||||
then
|
||||
echo "Error ! hyper threding config not correct!"
|
||||
echo "CPU(s) $cputotal should be $cpunumsexp,Thread(s) per core is $percode,please disable hyperthread in bios"
|
||||
|
||||
elif [[ $cputotal -lt $cpunumsexp ]]
|
||||
then
|
||||
echo "Error ! hyper threding config not correct!"
|
||||
echo "CPU(s) $cputotal should be $cpunumsexp,Thread(s) per core is $percode,please open hyperthread in bios"
|
||||
fi
|
||||
|
||||
|
||||
#check vt
|
||||
vtd=$(ls -al /sys/firmware/acpi/tables |grep DMAR || true)
|
||||
if [ -z "$vtd" ]
|
||||
then
|
||||
echo "Error ! vt-d not enabled!"
|
||||
echo "either hw not support vt-d or bios not enabled"
|
||||
fi
|
||||
vtx=$(lscpu |grep VT-x)
|
||||
|
||||
if [ -z "$vtx" ]
|
||||
then
|
||||
echo "Error ! vt-x not enabled!"
|
||||
echo "either hw not support vt-x or bios not enabled"
|
||||
fi
|
||||
|
||||
echo "vt-x/vt-d config is ok"
|
||||
|
||||
#check cpu
|
||||
|
||||
cputype=$(lscpu |awk '$1 == "Model"'|grep Core || true)
|
||||
if [ -z "$cputype" ]
|
||||
then
|
||||
echo "CPU type not Core"
|
||||
echo "Xeon not support!"
|
||||
echo "Waring ! ACRN may not support your hardware!"
|
||||
else
|
||||
echo "cpu type is ok"
|
||||
fi
|
||||
|
||||
|
||||
#check memory
|
||||
totalmemry=200000000000
|
||||
|
||||
wholememory=$(cat /proc/meminfo |grep MemTotal:|awk '{print $2}')
|
||||
|
||||
if [[ $wholememory -gt $totalmemry ]]
|
||||
then
|
||||
echo "Warning ! memory greater than 16G, please rebuild hypervisor"
|
||||
echo "if you had rebuild version please ignore"
|
||||
else
|
||||
echo "memory is ok, $wholememory"
|
||||
fi
|
@ -4,6 +4,9 @@ import os,sys,copy,json
|
||||
import subprocess
|
||||
import datetime
|
||||
import time
|
||||
import shlex
|
||||
import glob
|
||||
import multiprocessing
|
||||
|
||||
#parse json file
|
||||
with open("release.json","r") as load_f:
|
||||
@ -14,11 +17,40 @@ with open("deb.json","r") as load_fdeb:
|
||||
load_dictdeb = json.load(load_fdeb)
|
||||
load_fdeb.close()
|
||||
|
||||
def run_command(cmd, path):
|
||||
ret_code = 0
|
||||
print("cmd = %s, path = %s" % (cmd, path))
|
||||
cmd_proc = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd = path, universal_newlines=True)
|
||||
|
||||
while True:
|
||||
output = cmd_proc.stdout.readline()
|
||||
print(output.strip())
|
||||
|
||||
ret_code = cmd_proc.poll()
|
||||
if ret_code is not None:
|
||||
for output in cmd_proc.stdout.readlines():
|
||||
print(output.strip())
|
||||
break
|
||||
|
||||
return ret_code
|
||||
|
||||
def add_cmd_list(cmd_list, cmd_str, dir_str):
|
||||
cmd = {}
|
||||
cmd['cmd'] = cmd_str
|
||||
cmd['dir'] = dir_str
|
||||
cmd_list.append(cmd)
|
||||
|
||||
def run_cmd_list(cmd_list):
|
||||
for i, cmd in enumerate(cmd_list):
|
||||
ret = run_command(cmd['cmd'], cmd['dir'])
|
||||
if ret != 0:
|
||||
print("cmd(%s) run in dir(%s) failed and exit" % (cmd['cmd'], cmd['dir']))
|
||||
exit(-1)
|
||||
return
|
||||
# install compile package
|
||||
def install_compile_package():
|
||||
#check compile env
|
||||
os.system('apt install gcc \
|
||||
os.system('sudo apt install gcc \
|
||||
git \
|
||||
make \
|
||||
gnu-efi \
|
||||
@ -44,28 +76,47 @@ def install_compile_package():
|
||||
binutils_version = binutils_version_out.read().split(" ")
|
||||
if tuple(binutils_version[-1].split("\n")[0].split(".")) < tuple(load_dict['binutils'].split('.')):
|
||||
print("your binutils version is too old")
|
||||
os.system('apt install python-pip -y')
|
||||
os.system('pip3 install kconfiglib')
|
||||
os.system('apt-get install bison -y')
|
||||
os.system('apt-get install flex -y')
|
||||
os.system('apt install liblz4-tool -y')
|
||||
|
||||
os.system('sudo apt install python-pip -y')
|
||||
os.system('sudo pip3 install kconfiglib')
|
||||
os.system('sudo apt-get install bison -y')
|
||||
os.system('sudo apt-get install flex -y')
|
||||
os.system('sudo apt install liblz4-tool -y')
|
||||
os.system('sudo apt install bc -y')
|
||||
|
||||
# build acrn
|
||||
def build_acrn():
|
||||
cmd_list = []
|
||||
cur_dir = os.getcwd()
|
||||
hv_dir = cur_dir + '/' + 'acrn-hypervisor'
|
||||
if os.path.exists('acrn_release_img'):
|
||||
os.system('rm -rf acrn_release_img')
|
||||
os.system('mkdir -p acrn_release_img')
|
||||
add_cmd_list(cmd_list, 'rm -rf acrn_release_img', cur_dir)
|
||||
add_cmd_list(cmd_list, 'mkdir -p acrn_release_img', cur_dir)
|
||||
|
||||
if load_dict['sync_acrn_code'] == 'true':
|
||||
if os.path.exists('acrn-hypervisor'):
|
||||
os.system('rm -rf acrn-hypervisor')
|
||||
cmd = 'git clone %s' % load_dict['acrn_repo']
|
||||
os.system(cmd)
|
||||
cmd = 'cd acrn-hypervisor' + "&&" +'git checkout -b mybranch %s'% load_dict['release_version']
|
||||
os.system(cmd)
|
||||
add_cmd_list(cmd_list, 'rm -rf acrn-hypervisor', cur_dir)
|
||||
add_cmd_list(cmd_list, 'git clone %s' % load_dict['acrn_repo'], cur_dir)
|
||||
add_cmd_list(cmd_list, 'git checkout -b mybranch %s'% load_dict['release_version'], hv_dir)
|
||||
|
||||
else:
|
||||
#clean git code directory
|
||||
if os.path.exists('acrn-hypervisor'):
|
||||
add_cmd_list(cmd_list, 'git reset --hard HEAD', hv_dir)
|
||||
add_cmd_list(cmd_list, 'git checkout master', hv_dir)
|
||||
add_cmd_list(cmd_list, 'git branch -D mybranch', hv_dir)
|
||||
add_cmd_list(cmd_list, 'git checkout -b mybranch %s' % load_dict['release_version'], hv_dir)
|
||||
|
||||
|
||||
if load_dict['acrn_patch']['patch_need'] == 'true':
|
||||
#Need to apply additional acrn patch
|
||||
patch_path = os.getcwd() + '/' + load_dict['acrn_patch']['patch_dir']
|
||||
|
||||
for patch in load_dict['acrn_patch']['patch_list']:
|
||||
patch_full_name = patch_path + '/' + patch
|
||||
add_cmd_list(cmd_list, 'git am %s/%s' % (patch_path, patch), hv_dir)
|
||||
|
||||
run_cmd_list(cmd_list)
|
||||
cmd_list = []
|
||||
make_cmd_list =[]
|
||||
|
||||
release = load_dict['build_cmd']['release']
|
||||
@ -78,42 +129,48 @@ def build_acrn():
|
||||
for j in board:
|
||||
if board[j] == 'true':
|
||||
info_list.append((i,j))
|
||||
make_cmd = 'make all BOARD_FILE=misc/acrn-config/xmls/board-xmls/%s.xml SCENARIO_FILE=misc/acrn-config/xmls/config-xmls/%s/%s.xml RELEASE=%s'%(j,j,i,release)
|
||||
if load_dict['build_cmd']['build_method']['use_xml'] == 'true':
|
||||
make_cmd = 'make all BOARD_FILE=misc/acrn-config/xmls/board-xmls/%s.xml SCENARIO_FILE=misc/acrn-config/xmls/config-xmls/%s/%s.xml RELEASE=%s'%(j,j,i,release)
|
||||
else:
|
||||
make_cmd = 'make all BOARD=%s SCENARIO=%s RELEASE=%s'%(j,i,release)
|
||||
|
||||
make_cmd_list.append(make_cmd)
|
||||
|
||||
for i in range(len(make_cmd_list)):
|
||||
cmd = 'cd acrn-hypervisor' + "&&" +'make clean'
|
||||
os.system(cmd)
|
||||
|
||||
cmd = 'cd acrn-hypervisor' + "&&" +'%s'% make_cmd_list[i]
|
||||
os.system(cmd)
|
||||
add_cmd_list(cmd_list, 'make clean', hv_dir)
|
||||
add_cmd_list(cmd_list, make_cmd_list[i], hv_dir)
|
||||
|
||||
bin_name ='acrn.%s.%s.bin' % (info_list[i][0],info_list[i][1])
|
||||
out_name ='acrn.%s.%s.32.out' % (info_list[i][0],info_list[i][1])
|
||||
efi_name ='acrn.%s.%s.efi' % (info_list[i][0],info_list[i][1])
|
||||
|
||||
cmd = 'cp %s acrn_release_img/%s' %(load_dictdeb['acrn.bin']['source'],bin_name)
|
||||
os.system(cmd)
|
||||
add_cmd_list(cmd_list, 'cp %s acrn_release_img/%s' %(load_dictdeb['acrn.bin']['source'],bin_name), cur_dir)
|
||||
add_cmd_list(cmd_list, 'cp %s acrn_release_img/%s' %(load_dictdeb['acrn.32.out']['source'],out_name), cur_dir)
|
||||
|
||||
cmd = 'cp %s acrn_release_img/%s' %(load_dictdeb['acrn.32.out']['source'],out_name)
|
||||
os.system(cmd)
|
||||
|
||||
if os.path.exists(load_dictdeb['acrn.efi']['source']):
|
||||
cmd = 'cp %s acrn_release_img/%s' %(load_dictdeb['acrn.efi']['source'],efi_name)
|
||||
os.system(cmd)
|
||||
add_cmd_list(cmd_list, 'cp %s acrn_release_img/%s' %(load_dictdeb['acrn.efi']['source'],efi_name), cur_dir)
|
||||
run_cmd_list(cmd_list)
|
||||
return
|
||||
|
||||
def create_acrn_kernel_deb():
|
||||
|
||||
cmd_list = []
|
||||
cur_dir = os.getcwd()
|
||||
kernel_dir = cur_dir + '/' + 'acrn-kernel'
|
||||
kernel_deb_dir = cur_dir + '/' + 'acrn_kernel_deb'
|
||||
kernel_boot_dir = kernel_dir + '/' + 'boot'
|
||||
if os.path.exists('acrn_kernel_deb'):
|
||||
os.system('rm -rf acrn_kernel_deb')
|
||||
add_cmd_list(cmd_list, 'rm -rf acrn_kernel_deb', cur_dir)
|
||||
|
||||
os.system('mkdir -p acrn_kernel_deb')
|
||||
add_cmd_list(cmd_list, 'mkdir -p acrn_kernel_deb', cur_dir)
|
||||
add_cmd_list(cmd_list, 'mkdir DEBIAN', kernel_deb_dir)
|
||||
add_cmd_list(cmd_list, 'touch DEBIAN/control', kernel_deb_dir)
|
||||
|
||||
cmd = "cd acrn_kernel_deb" + "&&" +"mkdir DEBIAN"
|
||||
os.system(cmd)
|
||||
|
||||
cmd = "cd acrn_kernel_deb" + "&&" +"touch DEBIAN/control"
|
||||
os.system(cmd)
|
||||
# following operations depends on the previous cmmd. Run and clear cmd list here
|
||||
run_cmd_list(cmd_list)
|
||||
cmd_list = []
|
||||
|
||||
#control file description
|
||||
|
||||
@ -125,12 +182,11 @@ def create_acrn_kernel_deb():
|
||||
|
||||
cmd = 'cd acrn-kernel' + '&&' + 'ls *.gz'
|
||||
filename = os.popen(cmd).read().replace('\n', '').replace('\r', '')
|
||||
cmd = 'cp acrn-kernel/%s acrn_kernel_deb/' % filename
|
||||
os.system(cmd)
|
||||
|
||||
cmd = 'cd acrn_kernel_deb' + '&&' + 'tar -zvxf %s' % filename
|
||||
os.system(cmd)
|
||||
|
||||
add_cmd_list(cmd_list, 'cp acrn-kernel/%s acrn_kernel_deb/' % filename, cur_dir)
|
||||
add_cmd_list(cmd_list, 'tar -zvxf %s' % filename, kernel_deb_dir)
|
||||
# following operations depends on the previous cmmd. Run and clear cmd list here
|
||||
run_cmd_list(cmd_list)
|
||||
cmd_list = []
|
||||
|
||||
cmd = 'cd acrn_kernel_deb/boot' + '&&' + 'ls vmlinuz*'
|
||||
version = os.popen(cmd)
|
||||
@ -139,38 +195,47 @@ def create_acrn_kernel_deb():
|
||||
f.write(version.read())
|
||||
f.close()
|
||||
|
||||
os.system('cp acrn-kernel.postinst acrn_kernel_deb/DEBIAN/postinst' )
|
||||
|
||||
os.system('chmod +x acrn_kernel_deb/DEBIAN/postinst')
|
||||
|
||||
os.system('sed -i \'s/\r//\' acrn_kernel_deb/DEBIAN/postinst')
|
||||
|
||||
os.system('rm acrn_kernel_deb/%s' % filename)
|
||||
|
||||
os.system('dpkg -b acrn_kernel_deb acrn_kernel_deb_package.deb ')
|
||||
add_cmd_list(cmd_list, 'cp acrn-kernel.postinst acrn_kernel_deb/DEBIAN/postinst', cur_dir)
|
||||
add_cmd_list(cmd_list, 'chmod +x acrn_kernel_deb/DEBIAN/postinst', cur_dir)
|
||||
add_cmd_list(cmd_list, 'sed -i \'s/\r//\' acrn_kernel_deb/DEBIAN/postinst', cur_dir)
|
||||
add_cmd_list(cmd_list, 'rm acrn_kernel_deb/%s' % filename, cur_dir)
|
||||
add_cmd_list(cmd_list, 'dpkg -b acrn_kernel_deb acrn_kernel_deb_package.deb ', cur_dir)
|
||||
|
||||
run_cmd_list(cmd_list)
|
||||
cmd_list = []
|
||||
return
|
||||
|
||||
def build_acrn_kernel(acrn_repo,acrn_version):
|
||||
|
||||
cmd_list = []
|
||||
cur_dir = os.getcwd()
|
||||
kernel_dir = cur_dir + '/' + 'acrn-kernel'
|
||||
|
||||
if load_dict['sync_acrn_kernel_code'] == 'true':
|
||||
if os.path.exists('acrn-kernel'):
|
||||
os.system('rm -rf acrn-kernel')
|
||||
add_cmd_list(cmd_list, 'rm -rf acrn-kernel', cur_dir)
|
||||
|
||||
os.system('git clone %s' % acrn_repo)
|
||||
add_cmd_list(cmd_list, 'git clone %s' % acrn_repo, cur_dir)
|
||||
add_cmd_list(cmd_list, 'git checkout %s'% acrn_version, kernel_dir)
|
||||
|
||||
cmd = 'cd acrn-kernel' + "&&" +'git checkout %s'% acrn_version
|
||||
os.system(cmd)
|
||||
if load_dict['kernel_patch']['patch_need'] == 'true':
|
||||
#Need to apply additional acrn patch
|
||||
patch_path = os.getcwd() + '/' + load_dict['kernel_patch']['patch_dir']
|
||||
|
||||
cmd = 'cd acrn-kernel' + "&&" +'make clean'
|
||||
os.system(cmd)
|
||||
# build kernel
|
||||
cmd = 'cd acrn-kernel' + "&&" +'cp kernel_config_uefi_sos .config'
|
||||
os.system(cmd)
|
||||
for patch in load_dict['kernel_patch']['patch_list']:
|
||||
patch_full_name = patch_path + '/' + patch
|
||||
add_cmd_list(cmd_list, 'git am %s/%s' % (patch_path, patch), hv_dir)
|
||||
add_cmd_list(cmd_list, 'make clean', kernel_dir)
|
||||
add_cmd_list(cmd_list, 'cp kernel_config_uefi_sos .config', kernel_dir)
|
||||
add_cmd_list(cmd_list, 'make olddefconfig', kernel_dir)
|
||||
|
||||
cmd = 'cd acrn-kernel' + "&&" +'make olddefconfig'
|
||||
os.system(cmd)
|
||||
cpu_cnt = multiprocessing.cpu_count()
|
||||
cmd = 'make targz-pkg' + " -j%s" % str(cpu_cnt)
|
||||
add_cmd_list(cmd_list, cmd, kernel_dir)
|
||||
|
||||
cmd = 'cd acrn-kernel' + "&&" +'make targz-pkg -j4'
|
||||
os.system(cmd)
|
||||
run_cmd_list(cmd_list)
|
||||
cmd_list = []
|
||||
return
|
||||
|
||||
|
||||
|
||||
@ -187,20 +252,51 @@ def install_acrn_kernel_deb():
|
||||
|
||||
|
||||
def create_acrn_deb():
|
||||
|
||||
cmd_list = []
|
||||
cur_dir = os.getcwd()
|
||||
hv_dir = cur_dir + '/' + 'acrn_release_deb'
|
||||
path = 'acrn_release_deb'
|
||||
if os.path.exists(path):
|
||||
os.system('rm -rf acrn_release_deb')
|
||||
os.system('mkdir -p acrn_release_deb')
|
||||
cmd = "cd acrn_release_deb" + "&&" +"mkdir DEBIAN"
|
||||
os.system(cmd)
|
||||
|
||||
cmd = "cd acrn_release_deb" + "&&" +"touch DEBIAN/control"
|
||||
os.system(cmd)
|
||||
add_cmd_list(cmd_list, 'rm -rf acrn_release_deb', cur_dir)
|
||||
add_cmd_list(cmd_list, 'mkdir -p acrn_release_deb', cur_dir)
|
||||
add_cmd_list(cmd_list, 'mkdir DEBIAN', hv_dir)
|
||||
add_cmd_list(cmd_list, 'touch DEBIAN/control', hv_dir)
|
||||
|
||||
# following operations depends on the previous cmmd. Run and clear cmd list here
|
||||
run_cmd_list(cmd_list)
|
||||
cmd_list = []
|
||||
#control file description
|
||||
acrn_info = load_dict['release_version']
|
||||
scenario = load_dict['build_cmd']['scenario']
|
||||
board = load_dict['build_cmd']['board']
|
||||
|
||||
scenario_info=""
|
||||
board_info=""
|
||||
for i in scenario:
|
||||
scenario_info = scenario_info + i +" "
|
||||
|
||||
for i in board:
|
||||
board_info = board_info + i +" "
|
||||
|
||||
|
||||
lines=[]
|
||||
f=open("acrn-hypervisor.postinst",'r')
|
||||
for line in f:
|
||||
lines.append(line)
|
||||
f.close()
|
||||
|
||||
start = lines.index('echo "please choose <scenario> ,<board> ,<disk type>"\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()
|
||||
|
@ -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"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user