Skip to content

Commit

Permalink
Refactor scripts and fix fstab
Browse files Browse the repository at this point in the history
- gen-fstab module: decode command output
- options module: add parent "distinct" property check for parentCheckState
- boot scripts: remove RCVRY=1 as it is no longer required
- genfstab: add target_to_mntpt and remove swap

Signed-off-by: shadichy <hotrobb360web@gmail.com>
  • Loading branch information
shadichy committed Jan 9, 2025
1 parent b2a1b00 commit 4e3ec58
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 76 deletions.
4 changes: 2 additions & 2 deletions src/modules/bootcfg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def run():
[
"sed",
"-ri",
"s/efiBootLoader: .+/efiBootLoader: \"{}\"/g".format(bootloader),
"/usr/share/calamares/modules/bootloader.conf"
's/efiBootLoader: .+/efiBootLoader: "{}"/g'.format(bootloader),
"/usr/share/calamares/modules/bootloader.conf",
],
None,
)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/gen-fstab/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def run():
genfstab_output = subprocess.run(
["/usr/share/calamares/scripts/genfstab", "-U", root_mount_point],
stdout=subprocess.PIPE,
).stdout
).stdout.decode()

kernel_args = str(libcalamares.globalstorage.value("options"))

Expand Down
2 changes: 1 addition & 1 deletion src/modules/options/OptionTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ parentCheckState( OptionTreeItem* parent )
if ( parent )
{
// Avoid partially-checked .. a option can't be partial
return parent->isSelected() == Qt::Unchecked ? Qt::Unchecked : Qt::Checked;
return parent->isDistinct() || parent->isSelected() == Qt::Unchecked ? Qt::Unchecked : Qt::Checked;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/10_blissos
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ old_title=$TITLE
echo "submenu '$(echo "Recovery modes for $TITLE" | grub_quote)' --class recovery ${CLASS} \$menuentry_id_option '$OS-${TITLE// /_}-Recovery' {"
TITLE="$TITLE - Recovery Mode"
for arg in "${RECOVERY_ARGS[@]}"; do
entry "${arg%:*}" RCVRY=1 androidboot.mode=recovery androidboot.force_normal_boot=0 ${arg#*:}
entry "${arg%:*}" androidboot.mode=recovery androidboot.force_normal_boot=0 ${arg#*:}
done
echo "}"

Expand Down
111 changes: 53 additions & 58 deletions src/scripts/genfstab
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,17 @@ optstring_apply_quirks() {
esac
}

target_to_mntpt() {
local ret
case "$1" in
boot) ret=bootloader ;;
boot/efi) ret=esp ;;
data) ret=userdata ;;
*) ret=$1 ;;
esac
printf "%s" "$ret"
}

usage() {
cat <<EOF
usage: ${0##*/} [options] root
Expand Down Expand Up @@ -350,30 +361,14 @@ fi

while getopts ':f:LPpt:U' flag; do
case $flag in
L)
bytag=LABEL
;;
U)
bytag=UUID
;;
f)
prefixfilter=$OPTARG
;;
P)
pseudofs=1
;;
p)
pseudofs=0
;;
t)
bytag=${OPTARG^^}
;;
:)
die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG"
;;
?)
die '%s: invalid option -- '\''%s'\' "${0##*/}" "$OPTARG"
;;
L) bytag=LABEL ;;
U) bytag=UUID ;;
f) prefixfilter=$OPTARG ;;
P) pseudofs=1 ;;
p) pseudofs=0 ;;
t) bytag=${OPTARG^^} ;;
:) die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG" ;;
?) die '%s: invalid option -- '\''%s'\' "${0##*/}" "$OPTARG" ;;
esac
done
shift $(( OPTIND - 1 ))
Expand Down Expand Up @@ -444,39 +439,39 @@ while read -r src target fstype opts fsroot; do

