diff --git a/README.en.md b/README.en.md index 3a1fa56b702cda122cbf8eab17b858db192ac539..68c2cc49f45feac8f51a06aafff142774dc229fd 100644 --- a/README.en.md +++ b/README.en.md @@ -85,14 +85,14 @@ Refer to [Script for building openEuler image for Raspberry Pi](documents/openEu #### Quickly Build without kernel compilation(Recommended) ->![](documents/public_sys-resources/icon-notice.gif) **NOTICE:** +>![](documents/public_sys-resources/icon-notice.gif) **NOTICE:** >Only openEuler 20.09 is supported currently. Build images with packages of raspberrypi-kernel, raspberrypi-firmware, and raspberrypi-bluetooth. Run the following command to build an image: -`sudo bash build-image.sh -d DIR -r REPO -n IMAGE_NAME` +`sudo bash build-image.sh -d DIR -r REPO -n IMAGE_NAME -s SPEC` The meaning of each parameter: @@ -105,9 +105,9 @@ The meaning of each parameter: 2. -r, --repo REPO_INFO The URL/path of target repo file, or the list of repositories' baseurls. Note that, the baseurls should be separated by space and enclosed in double quotes. - + Examples are as follows: - + - The URL of target repo file: *currently unavailable* - The path of target repo file: `./openEuler-20.09.repo` @@ -130,11 +130,20 @@ The meaning of each parameter: 3. -n, --name IMAGE_NAME The image name to be built. - + For example, `openEuler-20.09.img`. The default is `openEuler-aarch64-raspi.img`, or it is automatically generated based on parameter: `-r, --repo REPO_INFO`. -4. -h, --help - +4. -s, --spec SPEC + + Specify the image version: + - `headless`, image without desktop environments。 + - `standard`,image with Xfce desktop environment and fundamental softwares without CJK fonts and IME. + - `full`,image with Xfce desktop environment and related softwares including CJK fonts and IME. + + The default is `headless`. + +5. -h, --help + Display help information. #### Build with kernel compilation @@ -145,18 +154,18 @@ Here, we provide two approaches to build an image, which both include compiling Run the following command to build an image: -`sudo bash build-image-common.sh -n IMAGE_NAME -k KERNEL_URL -b KERNEL_BRANCH -c KERNEL_DEFCONFIG -r REPO --cores N` +`sudo bash build-image-common.sh -n IMAGE_NAME -k KERNEL_URL -b KERNEL_BRANCH -c KERNEL_DEFCONFIG -r REPO -s SPEC --cores N` The meaning of each parameter: 1. -n, --name IMAGE_NAME The image name to be built. - + For example, `openEuler-20.03-LTS.img`. The default is `openEuler-aarch64-raspi.img`, or it is automatically generated based on parameter: `-r, --repo REPO_INFO`. 2. -k, --kernel KERNEL_URL - + The URL of kernel source's repository, which defaults to `https://gitee.com/openeuler/raspberrypi-kernel.git`. 3. -b, --branch KERNEL_BRANCH @@ -165,22 +174,31 @@ The meaning of each parameter: 4. -c, --config KERNEL_DEFCONFIG - The filename/path of configuration for compiling kernel, which defaults to `openeuler-raspi_defconfig`. If this parameter is the filename of configuration, please make sure the configuration file in arch/arm64/configs of the kernel source. + The filename/path of configuration for compiling kernel, which defaults to `openeuler-raspi_defconfig`. If this parameter is the filename of configuration, please make sure the configuration file in arch/arm64/configs of the kernel source. 5. -r, --repo REPO_INFO The URL/path of target repo file, or the list of repositories' baseurls. Note that, the baseurls should be separated by space and enclosed in double quotes. - + Examples are as follows: - + - The URL of target repo file: `https://gitee.com/src-openeuler/openEuler-repos/blob/openEuler-20.03-LTS/generic.repo` - The path of target repo file: `./openEuler-20.03-LTS.repo` - + Refer to `https://gitee.com/src-openeuler/openEuler-repos/blob/openEuler-20.03-LTS/generic.repo` for details about the content of the repo file. - List of repo's baseurls: `"http://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/ http://repo.openeuler.org/openEuler-20.03-LTS/EPOL/aarch64/ http://repo.openeuler.org/openEuler-20.03-LTS/source"` - -6. --cores N - + +6. -s, --spec SPEC + + Specify the image version: + - `headless`, image without desktop environments。 + - `standard`,image with Xfce desktop environment and fundamental softwares without CJK fonts and IME. + - `full`,image with Xfce desktop environment and related softwares including CJK fonts and IME. + + The default is `headless`. + +7. --cores N + The number of parallel compilations, according to the actual number of CPU of the host running the script. The default is the number of processing units available. ##### Build in a Docker container diff --git a/README.md b/README.md index 49e0ebdd8084416a99d8123ef6d6455279f63c3a..6dcda1dd3e1a03e483413bb8945453d326c95d40 100644 --- a/README.md +++ b/README.md @@ -86,27 +86,27 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community #### 快速构建(无需编译内核,推荐) ->![](documents/public_sys-resources/icon-notice.gif) **须知:** +>![](documents/public_sys-resources/icon-notice.gif) **须知:** >当前只支持 openEuler 20.09 版本。 使用已有的树莓派内核、固件、蓝牙等 RPM 包构建镜像。 构建镜像需执行命令: -`sudo bash build-image.sh -d DIR -r REPO -n IMAGE_NAME` +`sudo bash build-image.sh -d DIR -r REPO -n IMAGE_NAME -s SPEC` 各个参数意义: 1. -d, --dir DIR 构建镜像和临时文件的输出目录,默认为脚本所在目录。如果 `DIR` 不存在则会自动创建。 - + 脚本运行结束后,会提示镜像的存储位置,默认保存在 `DIR/raspi_output/img/` 下。 2. -r, --repo REPO_INFO 开发源 repo 文件的 URL 或者路径,也可以是开发源中资源库的 baseurl 列表。注意,如果该参数为资源库的 baseurl 列表,该参数需要使用双引号,各个 baseurl 之间以空格隔开。 - + 下面分别举例: - 开发源 repo 文件的 URL:*暂无* - 开发源的 repo 文件路径:`./openEuler-20.09.repo` @@ -128,13 +128,22 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community - 资源库的 baseurl 列表:`"http://119.3.219.20:82/openEuler:/Mainline/standard_aarch64/ http://119.3.219.20:82/openEuler:/Epol/standard_aarch64/"` 3. -n, --name IMAGE_NAME - + 构建的镜像名称。 - + 例如,`openEuler-20.09.img`。默认为`openEuler-aarch64-raspi.img`,或者根据 `-r, --repo REPO_INFO` 参数自动生成。 -4. -h, --help - +4. -s, --spec SPEC + + 构建的镜像版本: + - `headless`,无图形界面版的镜像。 + - `standard`,带 Xfce 桌面及必要的配套软件(不包括中文字体以及输入法)。 + - `full`,带 Xfce 桌面以及中文字体、输入法等全部配套软件。 + + 默认使用 `headless` 选项。 + +5. -h, --help + 显示帮助信息。 #### 完全构建(包括编译内核) @@ -147,18 +156,18 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community 构建镜像需执行命令: -`sudo bash build-image-common.sh -n IMAGE_NAME -k KERNEL_URL -b KERNEL_BRANCH -c KERNEL_DEFCONFIG -r REPO --cores N` +`sudo bash build-image-common.sh -n IMAGE_NAME -k KERNEL_URL -b KERNEL_BRANCH -c KERNEL_DEFCONFIG -r REPO -s SPEC --cores N` 各个参数意义: 1. -n, --name IMAGE_NAME - + 构建的镜像名称。 - + 例如,`openEuler-20.03-LTS.img`。默认为`openEuler-aarch64-raspi.img`,或者根据 `-r, --repo REPO_INFO` 参数自动生成。 2. -k, --kernel KERNEL_URL - + 内核源码仓库的项目地址,默认为 `https://gitee.com/openeuler/raspberrypi-kernel.git`。 3. -b, --branch KERNEL_BRANCH @@ -166,13 +175,13 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community 内核源码的对应分支,默认为 `master`。 4. -c, --config KERNEL_DEFCONFIG - + 内核编译使用的配置文件名称或路径,默认为 `openeuler-raspi_defconfig`。如果该参数为配置文件名称,请确保该文件在内核源码的目录 arch/arm64/configs 下。 5. -r, --repo REPO_INFO 开发源 repo 文件的 URL 或者路径,也可以是开发源中资源库的 baseurl 列表。注意,如果该参数为资源库的 baseurl 列表,该参数需要使用双引号,各个 baseurl 之间以空格隔开。 - + 下面分别举例: - 开发源 repo 文件的 URL:`https://gitee.com/src-openeuler/openEuler-repos/blob/openEuler-20.03-LTS/generic.repo` - 开发源的 repo 文件路径:`./openEuler-20.03-LTS.repo` @@ -180,7 +189,16 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community 该文件内容参考 `https://gitee.com/src-openeuler/openEuler-repos/blob/openEuler-20.03-LTS/generic.repo`。 - 资源库的 baseurl 列表:`"http://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/ http://repo.openeuler.org/openEuler-20.03-LTS/EPOL/aarch64/ http://repo.openeuler.org/openEuler-20.03-LTS/source"` -6. --cores N +6. -s, --spec SPEC + + 构建的镜像版本: + - `headless`,无图形界面版的镜像。 + - `standard`,带 Xfce 桌面及必要的配套软件(不包括中文字体以及输入法)。 + - `full`,带 Xfce 桌面以及中文字体、输入法等全部配套软件。 + + 默认使用 `headless` 选项。 + +7. --cores N 并行编译的数量,根据运行脚本的宿主机 CPU 实际数目设定,默认为可用的 CPU 总数。 @@ -196,4 +214,4 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community 1. -d, --docker DOCKER_FILE - Docker 镜像的 URL 或者路径, 默认为 `https://repo.openeuler.org/openEuler-20.03-LTS/docker_img/aarch64/openEuler-docker.aarch64.tar.xz`。使用该默认参数时,脚本会自动下载 openEuler 20.03 LTS 的 Docker 镜像,并导入本机系统中。 \ No newline at end of file + Docker 镜像的 URL 或者路径, 默认为 `https://repo.openeuler.org/openEuler-20.03-LTS/docker_img/aarch64/openEuler-docker.aarch64.tar.xz`。使用该默认参数时,脚本会自动下载 openEuler 20.03 LTS 的 Docker 镜像,并导入本机系统中。 diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index 5d9e08fd75f01b879990a21427105c9332a9099c..ad69cbb36a9fb726b2a049a999a3838bec0e84c0 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -3,7 +3,7 @@ set -e __usage=" Usage: build-image-common [OPTIONS] -Build raspberrypi image. +Build raspberrypi image. Options: -n, --name IMAGE_NAME The raspberrypi image name to be built. @@ -11,6 +11,7 @@ Options: -b, --branch KERNEL_BRANCH The branch name of kernel source's repository, which defaults to master. -c, --config KERNEL_DEFCONFIG The name/path of defconfig file when compiling kernel, which defaults to openeuler-raspi_defconfig. -r, --repo REPO_INFO Required! The URL/path of target repo file or list of repo's baseurls which should be a space separated list. + -s, --spec SPEC The image's specification: headless, standard, full. The default is headless. --cores N The number of cpu cores to be used during making. -h, --help Show command help. " @@ -53,6 +54,10 @@ parseargs() repo_file=`echo $2` shift shift + elif [ "x$1" == "x-s" -o "x$1" == "x--spec" ]; then + spec_param=`echo $2` + shift + shift elif [ "x$1" == "x--cores" ]; then make_cores=`echo $2` shift @@ -72,6 +77,34 @@ LOG(){ echo `date` - INFO, $* | tee -a ${cur_dir}/log/log_${builddate}.log } +UMOUNT_ALL(){ + set +e + if grep -q "${rootfs_dir}/dev " /proc/mounts ; then + umount -l ${rootfs_dir}/dev + fi + if grep -q "${rootfs_dir}/proc " /proc/mounts ; then + umount -l ${rootfs_dir}/proc + fi + if grep -q "${rootfs_dir}/sys " /proc/mounts ; then + umount -l ${rootfs_dir}/sys + fi + set -e +} + +INSTALL_PACKAGES(){ + for item in $(cat $1) + do + dnf --installroot=${rootfs_dir}/ install -y $item + if [ $? == 0 ]; then + LOG install $item. + else + ERROR can not install $item. + fi + done +} + +trap 'UMOUNT_ALL' EXIT + prepare(){ if [ ! -d ${tmp_dir} ]; then mkdir -p ${tmp_dir} @@ -91,6 +124,14 @@ prepare(){ echo `date` - ERROR, config file $default_defconfig can not be found. exit 2 fi + if [ "x$spec_param" == "xheadless" ] || [ "x$spec_param" == "x" ]; then + img_spec="headless" + elif [ "x$spec_param" == "xstandard" ] || [ "x$spec_param" == "xfull" ]; then + img_spec=$spec_param + else + echo `date` - ERROR, please check your params in option -s or --spec. + exit 2 + fi if [ "x$repo_file" == "x" ] ; then echo `date` - ERROR, \"-r REPO_INFO or --repo REPO_INFO\" missing. help 2 @@ -125,7 +166,7 @@ prepare(){ repo_file=${tmp_dir}/${repo_file_name} fi fi - + repo_suffix=${repo_file_name%.*} if [ "x$img_name" == "x" ]; then if [[ "${repo_suffix}" =~ ^${OS_NAME}.* ]]; then @@ -151,7 +192,7 @@ prepare(){ if [ ! -d ${run_dir}/img ]; then mkdir ${run_dir}/img fi - + repo_info_names=`cat ${repo_file} | grep "^\["` repo_baseurls=`cat ${repo_file} | grep "^baseurl="` index=1 @@ -393,15 +434,7 @@ make_rootfs(){ LOG "make rootfs for ${repo_file} begin..." cd "${run_dir}" if [[ -d ${rootfs_dir} ]]; then - if [[ -d ${rootfs_dir}/dev && `ls ${rootfs_dir}/dev | wc -l` -gt 1 ]]; then - umount -l ${rootfs_dir}/dev - fi - if [[ -d ${rootfs_dir}/proc && `ls ${rootfs_dir}/proc | wc -l` -gt 0 ]]; then - umount -l ${rootfs_dir}/proc - fi - if [[ -d ${rootfs_dir}/sys && `ls ${rootfs_dir}/sys | wc -l` -gt 0 ]]; then - umount -l ${rootfs_dir}/sys - fi + UMOUNT_ALL rm -rf ${rootfs_dir} fi mkdir ${rootfs_dir} @@ -419,22 +452,17 @@ make_rootfs(){ # dnf --installroot=${rootfs_dir}/ makecache # dnf --installroot=${rootfs_dir}/ install -y alsa-utils wpa_supplicant vim net-tools iproute iputils NetworkManager openssh-server passwd hostname ntp bluez pulseaudio-module-bluetooth set +e - for item in $(cat $CONFIG_RPM_LIST) - do - dnf --installroot=${rootfs_dir}/ install -y $item - if [ $? == 0 ]; then - LOG install $item. - else - ERROR can not install $item. - fi - done - cat ${rootfs_dir}/etc/ntp.conf | grep "^server*" - if [ $? -ne 0 ]; then - echo -e "\nserver 0.cn.pool.ntp.org\nserver 1.asia.pool.ntp.org\nserver 2.asia.pool.ntp.org\nserver 127.0.0.1">>${rootfs_dir}/etc/ntp.conf + if [ $img_spec == "headless" ]; then + INSTALL_PACKAGES $CONFIG_RPM_LIST + elif [ $img_spec == "standard" ]; then + INSTALL_PACKAGES $CONFIG_STANDARD_LIST + elif [ $img_spec == "full" ]; then + INSTALL_PACKAGES $CONFIG_FULL_LIST fi - cat ${rootfs_dir}/etc/ntp.conf | grep "^fudge*" + cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" if [ $? -ne 0 ]; then - echo -e "\nfudge 127.0.0.1 stratum 10">>${rootfs_dir}/etc/ntp.conf + sed -i 's/#NTP=/NTP=0.cn.pool.ntp.org/g' ${rootfs_dir}/etc/systemd/timesyncd.conf + sed -i 's/#FallbackNTP=/FallbackNTP=1.asia.pool.ntp.org 2.asia.pool.ntp.org/g' ${rootfs_dir}/etc/systemd/timesyncd.conf fi set -e cp ${euler_dir}/hosts ${rootfs_dir}/etc/hosts @@ -462,9 +490,7 @@ make_rootfs(){ mount -t proc /proc ${rootfs_dir}/proc mount -t sysfs /sys ${rootfs_dir}/sys chroot ${rootfs_dir} /bin/bash -c "echo 'Y' | /chroot.sh" - umount -l ${rootfs_dir}/dev - umount -l ${rootfs_dir}/proc - umount -l ${rootfs_dir}/sys + UMOUNT_ALL rm ${rootfs_dir}/etc/yum.repos.d/tmp.repo rm ${rootfs_dir}/chroot.sh LOG "make rootfs for ${repo_file} end." @@ -474,12 +500,12 @@ make_img(){ LOG "make ${img_file} begin..." cd "${run_dir}" size=`du -sh --block-size=1MiB ${rootfs_dir} | cut -f 1 | xargs` - size=$(($size+1100)) + size=$(($size+1150)) losetup -D dd if=/dev/zero of=${img_file} bs=1MiB count=$size && sync parted ${img_file} mklabel msdos mkpart primary fat32 8192s 593919s parted ${img_file} -s set 1 boot - parted ${img_file} mkpart primary linux-swap 593920s 1593343s + parted ${img_file} mkpart primary linux-swap 593920s 1593343s parted ${img_file} mkpart primary ext4 1593344s 100% device=`losetup -f --show -P ${img_file}` LOG "after losetup: ${device}" @@ -603,12 +629,17 @@ rootfs_dir=${run_dir}/rootfs_${builddate} root_mnt=${run_dir}/root boot_mnt=${run_dir}/boot euler_dir=${cur_dir}/config-common + CONFIG_RPM_LIST=${euler_dir}/rpmlist +CONFIG_STANDARD_LIST=${euler_dir}/standardlist +CONFIG_FULL_LIST=${euler_dir}/fulllist +img_spec="" +UMOUNT_ALL prepare IFS=$'\n' update_firmware_app update_kernel make_rootfs -make_img \ No newline at end of file +make_img diff --git a/scripts/build-image-docker.sh b/scripts/build-image-docker.sh index 4c10e4a41d492a3efcee702b6c87f40191c650c5..6787a7369508b128a9dfa1492a99388976d75639 100644 --- a/scripts/build-image-docker.sh +++ b/scripts/build-image-docker.sh @@ -4,7 +4,7 @@ set -e __usage=" Usage: build-image-docker [OPTIONS] -Build raspberrypi image. +Build raspberrypi image. Options: -d, --docker DOCKER_FILE The URL/path of the Docker image, which defaults to https://repo.openeuler.org/openEuler-20.03-LTS/docker_img/aarch64/openEuler-docker.aarch64.tar.xz. @@ -13,6 +13,7 @@ Options: -b, --branch KERNEL_BRANCH The branch name of kernel source's repository, which defaults to master. -c, --config KERNEL_DEFCONFIG The name/path of defconfig file when compiling kernel, which defaults to openeuler-raspi_defconfig. -r, --repo REPO_INFO Required! The URL/path of target repo file or list of repo's baseurls which should be a space separated list. + -s, --spec SPEC The image's specification: headless, standard, full. The default is headless. --cores N The number of cpu cores to be used during making. -h, --help Show command help. " @@ -84,6 +85,16 @@ parseargs() params="${params} -r ${repo_file}" shift shift + elif [ "x$1" == "x-s" -o "x$1" == "x--spec" ]; then + spec_param=`echo $2` + if [ "x$spec_param" != "xheadless" ] && [ "x$spec_param" != "x" ] \ + && [ "x$spec_param" != "xstandard" ] && [ "x$spec_param" != "xfull" ]; then + echo `date` - ERROR, please check your params in option -s or --spec. + exit 2 + fi + params="${params} -s ${spec_param}" + shift + shift elif [ "x$1" == "x--cores" ]; then make_cores=`echo $2` params="${params} --cores ${make_cores}" diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 32f489d1a5371f4a641fe592d5de0885b195034a..c4d2714887505e89a3f4bd8bbaa2598739c9eac0 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -10,6 +10,7 @@ Options: -d, --dir DIR The directory for storing the image and other temporary files, which defaults to be the directory in which the script resides. If the DIR does not exist, it will be created automatically. -r, --repo REPO_INFO Required! The URL/path of target repo file or list of repo's baseurls which should be a space separated list. -n, --name IMAGE_NAME The raspberrypi image name to be built. + -s, --spec SPEC The image's specification: headless, standard, full. The default is headless. -h, --help Show command help. " @@ -43,6 +44,10 @@ parseargs() workdir=`echo $2` shift shift + elif [ "x$1" == "x-s" -o "x$1" == "x--spec" ]; then + spec_param=`echo $2` + shift + shift else echo `date` - ERROR, UNKNOWN params "$@" return 2 @@ -58,12 +63,48 @@ LOG(){ echo `date` - INFO, $* | tee -a ${log_dir}/${builddate}.log } +UMOUNT_ALL(){ + set +e + if grep -q "${rootfs_dir}/dev " /proc/mounts ; then + umount -l ${rootfs_dir}/dev + fi + if grep -q "${rootfs_dir}/proc " /proc/mounts ; then + umount -l ${rootfs_dir}/proc + fi + if grep -q "${rootfs_dir}/sys " /proc/mounts ; then + umount -l ${rootfs_dir}/sys + fi + set -e +} + +INSTALL_PACKAGES(){ + for item in $(cat $1) + do + dnf --installroot=${rootfs_dir}/ install -y $item + if [ $? == 0 ]; then + LOG install $item. + else + ERROR can not install $item. + fi + done +} + +trap 'UMOUNT_ALL' EXIT + prepare(){ if [ ! -d ${tmp_dir} ]; then mkdir -p ${tmp_dir} else rm -rf ${tmp_dir}/* fi + if [ "x$spec_param" == "xheadless" ] || [ "x$spec_param" == "x" ]; then + img_spec="headless" + elif [ "x$spec_param" == "xstandard" ] || [ "x$spec_param" == "xfull" ]; then + img_spec=$spec_param + else + echo `date` - ERROR, please check your params in option -s or --spec. + exit 2 + fi if [ "x$repo_file" == "x" ] ; then echo `date` - ERROR, \"-r REPO_INFO or --repo REPO_INFO\" missing. help 2 @@ -98,7 +139,7 @@ prepare(){ repo_file=${tmp_dir}/${repo_file_name} fi fi - + repo_suffix=${repo_file_name%.*} if [ "x$img_name" == "x" ]; then if [[ "${repo_suffix}" =~ ^${OS_NAME}.* ]]; then @@ -162,15 +203,7 @@ prepare(){ make_rootfs(){ LOG "make rootfs for ${repo_file} begin..." if [[ -d ${rootfs_dir} ]]; then - if [[ -d ${rootfs_dir}/dev && `ls ${rootfs_dir}/dev | wc -l` -gt 1 ]]; then - umount -l ${rootfs_dir}/dev - fi - if [[ -d ${rootfs_dir}/proc && `ls ${rootfs_dir}/proc | wc -l` -gt 0 ]]; then - umount -l ${rootfs_dir}/proc - fi - if [[ -d ${rootfs_dir}/sys && `ls ${rootfs_dir}/sys | wc -l` -gt 0 ]]; then - umount -l ${rootfs_dir}/sys - fi + UMOUNT_ALL rm -rf ${rootfs_dir} fi mkdir -p ${rootfs_dir} @@ -189,22 +222,17 @@ make_rootfs(){ # dnf --installroot=${rootfs_dir}/ install -y alsa-utils wpa_supplicant vim net-tools iproute iputils NetworkManager openssh-server passwd hostname ntp bluez pulseaudio-module-bluetooth # dnf --installroot=${rootfs_dir}/ install -y raspberrypi-kernel raspberrypi-firmware openEuler-repos set +e - for item in $(cat $CONFIG_RPM_LIST) - do - dnf --installroot=${rootfs_dir}/ install -y $item - if [ $? == 0 ]; then - LOG install $item. - else - ERROR can not install $item. - fi - done - cat ${rootfs_dir}/etc/ntp.conf | grep "^server*" - if [ $? -ne 0 ]; then - echo -e "\nserver 0.cn.pool.ntp.org\nserver 1.asia.pool.ntp.org\nserver 2.asia.pool.ntp.org\nserver 127.0.0.1">>${rootfs_dir}/etc/ntp.conf + if [ $img_spec == "headless" ]; then + INSTALL_PACKAGES $CONFIG_RPM_LIST + elif [ $img_spec == "standard" ]; then + INSTALL_PACKAGES $CONFIG_STANDARD_LIST + elif [ $img_spec == "full" ]; then + INSTALL_PACKAGES $CONFIG_FULL_LIST fi - cat ${rootfs_dir}/etc/ntp.conf | grep "^fudge*" + cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" if [ $? -ne 0 ]; then - echo -e "\nfudge 127.0.0.1 stratum 10">>${rootfs_dir}/etc/ntp.conf + sed -i 's/#NTP=/NTP=0.cn.pool.ntp.org/g' ${rootfs_dir}/etc/systemd/timesyncd.conf + sed -i 's/#FallbackNTP=/FallbackNTP=1.asia.pool.ntp.org 2.asia.pool.ntp.org/g' ${rootfs_dir}/etc/systemd/timesyncd.conf fi set -e cp ${euler_dir}/hosts ${rootfs_dir}/etc/hosts @@ -220,9 +248,7 @@ make_rootfs(){ mount -t proc /proc ${rootfs_dir}/proc mount -t sysfs /sys ${rootfs_dir}/sys chroot ${rootfs_dir} /bin/bash -c "echo 'Y' | /chroot.sh" - umount -l ${rootfs_dir}/dev - umount -l ${rootfs_dir}/proc - umount -l ${rootfs_dir}/sys + UMOUNT_ALL rm ${rootfs_dir}/etc/yum.repos.d/tmp.repo rm ${rootfs_dir}/chroot.sh LOG "make rootfs for ${repo_file} end." @@ -236,7 +262,7 @@ make_img(){ dd if=/dev/zero of=${img_file} bs=1MiB count=$size && sync parted ${img_file} mklabel msdos mkpart primary fat32 8192s 593919s parted ${img_file} -s set 1 boot - parted ${img_file} mkpart primary linux-swap 593920s 1593343s + parted ${img_file} mkpart primary linux-swap 593920s 1593343s parted ${img_file} mkpart primary ext4 1593344s 100% device=`losetup -f --show -P ${img_file}` LOG "after losetup: ${device}" @@ -282,6 +308,9 @@ make_img(){ echo "UUID=${fstab_array[1]} /boot vfat defaults,noatime 0 0" >> ${rootfs_dir}/etc/fstab echo "UUID=${fstab_array[2]} swap swap defaults,noatime 0 0" >> ${rootfs_dir}/etc/fstab + if [ -d ${rootfs_dir}/boot/grub2 ]; then + rm -rf ${rootfs_dir}/boot/grub2 + fi cp -a ${rootfs_dir}/boot/* ${boot_mnt}/ cp ${euler_dir}/config.txt ${boot_mnt}/ echo "console=serial0,115200 console=tty1 root=/dev/mmcblk0p3 rootfstype=ext4 elevator=deadline rootwait" > ${boot_mnt}/cmdline.txt @@ -348,11 +377,16 @@ tmp_dir=${workdir}/raspi_output/tmp log_dir=${workdir}/raspi_output/log img_dir=${workdir}/raspi_output/img euler_dir=${cur_dir}/config + CONFIG_RPM_LIST=${euler_dir}/rpmlist +CONFIG_STANDARD_LIST=${euler_dir}/standardlist +CONFIG_FULL_LIST=${euler_dir}/fulllist +img_spec="" builddate=$(date +%Y%m%d) +UMOUNT_ALL prepare IFS=$'\n' make_rootfs -make_img \ No newline at end of file +make_img diff --git a/scripts/config-common/fulllist b/scripts/config-common/fulllist new file mode 100644 index 0000000000000000000000000000000000000000..e042ef316ac7dc25943a45cced4637e2c64fd637 --- /dev/null +++ b/scripts/config-common/fulllist @@ -0,0 +1,62 @@ +dnf +alsa-utils +wpa_supplicant +vim +net-tools +iproute +iputils +NetworkManager +openssh-server +passwd +hostname +bluez +pulseaudio-module-bluetooth +sudo +xorg-x11-drv-fbdev +lightdm +lightdm-gtk +xfce4-session +xfwm4 +xfce4-panel +Thunar +thunar-archive-plugin +thunar-media-tags-plugin +thunar-vcs-plugin +thunar-volman +ristretto +xarchiver +firefox +mousepad +parole +xfce4-appfinder +xfce4-notifyd +xfce4-power-manager +xfce4-screensaver +xfce4-screenshooter +xfce4-settings +xfce4-taskmanager +xfce4-terminal +xfce4-volumed-pulse +xfce-polkit +xfce-theme-manager +xfdesktop +blueman +network-manager-applet +gparted +librsvg2 +catfish +gigolo +xfburn +xfce4-dev-tools +xfce4-dict +xfce4-panel-profiles +imsettings +im-chooser +fcitx +fcitx-qt5 +fcitx-libpinyin +fcitx-configtool +google-noto-sans-sc-fonts +google-noto-serif-sc-fonts +google-noto-sans-mono-cjk-sc-fonts +openEuler-repos diff --git a/scripts/config-common/rpmlist b/scripts/config-common/rpmlist index e5e664bcd9e213aac3e163dbca1aa073f6d90975..8d11480fa9f625804cb451c04913436f8647e8cc 100644 --- a/scripts/config-common/rpmlist +++ b/scripts/config-common/rpmlist @@ -9,7 +9,7 @@ NetworkManager openssh-server passwd hostname -ntp bluez pulseaudio-module-bluetooth -openEuler-repos \ No newline at end of file +sudo +openEuler-repos diff --git a/scripts/config-common/standardlist b/scripts/config-common/standardlist new file mode 100644 index 0000000000000000000000000000000000000000..a18c4b2483140d717aa067296a6b6374c9b3b319 --- /dev/null +++ b/scripts/config-common/standardlist @@ -0,0 +1,47 @@ +dnf +alsa-utils +wpa_supplicant +vim +net-tools +iproute +iputils +NetworkManager +openssh-server +passwd +hostname +bluez +pulseaudio-module-bluetooth +sudo +xorg-x11-drv-fbdev +lightdm +lightdm-gtk +xfce4-session +xfwm4 +xfce4-panel +Thunar +thunar-archive-plugin +thunar-media-tags-plugin +thunar-vcs-plugin +thunar-volman +ristretto +xarchiver +firefox +mousepad +parole +xfce4-appfinder +xfce4-notifyd +xfce4-power-manager +xfce4-screensaver +xfce4-screenshooter +xfce4-settings +xfce4-taskmanager +xfce4-terminal +xfce4-volumed-pulse +xfce-polkit +xfce-theme-manager +xfdesktop +blueman +network-manager-applet +gparted +librsvg2 +openEuler-repos diff --git a/scripts/config/chroot.sh b/scripts/config/chroot.sh index 405262a7e39ac8232cf261a5e9c67b5cf278bddf..89bcbd1c818078236905c49fca07b0b6539a4aae 100755 --- a/scripts/config/chroot.sh +++ b/scripts/config/chroot.sh @@ -1,9 +1,11 @@ #!/bin/bash systemctl enable sshd -systemctl enable ntpd +systemctl enable systemd-timesyncd systemctl enable hciuart echo openEuler > /etc/hostname echo "openeuler" | passwd --stdin root +useradd -m -G "wheel" -s "/bin/bash" pi +echo "raspberry" | passwd --stdin pi if [ -f /usr/share/zoneinfo/Asia/Shanghai ]; then if [ -f /etc/localtime ]; then rm -f /etc/localtime @@ -12,4 +14,10 @@ if [ -f /usr/share/zoneinfo/Asia/Shanghai ]; then fi if [ -f /etc/rc.d/rc.local ]; then chmod +x /etc/rc.d/rc.local -fi \ No newline at end of file +fi +if [ -f /etc/lightdm/lightdm.conf ]; then + sed -i 's/#user-session=default/user-session=xfce/g' /etc/lightdm/lightdm.conf +fi +if [ -d /etc/X11/xorg.conf.d ]; then + echo -e "Section \"Device\"\n\tIdentifier \"fb gfx\"\n\tDriver \"fbdev\"\n\tOption \"fb\" \"/dev/fb0\"\nEndSection" > /etc/X11/xorg.conf.d/20-fbdev.conf +fi diff --git a/scripts/config/fulllist b/scripts/config/fulllist new file mode 100644 index 0000000000000000000000000000000000000000..4aed4d372f0ed3db17d8c575d4df71122f172d42 --- /dev/null +++ b/scripts/config/fulllist @@ -0,0 +1,65 @@ +dnf +alsa-utils +wpa_supplicant +vim +net-tools +iproute +iputils +NetworkManager +openssh-server +passwd +hostname +bluez +pulseaudio-module-bluetooth +raspberrypi-kernel +raspberrypi-firmware +raspberrypi-bluetooth +sudo +xorg-x11-drv-fbdev +lightdm +lightdm-gtk +xfce4-session +xfwm4 +xfce4-panel +Thunar +thunar-archive-plugin +thunar-media-tags-plugin +thunar-vcs-plugin +thunar-volman +ristretto +xarchiver +firefox +mousepad +parole +xfce4-appfinder +xfce4-notifyd +xfce4-power-manager +xfce4-screensaver +xfce4-screenshooter +xfce4-settings +xfce4-taskmanager +xfce4-terminal +xfce4-volumed-pulse +xfce-polkit +xfce-theme-manager +xfdesktop +blueman +network-manager-applet +gparted +librsvg2 +catfish +gigolo +xfburn +xfce4-dev-tools +xfce4-dict +xfce4-panel-profiles +imsettings +im-chooser +fcitx +fcitx-qt5 +fcitx-libpinyin +fcitx-configtool +google-noto-sans-sc-fonts +google-noto-serif-sc-fonts +google-noto-sans-mono-cjk-sc-fonts +openEuler-repos diff --git a/scripts/config/rpmlist b/scripts/config/rpmlist index 59f2fea6426d422f923698aa13b824c7ab19673a..a35bbf5ea5cf643b01ebc1dbe2a620c027a80658 100644 --- a/scripts/config/rpmlist +++ b/scripts/config/rpmlist @@ -9,10 +9,10 @@ NetworkManager openssh-server passwd hostname -ntp bluez pulseaudio-module-bluetooth raspberrypi-kernel raspberrypi-firmware raspberrypi-bluetooth -openEuler-repos \ No newline at end of file +sudo +openEuler-repos diff --git a/scripts/config/standardlist b/scripts/config/standardlist new file mode 100644 index 0000000000000000000000000000000000000000..37b0edc725785f560d1ae8488f09394102d503ea --- /dev/null +++ b/scripts/config/standardlist @@ -0,0 +1,50 @@ +dnf +alsa-utils +wpa_supplicant +vim +net-tools +iproute +iputils +NetworkManager +openssh-server +passwd +hostname +bluez +pulseaudio-module-bluetooth +raspberrypi-kernel +raspberrypi-firmware +raspberrypi-bluetooth +sudo +xorg-x11-drv-fbdev +lightdm +lightdm-gtk +xfce4-session +xfwm4 +xfce4-panel +Thunar +thunar-archive-plugin +thunar-media-tags-plugin +thunar-vcs-plugin +thunar-volman +ristretto +xarchiver +firefox +mousepad +parole +xfce4-appfinder +xfce4-notifyd +xfce4-power-manager +xfce4-screensaver +xfce4-screenshooter +xfce4-settings +xfce4-taskmanager +xfce4-terminal +xfce4-volumed-pulse +xfce-polkit +xfce-theme-manager +xfdesktop +blueman +network-manager-applet +gparted +librsvg2 +openEuler-repos