diff options
6 files changed, 65 insertions, 0 deletions
diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb index bdd8934aa..ebb23a1f8 100644 --- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb +++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager.bb @@ -51,4 +51,5 @@ SYSTEMD_SERVICE_${PN} += " \ obmc-flash-bios-ubiremount.service \ obmc-flash-bios-updatesymlinks.service \ obmc-flash-bios-ubiclear@.service \ + obmc-flash-bios-cleanup.service \ " diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios index 948c6ec05..6e4aa78cf 100644 --- a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios +++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios @@ -270,6 +270,27 @@ clear_ubi() { fi } +ubi_cleanup() { + # When ubi_cleanup is run, it expects one or no active version. + activeVersion=$(busctl --list --no-pager tree \ + org.open_power.Software.Host.Updater | \ + grep /xyz/openbmc_project/software/ | tail -c 9) + + if [[ -z "$activeVersion" ]]; then + vols=$(ubinfo -a | grep -e "pnor-ro-" -e "pnor-rw-" | cut -c 14-) + vols=(${vols}) + else + vols=$(ubinfo -a | grep -e "pnor-ro-" -e "pnor-rw-" | \ + grep -v "$activeVersion" | cut -c 14-) + vols=(${vols}) + fi + + for (( index=0; index<${#vols[@]}; index++ )); do + name=${vols[index]} + umount_ubi + done +} + case "$1" in ubiattach) attach_ubi @@ -297,6 +318,9 @@ case "$1" in name="$2" clear_ubi ;; + ubicleanup) + ubi_cleanup + ;; *) echo "Invalid argument" exit 1 diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-cleanup.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-cleanup.service new file mode 100644 index 000000000..07642a0e0 --- /dev/null +++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-cleanup.service @@ -0,0 +1,8 @@ +[Unit] +Description=Clean up UBI volumes unattached to a Host version + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/usr/bin/env obmc-flash-bios ubicleanup +SyslogIdentifier=obmc-flash-bios diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb index 0dc4dfd2d..fb24ee938 100644 --- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager.bb @@ -77,6 +77,7 @@ SYSTEMD_SERVICE_${PN}-updater += " \ obmc-flash-bmc-updateubootvars@.service \ reboot-guard-enable.service \ reboot-guard-disable.service \ + obmc-flash-bmc-cleanup.service \ " # Name of the mtd device where the ubi volumes should be created diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc index d8eed5732..2025a05f3 100644 --- a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc @@ -192,6 +192,26 @@ ubi_remove() { fi } +ubi_cleanup() { + # When ubi_cleanup is run, it expects one or no active version. + activeVersion=$(busctl --list --no-pager tree \ + xyz.openbmc_project.Software.BMC.Updater | \ + grep /xyz/openbmc_project/software/ | tail -c 9) + + if [[ -z "$activeVersion" ]]; then + vols=$(ubinfo -a | grep -e "kernel-" -e "rofs-" | cut -c 14-) + vols=(${vols}) + else + vols=$(ubinfo -a | grep -e "kernel-" -e "rofs-" | \ + grep -v "$activeVersion" | cut -c 14-) + vols=(${vols}) + fi + + for (( index=0; index<${#vols[@]}; index++ )); do + ubi_remove ${vols[index]} + done +} + remount_ubi() { bmcmtd="$(findmtd "bmc")" altbmcmtd="$(findmtd "alt-bmc")" @@ -346,6 +366,9 @@ case "$1" in name="$2" ubi_remove "${name}" ;; + ubicleanup) + ubi_cleanup + ;; ubisetenv) ubi_setenv "$2" ;; diff --git a/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-cleanup.service b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-cleanup.service new file mode 100644 index 000000000..41769a4dd --- /dev/null +++ b/meta-phosphor/common/recipes-phosphor/flash/phosphor-software-manager/obmc-flash-bmc-cleanup.service @@ -0,0 +1,8 @@ +[Unit] +Description=Clean up UBI volumes unattached to a BMC version + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/usr/bin/env obmc-flash-bmc ubicleanup +SyslogIdentifier=obmc-flash-bmc |