diff options
author | Saqib Khan <khansa@us.ibm.com> | 2017-08-02 12:48:12 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-08-15 19:47:58 +0000 |
commit | fa92e97a27dcd2ac20bf3d47ba95e037f386ef05 (patch) | |
tree | 32cd7ef80187476a12ae8c16b51b74fdd3b660cc /meta-openbmc-machines | |
parent | 8bcbb91411d3eea942eba23c460c075f447ca582 (diff) | |
download | talos-openbmc-fa92e97a27dcd2ac20bf3d47ba95e037f386ef05.tar.gz talos-openbmc-fa92e97a27dcd2ac20bf3d47ba95e037f386ef05.zip |
PNOR: Create a service file for updating symlinks.
- Replace the functionality of updating the symlinks
under openpower-pnor-code-mgmt to a service file.
- The new service has a dependency on mboxd.service.
This allows us to only defer the symlink creation/update
until the mboxd.service is started, which prevents
symlink updates while HOST is running.
Change-Id: I8542aa24a9058af9560a32eec5140ff5ddee60d1
Signed-off-by: Saqib Khan <khansa@us.ibm.com>
Diffstat (limited to 'meta-openbmc-machines')
3 files changed, 63 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 505250cb9..a463bd686 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 @@ -49,4 +49,5 @@ SYSTEMD_SERVICE_${PN} += " \ obmc-flash-bios-ubipatch.service \ obmc-flash-bios-squashfsmount@.service \ obmc-flash-bios-ubiremount.service \ + obmc-flash-bios-updatesymlinks.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 07931b6ec..b365b79b6 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 @@ -180,6 +180,56 @@ remount_ubi() { done } +update_symlinks() { + PNOR_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/" + PNOR_RO_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/ro" + PNOR_RO_PREFIX="/media/pnor-ro-" + PNOR_RW_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/rw" + PNOR_RW_PREFIX="/media/pnor-rw-" + PNOR_PRSV_ACTIVE_PATH="/var/lib/phosphor-software-manager/pnor/prsv" + PNOR_PRSV="/media/pnor-prsv" + + # Get the current PNOR version using the priorities stored in + # the persistence storage files. + persistencePath="/var/lib/obmc/openpower-pnor-code-mgmt/" + data="$(grep -r "priority" ${persistencePath})" + if [[ -z "$data" ]]; then + return 0; + fi + IFS=$'\n' array=(${data}) + for element in ${array[@]}; + do + element="${element#$persistencePath}" + version="$( cut -d ':' -f 1 <<< "$element" )"; + priority="${element: -1}" + + if [[ priority -le lowestPriority ]]; then + lowestPriority=${priority} + currentVersion=${version} + fi + done + + if [ ! -d "${PNOR_ACTIVE_PATH}" ]; then + mkdir -p "${PNOR_ACTIVE_PATH}" + fi + + # If the RW or RO active links doesn't point to the version with + # lowest priority, then remove the symlink and create new ones. + if [[ $(readlink -f "${PNOR_RO_ACTIVE_PATH}") != ${PNOR_RO_PREFIX}${currentVersion} ]]; then + rm -f ${PNOR_RO_ACTIVE_PATH} + ln -sfv ${PNOR_RO_PREFIX}${currentVersion} ${PNOR_RO_ACTIVE_PATH} + fi + + if [[ $(readlink -f "${PNOR_RW_ACTIVE_PATH}") != ${PNOR_RW_PREFIX}${currentVersion} ]]; then + rm -f ${PNOR_RW_ACTIVE_PATH} + ln -sfv ${PNOR_RW_PREFIX}${currentVersion} ${PNOR_RW_ACTIVE_PATH} + fi + + if [[ ! -h ${PNOR_PRSV_ACTIVE_PATH} ]]; then + ln -sfv ${PNOR_PRSV} ${PNOR_PRSV_ACTIVE_PATH} + fi +} + case "$1" in ubiattach) attach_ubi @@ -200,6 +250,9 @@ case "$1" in ubiremount) remount_ubi ;; + updatesymlinks) + update_symlinks + ;; *) echo "Invalid argument" exit 1 diff --git a/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-updatesymlinks.service b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-updatesymlinks.service new file mode 100644 index 000000000..a7e2b7a9e --- /dev/null +++ b/meta-openbmc-machines/meta-openpower/common/recipes-phosphor/flash/openpower-software-manager/obmc-flash-bios-updatesymlinks.service @@ -0,0 +1,9 @@ +[Unit] +Description=Updates symlinks for active PNOR version + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart={sbindir}/obmc-flash-bios updatesymlinks + +WantedBy=mboxd.service mboxd-reload@.service |