Make-initrd development discussion
 help / color / mirror / Atom feed
* [make-initrd] [PATCH v1 03/41] fork pipeline: 10 new files added
@ 2021-09-24 15:55 Leonid Krivoshein
  2021-09-24 18:31 ` Alexey Gladkov
  0 siblings, 1 reply; 5+ messages in thread
From: Leonid Krivoshein @ 2021-09-24 15:55 UTC (permalink / raw)
  To: make-initrd

---
  make-initrd/features/bootchain-core/config.mk |   5 +
  .../bootchain-core/data/bin/machine-info      | 123 ++++++++++++++++++
  .../bootchain-core/data/lib/bootchain/debug   |  84 ++++++++++++
  .../data/lib/initrd/cmdline.d/bootchain       |   6 +
  .../bootchain-core/data/sbin/bootchain-logvt  |  36 +++++
  make-initrd/features/bootchain-core/rules.mk  |   3 +
  .../features/bootchain-getimage/README.md     |  20 +++
  .../features/bootchain-getimage/config.mk     |   5 +
  .../features/bootchain-getimage/rules.mk      |   2 +
  .../features/bootchain-waitdev/README.md      |  21 +++
  10 files changed, 305 insertions(+)
  create mode 100644 make-initrd/features/bootchain-core/config.mk
  create mode 100755 
make-initrd/features/bootchain-core/data/bin/machine-info
  create mode 100755 
make-initrd/features/bootchain-core/data/lib/bootchain/debug
  create mode 100755 
make-initrd/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain
  create mode 100755 
make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
  create mode 100644 make-initrd/features/bootchain-core/rules.mk
  create mode 100644 make-initrd/features/bootchain-getimage/README.md
  create mode 100644 make-initrd/features/bootchain-getimage/config.mk
  create mode 100644 make-initrd/features/bootchain-getimage/rules.mk
  create mode 100644 make-initrd/features/bootchain-waitdev/README.md

diff --git a/make-initrd/features/bootchain-core/config.mk 
b/make-initrd/features/bootchain-core/config.mk
new file mode 100644
index 0000000..c87bad2
--- /dev/null
+++ b/make-initrd/features/bootchain-core/config.mk
@@ -0,0 +1,5 @@
+$(call feature-requires,depmod-image)
+
+BOOTCHAIN_CORE_DATADIR = $(FEATURESDIR)/bootchain-core/data
+
+BOOTCHAIN_CORE_MODULES = isofs squashfs overlay
diff --git a/make-initrd/features/bootchain-core/data/bin/machine-info 
b/make-initrd/features/bootchain-core/data/bin/machine-info
new file mode 100755
index 0000000..79c528e
--- /dev/null
+++ b/make-initrd/features/bootchain-core/data/bin/machine-info
@@ -0,0 +1,123 @@
+#!/bin/bash -efu
+
+# TODO: read additional machine data for non-x86 platforms
+
+show_help()
+{
+	cat <<-EOF
+	Usage: $0 [<options>]
+
+	Options:
+	-d, --drivers   Show drivers set unique ID
+	-i, --instance  Show hardware instance unique ID
+	-h, --help      Show this help message
+	EOF
+	exit 0
+}
+
+# Use DMI fields only on hardware that supports it
+
+show_dmi_info()
+{
+	local objects="bios_vendor board_name board_vendor board_version"
+	objects="$objects chassis_type chassis_vendor chassis_version sys_vendor"
+	objects="$objects product_family product_name product_sku product_version"
+	local f d dmi=/sys/class/dmi/id
+
+	[ -d "$dmi" ] ||
+		dmi=/sys/devices/virtual/dmi/id
+	[ -d "$dmi" ] ||
+		return 0
+	[ -z "${1-}" ] ||
+		objects="$objects product_uuid bios_version board_serial chassis_serial"
+
+	for f in $objects; do
+		[ -r "$dmi/$f" ] ||
+			continue
+		read -r d <"$dmi/$f"
+		[ -n "${d//[[:space:]]*/}" ] ||
+			continue
+		printf '%s: %s\n' "$f" "$d"
+	done
+}
+
+# Accessing PCI device resources through sysfs, see:
+# https://www.kernel.org/doc/html/latest/PCI/sysfs-pci.html
+# We reading fields, such as class, device, etc... as PCI ID's
+# (bus codes) according to Conventional PCI 3.0 specification.
+
+scan_pci_bus()
+{
+	local sysfs d h="[0-9a-f]"
+	local glob="$h$h$h$h\:$h$h\:$h$h.$h"
+
+	handle_field()
+	{
+		[ -r "$sysfs/$1" ] && read -r d <"$sysfs/$1" || d="-"
+		printf " %s" "$d"
+	}
+
+	find /sys/devices -mindepth 2 -maxdepth 2 -type d -name "$glob" |
+		grep '/sys/devices/pci' |
+		sort |
+	while read -r sysfs; do
+		printf "%s" "${sysfs##*/}"
+		handle_field class
+		handle_field vendor
+		handle_field device
+		handle_field subsystem_vendor
+		handle_field subsystem_device
+		handle_field revision
+		printf '\n'
+	done
+}
+
+show_cpu_info()
+{
+	local regex="vendor_id|cpu family|model"
+	regex="$regex|siblings|stepping|microcode"
+	regex="$regex|cache size|cpu cores|clflush size"
+	regex="$regex|cache_alignment|address sizes"
+
+	if [ -r /proc/cpuinfo ]; then
+		grep -E "^($regex)" /proc/cpuinfo |
+			sort -u |
+			sed -e 's/[[:space:]]*:/:/g'
+	fi
+}
+
+show_hw_info()
+{
+	printf 'platform: '
+	uname -m
+	show_dmi_info
+	scan_pci_bus
+}
+
+show_instance_info()
+{
+	printf 'platform: '
+	uname -m
+	show_cpu_info
+	show_dmi_info instance
+	scan_pci_bus
+}
+
+
+# Entry point
+case "${1-}" in
+-d|--drivers)
+	show_hw_info |sha256sum |cut -f1 -d' '
+	;;
+-i|--instance)
+	show_instance_info |sha256sum |cut -f1 -d' '
+	;;
+-h|--help)
+	show_help
+	;;
+*)	printf 'Hardware info:\n'
+	show_hw_info
+	printf '\nInstance info:\n'
+	show_instance_info
+	;;
+esac
diff --git 
a/make-initrd/features/bootchain-core/data/lib/bootchain/debug 
b/make-initrd/features/bootchain-core/data/lib/bootchain/debug
new file mode 100755
index 0000000..ed70536
--- /dev/null
+++ b/make-initrd/features/bootchain-core/data/lib/bootchain/debug
@@ -0,0 +1,84 @@
+#!/bin/bash -efu
+
+. bootchain-sh-functions
+
+
+listpvdir()
+{
+	# shellcheck disable=SC2012
+	if [ -z "${1-}" ]; then
+		ls -1F "$prevdir/" |sort |head -n20
+	else
+		ls -1F "$prevdir/" |sort |grep -svE "$1" |head -n20
+	fi
+}
+
+
+# Entry point
+message "$PROG for $name [$callnum] started"
+
+message "PREV DIR: $prevdir"
+message "Data DIR: $datadir"
+message "DEST DIR: $destdir"
+
+{ printf "##############################"
+
+  if [ -d "$prevdir" ]; then
+	printf "\nPrevious step results (%s):\n" "$prevdir"
+
+	if mountpoint -q -- "$prevdir"; then
+		listpvdir
+	elif [ ! -b "$prevdir/dev" ] &&
+		[ ! -c "$prevdir/dev" ] &&
+		[ ! -s "$prevdir/DEVNAME" ] &&
+		[ ! -s "$prevdir/FILESIZE" ]
+	then
+		listpvdir
+	else
+		if [ -b "$prevdir/dev" ] || [ -c "$prevdir/dev" ]; then
+			devno="$(mountpoint -x -- "$prevdir/dev")"
+			[ -b "$prevdir/dev" ] &&
+				devname=/sys/dev/block ||
+				devname=/sys/dev/char
+			devname="$(grep -sE ^DEVNAME= "$devname/$devno/uevent" |cut -f2- -d=)"
+			printf 'dev (%s -> %s)\n' "$devno" "/dev/$devname"
+		fi
+
+		if [ -s "$prevdir/DEVNAME" ]; then
+			read -r devname <"$prevdir/DEVNAME" ||
+				devname=
+			if [ -z "$devname" ]; then
+				printf 'DEVNAME\n'
+			else
+				devno="$(mountpoint -x -- "$devname")" ||
+					devno="ABSENT"
+				printf 'DEVNAME (%s -> %s)\n' "$devno" "$devname"
+			fi
+		fi
+
+		if [ -s "$prevdir/FILESIZE" ]; then
+			read -r fsize <"$prevdir/FILESIZE" ||
+				fsize="NOT READABLE"
+			printf 'FILESIZE (%s)\n' "$fsize"
+		fi
+
+		listpvdir "^(dev|DEVNAME|FILESIZE)$"
+	fi
+  fi
+
+  # FIXME: make this better to specify interested mount points only
+  [ -z "${OEM_CDROOT-}" ] && regex="$rootmnt" ||
+	regex="$rootmnt $OEM_CDROOT"
+  regex="$regex $mntdir"
+  regex="${regex//\//\\/}"
+  regex=" (${regex// /\|})\/"
+
+  if mount |grep -qsE "$regex"; then
+	printf "\nMount points and devices:\n"
+	mount |grep -sE "$regex"
+  fi
+
+  printf "##############################\n"
+} 1>&2
+
+message "$PROG for $name [$callnum] finished"
diff --git 
a/make-initrd/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain 
b/make-initrd/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain
new file mode 100755
index 0000000..b692f6d
--- /dev/null
+++ 
b/make-initrd/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain
@@ -0,0 +1,6 @@
+#!/bin/bash -efu
+
+. /.initrd/initenv
+
+[ "${ROOT-}" != bootchain ] ||
+	echo bootchain > /etc/initrd/method
diff --git 
a/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt 
b/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
new file mode 100755
index 0000000..037505a
--- /dev/null
+++ b/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
@@ -0,0 +1,36 @@
+#!/bin/bash -efu
+
+. bootchain-sh-functions
+
+pid=
+pidfile=/var/run/bootchained.pid
+
+
+exit_handler()
+{
+	local rc=$?
+
+	trap - EXIT
+
+	if [ -n "$pid" ]; then
+		kill -TERM "$pid" ||
+			kill -KILL "$pid" ||:
+		wait "$pid" ||:
+	fi >/dev/null 2>&1
+
+	clear
+	exit $rc
+}
+
+
+# Entry point
+[ -z "${NOTTYS-}" ] && [ -n "$BC_LOG_VT" ] ||
+	exit 1
+set_cleanup_handler exit_handler
+exec </dev/null >"/dev/tty$BC_LOG_VT" 2>&1
+printf "bootchain logger started on tty%s\n\n" "$BC_LOG_VT"
+tail -f -- "$BC_LOGFILE" & pid="$!"
+
+while [ -f "$pidfile" ]; do
+	sleep 1
+done
diff --git a/make-initrd/features/bootchain-core/rules.mk 
b/make-initrd/features/bootchain-core/rules.mk
new file mode 100644
index 0000000..aeddf91
--- /dev/null
+++ b/make-initrd/features/bootchain-core/rules.mk
@@ -0,0 +1,3 @@
+MODULES_TRY_ADD   += $(BOOTCHAIN_CORE_MODULES)
+
+PUT_FEATURE_DIRS  += $(BOOTCHAIN_CORE_DATADIR)
diff --git a/make-initrd/features/bootchain-getimage/README.md 
b/make-initrd/features/bootchain-getimage/README.md
new file mode 100644
index 0000000..349de6e
--- /dev/null
+++ b/make-initrd/features/bootchain-getimage/README.md
@@ -0,0 +1,20 @@
+# Bootchain sub-module: getimage
+
+## Chain elements
+
+- `getimage` receives and mounts the remote image.
+
+## Boot parameters
+
+- `getimage` specifies an URL to fetch and mount.
+
+This parameter can be specified more than once depending on how many times
+a corresponding element is mentioned in the `bootchain`.
+
+## Example
+
+Cmdline: root=bootchain bootchain=getimage,mountfs,overlayfs,rootfs 
getimage=http://ftp.altlinux.org/pub/people/mike/iso/misc/vi-20140918-i586.iso 
mountfs=rescue
+
+Following these parameters, the bootchain downloads the 
vi-20140918-i586.iso
+image, mount it as a loop, make it writable using overlayfs and will try to
+boot from it.
diff --git a/make-initrd/features/bootchain-getimage/config.mk 
b/make-initrd/features/bootchain-getimage/config.mk
new file mode 100644
index 0000000..498196e
--- /dev/null
+++ b/make-initrd/features/bootchain-getimage/config.mk
@@ -0,0 +1,5 @@
+$(call feature-requires,bootchain-core)
+
+BOOTCHAIN_GETIMAGE_DATADIR = $(FEATURESDIR)/bootchain-getimage/data
+
+BOOTCHAIN_GETIMAGE_PROGS = wget
diff --git a/make-initrd/features/bootchain-getimage/rules.mk 
b/make-initrd/features/bootchain-getimage/rules.mk
new file mode 100644
index 0000000..af50f8e
--- /dev/null
+++ b/make-initrd/features/bootchain-getimage/rules.mk
@@ -0,0 +1,2 @@
+PUT_FEATURE_DIRS  += $(BOOTCHAIN_GETIMAGE_DATADIR)
+PUT_FEATURE_PROGS += $(BOOTCHAIN_GETIMAGE_PROGS)
diff --git a/make-initrd/features/bootchain-waitdev/README.md 
b/make-initrd/features/bootchain-waitdev/README.md
new file mode 100644
index 0000000..f8c07a6
--- /dev/null
+++ b/make-initrd/features/bootchain-waitdev/README.md
@@ -0,0 +1,21 @@
+# Bootchain sub-module: waitdev
+
+## Chain elements
+
+- `waitdev` waits for the local device to appear.
+
+## Boot parameters
+
+- `waitdev` describes the local device to wait. The format of this 
parameter is
+   the same as `root=`, but with optional `CDROM:` prefix.
+
+This parameter can be specified more than once depending on how many times
+a corresponding element is mentioned in the `bootchain`.
+
+## Example
+
+Cmdline: root=bootchain 
bootchain=waitdev,mountfs,mountfs,overlayfs,rootfs 
waitdev=CDROM:LABEL=ALT_regular-rescue/x86_64 mountfs=dev mountfs=rescue
+
+Following these parameters, the bootchain wait local CDROM drive labeled as
+`ALT_regular-rescue/x86_64`, mount it, mount squash file `rescue` as a loop
+from it, make final rootfs writable using overlayfs and will try to 
boot from it.
-- 
2.21.0




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [make-initrd] [PATCH v1 03/41] fork pipeline: 10 new files added
  2021-09-24 15:55 [make-initrd] [PATCH v1 03/41] fork pipeline: 10 new files added Leonid Krivoshein
@ 2021-09-24 18:31 ` Alexey Gladkov
  2021-09-26 18:41   ` Leonid Krivoshein
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Gladkov @ 2021-09-24 18:31 UTC (permalink / raw)
  To: make-initrd

On Fri, Sep 24, 2021 at 06:55:00PM +0300, Leonid Krivoshein wrote:
> ---
>  make-initrd/features/bootchain-core/config.mk |   5 +
>  .../bootchain-core/data/bin/machine-info      | 123 ++++++++++++++++++
>  .../bootchain-core/data/lib/bootchain/debug   |  84 ++++++++++++
>  .../data/lib/initrd/cmdline.d/bootchain       |   6 +
>  .../bootchain-core/data/sbin/bootchain-logvt  |  36 +++++
>  make-initrd/features/bootchain-core/rules.mk  |   3 +
>  .../features/bootchain-getimage/README.md     |  20 +++
>  .../features/bootchain-getimage/config.mk     |   5 +
>  .../features/bootchain-getimage/rules.mk      |   2 +
>  .../features/bootchain-waitdev/README.md      |  21 +++
>  10 files changed, 305 insertions(+)

Леонид, ты мастер commit message! С твоими описаниями не поспоришь.
Действительно, 10. Но важнее, что это за файлы. Кстати, я хочу обратить
внимание:

https://github.com/osboot/make-initrd/blob/master/Documentation/Contributing.md

Для меня это важно.

Ты добавляешь фичи, но ни слова не пишешь о том, что это. Это же относится
и к README.md. Там ни слова про то что это. Только название и параметры.

>  create mode 100644 make-initrd/features/bootchain-core/config.mk
>  create mode 100755
> make-initrd/features/bootchain-core/data/bin/machine-info
>  create mode 100755
> make-initrd/features/bootchain-core/data/lib/bootchain/debug
>  create mode 100755
> make-initrd/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain
>  create mode 100755
> make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
>  create mode 100644 make-initrd/features/bootchain-core/rules.mk
>  create mode 100644 make-initrd/features/bootchain-getimage/README.md
>  create mode 100644 make-initrd/features/bootchain-getimage/config.mk
>  create mode 100644 make-initrd/features/bootchain-getimage/rules.mk
>  create mode 100644 make-initrd/features/bootchain-waitdev/README.md
> 
> diff --git a/make-initrd/features/bootchain-core/config.mk
> b/make-initrd/features/bootchain-core/config.mk
> new file mode 100644
> index 0000000..c87bad2
> --- /dev/null
> +++ b/make-initrd/features/bootchain-core/config.mk
> @@ -0,0 +1,5 @@
> +$(call feature-requires,depmod-image)
> +
> +BOOTCHAIN_CORE_DATADIR = $(FEATURESDIR)/bootchain-core/data
> +
> +BOOTCHAIN_CORE_MODULES = isofs squashfs overlay
> diff --git a/make-initrd/features/bootchain-core/data/bin/machine-info
> b/make-initrd/features/bootchain-core/data/bin/machine-info
> new file mode 100755
> index 0000000..79c528e
> --- /dev/null
> +++ b/make-initrd/features/bootchain-core/data/bin/machine-info
> @@ -0,0 +1,123 @@
> +#!/bin/bash -efu
> +
> +# TODO: read additional machine data for non-x86 platforms
> +
> +show_help()
> +{
> +	cat <<-EOF
> +	Usage: $0 [<options>]
> +
> +	Options:
> +	-d, --drivers   Show drivers set unique ID
> +	-i, --instance  Show hardware instance unique ID
> +	-h, --help      Show this help message
> +	EOF
> +	exit 0
> +}
> +
> +# Use DMI fields only on hardware that supports it
> +
> +show_dmi_info()
> +{
> +	local objects="bios_vendor board_name board_vendor board_version"
> +	objects="$objects chassis_type chassis_vendor chassis_version sys_vendor"
> +	objects="$objects product_family product_name product_sku product_version"
> +	local f d dmi=/sys/class/dmi/id
> +
> +	[ -d "$dmi" ] ||
> +		dmi=/sys/devices/virtual/dmi/id
> +	[ -d "$dmi" ] ||
> +		return 0
> +	[ -z "${1-}" ] ||
> +		objects="$objects product_uuid bios_version board_serial chassis_serial"
> +
> +	for f in $objects; do
> +		[ -r "$dmi/$f" ] ||
> +			continue
> +		read -r d <"$dmi/$f"
> +		[ -n "${d//[[:space:]]*/}" ] ||
> +			continue
> +		printf '%s: %s\n' "$f" "$d"
> +	done
> +}
> +
> +# Accessing PCI device resources through sysfs, see:
> +# https://www.kernel.org/doc/html/latest/PCI/sysfs-pci.html
> +# We reading fields, such as class, device, etc... as PCI ID's
> +# (bus codes) according to Conventional PCI 3.0 specification.
> +
> +scan_pci_bus()
> +{
> +	local sysfs d h="[0-9a-f]"
> +	local glob="$h$h$h$h\:$h$h\:$h$h.$h"
> +
> +	handle_field()
> +	{
> +		[ -r "$sysfs/$1" ] && read -r d <"$sysfs/$1" || d="-"
> +		printf " %s" "$d"
> +	}
> +
> +	find /sys/devices -mindepth 2 -maxdepth 2 -type d -name "$glob" |
> +		grep '/sys/devices/pci' |

find /sys/devices -mindepth 2 -maxdepth 2 -type d -path "/sys/devices/pci*/$glob"

> +		sort |
> +	while read -r sysfs; do
> +		printf "%s" "${sysfs##*/}"
> +		handle_field class
> +		handle_field vendor
> +		handle_field device
> +		handle_field subsystem_vendor
> +		handle_field subsystem_device
> +		handle_field revision

Мне кажется в handle_field() не имеет смысла проверять на существование
эти файлы. Это всё компоненты MODALIAS.

Зачем это печатать отдельно, если это ровно modalias ?

По сути всё тело функции можно заменить:

find /sys/devices -mindepth 2 -maxdepth 3 -type f -path "/sys/devices/pci*/$glob/modalias" | sort |
while read -r path; do
	read -r modalias < "$path"
	path="${path%/modalias}"
	printf '%s %s\n' "${path##*/}" "$modalias"
done

> +		printf '\n'
> +	done
> +}
> +
> +show_cpu_info()
> +{
> +	local regex="vendor_id|cpu family|model"
> +	regex="$regex|siblings|stepping|microcode"
> +	regex="$regex|cache size|cpu cores|clflush size"
> +	regex="$regex|cache_alignment|address sizes"
> +
> +	if [ -r /proc/cpuinfo ]; then
> +		grep -E "^($regex)" /proc/cpuinfo |
> +			sort -u |
> +			sed -e 's/[[:space:]]*:/:/g'
> +	fi
> +}
> +
> +show_hw_info()
> +{
> +	printf 'platform: '
> +	uname -m
> +	show_dmi_info
> +	scan_pci_bus
> +}
> +
> +show_instance_info()
> +{
> +	printf 'platform: '
> +	uname -m
> +	show_cpu_info
> +	show_dmi_info instance
> +	scan_pci_bus
> +}
> +
> +
> +# Entry point
> +case "${1-}" in
> +-d|--drivers)
> +	show_hw_info |sha256sum |cut -f1 -d' '
> +	;;
> +-i|--instance)
> +	show_instance_info |sha256sum |cut -f1 -d' '
> +	;;
> +-h|--help)
> +	show_help
> +	;;
> +*)	printf 'Hardware info:\n'
> +	show_hw_info
> +	printf '\nInstance info:\n'
> +	show_instance_info
> +	;;
> +esac
> diff --git a/make-initrd/features/bootchain-core/data/lib/bootchain/debug
> b/make-initrd/features/bootchain-core/data/lib/bootchain/debug
> new file mode 100755
> index 0000000..ed70536
> --- /dev/null
> +++ b/make-initrd/features/bootchain-core/data/lib/bootchain/debug
> @@ -0,0 +1,84 @@
> +#!/bin/bash -efu
> +
> +. bootchain-sh-functions
> +
> +
> +listpvdir()
> +{
> +	# shellcheck disable=SC2012
> +	if [ -z "${1-}" ]; then
> +		ls -1F "$prevdir/" |sort |head -n20
> +	else
> +		ls -1F "$prevdir/" |sort |grep -svE "$1" |head -n20
> +	fi
> +}
> +
> +
> +# Entry point
> +message "$PROG for $name [$callnum] started"
> +
> +message "PREV DIR: $prevdir"
> +message "Data DIR: $datadir"
> +message "DEST DIR: $destdir"
> +
> +{ printf "##############################"
> +
> +  if [ -d "$prevdir" ]; then
> +	printf "\nPrevious step results (%s):\n" "$prevdir"
> +
> +	if mountpoint -q -- "$prevdir"; then
> +		listpvdir
> +	elif [ ! -b "$prevdir/dev" ] &&
> +		[ ! -c "$prevdir/dev" ] &&
> +		[ ! -s "$prevdir/DEVNAME" ] &&
> +		[ ! -s "$prevdir/FILESIZE" ]
> +	then
> +		listpvdir
> +	else
> +		if [ -b "$prevdir/dev" ] || [ -c "$prevdir/dev" ]; then
> +			devno="$(mountpoint -x -- "$prevdir/dev")"
> +			[ -b "$prevdir/dev" ] &&
> +				devname=/sys/dev/block ||
> +				devname=/sys/dev/char
> +			devname="$(grep -sE ^DEVNAME= "$devname/$devno/uevent" |cut -f2- -d=)"
> +			printf 'dev (%s -> %s)\n' "$devno" "/dev/$devname"
> +		fi
> +
> +		if [ -s "$prevdir/DEVNAME" ]; then
> +			read -r devname <"$prevdir/DEVNAME" ||
> +				devname=
> +			if [ -z "$devname" ]; then
> +				printf 'DEVNAME\n'
> +			else
> +				devno="$(mountpoint -x -- "$devname")" ||
> +					devno="ABSENT"
> +				printf 'DEVNAME (%s -> %s)\n' "$devno" "$devname"
> +			fi
> +		fi
> +
> +		if [ -s "$prevdir/FILESIZE" ]; then
> +			read -r fsize <"$prevdir/FILESIZE" ||
> +				fsize="NOT READABLE"
> +			printf 'FILESIZE (%s)\n' "$fsize"
> +		fi
> +
> +		listpvdir "^(dev|DEVNAME|FILESIZE)$"
> +	fi
> +  fi
> +
> +  # FIXME: make this better to specify interested mount points only
> +  [ -z "${OEM_CDROOT-}" ] && regex="$rootmnt" ||
> +	regex="$rootmnt $OEM_CDROOT"
> +  regex="$regex $mntdir"
> +  regex="${regex//\//\\/}"
> +  regex=" (${regex// /\|})\/"
> +
> +  if mount |grep -qsE "$regex"; then
> +	printf "\nMount points and devices:\n"
> +	mount |grep -sE "$regex"
> +  fi
> +
> +  printf "##############################\n"
> +} 1>&2
> +
> +message "$PROG for $name [$callnum] finished"
> diff --git
> a/make-initrd/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain
> b/make-initrd/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain
> new file mode 100755
> index 0000000..b692f6d
> --- /dev/null
> +++
> b/make-initrd/features/bootchain-core/data/lib/initrd/cmdline.d/bootchain
> @@ -0,0 +1,6 @@
> +#!/bin/bash -efu
> +
> +. /.initrd/initenv
> +
> +[ "${ROOT-}" != bootchain ] ||
> +	echo bootchain > /etc/initrd/method
> diff --git a/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
> b/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
> new file mode 100755
> index 0000000..037505a
> --- /dev/null
> +++ b/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt

Зачем нужна эта утилита ? Она добавляется, но нигде в коммите не
используется. Описания у неё тоже нет.

> @@ -0,0 +1,36 @@
> +#!/bin/bash -efu
> +
> +. bootchain-sh-functions
> +
> +pid=
> +pidfile=/var/run/bootchained.pid
> +
> +
> +exit_handler()
> +{
> +	local rc=$?
> +
> +	trap - EXIT
> +
> +	if [ -n "$pid" ]; then
> +		kill -TERM "$pid" ||
> +			kill -KILL "$pid" ||:
> +		wait "$pid" ||:
> +	fi >/dev/null 2>&1
> +
> +	clear
> +	exit $rc
> +}
> +
> +
> +# Entry point
> +[ -z "${NOTTYS-}" ] && [ -n "$BC_LOG_VT" ] ||
> +	exit 1
> +set_cleanup_handler exit_handler
> +exec </dev/null >"/dev/tty$BC_LOG_VT" 2>&1
> +printf "bootchain logger started on tty%s\n\n" "$BC_LOG_VT"
> +tail -f -- "$BC_LOGFILE" & pid="$!"

Откуда берутся BC_LOG_VT и BC_LOGFILE ?

> +
> +while [ -f "$pidfile" ]; do
> +	sleep 1
> +done
> diff --git a/make-initrd/features/bootchain-core/rules.mk
> b/make-initrd/features/bootchain-core/rules.mk
> new file mode 100644
> index 0000000..aeddf91
> --- /dev/null
> +++ b/make-initrd/features/bootchain-core/rules.mk
> @@ -0,0 +1,3 @@
> +MODULES_TRY_ADD   += $(BOOTCHAIN_CORE_MODULES)
> +
> +PUT_FEATURE_DIRS  += $(BOOTCHAIN_CORE_DATADIR)
> diff --git a/make-initrd/features/bootchain-getimage/README.md
> b/make-initrd/features/bootchain-getimage/README.md
> new file mode 100644
> index 0000000..349de6e
> --- /dev/null
> +++ b/make-initrd/features/bootchain-getimage/README.md
> @@ -0,0 +1,20 @@
> +# Bootchain sub-module: getimage
> +
> +## Chain elements
> +
> +- `getimage` receives and mounts the remote image.
> +
> +## Boot parameters
> +
> +- `getimage` specifies an URL to fetch and mount.
> +
> +This parameter can be specified more than once depending on how many times
> +a corresponding element is mentioned in the `bootchain`.
> +
> +## Example
> +
> +Cmdline: root=bootchain bootchain=getimage,mountfs,overlayfs,rootfs getimage=http://ftp.altlinux.org/pub/people/mike/iso/misc/vi-20140918-i586.iso
> mountfs=rescue
> +
> +Following these parameters, the bootchain downloads the
> vi-20140918-i586.iso
> +image, mount it as a loop, make it writable using overlayfs and will try to
> +boot from it.
> diff --git a/make-initrd/features/bootchain-getimage/config.mk
> b/make-initrd/features/bootchain-getimage/config.mk
> new file mode 100644
> index 0000000..498196e
> --- /dev/null
> +++ b/make-initrd/features/bootchain-getimage/config.mk
> @@ -0,0 +1,5 @@
> +$(call feature-requires,bootchain-core)
> +
> +BOOTCHAIN_GETIMAGE_DATADIR = $(FEATURESDIR)/bootchain-getimage/data
> +
> +BOOTCHAIN_GETIMAGE_PROGS = wget
> diff --git a/make-initrd/features/bootchain-getimage/rules.mk
> b/make-initrd/features/bootchain-getimage/rules.mk
> new file mode 100644
> index 0000000..af50f8e
> --- /dev/null
> +++ b/make-initrd/features/bootchain-getimage/rules.mk
> @@ -0,0 +1,2 @@
> +PUT_FEATURE_DIRS  += $(BOOTCHAIN_GETIMAGE_DATADIR)
> +PUT_FEATURE_PROGS += $(BOOTCHAIN_GETIMAGE_PROGS)
> diff --git a/make-initrd/features/bootchain-waitdev/README.md
> b/make-initrd/features/bootchain-waitdev/README.md
> new file mode 100644
> index 0000000..f8c07a6
> --- /dev/null
> +++ b/make-initrd/features/bootchain-waitdev/README.md
> @@ -0,0 +1,21 @@
> +# Bootchain sub-module: waitdev
> +
> +## Chain elements
> +
> +- `waitdev` waits for the local device to appear.
> +
> +## Boot parameters
> +
> +- `waitdev` describes the local device to wait. The format of this
> parameter is
> +   the same as `root=`, but with optional `CDROM:` prefix.
> +
> +This parameter can be specified more than once depending on how many times
> +a corresponding element is mentioned in the `bootchain`.
> +
> +## Example
> +
> +Cmdline: root=bootchain bootchain=waitdev,mountfs,mountfs,overlayfs,rootfs
> waitdev=CDROM:LABEL=ALT_regular-rescue/x86_64 mountfs=dev mountfs=rescue
> +
> +Following these parameters, the bootchain wait local CDROM drive labeled as
> +`ALT_regular-rescue/x86_64`, mount it, mount squash file `rescue` as a loop
> +from it, make final rootfs writable using overlayfs and will try to boot
> from it.
> -- 
> 2.21.0
> 
> 
> _______________________________________________
> Make-initrd mailing list
> Make-initrd@lists.altlinux.org
> https://lists.altlinux.org/mailman/listinfo/make-initrd
> 

-- 
Rgrds, legion



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [make-initrd] [PATCH v1 03/41] fork pipeline: 10 new files added
  2021-09-24 18:31 ` Alexey Gladkov
