mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-09 02:46:47 +00:00
运行在docker中完成所有生成iso的动作
This commit is contained in:
parent
63c40fec13
commit
b1f7845520
109
run.sh
109
run.sh
@ -4,6 +4,8 @@
|
|||||||
# echo "请以sudo权限运行"
|
# echo "请以sudo权限运行"
|
||||||
# exit
|
# exit
|
||||||
#fi
|
#fi
|
||||||
|
GENERATE_ISO=0
|
||||||
|
IN_DOCKER=0
|
||||||
|
|
||||||
# 第一个参数如果是--notbuild 那就不构建,直接运行
|
# 第一个参数如果是--notbuild 那就不构建,直接运行
|
||||||
if [ ! "$1" == "--nobuild" ]; then
|
if [ ! "$1" == "--nobuild" ]; then
|
||||||
@ -11,9 +13,18 @@ if [ ! "$1" == "--nobuild" ]; then
|
|||||||
if [ "$1" == "--docker" ]; then
|
if [ "$1" == "--docker" ]; then
|
||||||
echo "使用docker构建"
|
echo "使用docker构建"
|
||||||
sudo bash tools/build_in_docker.sh
|
sudo bash tools/build_in_docker.sh
|
||||||
else
|
GENERATE_ISO=0
|
||||||
|
elif [ "$1" == "--current_in_docker" ]; then
|
||||||
|
echo "运行在docker内"
|
||||||
|
IN_DOCKER=1
|
||||||
make all -j 16
|
make all -j 16
|
||||||
make clean
|
make clean
|
||||||
|
GENERATE_ISO=1
|
||||||
|
else
|
||||||
|
|
||||||
|
make all -j 16
|
||||||
|
make clean
|
||||||
|
GENERATE_ISO=1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -29,60 +40,70 @@ iso='./DragonOS.iso'
|
|||||||
iso_folder='./iso/'
|
iso_folder='./iso/'
|
||||||
root_folder="$(pwd)"
|
root_folder="$(pwd)"
|
||||||
|
|
||||||
# toolchain
|
if [ "${GENERATE_ISO}" == "1" ]; then
|
||||||
OS=`uname -s`
|
echo "开始生成iso..."
|
||||||
if [ "${OS}" == "Linux" ]; then
|
|
||||||
GRUB_PATH="$(dirname $(which grub-file))"
|
|
||||||
elif [ "${OS}" == "Darwin" ]; then
|
|
||||||
GRUB_PATH="$(pwd)/tools/grub-2.06/build/grub/bin"
|
|
||||||
fi
|
|
||||||
export PATH="${GRUB_PATH}:$PATH"
|
|
||||||
|
|
||||||
# ==============检查文件是否齐全================
|
# toolchain
|
||||||
|
OS=`uname -s`
|
||||||
|
if [ "${OS}" == "Linux" ]; then
|
||||||
|
GRUB_PATH="$(dirname $(which grub-file))"
|
||||||
|
elif [ "${OS}" == "Darwin" ]; then
|
||||||
|
GRUB_PATH="$(pwd)/tools/grub-2.06/build/grub/bin"
|
||||||
|
fi
|
||||||
|
export PATH="${GRUB_PATH}:$PATH"
|
||||||
|
|
||||||
|
# ==============检查文件是否齐全================
|
||||||
|
|
||||||
|
|
||||||
bins[0]=${kernel}
|
bins[0]=${kernel}
|
||||||
|
|
||||||
for file in ${bins[*]};do
|
for file in ${bins[*]};do
|
||||||
if [ ! -x $file ]; then
|
if [ ! -x $file ]; then
|
||||||
echo "$file 不存在!"
|
echo "$file 不存在!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# ===============文件检查完毕===================
|
# ===============文件检查完毕===================
|
||||||
|
|
||||||
# 如果是 i386/x86_64,需要判断是否符合 multiboot2 标准
|
# 如果是 i386/x86_64,需要判断是否符合 multiboot2 标准
|
||||||
if [ ${ARCH} == "i386" ] || [ ${ARCH} == "x86_64" ]; then
|
if [ ${ARCH} == "i386" ] || [ ${ARCH} == "x86_64" ]; then
|
||||||
if ${GRUB_PATH}/grub-file --is-x86-multiboot2 ${kernel}; then
|
if ${GRUB_PATH}/grub-file --is-x86-multiboot2 ${kernel}; then
|
||||||
echo Multiboot2 Confirmed!
|
echo Multiboot2 Confirmed!
|
||||||
|
else
|
||||||
|
echo NOT Multiboot2!
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# 检测路径是否合法,发生过 rm -rf -f /* 的惨剧
|
||||||
|
if [ "${iso_boot}" == "" ]; then
|
||||||
|
echo iso_boot path error.
|
||||||
else
|
else
|
||||||
echo NOT Multiboot2!
|
mkdir -p ${iso_boot}
|
||||||
exit
|
rm -rf -f ${iso_boot}/*
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 设置 grub 相关数据
|
||||||
|
if [ ${ARCH} == "i386" ] || [ ${ARCH} == "x86_64" ]; then
|
||||||
|
cp ${kernel} ${iso_boot}
|
||||||
|
mkdir ${iso_boot_grub}
|
||||||
|
touch ${iso_boot_grub}/grub.cfg
|
||||||
|
echo 'set timeout=15
|
||||||
|
set default=0
|
||||||
|
menuentry "DragonOS" {
|
||||||
|
multiboot2 /boot/kernel.elf "KERNEL_ELF"
|
||||||
|
}' >${iso_boot_grub}/grub.cfg
|
||||||
|
fi
|
||||||
|
|
||||||
|
${GRUB_PATH}/grub-mkrescue -o ${iso} ${iso_folder}
|
||||||
|
rm -rf ${iso_folder}
|
||||||
|
if [ "${IN_DOCKER}" == "1" ]; then
|
||||||
|
echo "运行在docker中, 构建结束"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# 检测路径是否合法,发生过 rm -rf -f /* 的惨剧
|
|
||||||
if [ "${iso_boot}" == "" ]; then
|
|
||||||
echo iso_boot path error.
|
|
||||||
else
|
|
||||||
mkdir -p ${iso_boot}
|
|
||||||
rm -rf -f ${iso_boot}/*
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 设置 grub 相关数据
|
|
||||||
if [ ${ARCH} == "i386" ] || [ ${ARCH} == "x86_64" ]; then
|
|
||||||
cp ${kernel} ${iso_boot}
|
|
||||||
mkdir ${iso_boot_grub}
|
|
||||||
touch ${iso_boot_grub}/grub.cfg
|
|
||||||
echo 'set timeout=15
|
|
||||||
set default=0
|
|
||||||
menuentry "DragonOS" {
|
|
||||||
multiboot2 /boot/kernel.elf "KERNEL_ELF"
|
|
||||||
}' >${iso_boot_grub}/grub.cfg
|
|
||||||
fi
|
|
||||||
|
|
||||||
${GRUB_PATH}/grub-mkrescue -o ${iso} ${iso_folder}
|
|
||||||
rm -rf ${iso_folder}
|
|
||||||
# 进行启动前检查
|
# 进行启动前检查
|
||||||
flag_can_run=0
|
flag_can_run=0
|
||||||
|
|
||||||
|
@ -3,5 +3,5 @@ p=`pwd`
|
|||||||
cpu_count=$(cat /proc/cpuinfo |grep "processor"|wc -l)
|
cpu_count=$(cat /proc/cpuinfo |grep "processor"|wc -l)
|
||||||
docker run -v $p:/data --name dragonos-build -i dragonos-dev:v1.0 bash << EOF
|
docker run -v $p:/data --name dragonos-build -i dragonos-dev:v1.0 bash << EOF
|
||||||
cd /data
|
cd /data
|
||||||
make -j ${cpu_count}
|
bash run.sh --current_in_docker
|
||||||
EOF
|
EOF
|
Loading…
x
Reference in New Issue
Block a user