Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
Index: setup
===================================================================
--- setup	(revision 384)
+++ setup	(revision 385)
@@ -278,7 +278,9 @@
 swap_part_number=3
 
 uefi_bytes=
-if [ "${hardware}" = "baikal-m1" -o \
+if [ "${hardware}" = "baikal-m1"   -o \
+     "${hardware}" = "orange-pi5"  -o \
+     "${hardware}" = "visionfive2" -o \
      "${hardware}" = "intel-pc64" ] ; then
   partition_table_type=g
   uefi_bytes=268435456
@@ -452,6 +454,8 @@
 ${partition_table_type}
 w
 EOF
+
+  partprobe ${disk}
 }
 
 create_EFI_partition()
@@ -496,6 +500,8 @@
 EOF
   fi
 
+  partprobe ${disk}
+
   mkfs.fat -F 32 -n UEFI ${disk}${p}1  2>/dev/null 1>/dev/null
 }
 
@@ -548,7 +554,7 @@
     exit
   fi
 
-  let 'root_bytes = ( root_end_sector - root_start_sector + 1 ) * log_sector_size'
+  root_bytes=`echo "(${root_end_sector} - ${root_start_sector} + 1) * ${log_sector_size}" | bc`
 
   if [ "${root_part_number}" -eq "1" ] ; then
     if [ "${partition_table_type}" = "g" ] ; then
@@ -608,6 +614,8 @@
 EOF
     fi
   fi
+
+  partprobe ${disk}
 }
 
 create_HOME_partition()
@@ -693,6 +701,8 @@
     swap_bytes=0
     swap_start_sector=0
   fi
+
+  partprobe ${disk}
 }
 
 create_SWAP_partition()
@@ -734,6 +744,8 @@
 EOF
     fi
   fi
+
+  partprobe ${disk}
 }
 
 umount_target_partitions()
@@ -783,6 +795,8 @@
     EXITSTATUS=20
     exit
   fi
+
+  partprobe ${disk}
 }
 
 ask_formatting()
@@ -1149,9 +1163,9 @@
 
   for dev in `lsblk -ldn -o name` ; do
     #
-    # Skip 'mtd.*', 'mmcblk[0-9]*boot.*':
+    # Skip 'ram.*', 'zram.*', 'mtd.*', 'mmcblk[0-9]*boot.*':
     #
-    if `echo ${dev} | grep -q 'mtd.*\|mmcblk[0-9]*boot.*'` ; then
+    if `echo ${dev} | grep -q 'ram.*\|zram.*\|mtd.*\|mmcblk[0-9]*boot.*'` ; then
       continue
     fi
     #
@@ -2216,7 +2230,9 @@
 
 EOF
 
-  if [ "${hardware}" = "baikal-m1" ] ; then
+  if [ "${hardware}" = "baikal-m1"  -o \
+       "${hardware}" = "orange-pi5" -o \
+       "${hardware}" = "visionfive2" ] ; then
     cat >> ${grub_cfg} << EOF
 font '/boot/grub/fonts/dejavusansmono.pf2'
 EOF
@@ -2256,10 +2272,25 @@
 
   if [ "${hardware}" = "baikal-m1" ] ; then
     cat >> ${grub_cfg} << EOF
+  devicetree (\$root)/boot/bm1000-mbm20.dtb
   linux (\$root)/boot/Image root=PARTUUID=\$part_uuid ro rootwait console=tty1 earlyprintk=uart8250-32bit,0x20230000,115200
 EOF
   fi
 
+  if [ "${hardware}" = "orange-pi5" ] ; then
+    cat >> ${grub_cfg} << EOF
+  devicetree (\$root)/boot/rockchip/rk3588s-orangepi-5.dtb
+  linux (\$root)/boot/Image root=PARTUUID=\$part_uuid ro rootwait console=ttyS2,1500000n8 console=tty1
+EOF
+  fi
+
+  if [ "${hardware}" = "visionfive2" ] ; then
+    cat >> ${grub_cfg} << EOF
+  devicetree (\$root)/boot/starfive/jh7110-visionfive-v2.dtb
+  linux (\$root)/boot/Image root=PARTUUID=\$part_uuid ro rootwait console=ttyS0,115200n8 earlycon=sbi console=tty1
+EOF
+  fi
+
   cat >> ${grub_cfg} << EOF
 }
 EOF
