From patchwork Thu Nov 17 17:41:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1705248 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NCnRB0x1Jz23mV for ; Fri, 18 Nov 2022 04:46:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 9285E40186; Thu, 17 Nov 2022 17:46:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9285E40186 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Ngm6fhpK5lxn; Thu, 17 Nov 2022 17:46:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 001AB401F8; Thu, 17 Nov 2022 17:46:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 001AB401F8 X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 1ABC31BF401 for ; Thu, 17 Nov 2022 17:46:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id EA62D401F8 for ; Thu, 17 Nov 2022 17:46:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org EA62D401F8 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id peWKSjER-TuJ for ; Thu, 17 Nov 2022 17:46:24 +0000 (UTC) X-Greylist: delayed 00:05:05 by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org AE85D40186 Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) by smtp2.osuosl.org (Postfix) with ESMTPS id AE85D40186 for ; Thu, 17 Nov 2022 17:46:23 +0000 (UTC) Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MPXlM-1oZ5QY2L4M-00Mbwj; Thu, 17 Nov 2022 18:41:13 +0100 From: Laurent Vivier To: buildroot@buildroot.org Date: Thu, 17 Nov 2022 18:41:09 +0100 Message-Id: <20221117174110.314474-2-laurent@vivier.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117174110.314474-1-laurent@vivier.eu> References: <20221117174110.314474-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:KK498TUDxD5KojbeNW3v2luRbNhLMW55AFcvq+MHO+QhWvptTyl Af1a3iReFoPe3gN8USTVLSJ+9XBPWhRJ6ipxvrwwE8SgtZJVmmgJAIFRs8ke/98E55bsJWI E2LLaodwsGoUcVMraaH4B5cm1G8m9/IyoGgjR6PRf3Op3wFGP4889PIPBjXIkmvewdh+dlQ 75cQxICHjv/AoP05ZczTA== X-UI-Out-Filterresults: notjunk:1;V03:K0:qmCJMJT4Dpk=:syHvduWviVLrZym+4UCBjt g1ciS4P4UCk5ty4mYEEVQEpMwaHxyGfL+e0+lbBAbVs942cs0/ABhSfA4B4FjRDZRCLZV8eSP zNfcXPaHdUwBoqSUvgO0gLLy9r1vdfeCsk5TvMI6qvyJ8wPuHOp5cwxs1e0J1D/vrzYCX1eb/ A/lS6aZzSAUH1/tKgfP0Ic4XWpq4I2D1S1/lPt398LuTf5VUXI9fNOdHa0Sl7UzdHVS3Hw9h6 4nE+mvtZkLTrI3+b0R62KT958G6Hge+VQLvj4HHZX8KYTka6O5juBj3CR/sGksrRpFpW9X7qA Gmyn5pZnMbKYKCoNozwQoU/LvtqRN0k9WLieco93sUBRUoCe+LwoxorYyF0MKDbq6ZUk2f+B+ 5j6eebBwM4H/4H9HngR2S3eqAn8Kc8/2fSWk2k8txNl8s0yZaUvAKVbLnBm2uJQGsOe6rsyTN Ix0IrgSftdjPe2zsfhhBOSZ40JmmVnTIkoz9W8yDImmilGyk549j71Qx3/5Ad8ugZ/89JRKzl Xbh37WJf9hIXyOSGDlAl3Mjla/v0XTwhX1tiLIU2lG1+HAx2xUwXkI1m/sp9iSCYrkGnkPsOo 0OmmB3A0/X2maACGbetdTFu9iKYOgXeVBu7LnGQ0lo7WT3Y7vJy+Zelrwmi+c+J3Q2F1/kj9u rdv0f14pmm6v4s3JfW4dSIonDZ93i4RZMrwcAw4tGlHhYulrEVnhRsLrSuMyoUxxatkC5DBDU gL3rjLPn1Gl/UIdYvfz6ogfp4RbC6in8Sh59VClj/T3Nd7y7XVprOl5cg/UE/7XbrU7+MOVTJ 7bk1b3P Subject: [Buildroot] [PATCH v6 1/2] package: add petitboot X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Romain Naour , Laurent Vivier , Thomas Petazzoni Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" from https://github.com/glevand/petitboot--buildroot Updated to work with m68k architecture rather than PlayStation3 (focused on qemu-system-m68k virt machine) Signed-off-by: Laurent Vivier --- DEVELOPERS | 3 + package/Config.in | 1 + package/kexec/Config.in | 2 +- package/petitboot/63-md-raid-arrays.rules | 41 ++++++++++ package/petitboot/65-md-incremental.rules | 69 +++++++++++++++++ package/petitboot/66-add-sg-module.rules | 2 + package/petitboot/Config.in | 23 ++++++ package/petitboot/S14silence-console | 9 +++ package/petitboot/S15pb-discover | 38 ++++++++++ package/petitboot/fs-overlay/etc/inittab | 34 +++++++++ package/petitboot/fs-overlay/etc/locale | 1 + package/petitboot/fs-overlay/init | 8 ++ package/petitboot/kexec-restart | 8 ++ package/petitboot/petitboot-console-ui.rules | 6 ++ package/petitboot/petitboot.hash | 2 + package/petitboot/petitboot.mk | 78 ++++++++++++++++++++ package/petitboot/removable-event-poll.rules | 4 + package/petitboot/shell_config | 19 +++++ package/petitboot/shell_profile | 2 + 19 files changed, 349 insertions(+), 1 deletion(-) create mode 100644 package/petitboot/63-md-raid-arrays.rules create mode 100644 package/petitboot/65-md-incremental.rules create mode 100644 package/petitboot/66-add-sg-module.rules create mode 100644 package/petitboot/Config.in create mode 100755 package/petitboot/S14silence-console create mode 100755 package/petitboot/S15pb-discover create mode 100644 package/petitboot/fs-overlay/etc/inittab create mode 100644 package/petitboot/fs-overlay/etc/locale create mode 100755 package/petitboot/fs-overlay/init create mode 100755 package/petitboot/kexec-restart create mode 100644 package/petitboot/petitboot-console-ui.rules create mode 100644 package/petitboot/petitboot.hash create mode 100644 package/petitboot/petitboot.mk create mode 100644 package/petitboot/removable-event-poll.rules create mode 100644 package/petitboot/shell_config create mode 100755 package/petitboot/shell_profile diff --git a/DEVELOPERS b/DEVELOPERS index 826e04d8054d..70cb9ee68ca9 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1739,6 +1739,9 @@ F: package/aircrack-ng/ N: Laurent Charpentier F: package/open-lldp/ +N: Laurent Vivier +F: package/petitboot/ + N: Lee Jones F: boot/afboot-stm32/ diff --git a/package/Config.in b/package/Config.in index aef80f9ab0f2..eb920f61cd2a 100644 --- a/package/Config.in +++ b/package/Config.in @@ -2627,6 +2627,7 @@ menu "System tools" source "package/openrc/Config.in" source "package/openvmtools/Config.in" source "package/pamtester/Config.in" + source "package/petitboot/Config.in" source "package/polkit/Config.in" source "package/powerpc-utils/Config.in" source "package/procps-ng/Config.in" diff --git a/package/kexec/Config.in b/package/kexec/Config.in index 90a7bc2672bd..092a80b171fc 100644 --- a/package/kexec/Config.in +++ b/package/kexec/Config.in @@ -3,7 +3,7 @@ config BR2_PACKAGE_KEXEC depends on BR2_i386 || BR2_x86_64 || BR2_arm || BR2_armeb || \ BR2_mips || BR2_mips64 || BR2_mipsel || BR2_mips64el || \ BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le || \ - BR2_sh4 || BR2_sh4a || BR2_aarch64 || BR2_s390x + BR2_sh4 || BR2_sh4a || BR2_aarch64 || BR2_s390x || BR2_m68k help Kexec is a user space utility for loading another kernel and asking the currently running kernel to do something with diff --git a/package/petitboot/63-md-raid-arrays.rules b/package/petitboot/63-md-raid-arrays.rules new file mode 100644 index 000000000000..92aec36e69d4 --- /dev/null +++ b/package/petitboot/63-md-raid-arrays.rules @@ -0,0 +1,41 @@ +# do not edit this file, it will be overwritten on update + +SUBSYSTEM!="block", GOTO="md_end" + +# handle md arrays +ACTION!="add|change", GOTO="md_end" +KERNEL!="md*", GOTO="md_end" + +# partitions have no md/{array_state,metadata_version}, but should not +# for that reason be ignored. +ENV{DEVTYPE}=="partition", GOTO="md_ignore_state" + +# container devices have a metadata version of e.g. 'external:ddf' and +# never leave state 'inactive' +ATTR{md/metadata_version}=="external:[A-Za-z]*", ATTR{md/array_state}=="inactive", GOTO="md_ignore_state" +TEST!="md/array_state", ENV{SYSTEMD_READY}="0", GOTO="md_end" +ATTR{md/array_state}=="|clear|inactive", ENV{SYSTEMD_READY}="0", GOTO="md_end" +LABEL="md_ignore_state" + +IMPORT{program}="/sbin/mdadm --detail --export $devnode" +ENV{DEVTYPE}=="disk", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}", OPTIONS+="string_escape=replace" +ENV{DEVTYPE}=="disk", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}" +ENV{DEVTYPE}=="disk", ENV{MD_DEVNAME}=="?*", SYMLINK+="md/$env{MD_DEVNAME}" +ENV{DEVTYPE}=="partition", ENV{MD_NAME}=="?*", SYMLINK+="disk/by-id/md-name-$env{MD_NAME}-part%n", OPTIONS+="string_escape=replace" +ENV{DEVTYPE}=="partition", ENV{MD_UUID}=="?*", SYMLINK+="disk/by-id/md-uuid-$env{MD_UUID}-part%n" +ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[^0-9]", SYMLINK+="md/$env{MD_DEVNAME}%n" +ENV{DEVTYPE}=="partition", ENV{MD_DEVNAME}=="*[0-9]", SYMLINK+="md/$env{MD_DEVNAME}p%n" + +IMPORT{builtin}="blkid" +OPTIONS+="link_priority=100" +OPTIONS+="watch" +ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" +ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" + +ENV{MD_LEVEL}=="raid[1-9]*", ENV{SYSTEMD_WANTS}+="mdmonitor.service" + +# Tell systemd to run mdmon for our container, if we need it. +ENV{MD_LEVEL}=="raid[1-9]*", ENV{MD_CONTAINER}=="?*", PROGRAM="/usr/bin/readlink $env{MD_CONTAINER}", ENV{MD_MON_THIS}="%c" +ENV{MD_MON_THIS}=="?*", PROGRAM="/usr/bin/basename $env{MD_MON_THIS}", ENV{SYSTEMD_WANTS}+="mdmon@%c.service" + +LABEL="md_end" diff --git a/package/petitboot/65-md-incremental.rules b/package/petitboot/65-md-incremental.rules new file mode 100644 index 000000000000..153d12fe6f7e --- /dev/null +++ b/package/petitboot/65-md-incremental.rules @@ -0,0 +1,69 @@ +# This file causes block devices with Linux RAID (mdadm) signatures to +# automatically cause mdadm to be run. +# See udev(8) for syntax + +# Don't process any events if anaconda is running as anaconda brings up +# raid devices manually +ENV{ANACONDA}=="?*", GOTO="md_end" + +# Also don't process disks that are slated to be a multipath device +ENV{DM_MULTIPATH_DEVICE_PATH}=="?*", GOTO="md_end" + +# We process add events on block devices (since they are ready as soon as +# they are added to the system), but we must process change events as well +# on any dm devices (like LUKS partitions or LVM logical volumes) and on +# md devices because both of these first get added, then get brought live +# and trigger a change event. The reason we don't process change events +# on bare hard disks is because if you stop all arrays on a disk, then +# run fdisk on the disk to change the partitions, when fdisk exits it +# triggers a change event, and we want to wait until all the fdisks on +# all member disks are done before we do anything. Unfortunately, we have +# no way of knowing that, so we just have to let those arrays be brought +# up manually after fdisk has been run on all of the disks. + +# First, process all add events (md and dm devices will not really do +# anything here, just regular disks, and this also won't get any imsm +# array members either) +SUBSYSTEM=="block", ACTION=="add|change", ENV{ID_FS_TYPE}=="linux_raid_member", \ + RUN+="/sbin/mdadm -I --export $env{DEVNAME}" + +# Next, check to make sure the BIOS raid stuff wasn't turned off via cmdline +IMPORT{cmdline}="noiswmd" +IMPORT{cmdline}="nodmraid" +ENV{noiswmd}=="?*", GOTO="md_imsm_inc_end" +ENV{nodmraid}=="?*", GOTO="md_imsm_inc_end" +SUBSYSTEM=="block", ACTION=="add", ENV{ID_FS_TYPE}=="isw_raid_member", \ + RUN+="/sbin/mdadm -I $env{DEVNAME}" +LABEL="md_imsm_inc_end" + +SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}=="?*", \ + RUN+="/sbin/mdadm -If $name --path $env{ID_PATH}" +SUBSYSTEM=="block", ACTION=="remove", ENV{ID_PATH}!="?*", \ + RUN+="/sbin/mdadm -If $name" + +# Next make sure that this isn't a dm device we should skip for some reason +ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="dm_change_end" +ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}=="1", GOTO="dm_change_end" +ENV{DM_SUSPENDED}=="1", GOTO="dm_change_end" +KERNEL=="dm-*", SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="linux_raid_member", \ + ACTION=="change", RUN+="/sbin/mdadm -I $env{DEVNAME}" +LABEL="dm_change_end" + +# Finally catch any nested md raid arrays. If we brought up an md raid +# array that's part of another md raid array, it won't be ready to be used +# until the change event that occurs when it becomes live +KERNEL=="md*", SUBSYSTEM=="block", ENV{ID_FS_TYPE}=="linux_raid_member", \ + ACTION=="change", RUN+="/sbin/mdadm -I $env{DEVNAME}" + +# In case the initramfs only started some of the arrays in our container, +# run incremental assembly on the container itself. Note: we ran mdadm +# on the container in 64-md-raid.rules, and that's how the MD_LEVEL +# environment variable is already set. If that disappears from the other +# file, we will need to add this line into the middle of the next rule: +# IMPORT{program}="/sbin/mdadm -D --export $tempnode", \ + +SUBSYSTEM=="block", ACTION=="add|change", KERNEL=="md*", \ + ENV{MD_LEVEL}=="container", RUN+="/sbin/mdadm -I $env{DEVNAME}" + + +LABEL="md_end" diff --git a/package/petitboot/66-add-sg-module.rules b/package/petitboot/66-add-sg-module.rules new file mode 100644 index 000000000000..ae18d28c570e --- /dev/null +++ b/package/petitboot/66-add-sg-module.rules @@ -0,0 +1,2 @@ +# load modules to scsi disks, if they aren't in kernel +SUBSYSTEM=="scsi", ENV{DEVTYPE}=="scsi_device", TEST!="[module/sg]", RUN+="/sbin/modprobe sg" diff --git a/package/petitboot/Config.in b/package/petitboot/Config.in new file mode 100644 index 000000000000..fdcb26ccc924 --- /dev/null +++ b/package/petitboot/Config.in @@ -0,0 +1,23 @@ +config BR2_PACKAGE_PETITBOOT + bool "petitboot" + # petitboot needs udev /dev management + depends on BR2_PACKAGE_HAS_UDEV + select BR2_PACKAGE_ELFUTILS + select BR2_PACKAGE_LVM2 + select BR2_PACKAGE_NCURSES + select BR2_PACKAGE_NCURSES_TARGET_PANEL + select BR2_PACKAGE_NCURSES_TARGET_FORM + select BR2_PACKAGE_NCURSES_TARGET_MENU + # run-time dependency only + select BR2_PACKAGE_KEXEC_LITE if !BR2_PACKAGE_KEXEC + # run-time dependency only + select BR2_PACKAGE_POWERPC_UTILS if (( BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le ) && ! BR2_PACKAGE_PS3_UTILS ) + # run-time dependency only + select BR2_PACKAGE_NVME if (( BR2_powerpc || BR2_powerpc64 || BR2_powerpc64le ) && ! BR2_PACKAGE_PS3_UTILS ) + help + Petitboot is a small kexec-based bootloader + + http://www.kernel.org/pub/linux/kernel/people/geoff/petitboot/petitboot.html + +comment "petitboot requires udev to be enabled" + depends on !BR2_PACKAGE_HAS_UDEV diff --git a/package/petitboot/S14silence-console b/package/petitboot/S14silence-console new file mode 100755 index 000000000000..2ce6b39f427b --- /dev/null +++ b/package/petitboot/S14silence-console @@ -0,0 +1,9 @@ +#!/bin/sh + +case "$1" in + start) + echo 1 1 1 1 > /proc/sys/kernel/printk + ;; +esac + +exit 0 diff --git a/package/petitboot/S15pb-discover b/package/petitboot/S15pb-discover new file mode 100755 index 000000000000..9d9ec57de3f0 --- /dev/null +++ b/package/petitboot/S15pb-discover @@ -0,0 +1,38 @@ +#!/bin/sh + +LOGFILE=/var/log/petitboot/pb-discover.log +PIDFILE=/var/run/petitboot.pid + +PATH=/usr/bin:/usr/sbin:/bin:/sbin +export PATH + +verbose= +if pb-config debug | grep -q enabled +then + verbose=-v +fi + +case "$1" in + start) + ulimit -c unlimited + mkdir -p -m 0775 $(dirname $LOGFILE) + mkdir -p -m 0775 /var/petitboot + # Set permissions for normal users + chown -R root:petitgroup $(dirname $LOGFILE) + chown -R root:petitgroup /var/petitboot + + export $(cat /etc/locale) + pb-discover -l $LOGFILE $verbose & + echo $! > $PIDFILE + ;; + stop) + pid=$(cat $PIDFILE) + [ -n "$pid" ] && kill -TERM $pid + ;; + *) + echo "Usage: $0 {start|stop}" + exit 1 + ;; +esac + +exit 0 diff --git a/package/petitboot/fs-overlay/etc/inittab b/package/petitboot/fs-overlay/etc/inittab new file mode 100644 index 000000000000..1f503d5d56f7 --- /dev/null +++ b/package/petitboot/fs-overlay/etc/inittab @@ -0,0 +1,34 @@ +# /etc/inittab +# +# Copyright (C) 2001 Erik Andersen +# +# Note: BusyBox init doesn't support runlevels. The runlevels field is +# completely ignored by BusyBox init. If you want runlevels, use +# sysvinit. +# +# Format for each entry: ::: +# +# id == tty to run on, or empty for /dev/console +# runlevels == ignored +# action == one of sysinit, respawn, askfirst, wait, and once +# process == program to run + +# Startup the system +::sysinit:/bin/mount -t proc proc /proc +::sysinit:/bin/mount -o remount,rw / # REMOUNT_ROOTFS_RW +::sysinit:/bin/mkdir -p /dev/pts +::sysinit:/bin/mkdir -p /dev/shm +::sysinit:/bin/mount -a +::sysinit:/bin/hostname -F /etc/hostname +# now run any rc scripts +::sysinit:/etc/init.d/rcS +::sysinit:/sbin/petitboot-nc +# Stuff to do for the 3-finger salute +::ctrlaltdel:/sbin/reboot + +# Stuff to do before rebooting +::shutdown:/etc/init.d/rcK +::shutdown:/bin/umount -a -r +::shutdown:/sbin/swapoff -a + +::restart:/usr/sbin/kexec-restart diff --git a/package/petitboot/fs-overlay/etc/locale b/package/petitboot/fs-overlay/etc/locale new file mode 100644 index 000000000000..655683630776 --- /dev/null +++ b/package/petitboot/fs-overlay/etc/locale @@ -0,0 +1 @@ +LANG=en_US.utf-8 diff --git a/package/petitboot/fs-overlay/init b/package/petitboot/fs-overlay/init new file mode 100755 index 000000000000..1e56178db162 --- /dev/null +++ b/package/petitboot/fs-overlay/init @@ -0,0 +1,8 @@ +#!/bin/sh +# devtmpfs does not get automounted for initramfs +/bin/mount -t devtmpfs devtmpfs /dev +exec 0/dev/console +exec 2>/dev/console +exec /sbin/init "$@" + diff --git a/package/petitboot/kexec-restart b/package/petitboot/kexec-restart new file mode 100755 index 000000000000..0175e76df4cd --- /dev/null +++ b/package/petitboot/kexec-restart @@ -0,0 +1,8 @@ +#!/bin/sh + +/usr/sbin/kexec -f -e + +while : +do + sleep 1 +done diff --git a/package/petitboot/petitboot-console-ui.rules b/package/petitboot/petitboot-console-ui.rules new file mode 100644 index 000000000000..cbf1b7e1d765 --- /dev/null +++ b/package/petitboot/petitboot-console-ui.rules @@ -0,0 +1,6 @@ + +# spawn a petitboot UI on common user-visible interface devices +SUBSYSTEM=="tty", KERNEL=="ttyGF*", RUN+="/usr/libexec/petitboot/pb-console --getty=/sbin/agetty --detach -- -a petituser -n -i $name linux" +SUBSYSTEM=="tty", KERNEL=="hvc*", RUN+="/usr/libexec/petitboot/pb-console --getty=/sbin/agetty --detach -- -a petituser -n -i $name linux" +SUBSYSTEM=="tty", KERNEL=="tty0", RUN+="/usr/libexec/petitboot/pb-console --getty=/sbin/agetty --detach -- -a petituser -n -i $name linux" +SUBSYSTEM=="tty", KERNEL=="ttyS*", RUN+="/usr/libexec/petitboot/pb-console --getty=/sbin/agetty --detach -- -a petituser -n -i $name linux" diff --git a/package/petitboot/petitboot.hash b/package/petitboot/petitboot.hash new file mode 100644 index 000000000000..859e438e956a --- /dev/null +++ b/package/petitboot/petitboot.hash @@ -0,0 +1,2 @@ +# Locally computed +sha256 b42ae4fb2a81e9cf68f727c3f54c6312788c654bd97628ec9ba61b19a68990e6 petitboot-v1.13.tar.gz diff --git a/package/petitboot/petitboot.mk b/package/petitboot/petitboot.mk new file mode 100644 index 000000000000..0b9214d0d553 --- /dev/null +++ b/package/petitboot/petitboot.mk @@ -0,0 +1,78 @@ +################################################################################ +# +# petitboot +# +################################################################################ + +PETITBOOT_VERSION = v1.13 +PETITBOOT_SOURCE = petitboot-$(PETITBOOT_VERSION).tar.gz +PETITBOOT_SITE ?= https://github.com/open-power/petitboot/releases/download/$(PETITBOOT_VERSION) +PETITBOOT_DEPENDENCIES = elfutils ncurses udev host-bison host-flex lvm2 +PETITBOOT_LICENSE = GPLv2 +PETITBOOT_LICENSE_FILES = COPYING + +PETITBOOT_CONF_OPTS += --with-ncurses --without-twin-x11 --without-twin-fbdev \ + --localstatedir=/var \ + --enable-crypt \ + HOST_PROG_KEXEC=/usr/sbin/kexec \ + HOST_PROG_SHUTDOWN=/usr/sbin/kexec-restart \ + $(if $(BR2_PACKAGE_BUSYBOX),--with-tftp=busybox --enable-busybox) + +ifdef PETITBOOT_DEBUG +PETITBOOT_CONF_OPTS += --enable-debug +endif + +ifeq ($(BR2_PACKAGE_NCURSES_WCHAR),y) +PETITBOOT_CONF_OPTS += --with-ncursesw MENU_LIB=-lmenuw FORM_LIB=-lformw +endif + +define PETITBOOT_POST_INSTALL + $(INSTALL) -D -m 0755 $(@D)/utils/bb-kexec-reboot \ + $(TARGET_DIR)/usr/libexec/petitboot + $(INSTALL) -d -m 0755 $(TARGET_DIR)/etc/petitboot/boot.d + $(INSTALL) -D -m 0755 $(@D)/utils/hooks/01-create-default-dtb \ + $(TARGET_DIR)/etc/petitboot/boot.d/ + $(INSTALL) -D -m 0755 $(@D)/utils/hooks/90-sort-dtb \ + $(TARGET_DIR)/etc/petitboot/boot.d/ + + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/S14silence-console \ + $(TARGET_DIR)/etc/init.d/ + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/S15pb-discover \ + $(TARGET_DIR)/etc/init.d/ + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/kexec-restart \ + $(TARGET_DIR)/usr/sbin/ + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/petitboot-console-ui.rules \ + $(TARGET_DIR)/etc/udev/rules.d/ + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/removable-event-poll.rules \ + $(TARGET_DIR)/etc/udev/rules.d/ + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/63-md-raid-arrays.rules \ + $(TARGET_DIR)/etc/udev/rules.d/ + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/65-md-incremental.rules \ + $(TARGET_DIR)/etc/udev/rules.d/ + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/66-add-sg-module.rules \ + $(TARGET_DIR)/etc/udev/rules.d/ + + ln -sf /usr/sbin/pb-udhcpc \ + $(TARGET_DIR)/usr/share/udhcpc/default.script.d/ + + mkdir -p $(TARGET_DIR)/home/petituser + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/shell_profile \ + $(TARGET_DIR)/home/petituser/.profile + $(INSTALL) -D -m 0755 $(PETITBOOT_PKGDIR)/shell_config \ + $(TARGET_DIR)/home/petituser/.shrc + + $(MAKE) -C $(@D)/po DESTDIR=$(TARGET_DIR) install +endef + +define PETITBOOT_POST_INSTALL_DTB + $(INSTALL) -D -m 0755 $(@D)/utils/hooks/30-dtb-updates \ + $(TARGET_DIR)/etc/petitboot/boot.d/ +endef + +PETITBOOT_POST_INSTALL_TARGET_HOOKS += PETITBOOT_POST_INSTALL + +ifeq ($(BR2_PACKAGE_DTC),y) + PETITBOOT_POST_INSTALL_TARGET_HOOKS += PETITBOOT_POST_INSTALL_DTB +endif + +$(eval $(autotools-package)) diff --git a/package/petitboot/removable-event-poll.rules b/package/petitboot/removable-event-poll.rules new file mode 100644 index 000000000000..b736aef6101f --- /dev/null +++ b/package/petitboot/removable-event-poll.rules @@ -0,0 +1,4 @@ + +# petitboot needs notification for media change events on removable devices, +# which we only get if we've set the poll_msecs sysfs attribute. +ACTION!="remove", ATTR{removable}=="1", ATTR{events_poll_msecs}="2000" diff --git a/package/petitboot/shell_config b/package/petitboot/shell_config new file mode 100644 index 000000000000..59337ff53039 --- /dev/null +++ b/package/petitboot/shell_config @@ -0,0 +1,19 @@ +#!bin/sh + +reset + +echo "Exiting petitboot. Type 'exit' to return." +echo "You may run 'pb-sos' to gather diagnostic data" + +if [[ "$(id -u)" != "0" ]]; then + echo "" | sudo -S /bin/true 2&>1 >> /dev/null + if [[ $? = 0 ]]; then + echo "No password set, running as root. You may set a password in the System Configuration screen." + sudo -i + sudo -K + exit + fi + export PS1='$ ' +else + export PS1='# ' +fi diff --git a/package/petitboot/shell_profile b/package/petitboot/shell_profile new file mode 100755 index 000000000000..40062b423b79 --- /dev/null +++ b/package/petitboot/shell_profile @@ -0,0 +1,2 @@ +export ENV="/home/petituser/.shrc" +/usr/libexec/petitboot/pb-console From patchwork Thu Nov 17 17:41:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1705249 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NCnbj0Jg8z23mR for ; Fri, 18 Nov 2022 04:54:09 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id CFD38404F7; Thu, 17 Nov 2022 17:54:06 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org CFD38404F7 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tAWHTDWNbC7P; Thu, 17 Nov 2022 17:54:05 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id A8F0E40576; Thu, 17 Nov 2022 17:54:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org A8F0E40576 X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id ED39C1BF401 for ; Thu, 17 Nov 2022 17:54:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id C7AA740576 for ; Thu, 17 Nov 2022 17:54:02 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org C7AA740576 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nn0HJk4WjbsE for ; Thu, 17 Nov 2022 17:54:02 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 6739E404F7 Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.74]) by smtp4.osuosl.org (Postfix) with ESMTPS id 6739E404F7 for ; Thu, 17 Nov 2022 17:54:01 +0000 (UTC) Received: from quad ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MNso2-1obqa11duq-00OFZX; Thu, 17 Nov 2022 18:41:13 +0100 From: Laurent Vivier To: buildroot@buildroot.org Date: Thu, 17 Nov 2022 18:41:10 +0100 Message-Id: <20221117174110.314474-3-laurent@vivier.eu> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221117174110.314474-1-laurent@vivier.eu> References: <20221117174110.314474-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:AFyZdwrkdb7xRKthocFbbyULQB3sXZKEqx6xzaHCRezbKyf0Mau SZ6WVqomZxJpz7cnBwf/0bREh1YArCj1gBsSLTi8O/IpKH0MmBlu7RZFxIrd0WAbynOjkOQ nDW4wOqLWeBfjxzPOr2netdZJpzah/J7/ciYtLSu+rmoXY8faGPUiudHNXxPrb/1uskOVUK emIYD8iHbD91+Mw/M58eg== X-UI-Out-Filterresults: notjunk:1;V03:K0:lCjVtp68+cU=:0eVF+t43J/5QpZfjVT1oEh nCeMgyvYiGeC80diclsqSwyUU3WTQQdnkqVDe3nGUjb0D4HnEfa/uZ/P2/MAVNbU2doXAQFBu ZPuws5WM7fusERVf60ELByIHYcOdFpe6uhPQgaDHadc/KVqrHqSh7GURvR8YdUVvhRdNoKVn4 3rfCT4u7vQIc5JoyWtI7YPGPpV+Y4A6kwz16DlOu1foVMICRLUbzFQqIOJoZQvo3Nt4vQRpm4 WJC5RN7ThBf6JKnox5kXJrqFbK/N5vPJ38xru1go44rj45g0YgKWG7igP0187s2mZBxsE6s1S 6kwFsuRGoovVy3vfmJ65VKemruxPgknDYsCdRBvwsN9i+XAJ7ai8BRe4GOxxnvsbD4/4uznTV BqDA0y2Tf8i+gGr1L1mFR+JSDV0BeOF2E7R1R9+QjEqifC7A0721X/Uda3BMsvzPcdoykomYR 0CK7RP22wxabHEDn6vVS2lvNIC6yDv5cUrSBNrYl3MvNm4v2n3ytbvSy3DMkVIfAzDIleMhVq J7NSYXlQBOCq0n+ixSEK3JRW6U5Rzb5+cJdbgOGXQWQd0e1cPkesQBuoc7LT6nA4eWrr7AJYG YUG1pWXXy9gLF7wtsC5H1WEhk7rZ4FqghsVtcPi8YTqAwhLyK2bbjjJurE8rPCxJwrBPAxEPd tkSYFGLO8TRB2soZ3iArZmexZSoGdOU/8reBv0PL7kEHZ5QpyFKkqmDHX/Wc/cERFampyjEK/ SHxOnZVexlIWroWSdL4Sa7ENQZZXsXjkDKmZaLfDcSgo5ut/L0YU9GbOoAh0j3X9udzAjEMNP p0vQolB Subject: [Buildroot] [PATCH v6 2/2] board/qemu/m68k-virt: Add virt-m68k linux config X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth , Romain Naour , Laurent Vivier , Thomas Petazzoni Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Build a 5.19 (first version with the m68k virt machine) kernel for "qemu-system-m68k -M virt" machine. Signed-off-by: Laurent Vivier --- DEVELOPERS | 2 + board/qemu/m68k-virt/config.linux | 89 ++++++++++++++++++++++ board/qemu/m68k-virt/readme.txt | 5 ++ configs/qemu_m68k_virt_petitboot_defconfig | 25 ++++++ 4 files changed, 121 insertions(+) create mode 100644 board/qemu/m68k-virt/config.linux create mode 100644 board/qemu/m68k-virt/readme.txt create mode 100644 configs/qemu_m68k_virt_petitboot_defconfig diff --git a/DEVELOPERS b/DEVELOPERS index 70cb9ee68ca9..4fc33fd862d6 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1741,6 +1741,8 @@ F: package/open-lldp/ N: Laurent Vivier F: package/petitboot/ +F: board/qemu/m68k-virt/ +F: configs/qemu_m68k_virt_petitboot_defconfig N: Lee Jones F: boot/afboot-stm32/ diff --git a/board/qemu/m68k-virt/config.linux b/board/qemu/m68k-virt/config.linux new file mode 100644 index 000000000000..88edb9b1eb3f --- /dev/null +++ b/board/qemu/m68k-virt/config.linux @@ -0,0 +1,89 @@ +CONFIG_LOCALVERSION="-virt" +CONFIG_SYSVIPC=y +CONFIG_CGROUPS=y +CONFIG_BLK_CGROUP=y +CONFIG_CGROUP_SCHED=y +CONFIG_CGROUP_PIDS=y +CONFIG_CGROUP_RDMA=y +CONFIG_CGROUP_FREEZER=y +CONFIG_CGROUP_DEVICE=y +CONFIG_CGROUP_CPUACCT=y +CONFIG_BLK_DEV_INITRD=y +CONFIG_KEXEC=y +CONFIG_BOOTINFO_PROC=y +CONFIG_VIRT=y +CONFIG_PROC_HARDWARE=y +CONFIG_PARTITION_ADVANCED=y +CONFIG_AMIGA_PARTITION=y +CONFIG_ATARI_PARTITION=y +CONFIG_MAC_PARTITION=y +CONFIG_BSD_DISKLABEL=y +CONFIG_MINIX_SUBPARTITION=y +CONFIG_SOLARIS_X86_PARTITION=y +CONFIG_UNIXWARE_DISKLABEL=y +CONFIG_LDM_PARTITION=y +CONFIG_LDM_DEBUG=y +CONFIG_SUN_PARTITION=y +CONFIG_SYSV68_PARTITION=y +CONFIG_NET=y +CONFIG_PACKET=y +CONFIG_UNIX=y +CONFIG_INET=y +CONFIG_IP_PNP=y +CONFIG_IP_PNP_DHCP=y +CONFIG_IP_PNP_BOOTP=y +CONFIG_CGROUP_NET_PRIO=y +CONFIG_CGROUP_NET_CLASSID=y +CONFIG_NET_9P=y +CONFIG_NET_9P_VIRTIO=y +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_BLK_DEV_LOOP=y +CONFIG_BLK_DEV_RAM=y +CONFIG_VIRTIO_BLK=y +CONFIG_SCSI=y +CONFIG_BLK_DEV_SR=y +CONFIG_SCSI_VIRTIO=y +CONFIG_MD=y +CONFIG_MD_LINEAR=y +CONFIG_MD_MULTIPATH=y +CONFIG_MD_FAULTY=y +CONFIG_BLK_DEV_DM=y +CONFIG_DM_UNSTRIPED=y +CONFIG_DM_CRYPT=y +CONFIG_DM_SNAPSHOT=y +CONFIG_DM_THIN_PROVISIONING=y +CONFIG_DM_CACHE=y +CONFIG_DM_WRITECACHE=y +CONFIG_DM_EBS=y +CONFIG_DM_ERA=y +CONFIG_DM_CLONE=y +CONFIG_DM_MIRROR=y +CONFIG_DM_RAID=y +CONFIG_DM_ZERO=y +CONFIG_NETDEVICES=y +CONFIG_VIRTIO_NET=y +CONFIG_INPUT_MOUSEDEV=y +CONFIG_INPUT_EVDEV=y +CONFIG_VIRTIO_CONSOLE=y +CONFIG_HW_RANDOM_VIRTIO=y +CONFIG_DRM=y +CONFIG_DRM_VIRTIO_GPU=y +CONFIG_FB=y +CONFIG_SOUND=y +CONFIG_SND=y +CONFIG_SND_VIRTIO=y +CONFIG_VIRT_DRIVERS=y +CONFIG_VIRTIO_INPUT=y +CONFIG_EXT4_FS=y +CONFIG_AUTOFS_FS=y +CONFIG_ISO9660_FS=y +CONFIG_JOLIET=y +CONFIG_ZISOFS=y +CONFIG_UDF_FS=y +CONFIG_TMPFS=y +CONFIG_TMPFS_POSIX_ACL=y +CONFIG_9P_FS=y +CONFIG_9P_FS_POSIX_ACL=y +CONFIG_9P_FS_SECURITY=y +CONFIG_EARLY_PRINTK=y diff --git a/board/qemu/m68k-virt/readme.txt b/board/qemu/m68k-virt/readme.txt new file mode 100644 index 000000000000..30803d403a4c --- /dev/null +++ b/board/qemu/m68k-virt/readme.txt @@ -0,0 +1,5 @@ +Run the emulation with: + + qemu-system-m68k -M virt -kernel output/images/vmlinux -initrd output/images/rootfs.cpio.xz -append "console=ttyGF0" --nographic # /qemu_m68k_virt_petitboot_defconfig + +The petiboot menu will appear in the terminal where QEMU has been started. diff --git a/configs/qemu_m68k_virt_petitboot_defconfig b/configs/qemu_m68k_virt_petitboot_defconfig new file mode 100644 index 000000000000..4f289fb7a667 --- /dev/null +++ b/configs/qemu_m68k_virt_petitboot_defconfig @@ -0,0 +1,25 @@ +BR2_m68k=y +BR2_TOOLCHAIN_BUILDROOT_WCHAR=y +BR2_CCACHE=y +BR2_RELRO_NONE=y +BR2_TARGET_GENERIC_ISSUE="Welcome to Petitboot" +BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y +BR2_ROOTFS_MERGED_USR=y +BR2_TARGET_GENERIC_GETTY_PORT="ttyGF0" +BR2_ROOTFS_OVERLAY="package/petitboot/fs-overlay" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_CUSTOM_VERSION=y +BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.19" +BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/m68k-virt/config.linux" +BR2_LINUX_KERNEL_XZ=y +BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y +BR2_PACKAGE_KEXEC=y +BR2_PACKAGE_KEXEC_ZLIB=y +BR2_PACKAGE_ETHTOOL=y +BR2_PACKAGE_NET_TOOLS=y +BR2_PACKAGE_NETCAT=y +BR2_PACKAGE_RSYNC=y +BR2_PACKAGE_PETITBOOT=y +BR2_TARGET_ROOTFS_CPIO=y +BR2_TARGET_ROOTFS_CPIO_XZ=y