From bcbf7c6c9fc7d8a96b1d5c4cc9247b85fe3da2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=81LI=20G=C3=A1bor=20J=C3=A1nos?= Date: Sun, 10 Apr 2022 18:17:21 +0200 Subject: Move towards custom packages. Change the build image process in a way that custom-built packages can be utilized. This means a simpler `Makefile` since every modification is implemented on the level of packages. Include the sources for every customized package. --- aports/busybox/persistent-storage | 68 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 aports/busybox/persistent-storage (limited to 'aports/busybox/persistent-storage') diff --git a/aports/busybox/persistent-storage b/aports/busybox/persistent-storage new file mode 100644 index 0000000..ea68948 --- /dev/null +++ b/aports/busybox/persistent-storage @@ -0,0 +1,68 @@ +#!/bin/sh + +symlink_action() { + case "$ACTION" in + add) ln -sf "$1" "$2";; + remove) rm -f "$2";; + esac +} + +# cdrom symlink +case "$MDEV" in + sr*|xvd*) + caps="$(cat /sys/block/$MDEV/capability 2>/dev/null)" + if [ $(( 0x${caps:-0} & 8 )) -gt 0 ]; then + symlink_action $MDEV cdrom + fi +esac + +# by-id symlinks +mkdir -p disk/by-id + +partition=$(cat /sys/class/block/$MDEV/partition 2>/dev/null) +case "$partition" in + [0-9]*) partsuffix="-part$partition";; +esac + +wwid=$(cat /sys/class/block/$MDEV/wwid 2>/dev/null) +: ${wwid:=$(cat /sys/class/block/$MDEV/device/wwid 2>/dev/null)} + +if [ -n "$wwid" ]; then + case "$MDEV" in + nvme*) symlink_action ../../$MDEV disk/by-id/nvme-${wwid}${partsuffix};; + esac + case "$wwid" in + naa.*) symlink_action ../../$MDEV disk/by-id/wwn-0x${wwid#naa.};; + esac +fi + +serial=$(sed -E -e 's/^\s+//' -e 's/\s+$//' -e 's/ /_/g' \ + /sys/class/block/$MDEV/device/serial 2>/dev/null) + +model=$(sed -E -e 's/^\s+//' -e 's/\s+$//' -e 's/ /_/g' \ + /sys/class/block/$MDEV/device/model 2>/dev/null) + +if [ -n "$serial" ] && [ -n "$model" ]; then + case "$MDEV" in + nvme*) symlink_action ../../$MDEV disk/by-id/nvme-${model}_${serial}${partsuffix};; + esac +fi + +# virtio-blk +if [ -n "$serial" ]; then + case "$MDEV" in + vd*) symlink_action ../../$MDEV disk/by-id/virtio-${serial}${partsuffix};; + esac +fi + +# by-uuid, by-partuuid +eval $(blkid /dev/$MDEV | cut -d: -f2-) +if [ -n "$UUID" ]; then + mkdir -p disk/by-uuid + symlink_action ../../$MDEV disk/by-uuid/$UUID +fi +if [ -n "$PARTUUID" ]; then + mkdir -p disk/by-partuuid + symlink_action ../../$MDEV disk/by-partuuid/$PARTUUID +fi + -- cgit v1.2.3