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>
diff --git a/ubi/Makefile.am.include b/ubi/Makefile.am.include
index 98ea301..2e5b6e5 100644
--- a/ubi/Makefile.am.include
+++ b/ubi/Makefile.am.include
@@ -4,7 +4,7 @@
 	%reldir%/serialize.cpp \
 	%reldir%/watch.cpp
 
-dist_bin_SCRIPTS = \
+dist_bin_SCRIPTS += \
 	%reldir%/obmc-flash-bios
 
 if HAVE_SYSTEMD
@@ -17,6 +17,5 @@
 	%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 ff88185..b15ddc6 100644
--- a/ubi/obmc-flash-bios
+++ b/ubi/obmc-flash-bios
@@ -207,65 +207,6 @@
   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 @@
   ubiremount)
     remount_ubi
     ;;
-  updatesymlinks)
-    update_symlinks
-    ;;
   ubicleanup)
     ubi_cleanup
     ;;
diff --git a/ubi/obmc-flash-bios-updatesymlinks.service b/ubi/obmc-flash-bios-updatesymlinks.service
deleted file mode 100644
index d486088..0000000
--- a/ubi/obmc-flash-bios-updatesymlinks.service
+++ /dev/null
@@ -1,15 +0,0 @@
-[Unit]
-Description=Updates symlinks for active PNOR version
-Before=mboxd.service
-Before=mboxd-reload@0.service
-After=org.open_power.Software.Host.Updater.service
-After=op-reset-chassis-running@0.service
-ConditionPathExists=!/run/openbmc/chassis@0-on
-
-[Service]
-Type=oneshot
-RemainAfterExit=no
-ExecStart=/usr/bin/obmc-flash-bios updatesymlinks
-
-[Install]
-WantedBy=mboxd.service mboxd-reload@.service