@ 2021-09-26 18:41   ` Leonid Krivoshein
  2021-09-27  8:45     ` Alexey Gladkov
  0 siblings, 1 reply; 5+ messages in thread
From: Leonid Krivoshein @ 2021-09-26 18:41 UTC (permalink / raw)
  To: make-initrd



24.09.2021 21:31, Alexey Gladkov пишет:
> On Fri, Sep 24, 2021 at 06:55:00PM +0300, Leonid Krivoshein wrote:
>> ---
>>   make-initrd/features/bootchain-core/config.mk |   5 +
>>   .../bootchain-core/data/bin/machine-info      | 123 ++++++++++++++++++
>>   .../bootchain-core/data/lib/bootchain/debug   |  84 ++++++++++++
>>   .../data/lib/initrd/cmdline.d/bootchain       |   6 +
>>   .../bootchain-core/data/sbin/bootchain-logvt  |  36 +++++
>>   make-initrd/features/bootchain-core/rules.mk  |   3 +
>>   .../features/bootchain-getimage/README.md     |  20 +++
>>   .../features/bootchain-getimage/config.mk     |   5 +
>>   .../features/bootchain-getimage/rules.mk      |   2 +
>>   .../features/bootchain-waitdev/README.md      |  21 +++
>>   10 files changed, 305 insertions(+)
> Леонид, ты мастер commit message! С твоими описаниями не поспоришь.
> Действительно, 10. Но важнее, что это за файлы.

