From 41591d4f8c586aa801220fac0924556f406c58bd Mon Sep 17 00:00:00 2001 From: Jan-Simon Moeller Date: Tue, 8 Dec 2020 11:15:02 +0100 Subject: SPEC-3723: restructure meta-agl-demo All demo related components should be in here now. We keep the packagegroups on purpose for now to stay backward-compatible. v2: layer does pass yocto-check-layer, dependencies adapted v3: remove the dynamic-layer setup, use all-in-one approach v4: Fixed comments from Paul Barker. Tnx! v5: Removed wayland/weston/agl-compositor additions, except for demo specific weston-init bbappend Follow-up changes required later: - massaging packagegroups - scrub of recipes Bug-AGL: SPEC-3723 Signed-off-by: Jan-Simon Moeller Signed-off-by: Scott Murray Change-Id: I47cefd8c23d46b2cdd063470e3f7d97d5ad952d8 --- recipes-support/udisks/files/99-udisks2.rules | 5 ++ recipes-support/udisks/files/automount.service | 9 +++ recipes-support/udisks/files/automount.sh | 93 ++++++++++++++++++++++++++ recipes-support/udisks/udisks2_%.bbappend | 1 + recipes-support/udisks/udisks2_agldemo.inc | 27 ++++++++ 5 files changed, 135 insertions(+) create mode 100644 recipes-support/udisks/files/99-udisks2.rules create mode 100644 recipes-support/udisks/files/automount.service create mode 100644 recipes-support/udisks/files/automount.sh create mode 100644 recipes-support/udisks/udisks2_%.bbappend create mode 100644 recipes-support/udisks/udisks2_agldemo.inc (limited to 'recipes-support/udisks') diff --git a/recipes-support/udisks/files/99-udisks2.rules b/recipes-support/udisks/files/99-udisks2.rules new file mode 100644 index 000000000..996e43439 --- /dev/null +++ b/recipes-support/udisks/files/99-udisks2.rules @@ -0,0 +1,5 @@ +# UDISKS_FILESYSTEM_SHARED +# ==1: mount filesystem to a shared directory (/media/VolumeName) +# ==0: mount filesystem to a private directory (/run/media/$USER/VolumeName) +# See udisks(8) +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{UDISKS_FILESYSTEM_SHARED}="1" diff --git a/recipes-support/udisks/files/automount.service b/recipes-support/udisks/files/automount.service new file mode 100644 index 000000000..b16515196 --- /dev/null +++ b/recipes-support/udisks/files/automount.service @@ -0,0 +1,9 @@ +[Unit] +Description=Automount Disk Manager +After=udisks2.service + +[Service] +ExecStart=/usr/libexec/automount.sh + +[Install] +WantedBy=multi-user.target diff --git a/recipes-support/udisks/files/automount.sh b/recipes-support/udisks/files/automount.sh new file mode 100644 index 000000000..236791910 --- /dev/null +++ b/recipes-support/udisks/files/automount.sh @@ -0,0 +1,93 @@ +#!/bin/sh + +MOUNT_OPTIONS_DEFAULT="ro,noexec" +MOUNT_OPTIONS_VFAT="umask=0022" +MOUNT_OPTIONS_EXT="" +MOUNT_OPTIONS_NTFS="" +MOUNT_OPTIONS_ISO9660="" + +VERBOSE=false + +# Source a configuration file that can override mount options if exists +[ -f /etc/automount.conf ] && . /etc/automount.conf + +mount_device() { + MOUNT_OPTIONS="" + FSTYPE="$( udevadm info "${1}" "${2}" | awk -v FS== '/ID_FS_TYPE/ {print $2}' )" + DEVNAME="$( udevadm info "${1}" "${2}" | awk -v FS== '/DEVNAME/ {print $2}' )" + case $FSTYPE in + vfat) + MOUNT_OPTIONS="${MOUNT_OPTIONS_VFAT}" + ;; + ext[2-4]) + MOUNT_OPTIONS="${MOUNT_OPTIONS_EXT}" + ;; + ntfs) + MOUNT_OPTIONS="${MOUNT_OPTIONS_NTFS}" + ;; + iso9660) + MOUNT_OPTIONS="${MOUNT_OPTIONS_ISO9660}" + ;; + "") + if $VERBOSE; then + echo "[INFO][${DEVNAME}] Not a partition with a filesystem!" + fi + return + ;; + *) + echo "[WARNING][${DEVNAME}] The filesystem '${FSTYPE}' is not supported!" + return + ;; + esac + + if [ -n "${MOUNT_OPTIONS_DEFAULT}" ]; then + if [ -z "${MOUNT_OPTIONS}" ]; then + MOUNT_OPTIONS="${MOUNT_OPTIONS_DEFAULT}" + else + MOUNT_OPTIONS="${MOUNT_OPTIONS_DEFAULT},${MOUNT_OPTIONS}" + fi + fi + if $VERBOSE; then + echo "[INFO][${DEVNAME}] Mounting a ${FSTYPE}'s filesystem with options: ${MOUNT_OPTIONS}" + fi + + if command -v udisksctl > /dev/null 2>&1; then + if [ -n "${MOUNT_OPTIONS}" ]; then + MOUNT_OPTIONS="-o ${MOUNT_OPTIONS}" + fi + udisksctl mount -t "${FSTYPE}" -b "${DEVNAME}" ${MOUNT_OPTIONS} + elif command -v udisks >/dev/null 2>&1; then + if [ -n "${MOUNT_OPTIONS}" ]; then + MOUNT_OPTIONS="--mount-options ${MOUNT_OPTIONS}" + fi + udisks --mount-fstype "${FSTYPE}" --mount "${DEVNAME}" ${MOUNT_OPTIONS} + else + echo "[ERROR] Unable to find binary for mounting ${DEVNAME}" >&2 + return + fi + if [ "$?" -ne "0" ]; then + echo "[ERROR] Failed to mount the device ${DEVNAME} of type ${FSTYPE} with options ${MOUNT_OPTIONS}" >&2 + fi +} + +# At startup, remove empty directories that may exists +rmdir /media/* > /dev/null 2>&1 + +# Mount already plugged devices +for DEVICE in $( lsblk -dn | cut -d' ' -f1 ); do + REMOVABLE=$( cat "/sys/block/${DEVICE}/removable" ) + if [ "${REMOVABLE}" -eq "1" ]; then + for PART in "/dev/${DEVICE}"*; do + mount_device -n "${PART}" + done + fi +done + +# Wait for plug events and mount devices +stdbuf -oL -- udevadm monitor --udev -s block | +while read -r -- _ _ EVENT DEVPATH _ +do + if [ "${EVENT}" = "add" ]; then + mount_device -p "/sys/${DEVPATH}" + fi +done diff --git a/recipes-support/udisks/udisks2_%.bbappend b/recipes-support/udisks/udisks2_%.bbappend new file mode 100644 index 000000000..a36862b9e --- /dev/null +++ b/recipes-support/udisks/udisks2_%.bbappend @@ -0,0 +1 @@ +require ${@bb.utils.contains('AGL_FEATURES', 'agldemo', 'udisks2_agldemo.inc', '', d)} diff --git a/recipes-support/udisks/udisks2_agldemo.inc b/recipes-support/udisks/udisks2_agldemo.inc new file mode 100644 index 000000000..44c9a5bac --- /dev/null +++ b/recipes-support/udisks/udisks2_agldemo.inc @@ -0,0 +1,27 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/files:" + +SRC_URI_append = " file://automount.service \ + file://automount.sh \ + file://99-udisks2.rules \ +" + +SYSTEMD_AUTO_ENABLE = "enable" +SYSTEMD_SERVICE_${PN}_append = " automount.service" + +do_install_append () { + sed -i 's/^WantedBy=.*/WantedBy=multi-user.target/' ${D}${systemd_unitdir}/system/udisks2.service + + install -d ${D}${base_libdir}/systemd/system + install -m 0644 ${WORKDIR}/automount.service ${D}${systemd_unitdir}/system + + install -d ${D}${libexecdir} + install -m 0755 ${WORKDIR}/automount.sh ${D}${libexecdir}/automount.sh + + install -d ${D}${sysconfdir}/udev/rules.d + install -m 0644 ${WORKDIR}/99-udisks2.rules ${D}${sysconfdir}/udev/rules.d +} + +FILES_${PN}_append = " \ + ${base_libdir}/systemd/system/automount.service \ + ${libexecdir}/automount.sh \ +" -- cgit