# write one line
write_source "$src"
printf '\t%-10s' "/$(mangle "${target#/}")" "$fstype" "$opts"
printf '\t%-10s' "$(target_to_mntpt "$(mangle "${target#/}")")" "$fstype" "$opts"
printf '\tdefaults'
printf '\n\n'
done < <(findmnt -Recvruno SOURCE,TARGET,FSTYPE,OPTIONS,FSROOT "$root")

# handle swaps devices
{
# ignore header
read

while read -r device type _ _ prio; do
options=defaults
if (( prio >= 0 )); then
options+=,pri=$prio
fi

# skip files marked deleted by the kernel
[[ $device = *'\040(deleted)' ]] && continue

# skip devices not part of the prefix
[[ $device = "$prefixfilter"* ]] || continue

if [[ $type = file ]]; then
printf '%-20s' "${device#${root%/}}"
elif [[ $device = /dev/dm-+([0-9]) ]]; then
# device mapper doesn't allow characters we need to worry
# about being mangled, and it does the escaping of dashes
# for us in sysfs.
write_source "$(dm_name_for_devnode "$device")"
else
write_source "$(unmangle "$device")"
fi

printf '\t%-10s\t%-10s\t%-10s\tdefaults\n\n' 'none' 'swap' "$options"
done
} </proc/swaps
done < <(findmnt -Recvruno SOURCE,TARGET,FSTYPE,OPTIONS,FSROOT "$root" | grep -Ev '^/\s')

# # handle swaps devices
# {
# # ignore header
# read

# while read -r device type _ _ prio; do
# options=defaults
# if (( prio >= 0 )); then
# options+=,pri=$prio
# fi

# # skip files marked deleted by the kernel
# [[ $device = *'\040(deleted)' ]] && continue

# # skip devices not part of the prefix
# [[ $device = "$prefixfilter"* ]] || continue

# if [[ $type = file ]]; then
# printf '%-20s' "${device#${root%/}}"
# elif [[ $device = /dev/dm-+([0-9]) ]]; then
# # device mapper doesn't allow characters we need to worry
# # about being mangled, and it does the escaping of dashes
# # for us in sysfs.
# write_source "$(dm_name_for_devnode "$device")"
# else
# write_source "$(unmangle "$device")"
# fi

# printf '\t%-10s\t%-10s\t%-10s\tdefaults\n\n' 'none' 'swap' "$options"
# done
# } </proc/swaps
30 changes: 17 additions & 13 deletions src/scripts/refind-conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
root=$1
shift

. "$pkgdatadir/grub-mkconfig_lib"
. "/usr/share/grub/grub-mkconfig_lib"
. /etc/default/grub

export TEXTDOMAIN=grub
Expand All @@ -14,16 +14,20 @@ export TEXTDOMAINDIR="${datarootdir}/locale"
TITLE="BlissOS $(grep 'ro.bliss.version=' /system/build.prop | awk -F'=' '{print $2}')"

ADVANCED_ARGS=(
"DEBUG=2 androidboot.enable_console=1"
"nomodeset"
"Debug mode: DEBUG=2 androidboot.enable_console=1"
"No Modeset: nomodeset"
"No hwaccel: HWACCEL=0"
)

RECOVERY_ARGS=(
"androidboot.pixel_format=RGBX_8888"
"androidboot.pixel_format=ABGR_8888"
"androidboot.pixel_format=ARGB_8888"
"androidboot.pixel_format=BGRA_8888"
"androidboot.pixel_format=RGBA_8888"
""
"Debug mode: DEBUG=2 androidboot.enable_console=1"
"RGBX_8888 color mode: androidboot.pixel_format=RGBX_8888"
"ABGR_8888 color mode: androidboot.pixel_format=ABGR_8888"
"ARGB_8888 color mode: androidboot.pixel_format=ARGB_8888"
"BGRA_8888 color mode: androidboot.pixel_format=BGRA_8888"
"RGBA_8888 color mode: androidboot.pixel_format=RGBA_8888"
"BGRX_8888 color mode: androidboot.pixel_format=BGRX_8888"
)

# Extra indentation to add to menu entries in a submenu. We're not in a submenu
Expand All @@ -35,7 +39,7 @@ ROOT_PARTUUID=$(${grub_probe} --device "$GRUB_DEVICE" --target=partuuid 2>/dev/n
[ "$ROOT_UUID" ] &&
ROOT_DEVICE="UUID=$ROOT_UUID"

RECOVERY_PARAMETERS="RCVRY=1 androidboot.mode=recovery androidboot.force_normal_boot=0"
RECOVERY_PARAMETERS="androidboot.mode=recovery androidboot.force_normal_boot=0"

conf=efi/EFI/refind/refind.conf
CONFIG_FILE=$root/boot/$conf
Expand All @@ -56,16 +60,16 @@ EOF

for arg in "${ADVANCED_ARGS[@]}"; do
cat <<EOF >>"$CONFIG_FILE"
submenuentry "Advanced mode: $arg" {
add_options "$arg"
submenuentry "Advanced mode: ${arg%:*}" {
add_options "${arg#*:}"
}
EOF
done

for arg in "${RECOVERY_ARGS[@]}"; do
cat <<EOF >>"$CONFIG_FILE"
submenuentry "Recovery mode: $arg" {
add_options "$RECOVERY_PARAMETERS $arg"
submenuentry "Recovery mode: ${arg%:*}" {
add_options "$RECOVERY_PARAMETERS ${arg#*:}"
}
EOF
done
Expand Down

0 comments on commit 4e3ec58

Please sign in to comment.