From 305d1da29133f2dbc2160f0cd430601794e2c9ca Mon Sep 17 00:00:00 2001
From: Patrick Ohly <patrick.ohly@intel.com>
Date: Mon, 23 Mar 2015 15:03:40 -0700
Subject: [PATCH 2/2] cynara-db-migration: sysroot support

This is a first step towards running the script on a build host
when creating an image with Bitbake and OpenEmbedded. Creating
the database works, creating the checksums does not because
the target's cynara-db-chsgen will not run. Further work is
needed to select a cynara-db-chsgen on the host.

Upstream-status: Inappropriate [embedded specific]

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
 migration/cynara-db-migration | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/migration/cynara-db-migration b/migration/cynara-db-migration
index f6e7f94..24d9e9a 100644
--- a/migration/cynara-db-migration
+++ b/migration/cynara-db-migration
@@ -23,7 +23,10 @@ set -e
 
 ##### Constants (these must not be modified by shell)
 
-STATE_PATH='/var/cynara'
+# sysroot support via OpenEmbedded's D variable.
+STATE_PATH="$D/var/cynara"
+CYNARA_DB_CHSGEN="$D/usr/sbin/cynara-db-chsgen"
+
 DB_DIR='db'
 INDEX_NAME='buckets'
 DEFAULT_BUCKET_NAME='_'
@@ -145,7 +148,7 @@ generate_checksums() {
     # Actual checksums generation
     for FILE in $(find ${STATE_PATH}/${DB_DIR}/${WILDCARD} -type f ! -name "${CHECKSUM_NAME}*" \
                                                                    ! -name "${GUARD_NAME}"); do
-        CHECKSUM="$(/usr/sbin/cynara-db-chsgen ${FILE})"
+        CHECKSUM="$($CYNARA_DB_CHSGEN ${FILE})"
         if [ 0 -eq $? ] ; then
             echo "${CHECKSUM}" >> ${CHECKSUMS}
         else
-- 
1.8.4.5

