Draft for making OTA images
This commit is contained in:
@@ -1,21 +1,29 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
DEVICE="$1"
|
||||
FAKE_DEV="/tmp/dev"
|
||||
|
||||
mkdir -p "$FAKE_DEV"
|
||||
PARENT_NAME=$(basename "$DEVICE")
|
||||
|
||||
echo "Refreshing partition table..."
|
||||
partx -u "$DEVICE" 2>/dev/null || partx -a "$DEVICE"
|
||||
echo "Refreshing partition table for $DEVICE..."
|
||||
partx -u "$DEVICE" 2>/dev/null || partx -a "$DEVICE" || true
|
||||
|
||||
# Remove old fake nodes for this loop device first
|
||||
find "$FAKE_DEV" -maxdepth 1 -type b -name "${PARENT_NAME}*" -exec rm -f {} \;
|
||||
|
||||
# Find partitions and their Major:Minor numbers
|
||||
lsblk -rn -o NAME,MAJ:MIN "$DEVICE" | while read -r NAME MAJMIN; do
|
||||
# Skip the parent loop0
|
||||
if [[ "$NAME" == "loop0" ]]; then continue; fi
|
||||
# Skip the parent loop device itself
|
||||
if [[ "$NAME" == "$PARENT_NAME" ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
PART_PATH="$FAKE_DEV/$NAME"
|
||||
MAJOR=$(echo $MAJMIN | cut -d: -f1)
|
||||
MINOR=$(echo $MAJMIN | cut -d: -f2)
|
||||
MAJOR="${MAJMIN%%:*}"
|
||||
MINOR="${MAJMIN##*:}"
|
||||
|
||||
echo "Creating node: $PART_PATH (b $MAJOR $MINOR)"
|
||||
rm -f "$PART_PATH"
|
||||
mknod "$PART_PATH" b "$MAJOR" "$MINOR"
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user