Да, уже говорил, что на первой итерации первыми тремя патчами просто 
хотел показать крупными штрихами, что-куда переехало, и что было 
добавлено при форке.


> Кстати, я хочу обратить
> внимание:
>
> https://github.com/osboot/make-initrd/blob/master/Documentation/Contributing.md
>
> Для меня это важно.

Я понял, что финальный вариант должен пименяться к апстримному дереву с 
подписыванием коммитов.


> Ты добавляешь фичи, но ни слова не пишешь о том, что это.

В черновике документации всё же постарался всё отразить. Но я понимаю, 
что и коммиты теперь нужно превратить на какую-то правдоподобную историю.


> Это же относится
> и к README.md. Там ни слова про то что это. Только название и параметры.

Вот тут я не очень понял. Исходный pipeline содержал README.md, я просто 
скопировал отдельно описание getimage и waitdev, оставив на месте 
основной исходник. Фича pipeline же тоже осталась. В новой версии 
описания я просто добавил ссылку смотреть пока в README от pipeline.

Второй момент заключается в том, что я не прочь потренироваться в 
написании README и коммит-мессаджей, тем более, по плану до начала 
апстрима собирался их написать. Но вот на один README для interactive у 
меня вся ночь ушла.

Третий момент заключается в том, что ранее ты предлагал сам перевести 
README, если я сделаю документацию на русском. Вот на родном могу 
написать хорошо и быстро, но у тебя вроде пока нигде в фичах пока нет 
README.ru.md, а так я уже думал на эту тему.


