Skip to content

Commit c4020d9

Browse files
committed
fix partitioning with uniform device names (#126).
1 parent 276ab6d commit c4020d9

4 files changed

Lines changed: 43 additions & 17 deletions

File tree

linbofs/usr/bin/linbo_cmd

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# linbo_cmd: legacy command wrapper for the linbo_gui
44
#
55
6-
# 20250417
6+
# 20250801
77
# GPL v3
88
#
99

@@ -24,6 +24,11 @@ usage(){
2424
exit 0
2525
}
2626

27+
remove_args(){
28+
local item
29+
for item in $@; do shift; done
30+
}
31+
2732
[ -z "$1" ] && usage
2833

2934
# get command, substitute outdated commands for legacy reasons
@@ -32,8 +37,8 @@ case "$1" in
3237
create) cmd="create_image" ;;
3338
label) cmd="$1" ; options="all" ;;
3439
memory) cmd="mem" ;;
35-
partition) cmd="partition_format" ;;
36-
partition_noformat) cmd="partition" ;;
40+
partition) cmd="partition_format" ; remove_args ;;
41+
partition_noformat) cmd="partition" ; remove_args ;;
3742
sync|syncr) cmd="syncstart" ;;
3843
synconly) cmd="sync" ;;
3944
cmd|wrapper) usage ;;

linbofs/usr/bin/linbo_split_startconf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# split start.conf in machine parseable chunks
44
5-
# 20250423
5+
# 20250801
66
#
77

88

@@ -22,6 +22,11 @@ prefix="/tmp/start.conf."
2222
pc=0
2323
oc=0
2424

25+
# replace uniform device names with real ones
26+
grep ^[CcDdRr][AaEeOo][CcVvOo] /start.conf | grep /dev/ | awk '{print $3}' | sort -ur | while read item; do
27+
sed -i "s|$item|$(get_real_partname "$item")|g" /start.conf
28+
done
29+
2530
# split sections, remove comments
2631
grep ^"[\[a-zA-Z]" /start.conf | sed 's|# .*||' | awk '{$1=$1};1' | csplit -s -z -f "$prefix" - '/^\[/' '{*}'
2732

linbofs/usr/bin/linbo_start

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# linbo_start
44
5-
# 20250510
5+
# 20250801
66
#
77

88

@@ -56,7 +56,7 @@ if isinteger "$1"; then
5656

5757
# check root partition
5858
elif [ -b "$1" ]; then
59-
[ "$(realpath "$1")" = "$(realpath "$cache")" ] && shift
59+
[ "$cache" = "$1" ] && shift
6060
source /conf/os.$(osnr_startconf "$1") &> /dev/null || usage 1
6161

6262
else
@@ -69,7 +69,6 @@ kernel="${kernel#/}"
6969
initrd="${initrd#/}"
7070

7171
# partition or isofile
72-
[ -L "$root" ] && root="$(realpath "$root")"
7372
ext="$(tolower "${baseimage##*.}")"
7473
if [ "$ext" = "iso" ]; then
7574
bootpart="/cache/$baseimage"

linbofs/usr/share/linbo/shell_functions

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# common linbo shell functions
22
#
33
4-
# 20250717
4+
# 20250801
55
#
66

77
set -o pipefail
@@ -501,6 +501,23 @@ get_partnr(){
501501
}
502502

503503

504+
# compute real partition name from unified partition name
505+
get_real_partname(){
506+
local part="$1"
507+
# if not a unified name do nothing
508+
if [ "${part:0:9}" != "/dev/disk" ]; then
509+
echo "$part"
510+
return
511+
fi
512+
local disk="$(get_disk_from_partition "$part")"
513+
local realdisk="$(realpath "$disk")"
514+
case "$realdisk" in
515+
/dev/mmcblk[0-9]|/dev/nvme0n[0-9]) echo "$part" | sed -e "s|$disk|$realdisk|" ;;
516+
*) echo "$part" | sed -e "s|${disk}p|$realdisk|" ;;
517+
esac
518+
}
519+
520+
504521

505522
#### boot, grub & efi ####
506523

@@ -608,7 +625,7 @@ create_efiboot(){
608625
# return if entry exists
609626
efibootmgr | grep ^Boot[0-9] | awk -F\* '{ print $2 }' | grep -qiw " $1" && return 0
610627
local label="$1"
611-
local efipart="$(realpath "$2")"
628+
local efipart="$2"
612629
local efipartnr="$(get_partnr "$efipart")"
613630
local efidisk="$(get_disk_from_partition "$efipart")"
614631
local efiloader
@@ -689,7 +706,7 @@ repair_efi(){
689706
echo "repair_efi $@"
690707
local doneflag="/tmp/.repair_efi"
691708
[ -e "$doneflag" ] && return 0
692-
local efipart="$(realpath "$1")"
709+
local efipart="$1"
693710
local efiout="/tmp/efiout"
694711
local startflag="/tmp/.start"
695712
local line
@@ -730,7 +747,7 @@ mk_winefiboot(){
730747
local partition="$1"
731748
local doneflag="/tmp/.mk_winefiboot.$(basename "$partition")"
732749
[ -e "$doneflag" ] && return 0
733-
local efipart="$(realpath "$2")"
750+
local efipart="$2"
734751
local bootloaderid="$3"
735752
local RC="0"
736753
local win_bootdir="$(ls -d /mnt/[Ee][Ff][Ii]/[Mm][Ii][Cc][Rr][Oo][Ss][Oo][Ff][Tt]/[Bb][Oo][Oo][Tt] 2> /dev/null)"
@@ -762,7 +779,7 @@ mk_winefiboot(){
762779
# mk_efiboot: if returns 1 a reboot via grub will be initiated, othwerwise reboot via efi directly
763780
# args: efipart partition grubdisk
764781
mk_efiboot(){
765-
local efipart="$(realpath "$1")"
782+
local efipart="$1"
766783
local partition="$2"
767784
local grubdisk="$3"
768785
local startflag="/tmp/.start"
@@ -822,7 +839,7 @@ mk_linefiboot(){
822839
local doneflag="/tmp/.mk_linefiboot.$(basename "$partition")"
823840
[ -e "$doneflag" ] && return 0
824841
local grubdisk="$2"
825-
local efipart="$(realpath "$3")"
842+
local efipart="$3"
826843
local bootloaderid="$4"
827844
local RC="0"
828845
mkdir -p /mnt/boot/efi
@@ -880,14 +897,14 @@ prepare_grub(){
880897
# args: grubdisk partition grubenv kernel initrd append efipart
881898
prepare_reboot(){
882899
echo "prepare_reboot $@"
883-
local grubdisk="$(realpath "$1")"
884-
local partition="$(realpath "$2")"
900+
local grubdisk="$1"
901+
local partition="$2"
885902
local grubenv="$3"
886903
local KERNEL="${4#/}"
887904
local INITRD="${5#/}"
888905
local APPEND="$6"
889906
if [ -n "$7" ]; then
890-
local efipart="$(realpath "$7")"
907+
local efipart="$7"
891908
fi
892909
local efiboot="false"
893910
remote_cache "$cache" || local localcache="yes"
@@ -958,7 +975,7 @@ mk_boot(){
958975
local INITRD="${3#/}"
959976
local APPEND="$4"
960977
if [ -n "$(print_efipart)" ]; then
961-
local efipart="$(realpath "$(print_efipart)")"
978+
local efipart="$(print_efipart)"
962979
fi
963980
local partition="$1"
964981
remote_cache "$cache" || local localcache="yes"

0 commit comments

Comments
 (0)