@@ -2324,6 +2355,8 @@
   cat ${fstab} > ${ROOT_MPOINT}/etc/fstab
 
   if [ "${hardware}" = "baikal-m1"    -o \
+       "${hardware}" = "orange-pi5"   -o \
+       "${hardware}" = "visionfive2"  -o \
        "${hardware}" = "ebox-3350dx2" -o \
        "${hardware}" = "intel-pc32"   -o \
        "${hardware}" = "intel-pc64" ] ; then
@@ -2447,6 +2480,125 @@
                         ${grub_modules}  2>/dev/null 1>/dev/null
 }
 
+install_orange_pi5_grub()
+{
+  UEFI=`get_uefi_devname`
+  UEFI_MPOINT=$MNT/UEFI
+
+  if [ "x${UEFI}" = "x" ] ; then
+    fatal_error_dialog "Cannot mount EFI partition. Exit ${program}."
+    push_log "ERROR: Cannot mount EFI partition"
+    push_log "Aborted due to an error"
+    push_err "ERROR: Cannot mount EFI partition"
+    EXITSTATUS=22
+    exit
+  fi
+
+  if `mount | grep -q ${UEFI}` ; then
+    umount ${UEFI}
+  fi
+  mkdir -p ${UEFI_MPOINT}
+  if [ "x`mount | grep ${UEFI_MPOINT}`" != "x" ] ; then
+    umount ${UEFI_MPOINT}
+  fi
+  mount ${UEFI} ${UEFI_MPOINT}
+
+  local grub_modules="all_video archelp bfs bitmap bitmap_scale blocklist boot btrfs"
+  grub_modules="${grub_modules} cat chain configfile cpio date datehook datetime disk diskfilter"
+  grub_modules="${grub_modules} echo efi_gop efifwsetup efinet elf eval exfat ext2 extcmd f2fs fat"
+  grub_modules="${grub_modules} fdt file font fshelp gettext gfxmenu gfxterm gfxterm_background"
+  grub_modules="${grub_modules} gfxterm_menu gptsync gzio halt hashsum help hexdump iso9660 jpeg"
+  grub_modules="${grub_modules} json keystatus linux loadenv loopback ls lsefi lzopio mdraid1x"
+  grub_modules="${grub_modules} memdisk minicmd msdospart net newc normal part_gpt part_msdos"
+  grub_modules="${grub_modules} png probe procfs read reboot regexp reiserfs search search_fs_file"
+  grub_modules="${grub_modules} search_fs_uuid search_label serial squash4 tar terminal terminfo"
+  grub_modules="${grub_modules} test tftp time tr trig true udf ufs1 ufs2 video video_colors"
+  grub_modules="${grub_modules} video_fb videoinfo xzio zstd"
+
+  /usr/sbin/grub-install --skip-fs-probe \
+                         --fonts=dejavusansmono \
+                         --boot-directory=${ROOT_MPOINT}/boot \
+                         --directory=/usr/lib/grub/arm64-efi \
+                         --target=arm64-efi --no-efi \
+                         --no-bootsector --no-nvram  2>/dev/null 1>/dev/null
+
+  mkdir -p ${ROOT_MPOINT}/boot/efi
+  mkdir -p ${ROOT_MPOINT}/boot/grub/arm64-efi
+  cat ${grub_load_cfg} > ${ROOT_MPOINT}/boot/grub/arm64-efi/load.cfg
+
+  mkdir -p ${UEFI_MPOINT}/efi/boot
+  /usr/bin/grub-mkimage --format=arm64-efi \
+                        --directory=/usr/lib/grub/arm64-efi \
+                        --compression=xz \
+                        --prefix=/efi/boot \
+                        --config="${grub_load_cfg}" \
+                        --output=${UEFI_MPOINT}/efi/boot/bootaa64.efi \
+                        ${grub_modules}  2>/dev/null 1>/dev/null
+}
+
+install_orange_pi5_edk2() {
+  FLASHCP=`PATH=/sbin:/usr/sbin:$PATH which flashcp`
+  if [ -c /dev/mtd0 -a "`basename ${FLASHCP}`" = "flashcp" -a -f "/boot/edk2/spi-flash.image" ] ; then
+    ${FLASHCP} /boot/edk2/spi-flash.image /dev/mtd0
+  fi
+}
+
+install_starfive_vf2_grub()
+{
+  UEFI=`get_uefi_devname`
+  UEFI_MPOINT=$MNT/UEFI
+
+  if [ "x${UEFI}" = "x" ] ; then
+    fatal_error_dialog "Cannot mount EFI partition. Exit ${program}."
+    push_log "ERROR: Cannot mount EFI partition"
+    push_log "Aborted due to an error"
+    push_err "ERROR: Cannot mount EFI partition"
+    EXITSTATUS=22
+    exit
+  fi
+
+  if `mount | grep -q ${UEFI}` ; then
+    umount ${UEFI}
+  fi
+  mkdir -p ${UEFI_MPOINT}
+  if [ "x`mount | grep ${UEFI_MPOINT}`" != "x" ] ; then
+    umount ${UEFI_MPOINT}
+  fi
+  mount ${UEFI} ${UEFI_MPOINT}
+
+  local grub_modules="all_video archelp bfs bitmap bitmap_scale blocklist boot btrfs"
+  grub_modules="${grub_modules} cat chain configfile cpio date datehook datetime disk diskfilter"
+  grub_modules="${grub_modules} echo efi_gop efifwsetup efinet elf eval exfat ext2 extcmd f2fs fat"
+  grub_modules="${grub_modules} fdt file font fshelp gettext gfxmenu gfxterm gfxterm_background"
+  grub_modules="${grub_modules} gfxterm_menu gptsync gzio halt hashsum help hexdump iso9660 jpeg"
+  grub_modules="${grub_modules} json keystatus linux loadenv loopback ls lsefi lzopio mdraid1x"
+  grub_modules="${grub_modules} memdisk minicmd msdospart net newc normal part_gpt part_msdos"
+  grub_modules="${grub_modules} png probe procfs read reboot regexp reiserfs search search_fs_file"
+  grub_modules="${grub_modules} search_fs_uuid search_label serial squash4 tar terminal terminfo"
+  grub_modules="${grub_modules} test tftp time tr trig true udf ufs1 ufs2 video video_colors"
+  grub_modules="${grub_modules} video_fb videoinfo xzio zstd"
+
+  /usr/sbin/grub-install --skip-fs-probe \
+                         --fonts=dejavusansmono \
+                         --boot-directory=${ROOT_MPOINT}/boot \
+                         --directory=/usr/lib/grub/riscv64-efi \
+                         --target=riscv64-efi --no-efi \
+                         --no-bootsector --no-nvram  2>/dev/null 1>/dev/null
+
+  mkdir -p ${ROOT_MPOINT}/boot/efi
+  mkdir -p ${ROOT_MPOINT}/boot/grub/riscv64-efi
+  cat ${grub_load_cfg} > ${ROOT_MPOINT}/boot/grub/riscv64-efi/load.cfg
+
+  mkdir -p ${UEFI_MPOINT}/efi/boot
+  /usr/bin/grub-mkimage --format=riscv64-efi \
+                        --directory=/usr/lib/grub/riscv64-efi \
+                        --compression=xz \
+                        --prefix=/efi/boot \
+                        --config="${grub_load_cfg}" \
+                        --output=${UEFI_MPOINT}/efi/boot/bootriscv64.efi \
+                        ${grub_modules}  2>/dev/null 1>/dev/null
+}
+
 install_intel_pc64_grub()
 {
   UEFI=`get_uefi_devname`
@@ -2579,12 +2731,79 @@
   ln -sfr ${ROOT_MPOINT}/boot/boot.emmc.scr ${ROOT_MPOINT}/boot/boot.scr
 }
 #