>> [...]
>> +
>> +	find /sys/devices -mindepth 2 -maxdepth 2 -type d -name "$glob" |
>> +		grep '/sys/devices/pci' |
> find /sys/devices -mindepth 2 -maxdepth 2 -type d -path "/sys/devices/pci*/$glob"
>
>> +		sort |
>> +	while read -r sysfs; do
>> +		printf "%s" "${sysfs##*/}"
>> +		handle_field class
>> +		handle_field vendor
>> +		handle_field device
>> +		handle_field subsystem_vendor
>> +		handle_field subsystem_device
>> +		handle_field revision
> Мне кажется в handle_field() не имеет смысла проверять на существование
> эти файлы. Это всё компоненты MODALIAS.
>
> Зачем это печатать отдельно, если это ровно modalias ?
>
> По сути всё тело функции можно заменить:
>
> find /sys/devices -mindepth 2 -maxdepth 3 -type f -path "/sys/devices/pci*/$glob/modalias" | sort |
> while read -r path; do
> 	read -r modalias < "$path"
> 	path="${path%/modalias}"
> 	printf '%s %s\n' "${path##*/}" "$modalias"
> done

Давай переделаю, как ты предлагаешь. machine-info вместе с частью 
OEM-установки драйверов это всё равно та часть, которую я сначала 
предлагал написать полностью тебе, но потом всё же изобразил какое-то её 
подобие. Ты сначала было даже хотел, а потом решил, что в твоих 
применениях проще пересобрать initrd, но для уже выпущенных 
дистрибутивов это действительно важно.

