Skip to content

Commit

Permalink
[bot] AutoMerging: merge all upstream's changes:
Browse files Browse the repository at this point in the history
* https://github.com/coolsnowwolf/lede:
  base-files: fixes x86 sysupgrade (coolsnowwolf#10992)
  • Loading branch information
github-actions[bot] committed Mar 12, 2023
2 parents eae7ec3 + dd7c89a commit c4923c8
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions package/base-files/files/lib/upgrade/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,9 @@ _v() {
[ -n "$VERBOSE" ] && [ "$VERBOSE" -ge 1 ] && echo "$*" >&2
}

_vn() {
[ -n "$VERBOSE" ] && [ "$VERBOSE" -ge 1 ] && echo -n "$*" >&2
}

v() {
_v "$(date) upgrade: $@"
}

vn() {
_vn "$(date) upgrade: $@"
logger -p info -t upgrade "$@"
}

json_string() {
Expand All @@ -95,8 +88,7 @@ get_image() { # <source> [ <command> ]
if [ -z "$cmd" ]; then
local magic="$(dd if="$from" bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')"
case "$magic" in
1f8b) cmd="zcat";;
425a) cmd="bzcat";;
1f8b) cmd="busybox zcat";;
*) cmd="cat";;
esac
fi
Expand Down Expand Up @@ -135,6 +127,33 @@ get_magic_fat32() {
(get_image "$@" | dd bs=1 count=5 skip=82) 2>/dev/null
}

identify_magic_long() {
local magic=$1
case "$magic" in
"55424923")
echo "ubi"
;;
"31181006")
echo "ubifs"
;;
"68737173")
echo "squashfs"
;;
"d00dfeed")
echo "fit"
;;
"4349"*)
echo "combined"
;;
"1f8b"*)
echo "gzip"
;;
*)
echo "unknown $magic"
;;
esac
}

part_magic_efi() {
local magic=$(get_magic_gpt "$@")
[ "$magic" = "EFI PART" ]
Expand Down Expand Up @@ -163,9 +182,11 @@ export_bootdevice() {
fi
done
;;
PARTUUID=????????-????-????-????-??????????0?/PARTNROFF=1 | \
PARTUUID=????????-????-????-????-??????????02)
uuid="${rootpart#PARTUUID=}"
uuid="${uuid%02}00"
uuid="${uuid%/PARTNROFF=1}"
uuid="${uuid%0?}00"
for disk in $(find /dev -type b); do
set -- $(dd if=$disk bs=1 skip=568 count=16 2>/dev/null | hexdump -v -e '8/1 "%02x "" "2/1 "%02x""-"6/1 "%02x"')
if [ "$4$3$2$1-$6$5-$8$7-$9" = "$uuid" ]; then
Expand Down Expand Up @@ -211,7 +232,7 @@ export_partdevice() {
while read line; do
export -n "$line"
done < "$uevent"
if [ $BOOTDEV_MAJOR = $MAJOR -a $(($BOOTDEV_MINOR + $offset)) = $MINOR -a -b "/dev/$DEVNAME" ]; then
if [ "$BOOTDEV_MAJOR" = "$MAJOR" -a $(($BOOTDEV_MINOR + $offset)) = "$MINOR" -a -b "/dev/$DEVNAME" ]; then
export "$var=$DEVNAME"
return 0
fi
Expand All @@ -228,15 +249,6 @@ hex_le32_to_cpu() {
echo "$@"
}

get_partition_by_name() {
for partname in /sys/class/block/$1/*/name; do
[ "$(cat ${partname})" = "$2" ] && {
basename ${partname%%/name}
break
}
done
}

get_partitions() { # <device> <filename>
local disk="$1"
local filename="$2"
Expand Down

0 comments on commit c4923c8

Please sign in to comment.