-# End of install U-Boot:
+# End of install U-Boot.
 #
 ####################################################################
 
+####################################################################
+#
+# Select Desktop Environment:
+#
+select_desktop_environment()
+{
+  local height=10
+  local items=0
 
+  cat > $TMP/select-desktop-envitonment$$ << EOF
+--colors --clear $nocancel \\
+--backtitle "\Z7Radix\Zn \Z1cross\Zn\Z7 Linux\Zn" \\
+--title " \Z0Select Desktop Environment\Zn " \\
+--menu "\\n\\
+EOF
+
+
+  cat >> $TMP/select-desktop-envitonment$$ << EOF
+\\n\\
+ Please select your preferred Desktop Environment:\\
+" ${height} 74 ${items} \\
+EOF
+
+  #
+  # Currently we have only 'OpenBox' and 'Mate' Environments:
+  #
+  for session in `ls ${ROOT_MPOINT}/etc/X11/xinit/xinitrc.*-session` ; do
+    case ${session} in
+      *openbox*)
+        let 'items += 1'
+        let 'height += 1'
+        cat >> $TMP/select-desktop-envitonment$$ << EOF
+"OpenBox" "- Lightweight window manager for X Window" \\
+EOF
+       ;;
+      *mate*)
+        let 'items += 1'
+        let 'height += 1'
+        cat >> $TMP/select-desktop-envitonment$$ << EOF
+"MATE" "- MATE Desktop Environment (based on GNOME 2)" \\
+EOF
+       ;;
+    esac
+  done
+
+  $DIALOG --default-item "OpenBox" --file $TMP/select-desktop-envitonment$$ 2> $TMP/desktop$$
+  ret=$?
+  if [ ${ret} -eq 255 ]; then
+    rm -f $TMP/desktopt$$
+    rm -f $TMP/select-desktop-envitonment$$
+    result="OpenBox"
+  else
+    result=`cat $TMP/desktop$$`
+  fi
+  rm -f $TMP/desktop$$
+  rm -f $TMP/select-desktop-envitonment$$
+  if [ "${result}" = "MATE" ]; then
+    ln -srf ${ROOT_MPOINT}/etc/X11/xinit/xinitrc.mate-session ${ROOT_MPOINT}/etc/X11/xinit/xinitrc
+  else
+    ln -srf ${ROOT_MPOINT}/etc/X11/xinit/xinitrc.openbox-session ${ROOT_MPOINT}/etc/X11/xinit/xinitrc
+  fi
+}
 #