Предметным вопросом для обсуждения тут конечно является обсуждение 
принадлежности machine-info к той или иной фиче. У меня она используется 
в localdev (altboot), в части, отвечающей за пропагаторный параметр 
UPDATEMODULES. Но она может пригодиться и для деплоя, и много где ещё. 
Может, её вынести уровнем ещё выше, сделать частью самого make-initrd? К 
bootchain-core она точно не имеет отношения.


>> [...]
>> diff --git a/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
>> b/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
>> new file mode 100755
>> index 0000000..037505a
>> --- /dev/null
>> +++ b/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
> Зачем нужна эта утилита ? Она добавляется, но нигде в коммите не
> используется. Описания у неё тоже нет.

Такое восприятие из-за последовательности коммитов и отсутствия 
описаний. Самые важные и сложные изменения были оставлены на конец, 
собственно сам демон, набор общих функций и отделённый главный цикл 
демона. А это ещё одна часть, которую использует демон как отдельный 
процесс, отвечающий за терминал вывода журнала (по умолчанию tty3).


>> @@ -0,0 +1,36 @@
>> +#!/bin/bash -efu
>> +
>> +. bootchain-sh-functions
[...]
>> +[ -z "${NOTTYS-}" ] && [ -n "$BC_LOG_VT" ] ||
>> +	exit 1
>> +set_cleanup_handler exit_handler
>> +exec </dev/null >"/dev/tty$BC_LOG_VT" 2>&1
>> +printf "bootchain logger started on tty%s\n\n" "$BC_LOG_VT"
>> +tail -f -- "$BC_LOGFILE" & pid="$!"
> Откуда берутся BC_LOG_VT и BC_LOGFILE ?

