From 4b29ee92ebae59b3367405386c60fccd91f4c8ec Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Sat, 5 Sep 2020 10:44:15 +0800 Subject: [PATCH 01/15] use systemd-timesyncd to replace ntp * reduce some space Signed-off-by: Luke Yue --- scripts/build-image-common.sh | 19 ++++++++----------- scripts/build-image.sh | 15 ++++++--------- scripts/config-common/rpmlist | 3 +-- scripts/config/chroot.sh | 4 ++-- scripts/config/rpmlist | 3 +-- 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index 5d9e08f..2e22285 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. @@ -125,7 +125,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 +151,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 @@ -428,13 +428,10 @@ make_rootfs(){ 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 - 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 @@ -479,7 +476,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}" @@ -611,4 +608,4 @@ update_firmware_app update_kernel make_rootfs -make_img \ No newline at end of file +make_img diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 32f489d..09599c4 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -98,7 +98,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 @@ -198,13 +198,10 @@ make_rootfs(){ 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 - 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 @@ -236,7 +233,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}" @@ -355,4 +352,4 @@ builddate=$(date +%Y%m%d) prepare IFS=$'\n' make_rootfs -make_img \ No newline at end of file +make_img diff --git a/scripts/config-common/rpmlist b/scripts/config-common/rpmlist index e5e664b..a1590fc 100644 --- a/scripts/config-common/rpmlist +++ b/scripts/config-common/rpmlist @@ -9,7 +9,6 @@ NetworkManager openssh-server passwd hostname -ntp bluez pulseaudio-module-bluetooth -openEuler-repos \ No newline at end of file +openEuler-repos diff --git a/scripts/config/chroot.sh b/scripts/config/chroot.sh index 405262a..8ce0f92 100755 --- a/scripts/config/chroot.sh +++ b/scripts/config/chroot.sh @@ -1,6 +1,6 @@ #!/bin/bash systemctl enable sshd -systemctl enable ntpd +systemctl enable systemd-timesyncd systemctl enable hciuart echo openEuler > /etc/hostname echo "openeuler" | passwd --stdin root @@ -12,4 +12,4 @@ 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 diff --git a/scripts/config/rpmlist b/scripts/config/rpmlist index 59f2fea..3921fb7 100644 --- a/scripts/config/rpmlist +++ b/scripts/config/rpmlist @@ -9,10 +9,9 @@ NetworkManager openssh-server passwd hostname -ntp bluez pulseaudio-module-bluetooth raspberrypi-kernel raspberrypi-firmware raspberrypi-bluetooth -openEuler-repos \ No newline at end of file +openEuler-repos -- Gitee From ef8a8fb02605bc95ccc71c3b3556c5fce1c2a00a Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Sat, 5 Sep 2020 10:47:48 +0800 Subject: [PATCH 02/15] add a non-root user for desktop * add sudo package for non-privileged user Signed-off-by: Luke Yue --- scripts/config-common/rpmlist | 1 + scripts/config/chroot.sh | 2 ++ scripts/config/rpmlist | 1 + 3 files changed, 4 insertions(+) diff --git a/scripts/config-common/rpmlist b/scripts/config-common/rpmlist index a1590fc..c8506e8 100644 --- a/scripts/config-common/rpmlist +++ b/scripts/config-common/rpmlist @@ -12,3 +12,4 @@ hostname bluez pulseaudio-module-bluetooth openEuler-repos +sudo diff --git a/scripts/config/chroot.sh b/scripts/config/chroot.sh index 8ce0f92..ecd8a1e 100755 --- a/scripts/config/chroot.sh +++ b/scripts/config/chroot.sh @@ -4,6 +4,8 @@ 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 diff --git a/scripts/config/rpmlist b/scripts/config/rpmlist index 3921fb7..2626873 100644 --- a/scripts/config/rpmlist +++ b/scripts/config/rpmlist @@ -15,3 +15,4 @@ raspberrypi-kernel raspberrypi-firmware raspberrypi-bluetooth openEuler-repos +sudo -- Gitee From 14084b1ebea7581d1719bdcc0a60dd8e46733bd5 Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Sat, 5 Sep 2020 11:03:32 +0800 Subject: [PATCH 03/15] feat(scripts): add function UNMOUNT_ALL feat(scripts): add options spec to determine which spec to build feat(scripts): add trap to trigger UNMOUNT_ALL on exit Signed-off-by: Luke Yue --- scripts/build-image-common.sh | 69 ++++++++++++++++++++++++++++++ scripts/build-image-docker.sh | 21 ++++++++- scripts/build-image.sh | 69 ++++++++++++++++++++++++++++++ scripts/config-common/fulllist | 1 + scripts/config-common/standardlist | 1 + scripts/config/chroot.sh | 4 ++ scripts/config/fulllist | 22 ++++++++++ scripts/config/standardlist | 31 ++++++++++++++ 8 files changed, 217 insertions(+), 1 deletion(-) create mode 120000 scripts/config-common/fulllist create mode 120000 scripts/config-common/standardlist create mode 100644 scripts/config/fulllist create mode 100644 scripts/config/standardlist diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index 2e22285..e67818a 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -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, 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=`echo $2` + shift + shift elif [ "x$1" == "x--cores" ]; then make_cores=`echo $2` shift @@ -72,6 +77,32 @@ LOG(){ echo `date` - INFO, $* | tee -a ${cur_dir}/log/log_${builddate}.log } +UNMOUNT_ALL(){ + if [ -d ${root_mnt} ]; then + df -lh | grep ${root_mnt} + if [ $? -eq 0 ]; then + umount ${root_mnt} + fi + rm -rf ${root_mnt} + fi + if [ -d ${boot_mnt} ]; then + df -lh | grep ${boot_mnt} + if [ $? -eq 0 ]; then + umount ${boot_mnt} + fi + rm -rf ${boot_mnt} + fi + 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 +} + prepare(){ if [ ! -d ${tmp_dir} ]; then mkdir -p ${tmp_dir} @@ -91,6 +122,19 @@ prepare(){ echo `date` - ERROR, config file $default_defconfig can not be found. exit 2 fi + if [ "x$spec" == "xheadless" ] || [ "x$spec" == "x" ]; then + with_standard=0 + with_full=0 + elif [ "x$spec" == "xstandard" ]; then + with_standard=1 + with_full=0 + elif [ "x$spec" == "xfull" ]; then + with_standard=1 + with_full=1 + 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 @@ -428,6 +472,28 @@ make_rootfs(){ ERROR can not install $item. fi done + if [ $with_standard == 1 ]; then + for item in $(cat $CONFIG_STANDARD_LIST) + do + dnf --installroot=${rootfs_dir}/ install -y $item + if [ $? == 0 ]; then + LOG install $item. + else + ERROR can not install $item. + fi + done + fi + if [ $with_full == 1 ]; then + for item in $(cat $CONFIG_FULL_LIST) + do + dnf --installroot=${rootfs_dir}/ install -y $item + if [ $? == 0 ]; then + LOG install $item. + else + ERROR can not install $item. + fi + done + fi cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" if [ $? -ne 0 ]; then sed -i 's/#NTP=/NTP=0.cn.pool.ntp.org/g' ${rootfs_dir}/etc/systemd/timesyncd.conf @@ -601,6 +667,8 @@ 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 prepare IFS=$'\n' @@ -609,3 +677,4 @@ update_kernel make_rootfs make_img +trap 'UNMOUNT_ALL' EXIT diff --git a/scripts/build-image-docker.sh b/scripts/build-image-docker.sh index 4c10e4a..986be03 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, default is headless. --cores N The number of cpu cores to be used during making. -h, --help Show command help. " @@ -84,6 +85,10 @@ parseargs() params="${params} -r ${repo_file}" shift shift + elif [ "x$1" == "x-s" -o "x$1" == "x--spec" ]; then + spec=`echo $2` + shift + shift elif [ "x$1" == "x--cores" ]; then make_cores=`echo $2` params="${params} --cores ${make_cores}" @@ -129,6 +134,20 @@ else exit 2 fi +if [ "x$spec" == "xheadless" ] || [ "x$spec" == "x" ]; then + with_standard=0 + with_full=0 +elif [ "x$spec" == "xstandard" ]; then + with_standard=1 + with_full=0 +elif [ "x$spec" == "xfull" ]; then + with_standard=1 + with_full=1 +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 diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 09599c4..3895432 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, 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=`echo $2` + shift + shift else echo `date` - ERROR, UNKNOWN params "$@" return 2 @@ -58,12 +63,51 @@ LOG(){ echo `date` - INFO, $* | tee -a ${log_dir}/${builddate}.log } +UNMOUNT_ALL(){ + if [ -d ${root_mnt} ]; then + df -lh | grep ${root_mnt} + if [ $? -eq 0 ]; then + umount ${root_mnt} + fi + rm -rf ${root_mnt} + fi + if [ -d ${boot_mnt} ]; then + df -lh | grep ${boot_mnt} + if [ $? -eq 0 ]; then + umount ${boot_mnt} + fi + rm -rf ${boot_mnt} + fi + 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 +} + prepare(){ if [ ! -d ${tmp_dir} ]; then mkdir -p ${tmp_dir} else rm -rf ${tmp_dir}/* fi + if [ "x$spec" == "xheadless" ] || [ "x$spec" == "x" ]; then + with_standard=0 + with_full=0 + elif [ "x$spec" == "xstandard" ]; then + with_standard=1 + with_full=0 + elif [ "x$spec" == "xfull" ]; then + with_standard=1 + with_full=1 + 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 @@ -198,6 +242,28 @@ make_rootfs(){ ERROR can not install $item. fi done + if [ $with_standard == 1 ]; then + for item in $(cat $CONFIG_STANDARD_LIST) + do + dnf --installroot=${rootfs_dir}/ install -y $item + if [ $? == 0 ]; then + LOG install $item. + else + ERROR can not install $item. + fi + done + fi + if [ $with_full == 1 ]; then + for item in $(cat $CONFIG_FULL_LIST) + do + dnf --installroot=${rootfs_dir}/ install -y $item + if [ $? == 0 ]; then + LOG install $item. + else + ERROR can not install $item. + fi + done + fi cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" if [ $? -ne 0 ]; then sed -i 's/#NTP=/NTP=0.cn.pool.ntp.org/g' ${rootfs_dir}/etc/systemd/timesyncd.conf @@ -346,6 +412,8 @@ 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 builddate=$(date +%Y%m%d) @@ -353,3 +421,4 @@ prepare IFS=$'\n' make_rootfs make_img +trap 'UNMOUNT_ALL' EXIT diff --git a/scripts/config-common/fulllist b/scripts/config-common/fulllist new file mode 120000 index 0000000..6a7636a --- /dev/null +++ b/scripts/config-common/fulllist @@ -0,0 +1 @@ +../config/fulllist \ No newline at end of file diff --git a/scripts/config-common/standardlist b/scripts/config-common/standardlist new file mode 120000 index 0000000..6f8b2be --- /dev/null +++ b/scripts/config-common/standardlist @@ -0,0 +1 @@ +../config/standardlist \ No newline at end of file diff --git a/scripts/config/chroot.sh b/scripts/config/chroot.sh index ecd8a1e..2b8dfc2 100755 --- a/scripts/config/chroot.sh +++ b/scripts/config/chroot.sh @@ -15,3 +15,7 @@ fi if [ -f /etc/rc.d/rc.local ]; then chmod +x /etc/rc.d/rc.local fi +if [ -f /etc/lightdm/lightdm.conf ]; then + sudo sed -i 's/#user-session=default/user-session=xfce/g' /etc/lightdm/lightdm.conf +fi +curl https://gitee.com/src-openeuler/openEuler-repos/raw/openEuler-20.03-LTS/generic.repo > /etc/yum.repos.d/generic.repo diff --git a/scripts/config/fulllist b/scripts/config/fulllist new file mode 100644 index 0000000..c67d7f0 --- /dev/null +++ b/scripts/config/fulllist @@ -0,0 +1,22 @@ +catfish +htop +gigolo +xfburn +xfce4-dev-tools +xfce4-dict +xfce4-panel-profiles +ncdu +neofetch +imsettings +im-chooser +fcitx +fcitx-qt5 +fcitx-libpinyin +fcitx-configtool +google-roboto-fonts +gtk-murrine-engine +materia-gtk-theme +papirus-icon-theme +google-noto-sans-sc-fonts +google-noto-serif-sc-fonts +google-noto-sans-mono-cjk-sc-fonts diff --git a/scripts/config/standardlist b/scripts/config/standardlist new file mode 100644 index 0000000..e80cd1e --- /dev/null +++ b/scripts/config/standardlist @@ -0,0 +1,31 @@ +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 +midori +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 -- Gitee From 4edc5bcfb35664a8f8aa04e0c3bca4bd57ae0b20 Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Tue, 8 Sep 2020 17:48:27 +0800 Subject: [PATCH 04/15] feat(scripts): add trap for INT Signed-off-by: Luke Yue --- scripts/build-image-common.sh | 2 ++ scripts/build-image.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index e67818a..566bdf1 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -103,6 +103,8 @@ UNMOUNT_ALL(){ fi } +trap 'UNMOUNT_ALL' INT + prepare(){ if [ ! -d ${tmp_dir} ]; then mkdir -p ${tmp_dir} diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 3895432..9855b21 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -89,6 +89,8 @@ UNMOUNT_ALL(){ fi } +trap 'UNMOUNT_ALL' INT + prepare(){ if [ ! -d ${tmp_dir} ]; then mkdir -p ${tmp_dir} -- Gitee From c3ec279097f46b467f3eb0b782526967a8243066 Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Fri, 18 Sep 2020 20:59:01 +0800 Subject: [PATCH 05/15] fix(chroot): remove unused code Signed-off-by: Luke Yue --- scripts/config/chroot.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/config/chroot.sh b/scripts/config/chroot.sh index 2b8dfc2..fe57eab 100755 --- a/scripts/config/chroot.sh +++ b/scripts/config/chroot.sh @@ -18,4 +18,3 @@ fi if [ -f /etc/lightdm/lightdm.conf ]; then sudo sed -i 's/#user-session=default/user-session=xfce/g' /etc/lightdm/lightdm.conf fi -curl https://gitee.com/src-openeuler/openEuler-repos/raw/openEuler-20.03-LTS/generic.repo > /etc/yum.repos.d/generic.repo -- Gitee From 4305e9dce494cd6eee4c59039c14a4d27bde5bab Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Fri, 18 Sep 2020 21:05:50 +0800 Subject: [PATCH 06/15] fix(scripts): trigger UNMOUNT_ALL before 'prepare' to prevent unwanted deletion feat(list): add librsvg2 for rendering app icons feat(scripts): reuse some codes Signed-off-by: Luke Yue --- scripts/build-image-common.sh | 72 +++++++++-------------------------- scripts/build-image.sh | 72 +++++++++-------------------------- scripts/config/standardlist | 1 + 3 files changed, 39 insertions(+), 106 deletions(-) diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index 566bdf1..38d3377 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -78,20 +78,6 @@ LOG(){ } UNMOUNT_ALL(){ - if [ -d ${root_mnt} ]; then - df -lh | grep ${root_mnt} - if [ $? -eq 0 ]; then - umount ${root_mnt} - fi - rm -rf ${root_mnt} - fi - if [ -d ${boot_mnt} ]; then - df -lh | grep ${boot_mnt} - if [ $? -eq 0 ]; then - umount ${boot_mnt} - fi - rm -rf ${boot_mnt} - fi if [[ -d ${rootfs_dir}/dev && `ls ${rootfs_dir}/dev | wc -l` -gt 1 ]]; then umount -l ${rootfs_dir}/dev fi @@ -103,6 +89,18 @@ UNMOUNT_ALL(){ fi } +INSTALL_PACKAGES(){ + for item in $(cat $*) + do + dnf --installroot=${rootfs_dir}/ install -y $item + if [ $? == 0 ]; then + LOG install $item. + else + ERROR can not install $item. + fi + done +} + trap 'UNMOUNT_ALL' INT prepare(){ @@ -439,15 +437,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 + UNMOUNT_ALL rm -rf ${rootfs_dir} fi mkdir ${rootfs_dir} @@ -465,36 +455,12 @@ 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 + INSTALL_PACKAGES $CONFIG_RPM_LIST if [ $with_standard == 1 ]; then - for item in $(cat $CONFIG_STANDARD_LIST) - do - dnf --installroot=${rootfs_dir}/ install -y $item - if [ $? == 0 ]; then - LOG install $item. - else - ERROR can not install $item. - fi - done + INSTALL_PACKAGES $CONFIG_STANDARD_LIST fi if [ $with_full == 1 ]; then - for item in $(cat $CONFIG_FULL_LIST) - do - dnf --installroot=${rootfs_dir}/ install -y $item - if [ $? == 0 ]; then - LOG install $item. - else - ERROR can not install $item. - fi - done + INSTALL_PACKAGES $CONFIG_FULL_LIST fi cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" if [ $? -ne 0 ]; then @@ -527,9 +493,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 + UNMOUNT_ALL rm ${rootfs_dir}/etc/yum.repos.d/tmp.repo rm ${rootfs_dir}/chroot.sh LOG "make rootfs for ${repo_file} end." @@ -578,6 +542,7 @@ make_img(){ fi set -e mkdir ${root_mnt} ${boot_mnt} + sudo e2fsck -y ${rootp} mount -t vfat -o uid=root,gid=root,umask=0000 ${bootp} ${boot_mnt} mount -t ext4 ${rootp} ${root_mnt} fstab_array=("" "" "" "") @@ -672,6 +637,7 @@ CONFIG_RPM_LIST=${euler_dir}/rpmlist CONFIG_STANDARD_LIST=${euler_dir}/standardlist CONFIG_FULL_LIST=${euler_dir}/fulllist +UNMOUNT_ALL prepare IFS=$'\n' update_firmware_app diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 9855b21..63bae9e 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -64,20 +64,6 @@ LOG(){ } UNMOUNT_ALL(){ - if [ -d ${root_mnt} ]; then - df -lh | grep ${root_mnt} - if [ $? -eq 0 ]; then - umount ${root_mnt} - fi - rm -rf ${root_mnt} - fi - if [ -d ${boot_mnt} ]; then - df -lh | grep ${boot_mnt} - if [ $? -eq 0 ]; then - umount ${boot_mnt} - fi - rm -rf ${boot_mnt} - fi if [[ -d ${rootfs_dir}/dev && `ls ${rootfs_dir}/dev | wc -l` -gt 1 ]]; then umount -l ${rootfs_dir}/dev fi @@ -89,6 +75,18 @@ UNMOUNT_ALL(){ fi } +INSTALL_PACKAGES(){ + for item in $(cat $*) + do + dnf --installroot=${rootfs_dir}/ install -y $item + if [ $? == 0 ]; then + LOG install $item. + else + ERROR can not install $item. + fi + done +} + trap 'UNMOUNT_ALL' INT prepare(){ @@ -208,15 +206,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 + UNMOUNT_ALL rm -rf ${rootfs_dir} fi mkdir -p ${rootfs_dir} @@ -235,36 +225,12 @@ 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 + INSTALL_PACKAGES $CONFIG_RPM_LIST if [ $with_standard == 1 ]; then - for item in $(cat $CONFIG_STANDARD_LIST) - do - dnf --installroot=${rootfs_dir}/ install -y $item - if [ $? == 0 ]; then - LOG install $item. - else - ERROR can not install $item. - fi - done + INSTALL_PACKAGES $CONFIG_STANDARD_LIST fi if [ $with_full == 1 ]; then - for item in $(cat $CONFIG_FULL_LIST) - do - dnf --installroot=${rootfs_dir}/ install -y $item - if [ $? == 0 ]; then - LOG install $item. - else - ERROR can not install $item. - fi - done + INSTALL_PACKAGES $CONFIG_FULL_LIST fi cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" if [ $? -ne 0 ]; then @@ -285,9 +251,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 + UNMOUNT_ALL rm ${rootfs_dir}/etc/yum.repos.d/tmp.repo rm ${rootfs_dir}/chroot.sh LOG "make rootfs for ${repo_file} end." @@ -335,6 +299,7 @@ make_img(){ fi set -e mkdir -p ${root_mnt} ${boot_mnt} + sudo e2fsck -y ${rootp} mount -t vfat -o uid=root,gid=root,umask=0000 ${bootp} ${boot_mnt} mount -t ext4 ${rootp} ${root_mnt} fstab_array=("" "" "" "") @@ -419,6 +384,7 @@ CONFIG_FULL_LIST=${euler_dir}/fulllist builddate=$(date +%Y%m%d) +UNMOUNT_ALL prepare IFS=$'\n' make_rootfs diff --git a/scripts/config/standardlist b/scripts/config/standardlist index e80cd1e..fbfb910 100644 --- a/scripts/config/standardlist +++ b/scripts/config/standardlist @@ -29,3 +29,4 @@ xfdesktop blueman network-manager-applet gparted +librsvg2 -- Gitee From 0c18945f0bfdde67b36a696f8de6f15a5741067e Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Tue, 22 Sep 2020 14:15:05 +0800 Subject: [PATCH 07/15] feat(README): update README for build spec options Signed-off-by: Luke Yue --- README.en.md | 37 +++++++++++++++++++++++-------------- README.md | 35 ++++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 27 deletions(-) diff --git a/README.en.md b/README.en.md index 3a1fa56..49c6b8f 100644 --- a/README.en.md +++ b/README.en.md @@ -85,7 +85,7 @@ 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. @@ -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 + + The specification to be built: + - `headless`, image without desktop environments。 + - `standard`,image with Xfce desktop environment and fundamental softwares but 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 @@ -152,11 +161,11 @@ 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,22 @@ 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 - + 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 49e0ebd..1c4b683 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ 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 包构建镜像。 @@ -100,13 +100,13 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community 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 + 显示帮助信息。 #### 完全构建(包括编译内核) @@ -152,13 +161,13 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community 各个参数意义: 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` @@ -196,4 +205,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 镜像,并导入本机系统中。 -- Gitee From af601713536ac9f76ba46ee72eb049ed288186d2 Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Thu, 24 Sep 2020 11:30:52 +0800 Subject: [PATCH 08/15] refactor(scripts): refactor build scripts to separate specs feat(README): update README for build spec options in build-image-common Signed-off-by: Luke Yue --- README.en.md | 15 +++++++-- README.md | 15 +++++++-- scripts/build-image-common.sh | 35 ++++++++++----------- scripts/build-image-docker.sh | 22 +++++--------- scripts/build-image.sh | 35 ++++++++++----------- scripts/config/fulllist | 57 ++++++++++++++++++++++++++++++----- scripts/config/standardlist | 18 +++++++++++ 7 files changed, 131 insertions(+), 66 deletions(-) diff --git a/README.en.md b/README.en.md index 49c6b8f..9521187 100644 --- a/README.en.md +++ b/README.en.md @@ -92,7 +92,7 @@ Build images with packages of raspberrypi-kernel, raspberrypi-firmware, and rasp 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: @@ -154,7 +154,7 @@ 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: @@ -188,7 +188,16 @@ The meaning of each parameter: 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 + + The specification to be built: + - `headless`, image without desktop environments。 + - `standard`,image with Xfce desktop environment and fundamental softwares but 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. diff --git a/README.md b/README.md index 1c4b683..651db06 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community 构建镜像需执行命令: -`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` 各个参数意义: @@ -156,7 +156,7 @@ 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` 各个参数意义: @@ -189,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 总数。 diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index 38d3377..e09d00d 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -55,7 +55,7 @@ parseargs() shift shift elif [ "x$1" == "x-s" -o "x$1" == "x--spec" ]; then - spec=`echo $2` + spec_param=`echo $2` shift shift elif [ "x$1" == "x--cores" ]; then @@ -78,19 +78,19 @@ LOG(){ } UNMOUNT_ALL(){ - if [[ -d ${rootfs_dir}/dev && `ls ${rootfs_dir}/dev | wc -l` -gt 1 ]]; then + if grep -q "${rootfs_dir}/dev" /proc/mounts ; then umount -l ${rootfs_dir}/dev fi - if [[ -d ${rootfs_dir}/proc && `ls ${rootfs_dir}/proc | wc -l` -gt 0 ]]; then + if grep -q "${rootfs_dir}/proc" /proc/mounts ; then umount -l ${rootfs_dir}/proc fi - if [[ -d ${rootfs_dir}/sys && `ls ${rootfs_dir}/sys | wc -l` -gt 0 ]]; then + if grep -q "${rootfs_dir}/sys" /proc/mounts ; then umount -l ${rootfs_dir}/sys fi } INSTALL_PACKAGES(){ - for item in $(cat $*) + for item in $(cat $1) do dnf --installroot=${rootfs_dir}/ install -y $item if [ $? == 0 ]; then @@ -122,15 +122,10 @@ prepare(){ echo `date` - ERROR, config file $default_defconfig can not be found. exit 2 fi - if [ "x$spec" == "xheadless" ] || [ "x$spec" == "x" ]; then - with_standard=0 - with_full=0 - elif [ "x$spec" == "xstandard" ]; then - with_standard=1 - with_full=0 - elif [ "x$spec" == "xfull" ]; then - with_standard=1 - with_full=1 + 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 @@ -455,11 +450,11 @@ 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 - INSTALL_PACKAGES $CONFIG_RPM_LIST - if [ $with_standard == 1 ]; then + if [ $img_spec == "headless" ]; then + INSTALL_PACKAGES $CONFIG_RPM_LIST + elif [ $img_spec == "standard" ]; then INSTALL_PACKAGES $CONFIG_STANDARD_LIST - fi - if [ $with_full == 1 ]; then + elif [ $img_spec == "full" ]; then INSTALL_PACKAGES $CONFIG_FULL_LIST fi cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" @@ -542,7 +537,7 @@ make_img(){ fi set -e mkdir ${root_mnt} ${boot_mnt} - sudo e2fsck -y ${rootp} + e2fsck -y ${rootp} mount -t vfat -o uid=root,gid=root,umask=0000 ${bootp} ${boot_mnt} mount -t ext4 ${rootp} ${root_mnt} fstab_array=("" "" "" "") @@ -633,9 +628,11 @@ 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="" UNMOUNT_ALL prepare diff --git a/scripts/build-image-docker.sh b/scripts/build-image-docker.sh index 986be03..17a238c 100644 --- a/scripts/build-image-docker.sh +++ b/scripts/build-image-docker.sh @@ -86,7 +86,13 @@ parseargs() shift shift elif [ "x$1" == "x-s" -o "x$1" == "x--spec" ]; then - spec=`echo $2` + 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 @@ -134,20 +140,6 @@ else exit 2 fi -if [ "x$spec" == "xheadless" ] || [ "x$spec" == "x" ]; then - with_standard=0 - with_full=0 -elif [ "x$spec" == "xstandard" ]; then - with_standard=1 - with_full=0 -elif [ "x$spec" == "xfull" ]; then - with_standard=1 - with_full=1 -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 diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 63bae9e..c2d3ab9 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -45,7 +45,7 @@ parseargs() shift shift elif [ "x$1" == "x-s" -o "x$1" == "x--spec" ]; then - spec=`echo $2` + spec_param=`echo $2` shift shift else @@ -64,19 +64,19 @@ LOG(){ } UNMOUNT_ALL(){ - if [[ -d ${rootfs_dir}/dev && `ls ${rootfs_dir}/dev | wc -l` -gt 1 ]]; then + if grep -q "${rootfs_dir}/dev" /proc/mounts ; then umount -l ${rootfs_dir}/dev fi - if [[ -d ${rootfs_dir}/proc && `ls ${rootfs_dir}/proc | wc -l` -gt 0 ]]; then + if grep -q "${rootfs_dir}/proc" /proc/mounts ; then umount -l ${rootfs_dir}/proc fi - if [[ -d ${rootfs_dir}/sys && `ls ${rootfs_dir}/sys | wc -l` -gt 0 ]]; then + if grep -q "${rootfs_dir}/sys" /proc/mounts ; then umount -l ${rootfs_dir}/sys fi } INSTALL_PACKAGES(){ - for item in $(cat $*) + for item in $(cat $1) do dnf --installroot=${rootfs_dir}/ install -y $item if [ $? == 0 ]; then @@ -95,15 +95,10 @@ prepare(){ else rm -rf ${tmp_dir}/* fi - if [ "x$spec" == "xheadless" ] || [ "x$spec" == "x" ]; then - with_standard=0 - with_full=0 - elif [ "x$spec" == "xstandard" ]; then - with_standard=1 - with_full=0 - elif [ "x$spec" == "xfull" ]; then - with_standard=1 - with_full=1 + 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 @@ -225,11 +220,11 @@ 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 - INSTALL_PACKAGES $CONFIG_RPM_LIST - if [ $with_standard == 1 ]; then + if [ $img_spec == "headless" ]; then + INSTALL_PACKAGES $CONFIG_RPM_LIST + elif [ $img_spec == "standard" ]; then INSTALL_PACKAGES $CONFIG_STANDARD_LIST - fi - if [ $with_full == 1 ]; then + elif [ $img_spec == "full" ]; then INSTALL_PACKAGES $CONFIG_FULL_LIST fi cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" @@ -299,7 +294,7 @@ make_img(){ fi set -e mkdir -p ${root_mnt} ${boot_mnt} - sudo e2fsck -y ${rootp} + e2fsck -y ${rootp} mount -t vfat -o uid=root,gid=root,umask=0000 ${bootp} ${boot_mnt} mount -t ext4 ${rootp} ${root_mnt} fstab_array=("" "" "" "") @@ -378,9 +373,11 @@ 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) diff --git a/scripts/config/fulllist b/scripts/config/fulllist index c67d7f0..ec9bf9b 100644 --- a/scripts/config/fulllist +++ b/scripts/config/fulllist @@ -1,22 +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 +openEuler-repos +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 +midori +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 -htop gigolo xfburn xfce4-dev-tools xfce4-dict xfce4-panel-profiles -ncdu -neofetch imsettings im-chooser fcitx fcitx-qt5 fcitx-libpinyin fcitx-configtool -google-roboto-fonts -gtk-murrine-engine -materia-gtk-theme -papirus-icon-theme google-noto-sans-sc-fonts google-noto-serif-sc-fonts google-noto-sans-mono-cjk-sc-fonts diff --git a/scripts/config/standardlist b/scripts/config/standardlist index fbfb910..afc2866 100644 --- a/scripts/config/standardlist +++ b/scripts/config/standardlist @@ -1,3 +1,21 @@ +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 +openEuler-repos +sudo xorg-x11-drv-fbdev lightdm lightdm-gtk -- Gitee From d7127752c2b49105beed90d90f27e4dc778a8b04 Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Mon, 12 Oct 2020 12:18:44 +0800 Subject: [PATCH 09/15] fix(scripts): fix for unused dependencies Signed-off-by: Luke Yue --- scripts/build-image-common.sh | 10 ++--- scripts/build-image.sh | 12 +++--- scripts/config-common/fulllist | 63 +++++++++++++++++++++++++++++- scripts/config-common/standardlist | 48 ++++++++++++++++++++++- 4 files changed, 119 insertions(+), 14 deletions(-) mode change 120000 => 100644 scripts/config-common/fulllist mode change 120000 => 100644 scripts/config-common/standardlist diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index e09d00d..a305ad5 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -78,13 +78,13 @@ LOG(){ } UNMOUNT_ALL(){ - if grep -q "${rootfs_dir}/dev" /proc/mounts ; then + if grep -q "${rootfs_dir}/dev " /proc/mounts ; then umount -l ${rootfs_dir}/dev fi - if grep -q "${rootfs_dir}/proc" /proc/mounts ; then + if grep -q "${rootfs_dir}/proc " /proc/mounts ; then umount -l ${rootfs_dir}/proc fi - if grep -q "${rootfs_dir}/sys" /proc/mounts ; then + if grep -q "${rootfs_dir}/sys " /proc/mounts ; then umount -l ${rootfs_dir}/sys fi } @@ -101,7 +101,7 @@ INSTALL_PACKAGES(){ done } -trap 'UNMOUNT_ALL' INT +trap 'UNMOUNT_ALL' EXIT prepare(){ if [ ! -d ${tmp_dir} ]; then @@ -537,7 +537,6 @@ make_img(){ fi set -e mkdir ${root_mnt} ${boot_mnt} - e2fsck -y ${rootp} mount -t vfat -o uid=root,gid=root,umask=0000 ${bootp} ${boot_mnt} mount -t ext4 ${rootp} ${root_mnt} fstab_array=("" "" "" "") @@ -642,4 +641,3 @@ update_kernel make_rootfs make_img -trap 'UNMOUNT_ALL' EXIT diff --git a/scripts/build-image.sh b/scripts/build-image.sh index c2d3ab9..aabdb50 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -64,13 +64,13 @@ LOG(){ } UNMOUNT_ALL(){ - if grep -q "${rootfs_dir}/dev" /proc/mounts ; then + if grep -q "${rootfs_dir}/dev " /proc/mounts ; then umount -l ${rootfs_dir}/dev fi - if grep -q "${rootfs_dir}/proc" /proc/mounts ; then + if grep -q "${rootfs_dir}/proc " /proc/mounts ; then umount -l ${rootfs_dir}/proc fi - if grep -q "${rootfs_dir}/sys" /proc/mounts ; then + if grep -q "${rootfs_dir}/sys " /proc/mounts ; then umount -l ${rootfs_dir}/sys fi } @@ -87,7 +87,7 @@ INSTALL_PACKAGES(){ done } -trap 'UNMOUNT_ALL' INT +trap 'UNMOUNT_ALL' EXIT prepare(){ if [ ! -d ${tmp_dir} ]; then @@ -224,8 +224,10 @@ make_rootfs(){ INSTALL_PACKAGES $CONFIG_RPM_LIST elif [ $img_spec == "standard" ]; then INSTALL_PACKAGES $CONFIG_STANDARD_LIST + rm ${rootfs_dir}/boot/grub2/grubenv elif [ $img_spec == "full" ]; then INSTALL_PACKAGES $CONFIG_FULL_LIST + rm ${rootfs_dir}/boot/grub2/grubenv fi cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" if [ $? -ne 0 ]; then @@ -294,7 +296,6 @@ make_img(){ fi set -e mkdir -p ${root_mnt} ${boot_mnt} - e2fsck -y ${rootp} mount -t vfat -o uid=root,gid=root,umask=0000 ${bootp} ${boot_mnt} mount -t ext4 ${rootp} ${root_mnt} fstab_array=("" "" "" "") @@ -386,4 +387,3 @@ prepare IFS=$'\n' make_rootfs make_img -trap 'UNMOUNT_ALL' EXIT diff --git a/scripts/config-common/fulllist b/scripts/config-common/fulllist deleted file mode 120000 index 6a7636a..0000000 --- a/scripts/config-common/fulllist +++ /dev/null @@ -1 +0,0 @@ -../config/fulllist \ No newline at end of file diff --git a/scripts/config-common/fulllist b/scripts/config-common/fulllist new file mode 100644 index 0000000..2a89409 --- /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 +openEuler-repos +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 +midori +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 diff --git a/scripts/config-common/standardlist b/scripts/config-common/standardlist deleted file mode 120000 index 6f8b2be..0000000 --- a/scripts/config-common/standardlist +++ /dev/null @@ -1 +0,0 @@ -../config/standardlist \ No newline at end of file diff --git a/scripts/config-common/standardlist b/scripts/config-common/standardlist new file mode 100644 index 0000000..8f3cdab --- /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 +openEuler-repos +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 +midori +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 -- Gitee From 2e8f28694db8c444f0541d90cdf933247504d044 Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Fri, 16 Oct 2020 22:56:29 +0800 Subject: [PATCH 10/15] feat(lists): replace midori with firefox feat(lists): move openeuler-repo to last line feat(chroot): add 20-fbdev.conf Signed-off-by: Luke Yue --- scripts/build-image.sh | 5 +++-- scripts/config-common/fulllist | 4 ++-- scripts/config-common/rpmlist | 2 +- scripts/config-common/standardlist | 4 ++-- scripts/config/chroot.sh | 5 ++++- scripts/config/fulllist | 4 ++-- scripts/config/rpmlist | 2 +- scripts/config/standardlist | 4 ++-- 8 files changed, 17 insertions(+), 13 deletions(-) diff --git a/scripts/build-image.sh b/scripts/build-image.sh index aabdb50..f1640c1 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -224,10 +224,8 @@ make_rootfs(){ INSTALL_PACKAGES $CONFIG_RPM_LIST elif [ $img_spec == "standard" ]; then INSTALL_PACKAGES $CONFIG_STANDARD_LIST - rm ${rootfs_dir}/boot/grub2/grubenv elif [ $img_spec == "full" ]; then INSTALL_PACKAGES $CONFIG_FULL_LIST - rm ${rootfs_dir}/boot/grub2/grubenv fi cat ${rootfs_dir}/etc/systemd/timesyncd.conf | grep "^NTP*" if [ $? -ne 0 ]; then @@ -308,6 +306,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 [ -f ${rootfs_dir}/boot/grub2/grubenv ]; then + rm ${rootfs_dir}/boot/grub2/grubenv + 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 diff --git a/scripts/config-common/fulllist b/scripts/config-common/fulllist index 2a89409..e042ef3 100644 --- a/scripts/config-common/fulllist +++ b/scripts/config-common/fulllist @@ -11,7 +11,6 @@ passwd hostname bluez pulseaudio-module-bluetooth -openEuler-repos sudo xorg-x11-drv-fbdev lightdm @@ -26,7 +25,7 @@ thunar-vcs-plugin thunar-volman ristretto xarchiver -midori +firefox mousepad parole xfce4-appfinder @@ -60,3 +59,4 @@ 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 c8506e8..8d11480 100644 --- a/scripts/config-common/rpmlist +++ b/scripts/config-common/rpmlist @@ -11,5 +11,5 @@ passwd hostname bluez pulseaudio-module-bluetooth -openEuler-repos sudo +openEuler-repos diff --git a/scripts/config-common/standardlist b/scripts/config-common/standardlist index 8f3cdab..a18c4b2 100644 --- a/scripts/config-common/standardlist +++ b/scripts/config-common/standardlist @@ -11,7 +11,6 @@ passwd hostname bluez pulseaudio-module-bluetooth -openEuler-repos sudo xorg-x11-drv-fbdev lightdm @@ -26,7 +25,7 @@ thunar-vcs-plugin thunar-volman ristretto xarchiver -midori +firefox mousepad parole xfce4-appfinder @@ -45,3 +44,4 @@ blueman network-manager-applet gparted librsvg2 +openEuler-repos diff --git a/scripts/config/chroot.sh b/scripts/config/chroot.sh index fe57eab..89bcbd1 100755 --- a/scripts/config/chroot.sh +++ b/scripts/config/chroot.sh @@ -16,5 +16,8 @@ if [ -f /etc/rc.d/rc.local ]; then chmod +x /etc/rc.d/rc.local fi if [ -f /etc/lightdm/lightdm.conf ]; then - sudo sed -i 's/#user-session=default/user-session=xfce/g' /etc/lightdm/lightdm.conf + 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 index ec9bf9b..4aed4d3 100644 --- a/scripts/config/fulllist +++ b/scripts/config/fulllist @@ -14,7 +14,6 @@ pulseaudio-module-bluetooth raspberrypi-kernel raspberrypi-firmware raspberrypi-bluetooth -openEuler-repos sudo xorg-x11-drv-fbdev lightdm @@ -29,7 +28,7 @@ thunar-vcs-plugin thunar-volman ristretto xarchiver -midori +firefox mousepad parole xfce4-appfinder @@ -63,3 +62,4 @@ 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 2626873..a35bbf5 100644 --- a/scripts/config/rpmlist +++ b/scripts/config/rpmlist @@ -14,5 +14,5 @@ pulseaudio-module-bluetooth raspberrypi-kernel raspberrypi-firmware raspberrypi-bluetooth -openEuler-repos sudo +openEuler-repos diff --git a/scripts/config/standardlist b/scripts/config/standardlist index afc2866..37b0edc 100644 --- a/scripts/config/standardlist +++ b/scripts/config/standardlist @@ -14,7 +14,6 @@ pulseaudio-module-bluetooth raspberrypi-kernel raspberrypi-firmware raspberrypi-bluetooth -openEuler-repos sudo xorg-x11-drv-fbdev lightdm @@ -29,7 +28,7 @@ thunar-vcs-plugin thunar-volman ristretto xarchiver -midori +firefox mousepad parole xfce4-appfinder @@ -48,3 +47,4 @@ blueman network-manager-applet gparted librsvg2 +openEuler-repos -- Gitee From 89c79e0108426a73b82217343d6c2e293925913c Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Tue, 20 Oct 2020 12:57:12 +0800 Subject: [PATCH 11/15] feats(scripts): exit script when umount failed Signed-off-by: Luke Yue --- scripts/build-image-common.sh | 12 +++++++----- scripts/build-image.sh | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index a305ad5..0e70a38 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -77,7 +77,8 @@ LOG(){ echo `date` - INFO, $* | tee -a ${cur_dir}/log/log_${builddate}.log } -UNMOUNT_ALL(){ +UMOUNT_ALL(){ + set +e if grep -q "${rootfs_dir}/dev " /proc/mounts ; then umount -l ${rootfs_dir}/dev fi @@ -87,6 +88,7 @@ UNMOUNT_ALL(){ if grep -q "${rootfs_dir}/sys " /proc/mounts ; then umount -l ${rootfs_dir}/sys fi + set -e } INSTALL_PACKAGES(){ @@ -101,7 +103,7 @@ INSTALL_PACKAGES(){ done } -trap 'UNMOUNT_ALL' EXIT +trap 'UMOUNT_ALL' EXIT prepare(){ if [ ! -d ${tmp_dir} ]; then @@ -432,7 +434,7 @@ make_rootfs(){ LOG "make rootfs for ${repo_file} begin..." cd "${run_dir}" if [[ -d ${rootfs_dir} ]]; then - UNMOUNT_ALL + UMOUNT_ALL rm -rf ${rootfs_dir} fi mkdir ${rootfs_dir} @@ -488,7 +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" - UNMOUNT_ALL + UMOUNT_ALL rm ${rootfs_dir}/etc/yum.repos.d/tmp.repo rm ${rootfs_dir}/chroot.sh LOG "make rootfs for ${repo_file} end." @@ -633,7 +635,7 @@ CONFIG_STANDARD_LIST=${euler_dir}/standardlist CONFIG_FULL_LIST=${euler_dir}/fulllist img_spec="" -UNMOUNT_ALL +UMOUNT_ALL prepare IFS=$'\n' update_firmware_app diff --git a/scripts/build-image.sh b/scripts/build-image.sh index f1640c1..7a0ac47 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -63,7 +63,8 @@ LOG(){ echo `date` - INFO, $* | tee -a ${log_dir}/${builddate}.log } -UNMOUNT_ALL(){ +UMOUNT_ALL(){ + set +e if grep -q "${rootfs_dir}/dev " /proc/mounts ; then umount -l ${rootfs_dir}/dev fi @@ -73,6 +74,7 @@ UNMOUNT_ALL(){ if grep -q "${rootfs_dir}/sys " /proc/mounts ; then umount -l ${rootfs_dir}/sys fi + set -e } INSTALL_PACKAGES(){ @@ -87,7 +89,7 @@ INSTALL_PACKAGES(){ done } -trap 'UNMOUNT_ALL' EXIT +trap 'UMOUNT_ALL' EXIT prepare(){ if [ ! -d ${tmp_dir} ]; then @@ -201,7 +203,7 @@ prepare(){ make_rootfs(){ LOG "make rootfs for ${repo_file} begin..." if [[ -d ${rootfs_dir} ]]; then - UNMOUNT_ALL + UMOUNT_ALL rm -rf ${rootfs_dir} fi mkdir -p ${rootfs_dir} @@ -246,7 +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" - UNMOUNT_ALL + UMOUNT_ALL rm ${rootfs_dir}/etc/yum.repos.d/tmp.repo rm ${rootfs_dir}/chroot.sh LOG "make rootfs for ${repo_file} end." @@ -383,7 +385,7 @@ img_spec="" builddate=$(date +%Y%m%d) -UNMOUNT_ALL +UMOUNT_ALL prepare IFS=$'\n' make_rootfs -- Gitee From 682fdb3f968407e36607e1ede8e9a2b0f3c57f1b Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Wed, 21 Oct 2020 13:25:08 +0800 Subject: [PATCH 12/15] feats(scripts): remove grub dir Signed-off-by: Luke Yue --- scripts/build-image.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 7a0ac47..7fde9ac 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -308,8 +308,8 @@ 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 [ -f ${rootfs_dir}/boot/grub2/grubenv ]; then - rm ${rootfs_dir}/boot/grub2/grubenv + 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}/ -- Gitee From 5a7af2c4a27a432d1a41655c2a556f01f4ffd764 Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Thu, 22 Oct 2020 17:49:25 +0800 Subject: [PATCH 13/15] doc(scripts): polish some sentences Signed-off-by: Luke Yue --- scripts/build-image-common.sh | 2 +- scripts/build-image.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index 0e70a38..c0c9b8a 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -11,7 +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, default is headless. + -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. " diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 7fde9ac..c4d2714 100644 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -10,7 +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, default is headless. + -s, --spec SPEC The image's specification: headless, standard, full. The default is headless. -h, --help Show command help. " -- Gitee From 96e71a5d177bd0e576c07ef2a1ef7ad826759e1a Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Thu, 22 Oct 2020 17:51:43 +0800 Subject: [PATCH 14/15] doc(README): polish some sentences Signed-off-by: Luke Yue --- README.en.md | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.en.md b/README.en.md index 9521187..f74fd8c 100644 --- a/README.en.md +++ b/README.en.md @@ -190,9 +190,9 @@ The meaning of each parameter: 6. -s, --spec SPEC - The specification to be built: + Specify the image version: - `headless`, image without desktop environments。 - - `standard`,image with Xfce desktop environment and fundamental softwares but without CJK fonts and IME. + - `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`. diff --git a/README.md b/README.md index 651db06..6dcda1d 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community 构建的镜像版本: - `headless`,无图形界面版的镜像。 - `standard`,带 Xfce 桌面及必要的配套软件(不包括中文字体以及输入法)。 - - `full`,带 Xfce 桌面以及中文字体、输入法等等全部配套软件。 + - `full`,带 Xfce 桌面以及中文字体、输入法等全部配套软件。 默认使用 `headless` 选项。 @@ -194,7 +194,7 @@ SIG 组基本信息位于 [sig-RaspberryPi](https://gitee.com/jianminw/community 构建的镜像版本: - `headless`,无图形界面版的镜像。 - `standard`,带 Xfce 桌面及必要的配套软件(不包括中文字体以及输入法)。 - - `full`,带 Xfce 桌面以及中文字体、输入法等等全部配套软件。 + - `full`,带 Xfce 桌面以及中文字体、输入法等全部配套软件。 默认使用 `headless` 选项。 -- Gitee From d11b3f761052b02a48d8cf251d16fe626cb620ef Mon Sep 17 00:00:00 2001 From: Luke Yue Date: Fri, 23 Oct 2020 15:33:02 +0800 Subject: [PATCH 15/15] doc(README): polish some sentences doc(scripts): polish some sentences fix(scripts): spare more space for full spec Signed-off-by: Luke Yue --- README.en.md | 4 ++-- scripts/build-image-common.sh | 2 +- scripts/build-image-docker.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.en.md b/README.en.md index f74fd8c..68c2cc4 100644 --- a/README.en.md +++ b/README.en.md @@ -135,9 +135,9 @@ The meaning of each parameter: 4. -s, --spec SPEC - The specification to be built: + Specify the image version: - `headless`, image without desktop environments。 - - `standard`,image with Xfce desktop environment and fundamental softwares but without CJK fonts and IME. + - `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`. diff --git a/scripts/build-image-common.sh b/scripts/build-image-common.sh index c0c9b8a..ad69cbb 100644 --- a/scripts/build-image-common.sh +++ b/scripts/build-image-common.sh @@ -500,7 +500,7 @@ 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 diff --git a/scripts/build-image-docker.sh b/scripts/build-image-docker.sh index 17a238c..6787a73 100644 --- a/scripts/build-image-docker.sh +++ b/scripts/build-image-docker.sh @@ -13,7 +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, default is headless. + -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. " -- Gitee