+# End of Select Desktop Environment.
+#
+####################################################################
+
+
+#
 # Parse Options:
 #
 while [ 0 ]; do
@@ -2671,7 +2890,9 @@
 # /etc/fstab:
 # ----------
 #
-if [ "${hardware}" = "baikal-m1" -o \
+if [ "${hardware}" = "baikal-m1"   -o \
+     "${hardware}" = "orange-pi5"  -o \
+     "${hardware}" = "visionfive2" -o \
      "${hardware}" = "intel-pc64" ] ; then
   prepare_partuuid_etc_fstab
 else
@@ -2684,6 +2905,8 @@
 # -------------------
 #
 if [ "${hardware}" = "baikal-m1"    -o \
+     "${hardware}" = "orange-pi5"   -o \
+     "${hardware}" = "visionfive2"  -o \
      "${hardware}" = "ebox-3350dx2" -o \
      "${hardware}" = "intel-pc32"   -o \
      "${hardware}" = "intel-pc64" ] ; then
@@ -2704,6 +2927,12 @@
 if [ "${hardware}" = "baikal-m1" ] ; then
   install_baikal_m1_grub
 fi
+if [ "${hardware}" = "orange-pi5" ] ; then
+  install_orange_pi5_grub
+fi
+if [ "${hardware}" = "visionfive2" ] ; then
+  install_starfive_vf2_grub
+fi
 if [ "${hardware}" = "intel-pc64" ] ; then
   install_intel_pc64_grub
 fi
@@ -2715,8 +2944,8 @@
 fi
 
 #
-# Install GRUB:
-# ------------
+# Install U-Boot:
+# --------------
 #
 if [ "${hardware}" = "leez-p710" ] ; then
   install_leez_p710_uboot "${device}"
@@ -2723,6 +2952,14 @@
 fi
 
 #
+# Install EDK2:
+# ------------
+#
+if [ "${hardware}" = "orange-pi5" ] ; then
+  install_orange_pi5_edk2
+fi
+
+#
 # post-install settings:
 #
 if [ -x ${ROOT_MPOINT}/usr/sbin/timeconfig ] ; then
@@ -2729,6 +2966,14 @@
   ${ROOT_MPOINT}/usr/sbin/timeconfig --root ${ROOT_MPOINT}
 fi
 
+#
+# Select Desktop Environment:
+#
+enabled=$(echo "`ls /etc/X11/xinit/xinitrc.*-session`" | wc -l)
+if [ ${enabled} -gt 1 ] ; then
+  select_desktop_environment
+fi
+
 $DIALOG --colors --clear \
         --backtitle "\Z7Radix\Zn \Z1cross\Zn\Z7 Linux\Zn" \
         --title " \Z0System Installation is Complete\Zn " \