diff options
author | PÁLI Gábor János <pali.gabor@gmail.com> | 2022-04-10 18:17:21 +0200 |
---|---|---|
committer | PÁLI Gábor János <pali.gabor@gmail.com> | 2022-04-10 23:09:31 +0200 |
commit | bcbf7c6c9fc7d8a96b1d5c4cc9247b85fe3da2ad (patch) | |
tree | 46d796182b2249408b0597485462ef1698dc4c13 /aports/busybox/persistent-storage | |
parent | 40d2daea11738408b7bf7b60f14a558ff8c47fb0 (diff) | |
download | freebsd-wifibox-alpine-bcbf7c6c9fc7d8a96b1d5c4cc9247b85fe3da2ad.zip |
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.
Diffstat (limited to 'aports/busybox/persistent-storage')
-rw-r--r-- | aports/busybox/persistent-storage | 68 |
1 files changed, 68 insertions, 0 deletions
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 + |