Выше по коду подключается bootchain-sh-functions, до которого ты пока не 
дошёл, и там эти дефолты есть. Они перебиваются внешним конфигом, 
подключаемым там же из /etc/sysconfig/bootchain. За последовательность 
коммитов я уже извинялся. :-)


-- 
Best regards,
Leonid Krivoshein.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [make-initrd] [PATCH v1 03/41] fork pipeline: 10 new files added
  2021-09-26 18:41   ` Leonid Krivoshein
@ 2021-09-27  8:45     ` Alexey Gladkov
  2021-09-27 13:03       ` Leonid Krivoshein
  0 siblings, 1 reply; 5+ messages in thread
From: Alexey Gladkov @ 2021-09-27  8:45 UTC (permalink / raw)
  To: make-initrd

On Sun, Sep 26, 2021 at 09:41:49PM +0300, Leonid Krivoshein wrote:
> 
> 
> 24.09.2021 21:31, Alexey Gladkov пишет:
> > On Fri, Sep 24, 2021 at 06:55:00PM +0300, Leonid Krivoshein wrote:
> > > ---
> > >   make-initrd/features/bootchain-core/config.mk |   5 +
> > >   .../bootchain-core/data/bin/machine-info      | 123 ++++++++++++++++++
> > >   .../bootchain-core/data/lib/bootchain/debug   |  84 ++++++++++++
> > >   .../data/lib/initrd/cmdline.d/bootchain       |   6 +
> > >   .../bootchain-core/data/sbin/bootchain-logvt  |  36 +++++
> > >   make-initrd/features/bootchain-core/rules.mk  |   3 +
> > >   .../features/bootchain-getimage/README.md     |  20 +++
> > >   .../features/bootchain-getimage/config.mk     |   5 +
> > >   .../features/bootchain-getimage/rules.mk      |   2 +
> > >   .../features/bootchain-waitdev/README.md      |  21 +++
> > >   10 files changed, 305 insertions(+)
> > Леонид, ты мастер commit message! С твоими описаниями не поспоришь.
> > Действительно, 10. Но важнее, что это за файлы.
> 
> Да, уже говорил, что на первой итерации первыми тремя патчами просто хотел
> показать крупными штрихами, что-куда переехало, и что было добавлено при
> форке.
> 
> 
> > Кстати, я хочу обратить
> > внимание:
> > 
> > https://github.com/osboot/make-initrd/blob/master/Documentation/Contributing.md
> > 
> > Для меня это важно.
> 
> Я понял, что финальный вариант должен пименяться к апстримному дереву с
> подписыванием коммитов.
> 
> 
> > Ты добавляешь фичи, но ни слова не пишешь о том, что это.
> 
> В черновике документации всё же постарался всё отразить. Но я понимаю, что и
> коммиты теперь нужно превратить на какую-то правдоподобную историю.
> 
> 
> > Это же относится
> > и к README.md. Там ни слова про то что это. Только название и параметры.
> 
> Вот тут я не очень понял. Исходный pipeline содержал README.md, я просто
> скопировал отдельно описание getimage и waitdev, оставив на месте основной
> исходник. Фича pipeline же тоже осталась. В новой версии описания я просто
> добавил ссылку смотреть пока в README от pipeline.

# Feature bootchain-getimage

This is not a standalone feature. This is an add-on to the bootchain
feature. It allows to get a remote image and mount it. This is useful for
network boot.

## Boot parameters

...

Что-нибудь такое или получше.

> Второй момент заключается в том, что я не прочь потренироваться в написании
> README и коммит-мессаджей, тем более, по плану до начала апстрима собирался
> их написать. Но вот на один README для interactive у меня вся ночь ушла.
> 
> Третий момент заключается в том, что ранее ты предлагал сам перевести
> README, если я сделаю документацию на русском. Вот на родном могу написать
> хорошо и быстро, но у тебя вроде пока нигде в фичах пока нет README.ru.md, а
> так я уже думал на эту тему.

Русской документации пока нет.

> > > [...]
> > > +
> > > +	find /sys/devices -mindepth 2 -maxdepth 2 -type d -name "$glob" |
> > > +		grep '/sys/devices/pci' |
> > find /sys/devices -mindepth 2 -maxdepth 2 -type d -path "/sys/devices/pci*/$glob"
> > 
> > > +		sort |
> > > +	while read -r sysfs; do
> > > +		printf "%s" "${sysfs##*/}"
> > > +		handle_field class
> > > +		handle_field vendor
> > > +		handle_field device
> > > +		handle_field subsystem_vendor
> > > +		handle_field subsystem_device
> > > +		handle_field revision
> > Мне кажется в handle_field() не имеет смысла проверять на существование
> > эти файлы. Это всё компоненты MODALIAS.
> > 
> > Зачем это печатать отдельно, если это ровно modalias ?
> > 
> > По сути всё тело функции можно заменить:
> > 
> > find /sys/devices -mindepth 2 -maxdepth 3 -type f -path "/sys/devices/pci*/$glob/modalias" | sort |
> > while read -r path; do
> > 	read -r modalias < "$path"
> > 	path="${path%/modalias}"
> > 	printf '%s %s\n' "${path##*/}" "$modalias"
> > done

В приведённом выше коде я не уверен в необходимости первой колонки.

> Давай переделаю, как ты предлагаешь. machine-info вместе с частью
> OEM-установки драйверов это всё равно та часть, которую я сначала предлагал
> написать полностью тебе, но потом всё же изобразил какое-то её подобие. Ты
> сначала было даже хотел, а потом решил, что в твоих применениях проще
> пересобрать initrd, но для уже выпущенных дистрибутивов это действительно
> важно.

Я помню, что был разговор про OEM, но плохо помню детали.
И если нужен точный слепок машины, то почему например не использовать:

dmidecode | sed -n -e '/^Table at /,/^End Of Table$/p' | sha256sum

?

> Предметным вопросом для обсуждения тут конечно является обсуждение
> принадлежности machine-info к той или иной фиче. У меня она используется в
> localdev (altboot), в части, отвечающей за пропагаторный параметр
> UPDATEMODULES. Но она может пригодиться и для деплоя, и много где ещё.
> Может, её вынести уровнем ещё выше, сделать частью самого make-initrd? К
> bootchain-core она точно не имеет отношения.

Я до сих пор не очень понимаю назначение machine-info. Когда ты
рассказывал юскейс, то он мне тогда казался хакерством каким-то.

> > > [...]
> > > diff --git a/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
> > > b/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
> > > new file mode 100755
> > > index 0000000..037505a
> > > --- /dev/null
> > > +++ b/make-initrd/features/bootchain-core/data/sbin/bootchain-logvt
> > Зачем нужна эта утилита ? Она добавляется, но нигде в коммите не
> > используется. Описания у неё тоже нет.
> 
> Такое восприятие из-за последовательности коммитов и отсутствия описаний.
> Самые важные и сложные изменения были оставлены на конец, собственно сам
> демон, набор общих функций и отделённый главный цикл демона. А это ещё одна
> часть, которую использует демон как отдельный процесс, отвечающий за
> терминал вывода журнала (по умолчанию tty3).
> 
> 
> > > @@ -0,0 +1,36 @@
> > > +#!/bin/bash -efu
> > > +
> > > +. bootchain-sh-functions
> [...]
> > > +[ -z "${NOTTYS-}" ] && [ -n "$BC_LOG_VT" ] ||
> > > +	exit 1
> > > +set_cleanup_handler exit_handler
> > > +exec </dev/null >"/dev/tty$BC_LOG_VT" 2>&1
> > > +printf "bootchain logger started on tty%s\n\n" "$BC_LOG_VT"
> > > +tail -f -- "$BC_LOGFILE" & pid="$!"
> > Откуда берутся BC_LOG_VT и BC_LOGFILE ?
> 
> Выше по коду подключается bootchain-sh-functions, до которого ты пока не
> дошёл, и там эти дефолты есть. Они перебиваются внешним конфигом,
> подключаемым там же из /etc/sysconfig/bootchain. За последовательность
> коммитов я уже извинялся. :-)

Коммиты читаются последовательно. Я же ещё не знаю, что будет, где и в
каком формате. Именно поэтому я в последующих письмах попросил переделать
коммиты.

-- 
Rgrds, legion



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [make-initrd] [PATCH v1 03/41] fork pipeline: 10 new files added
  2021-09-27  8:45     ` Alexey Gladkov
