summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdriana Kobylak <anoo@us.ibm.com>2019-10-08 11:35:55 -0500
committerAdriana Kobylak <anoo@us.ibm.com>2019-10-25 09:20:20 -0500
commitf3dfe65de8487364c21b7b49396cf912821ea339 (patch)
tree97117eca8fcb20c478dfbffa9d7d0a45b9246198
parent85f25407598494d8f91890df5152501680a067dd (diff)
downloadopenpower-pnor-code-mgmt-f3dfe65de8487364c21b7b49396cf912821ea339.tar.gz
openpower-pnor-code-mgmt-f3dfe65de8487364c21b7b49396cf912821ea339.zip
Move updatesymlinks to new vpnor feature
The updatesymlinks functionality is to support virtual pnor and it does not depend on the filesystem type. Move it to a new vpnor feature so that users can make use of this feature without being tied to UBI, for example on a eMMC that has a combined BMC+PNOR image. Tested: Verified that the witherspoon image contained the new script and service file and that it powered on to the host. Change-Id: Ic5e51dfde81718e5e285f010be67afbd58eac2e1 Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
-rwxr-xr-xMakefile.am5
-rwxr-xr-xconfigure.ac6
-rw-r--r--ubi/Makefile.am.include5
-rw-r--r--ubi/obmc-flash-bios62
-rw-r--r--vpnor/Makefile.am.include7
-rw-r--r--vpnor/obmc-vpnor-updatesymlinks.service (renamed from ubi/obmc-flash-bios-updatesymlinks.service)2
-rw-r--r--vpnor/obmc-vpnor-util75
7 files changed, 96 insertions, 66 deletions
diff --git a/Makefile.am b/Makefile.am
index 11e5a96b2..fc31b9f50 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,8 @@ AM_DEFAULT_SOURCE_EXT = .cpp
ACLOCAL_AMFLAGS = -Im4
+dist_bin_SCRIPTS =
+
bin_PROGRAMS = \
openpower-update-manager \
openpower-pnor-msl
@@ -34,6 +36,9 @@ openpower_update_manager_SOURCES += \
image_verify.cpp
endif
+if VIRTUAL_PNOR_ENABLED
+include vpnor/Makefile.am.include
+endif
openpower_pnor_msl_SOURCES = \
msl_verify.cpp \
diff --git a/configure.ac b/configure.ac
index b43e50d2f..07cc7de8b 100755
--- a/configure.ac
+++ b/configure.ac
@@ -116,6 +116,12 @@ AS_IF([test "x$enable_verify_pnor_signature" == "xyes"], \
[AC_DEFINE([WANT_SIGNATURE_VERIFY],[],[Enable image signature validation.])])
AM_CONDITIONAL([WANT_SIGNATURE_VERIFY_BUILD], [test "x$enable_verify_pnor_signature" == "xyes"])
+# setup virtual pnor support
+AC_ARG_ENABLE([virtual-pnor],
+ AS_HELP_STRING([--enable-virtual-pnor], [Enable support for virtual pnor])
+)
+AM_CONDITIONAL([VIRTUAL_PNOR_ENABLED], [test "x$enable_virtual_pnor" == "xyes"])
+
AC_DEFINE(CHASSIS_STATE_PATH, "/xyz/openbmc_project/state/chassis0",
[The chassis state path.])
AC_DEFINE(CHASSIS_STATE_OBJ, "xyz.openbmc_project.State.Chassis",
diff --git a/ubi/Makefile.am.include b/ubi/Makefile.am.include
index 98ea30119..2e5b6e50e 100644
--- a/ubi/Makefile.am.include
+++ b/ubi/Makefile.am.include
@@ -4,7 +4,7 @@ openpower_update_manager_SOURCES += \
%reldir%/serialize.cpp \
%reldir%/watch.cpp
-dist_bin_SCRIPTS = \
+dist_bin_SCRIPTS += \
%reldir%/obmc-flash-bios
if HAVE_SYSTEMD
@@ -17,6 +17,5 @@ systemdsystemunit_DATA += \
%reldir%/obmc-flash-bios-ubipatch.service \
%reldir%/obmc-flash-bios-ubiremount.service \
%reldir%/obmc-flash-bios-ubiumount-ro@.service \
- %reldir%/obmc-flash-bios-ubiumount-rw@.service \
- %reldir%/obmc-flash-bios-updatesymlinks.service
+ %reldir%/obmc-flash-bios-ubiumount-rw@.service
endif
diff --git a/ubi/obmc-flash-bios b/ubi/obmc-flash-bios
index ff8818518..b15ddc698 100644
--- a/ubi/obmc-flash-bios
+++ b/ubi/obmc-flash-bios
@@ -207,65 +207,6 @@ 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"
- PERSISTENCE_PATH="/var/lib/obmc/openpower-pnor-code-mgmt/"
- PNOR_PATCH_LOCATION="/usr/local/share/pnor/"
-
- # Get a list of all active PNOR versions
- data="$(ls -d ${PNOR_RO_PREFIX}*)"
- IFS=$'\n' array=(${data})
-
- currentVersion=""
- lowestPriority=255
- for element in ${array[@]}; do
- #Remove the PNOR_RO_PREFIX from the path to get version ID.
- versionId="${element#${PNOR_RO_PREFIX}}"
-
- # Get the priority of active versions from persistence files.
- if [[ -f "${PERSISTENCE_PATH}${versionId}" ]]; then
- data="$(grep -r "priority" ${PERSISTENCE_PATH}${versionId})"
- priority="${data: -1}"
- if [[ priority -le lowestPriority ]]; then
- lowestPriority=${priority}
- currentVersion=${versionId}
- fi
- fi
- done
-
- # Return if no active version found
- if [ -z $currentVersion ]; then
- return 0;
- fi
-
- 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}
- rm -rf ${PNOR_PATCH_LOCATION}*
- 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
-}
-
ubi_cleanup() {
# When ubi_cleanup is run, it expects one or no active version.
activeVersion=$(busctl --list --no-pager tree \
@@ -341,9 +282,6 @@ case "$1" in
ubiremount)
remount_ubi
;;
- updatesymlinks)
- update_symlinks
- ;;
ubicleanup)
ubi_cleanup
;;
diff --git a/vpnor/Makefile.am.include b/vpnor/Makefile.am.include
new file mode 100644
index 000000000..49d9c1afe
--- /dev/null
+++ b/vpnor/Makefile.am.include
@@ -0,0 +1,7 @@
+dist_bin_SCRIPTS += \
+ %reldir%/obmc-vpnor-util
+
+if HAVE_SYSTEMD
+systemdsystemunit_DATA += \
+ %reldir%/obmc-vpnor-updatesymlinks.service
+endif
diff --git a/ubi/obmc-flash-bios-updatesymlinks.service b/vpnor/obmc-vpnor-updatesymlinks.service
index d486088ec..8184f51f6 100644
--- a/ubi/obmc-flash-bios-updatesymlinks.service
+++ b/vpnor/obmc-vpnor-updatesymlinks.service
@@ -9,7 +9,7 @@ ConditionPathExists=!/run/openbmc/chassis@0-on
[Service]
Type=oneshot
RemainAfterExit=no
-ExecStart=/usr/bin/obmc-flash-bios updatesymlinks
+ExecStart=/usr/bin/obmc-vpnor-util updatesymlinks
[Install]
WantedBy=mboxd.service mboxd-reload@.service
diff --git a/vpnor/obmc-vpnor-util b/vpnor/obmc-vpnor-util
new file mode 100644
index 000000000..25e67265b
--- /dev/null
+++ b/vpnor/obmc-vpnor-util
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+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"
+ PERSISTENCE_PATH="/var/lib/obmc/openpower-pnor-code-mgmt/"
+ PNOR_PATCH_LOCATION="/usr/local/share/pnor/"
+
+ # Get a list of all active PNOR versions
+ data="$(ls -d ${PNOR_RO_PREFIX}*)"
+ IFS=$'\n' array=(${data})
+
+ currentVersion=""
+ lowestPriority=255
+ for element in ${array[@]}; do
+ #Remove the PNOR_RO_PREFIX from the path to get version ID.
+ versionId="${element#${PNOR_RO_PREFIX}}"
+
+ # Get the priority of active versions from persistence files.
+ if [[ -f "${PERSISTENCE_PATH}${versionId}" ]]; then
+ data="$(grep -r "priority" ${PERSISTENCE_PATH}${versionId})"
+ priority="${data: -1}"
+ if [[ priority -le lowestPriority ]]; then
+ lowestPriority=${priority}
+ currentVersion=${versionId}
+ fi
+ fi
+ done
+
+ # Return if no active version found
+ if [ -z $currentVersion ]; then
+ return 0;
+ fi
+
+ 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}
+ rm -rf ${PNOR_PATCH_LOCATION}*
+ 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
+ updatesymlinks)
+ update_symlinks
+ ;;
+ *)
+ echo "Invalid argument"
+ exit 1
+ ;;
+esac
+rc=$?
+if [ ${rc} -ne 0 ]; then
+ echo "$0: error ${rc}"
+ exit ${rc}
+fi
OpenPOWER on IntegriCloud