cleanup scripts: packages/

This commit is contained in:
CvH
2024-07-06 11:48:56 +02:00
parent 99ae3fc3b1
commit 67dcda694b
41 changed files with 466 additions and 483 deletions

View File

@@ -25,7 +25,7 @@ mkdir -p "${TMPDIR}/usr/lib/firmware"
cp -r "${EDID_DIR}" "${TMPDIR}/usr/lib/firmware"
cd "${TMPDIR}"
mount -o remount,rw /flash
find usr -print | cpio -ov -H newc > "${EDID_CPIO}"
find usr -print | cpio -ov -H newc >"${EDID_CPIO}"
sync
mount -o remount,ro /flash
cd /storage

View File

@@ -5,7 +5,7 @@
COMPATIBLE=$(cat /proc/device-tree/compatible 2>/dev/null | tr -d '\000' | sed -n -e 's/.*\(allwinner\|amlogic\|fsl\|nxp\|qcom\|raspberrypi\|rockchip\|samsung\).*/\1/p')
do_dtfile(){
do_dtfile() {
if [[ -n $(find /flash -name extlinux.conf) ]]; then
EXTLINUX=$(find /flash -name extlinux.conf)
DTFILE=$(grep FDT "${EXTLINUX}" | sed 's,^ *FDT /,,g')
@@ -19,7 +19,7 @@ do_dtfile(){
echo "${DTFILE}"
}
do_dtflag(){
do_dtflag() {
if [ "${COMPATIBLE}" = "raspberrypi" ]; then
DTFLAG=$(cat /proc/device-tree/compatible | cut -f1,2 -d',' | head -n 1)
PIREV=$(awk '/^Revision/ {sub($3,-6, "", $3); print $3}' /proc/cpuinfo) # truncate to 6-chars
@@ -36,10 +36,10 @@ do_dtflag(){
a*)
MEMSIZE="-1g"
;;
*0002|*0003|*0004|*0005|*0006|*0007|*0008|*0009|*0012)
*0002 | *0003 | *0004 | *0005 | *0006 | *0007 | *0008 | *0009 | *0012)
MEMSIZE="-256"
;;
0*|9*)
0* | 9*)
MEMSIZE="-512"
;;
*)
@@ -58,17 +58,17 @@ do_dtflag(){
echo "${DTFLAG}${MEMSIZE}"
}
do_dtname(){
do_dtname() {
DTNAME=$(cat /proc/device-tree/compatible | cut -f1,2 -d',' | head -n 1)
echo "${DTNAME}"
}
do_dtsoc(){
do_dtsoc() {
DTSOC=$(cat /proc/device-tree/compatible | cut -f1,2 -d',' | tail -n 1)
echo "${DTSOC}"
}
do_unknown(){
do_unknown() {
echo "unknown"
exit 1
}

View File

@@ -18,14 +18,14 @@ info() {
mkdir -p "${EDID_DIR}"
for c in /sys/class/drm/card?-* ; do
for c in /sys/class/drm/card?-*; do
[ ! -d "$c" ] && continue
[ ! -e "$c/status" ] && continue
if [ $(cat $c/status 2>/dev/null) = "connected" ]; then
CONNECTOR=$(basename $c | cut -c 7-)
EDID_NAME="edid-${CONNECTOR}.bin"
cat $c/edid > "${EDID_DIR}/${EDID_NAME}" 2>/dev/null
cat $c/edid >"${EDID_DIR}/${EDID_NAME}" 2>/dev/null
if [ $? -eq 0 ]; then
[ -n "${CONNECTORS}" ] && CONNECTORS="${CONNECTORS} "
CONNECTORS="${CONNECTORS}${CONNECTOR}"

View File

@@ -26,10 +26,9 @@ help() {
echo "And then use: getedid create"
}
# check for GPU and store string
check_gpu() {
if lspci | grep -i vga | grep -i -q -E 'intel|amd' ; then
if lspci | grep -i vga | grep -i -q -E 'intel|amd'; then
gpu="intel/amd"
elif lspci | grep -i vga | grep -i -q nvidia; then
gpu="nvidia"
@@ -39,12 +38,11 @@ check_gpu() {
fi
}
# run this first if the user already has a custom EDID but want to create a new one (TV or AVR change)
del_edid() {
if [ "$gpu" = "intel/amd" ]; then
check_file
if [ -f "$file".old ]; then
if [ -f "$file".old ]; then
mount_rw
rm "$file"
mv "$file".old "$file"
@@ -60,10 +58,9 @@ del_edid() {
rm -f /storage/.config/xorg.conf
rm -f /storage/.config/xorg.le.backup
systemctl restart xorg.service
fi
fi
}
# run main script depending on the GPU
run() {
if [ "$gpu" = "intel/amd" ]; then
@@ -73,19 +70,16 @@ run() {
fi
}
# mounting /flash to rw
mount_rw() {
mount -o remount,rw /flash
}
# mounting /flash to ro
mount_ro() {
mount -o remount,ro /flash
}
# remount /flash to ro and reboot
sys_reboot() {
mount_ro
@@ -94,11 +88,10 @@ sys_reboot() {
reboot
}
# check syslinux.cfg and/or extlinux.conf
check_file() {
# check boot system
if [ -d /sys/firmware/efi -a -f /flash/EFI/BOOT/syslinux.cfg ] ; then
if [ -d /sys/firmware/efi -a -f /flash/EFI/BOOT/syslinux.cfg ]; then
sys_boot="UEFI"
sys_path="/flash/EFI/BOOT"
else
@@ -122,30 +115,26 @@ check_file() {
fi
}
check_content() {
# check if changes are already made to $file and exit if yes
if grep -q "initrd=/edid.cpio" $file ; then
if grep -q "initrd=/edid.cpio" $file; then
echo "$file has been modified. Please run 'getedid delete' first if you want to modify it again. Exiting."
exit 5
fi
}
create_edid() {
# create edid
# create edid
mkdir -p /tmp/cpio/lib/firmware/edid
cat "/sys/class/drm/$card/edid" > /tmp/cpio/lib/firmware/edid/edid.bin
cat "/sys/class/drm/$card/edid" >/tmp/cpio/lib/firmware/edid/edid.bin
mkdir -p /storage/.config/firmware/edid
cp /tmp/cpio/lib/firmware/edid/edid.bin /storage/.config/firmware/edid
# create cpio archive
cd /tmp/cpio/
find . -print | cpio -ov -H newc > /storage/edid.cpio
find . -print | cpio -ov -H newc >/storage/edid.cpio
}
intel_amd() {
# check which output is connnected:
counter=0
@@ -162,7 +151,7 @@ intel_amd() {
fi
done
# create the edid
# create the edid
create_edid
# check extlinux.conf and syslinux.cfg
@@ -175,7 +164,7 @@ intel_amd() {
# make a backup of $file
cp "$file" "$file".old
# add boot parameters to $file
sed -i "/ APPEND/s/$/ initrd=\/edid.cpio drm.edid_firmware=edid\/edid.bin video=$hdmi:D/" "$file"
@@ -183,7 +172,6 @@ intel_amd() {
sys_reboot
}
nvidia() {
# check if xorg.conf already exists
if [ -f /storage/.config/xorg.conf -o -f /storage/.config/xorg-nvidia.conf ]; then
@@ -191,7 +179,6 @@ nvidia() {
exit 6
fi
# check for multi-montior setup
monitors="$(grep -i -w "connected" /var/log/Xorg.0.log | grep -i -o "dfp-[0-9]" | sort -u | wc -l)"
if [ "$monitors" -gt "1" ]; then
@@ -199,12 +186,10 @@ nvidia() {
exit 7
fi
# set debug and restart Xorg
cp /etc/X11/xorg-nvidia.conf /storage/.config/xorg.conf
sed -i 's/"ModeDebug" "false"/"ModeDebug" "true"/g' /storage/.config/xorg.conf
systemctl restart xorg.service
# get port
nv_port="$(grep -i -w connected /var/log/Xorg.0.log | grep -i -o "dfp-[0-9]" | sort -u)"
@@ -212,7 +197,7 @@ nvidia() {
# set mode debug back to false
sed -i 's/"ModeDebug" "true"/"ModeDebug" "false"/g' /storage/.config/xorg.conf
# set port and uncomment lines
sed -i "s/# Option \"ConnectedMonitor\" \"DFP-0\"/ Option \"ConnectedMonitor\" \"$nv_port\"/g" /storage/.config/xorg.conf
sed -i "s/# Option \"CustomEDID\" \"DFP-0:\/storage\/.config\/edid.bin\"/ Option \"CustomEDID\" \"$nv_port:\/storage\/.config\/edid.bin\"/g" /storage/.config/xorg.conf
@@ -223,7 +208,6 @@ nvidia() {
systemctl restart xorg.service
}
# start script from here
case "$1" in
'create')

View File

@@ -15,7 +15,7 @@ mkdir -p "${MODULES_DIR}"
mkdir -p "${FIRMWARE_DIR}"
log() {
echo "kernel-overlays-setup: $@" > /dev/kmsg
echo "kernel-overlays-setup: $@" >/dev/kmsg
}
apply_overlay() {
@@ -30,18 +30,18 @@ apply_overlay() {
;;
esac
if [ -d "${modules_overlay_dir}" ] ; then
if [ -d "${modules_overlay_dir}" ]; then
GOT_MODULE_OVERLAY="yes"
if cp -rfs "${modules_overlay_dir}"/* "${MODULES_DIR}" ; then
if cp -rfs "${modules_overlay_dir}"/* "${MODULES_DIR}"; then
log "added modules from $modules_overlay_dir"
else
log "failed to add modules from $modules_overlay_dir"
fi
fi
if [ -d "${firmware_overlay_dir}" ] ; then
if cp -rfs "${firmware_overlay_dir}"/* "${FIRMWARE_DIR}" ; then
if [ -d "${firmware_overlay_dir}" ]; then
if cp -rfs "${firmware_overlay_dir}"/* "${FIRMWARE_DIR}"; then
log "added firmware from $firmware_overlay_dir"
else
log "failed to add firmware from $firmware_overlay_dir"
@@ -56,26 +56,26 @@ apply_overlay base
# apply user-configured module overlays
if [ -d "${OVERLAY_CONFIG_DIR}" ] ; then
if [ -d "${OVERLAY_CONFIG_DIR}" ]; then
log "adding overlays from ${OVERLAY_CONFIG_DIR}"
GOT_MODULE_OVERLAY="no"
for conf in "${OVERLAY_CONFIG_DIR}/"*.conf ; do
if [ -e "$conf" ] ; then
for conf in "${OVERLAY_CONFIG_DIR}/"*.conf; do
if [ -e "$conf" ]; then
log "processing conf $conf"
overlay=$(cat "$conf")
[ -n "$overlay" ] && apply_overlay "$overlay"
fi
done
if [ "yes" = "$GOT_MODULE_OVERLAY" ] ; then
if [ "yes" = "$GOT_MODULE_OVERLAY" ]; then
log "running depmod"
/usr/sbin/depmod -a >/dev/kmsg 2>&1
fi
fi
if [ -d "${USER_FIRMWARE_DIR}" ] && [ -n "$(ls ${USER_FIRMWARE_DIR})" ] ; then
if cp -rfs "${USER_FIRMWARE_DIR}"/* "${FIRMWARE_DIR}" ; then
if [ -d "${USER_FIRMWARE_DIR}" ] && [ -n "$(ls ${USER_FIRMWARE_DIR})" ]; then
if cp -rfs "${USER_FIRMWARE_DIR}"/* "${FIRMWARE_DIR}"; then
log "added firmware from ${USER_FIRMWARE_DIR}"
else
log "failed to add firmware from ${USER_FIRMWARE_DIR}"

View File

@@ -9,8 +9,8 @@ case $(dtsoc) in
for triggerfile in $(find /sys/devices/platform/leds -name trigger); do
trigger=$(awk -F'[][]' '{print $2}' "$triggerfile")
if [ "$trigger" = "heartbeat" ]; then
echo "none" > "$triggerfile"
echo "none" >"$triggerfile"
fi
done
;;
;;
esac

View File

@@ -7,7 +7,7 @@
EARLY_DIR="$2"
log() {
echo "libreelec-target-generator: $@" > /dev/kmsg
echo "libreelec-target-generator: $@" >/dev/kmsg
}
if [ -z "$EARLY_DIR" ]; then

View File

@@ -3,13 +3,13 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2022-present Team LibreELEC (https://libreelec.tv)
do_install(){
do_install() {
# create the persistent firmware dir
mkdir -p "/storage/.config/firmware/edid"
# capture the raw edid file
if [ ! -e /storage/.config/firmware/edid/edid.bin ]; then
cat "/sys/class/drm/card0-HDMI-A-1/edid" > "/storage/.config/firmware/edid/edid.bin"
cat "/sys/class/drm/card0-HDMI-A-1/edid" >"/storage/.config/firmware/edid/edid.bin"
else
echo "info: using existing edid.bin"
fi
@@ -18,7 +18,7 @@ do_install(){
mkdir -p "/storage/cpio/lib/firmware/edid"
cp "/storage/.config/firmware/edid/edid.bin" "/storage/cpio/lib/firmware/edid/"
cd "/storage/cpio"
find . -print | cpio -ov -H newc > "/storage/.config/firmware/edid/edid.cpio"
find . -print | cpio -ov -H newc >"/storage/.config/firmware/edid/edid.cpio"
# mount /flash rw
mount -o remount,rw /flash
@@ -32,7 +32,7 @@ do_install(){
# determine boot method and set params
if [ -f "/flash/extlinux/extlinux.conf" ]; then
FILE="/flash/extlinux/extlinux.conf"
if grep -q "initrd=/edid.cpio" "${FILE}" ; then
if grep -q "initrd=/edid.cpio" "${FILE}"; then
echo "error: ${FILE} already contains edid.cpio, aborting!"
exit 1
else
@@ -43,7 +43,7 @@ do_install(){
fi
else
FILE="/flash/uEnv.ini"
if grep -q "initrd=/edid.cpio" "${FILE}" ; then
if grep -q "initrd=/edid.cpio" "${FILE}"; then
echo "error: ${FILE} already contains edid.cpio info .. aborting!"
exit 1
else
@@ -55,7 +55,7 @@ do_install(){
fi
}
do_cleanup(){
do_cleanup() {
rm "/storage/.config/firmware/edid/edid.bin"
rm "/storage/.config/firmware/edid/edid.cpio"
mount -o remount,rw /flash
@@ -69,7 +69,7 @@ do_cleanup(){
mount -o remount,ro /flash
}
do_usage(){
do_usage() {
echo "usage: getedid {create|delete}"
exit 0
}

View File

@@ -43,21 +43,21 @@ get_cleaned_cmdline_txt() {
add_initramfs() {
# make sure config.txt ends with a newline
if [ "$(tail -c 1 ${CONFIG_TXT} | tr -c -d '\n' | tr '\n' 'X')" != "X" ]; then
echo "" >> ${CONFIG_TXT}
echo "" >>${CONFIG_TXT}
fi
echo "initramfs edid.cpio" >> ${CONFIG_TXT}
echo "initramfs edid.cpio" >>${CONFIG_TXT}
}
add_cmdline() {
CMDLINE=$(get_cleaned_cmdline_txt)
FIRMWARE=""
FIRMWARE=""
VIDEO=""
for conn in "$@"; do
VIDEO="${VIDEO} video=${conn}:D"
[ -n "${FIRMWARE}" ] && FIRMWARE="${FIRMWARE},"
FIRMWARE="${FIRMWARE}${conn}:edid/edid-${conn}.bin"
done
echo "${CMDLINE} drm.edid_firmware=${FIRMWARE}${VIDEO}" > ${CMDLINE_TXT}
echo "${CMDLINE} drm.edid_firmware=${FIRMWARE}${VIDEO}" >${CMDLINE_TXT}
}
set_edids() {
@@ -73,7 +73,7 @@ delete_edids() {
mount -o remount,rw /flash
cleanup_config_txt
CMDLINE=$(get_cleaned_cmdline_txt)
echo "${CMDLINE}" > ${CMDLINE_TXT}
echo "${CMDLINE}" >${CMDLINE_TXT}
mount -o remount,ro /flash
}

View File

@@ -3,31 +3,30 @@
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2022-present Team LibreELEC (https://libreelec.tv)
do_start(){
while sleep 1
do
printf "%4s" "$(date +'%l %M' | tr -d '[:space:]')" > "$LED_PATH_TEXT"
do_start() {
while sleep 1; do
printf "%4s" "$(date +'%l %M' | tr -d '[:space:]')" >"$LED_PATH_TEXT"
if [ "$LED_COLON" = "off" ]; then
echo "1" > "$LED_PATH_COLON"
echo "1" >"$LED_PATH_COLON"
LED_COLON="on"
else
echo "0" > "$LED_PATH_COLON"
echo "0" >"$LED_PATH_COLON"
LED_COLON="off"
fi
done
}
do_stop(){
echo "0" > "$LED_PATH_COLON"
echo " " > "$LED_PATH_TEXT"
do_stop() {
echo "0" >"$LED_PATH_COLON"
echo " " >"$LED_PATH_TEXT"
}
case $(dtname) in
oranth,tx3-mini|oranth,tx9-pro|sunvell,t95z-plus)
oranth,tx3-mini | oranth,tx9-pro | sunvell,t95z-plus)
LED_PATH_COLON="/sys/devices/platform/spi/spi_master/spi0/spi0.0/leds/:colon/brightness"
LED_PATH_TEXT="/sys/devices/platform/spi/spi_master/spi0/spi0.0/display_text"
;;
default|*)
default | *)
# noop
;;
esac