@ 2021-09-27 13:03       ` Leonid Krivoshein
  0 siblings, 0 replies; 5+ messages in thread
From: Leonid Krivoshein @ 2021-09-27 13:03 UTC (permalink / raw)
  To: make-initrd


27.09.2021 11:45, Alexey Gladkov пишет:
> On Sun, Sep 26, 2021 at 09:41:49PM +0300, Leonid Krivoshein wrote:
>> [...]
>>> Это же относится
>>> и к README.md. Там ни слова про то что это. Только название и параметры.
>> Вот тут я не очень понял. Исходный pipeline содержал README.md, я просто
>> скопировал отдельно описание getimage и waitdev, оставив на месте основной
>> исходник. Фича pipeline же тоже осталась. В новой версии описания я просто
>> добавил ссылку смотреть пока в README от pipeline.
> # Feature bootchain-getimage
>
> This is not a standalone feature. This is an add-on to the bootchain
> feature. It allows to get a remote image and mount it. This is useful for
> network boot.
>
> ## Boot parameters
>
> ...
>
> Что-нибудь такое или получше.

Понял, сделаю.


>> Второй момент заключается в том, что я не прочь потренироваться в написании
>> README и коммит-мессаджей, тем более, по плану до начала апстрима собирался
>> их написать. Но вот на один README для interactive у меня вся ночь ушла.
>>
>> Третий момент заключается в том, что ранее ты предлагал сам перевести
>> README, если я сделаю документацию на русском. Вот на родном могу написать
>> хорошо и быстро, но у тебя вроде пока нигде в фичах пока нет README.ru.md, а
>> так я уже думал на эту тему.
> Русской документации пока нет.

Мне всё равно нужен такой опыт, но сейчас главный вопрос времени. Нужно 
быстрее или чтобы было обязательно всё и на английском?


> [...]
>>> По сути всё тело функции можно заменить:
>>>
>>> find /sys/devices -mindepth 2 -maxdepth 3 -type f -path "/sys/devices/pci*/$glob/modalias" | sort |
>>> while read -r path; do
>>> 	read -r modalias < "$path"
>>> 	path="${path%/modalias}"
>>> 	printf '%s %s\n' "${path##*/}" "$modalias"
>>> done
> В приведённом выше коде я не уверен в необходимости первой колонки.
>
>> Давай переделаю, как ты предлагаешь. machine-info вместе с частью
>> OEM-установки драйверов это всё равно та часть, которую я сначала предлагал
>> написать полностью тебе, но потом всё же изобразил какое-то её подобие. Ты
>> сначала было даже хотел, а потом решил, что в твоих применениях проще
>> пересобрать initrd, но для уже выпущенных дистрибутивов это действительно
>> важно.
> Я помню, что был разговор про OEM, но плохо помню детали.
> И если нужен точный слепок машины, то почему например не использовать:
>
> dmidecode | sed -n -e '/^Table at /,/^End Of Table$/p' | sha256sum
>
> ?

Наверное, плохо тащить в initramfs целую тулзу, да ещё и полагаться на 
низменность её выходного потока, тогда как отсортированный вывод 
стандартных полей DMI INFO обычно неизменен. В начале 90-х, помнится, 
для решения подобных задач просто привязывались к какой-нибудь сигнатуре 
BIOS.


>> Предметным вопросом для обсуждения тут конечно является обсуждение
>> принадлежности machine-info к той или иной фиче. У меня она используется в
>> localdev (altboot), в части, отвечающей за пропагаторный параметр
>> UPDATEMODULES. Но она может пригодиться и для деплоя, и много где ещё.
>> Может, её вынести уровнем ещё выше, сделать частью самого make-initrd? К
>> bootchain-core она точно не имеет отношения.
> Я до сих пор не очень понимаю назначение machine-info. Когда ты
> рассказывал юскейс, то он мне тогда казался хакерством каким-то.

Задача вычислить уникальный хэш для типа компьютера и для конкретного 
экземпляра данного типа. И то, и другое, может быть полезно для 
автоматизации развёртывания, для определения набора необходимых 
драйверов, для привязки сценариев, для всяких бэкапов. Поскольку я 
полагал, что функционал будет использован не только в altboot/localdev, 
но и другими шагами для деплоя, убрал уровнем выше -- в bootchain-core. 
Но возможно правильней будет данную утилиту отдельно опакетить и тащить 
тем фичам, которым она действительно нужна. Хотя, если на определённые 
хэши вешать хуки make-initrd для решения известных проблем, она может 
пригодиться и в самом make-initrd. Ещё можно сделать отдельную фичу 
machine-info, чтобы она считала эти хэши и клала их в определённые 
места, например в /run/machine-info/.


-- 
Best regards,
Leonid Krivoshein.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-27 13:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-24 15:55 [make-initrd] [PATCH v1 03/41] fork pipeline: 10 new files added Leonid Krivoshein
2021-09-24 18:31 ` Alexey Gladkov
2021-09-26 18:41   ` Leonid Krivoshein
2021-09-27  8:45     ` Alexey Gladkov
2021-09-27 13:03       ` Leonid Krivoshein

Make-initrd development discussion

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/make-initrd/0 make-initrd/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 make-initrd make-initrd/ http://lore.altlinux.org/make-initrd \
		make-initrd@lists.altlinux.org make-initrd@lists.altlinux.ru make-initrd@lists.altlinux.com
	public-inbox-index make-initrd

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.make-initrd


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git