Fix sqlite2 DB operations during the build & small spellchek fix 22/305522/5 accepted/tizen_8.0_unified accepted/tizen_unified accepted/tizen_unified_toolchain accepted/tizen_unified_x tizen tizen_8.0 accepted/tizen/8.0/unified/20240208.163159 accepted/tizen/unified/20240208.163947 accepted/tizen/unified/toolchain/20240311.065521 accepted/tizen/unified/x/20240214.051933
authorTomasz Swierczek <t.swierczek@samsung.com>
Thu, 1 Feb 2024 12:28:10 +0000 (13:28 +0100)
committerTomasz Swierczek <t.swierczek@samsung.com>
Mon, 5 Feb 2024 06:53:27 +0000 (07:53 +0100)
Now, if inserting certificates into DB fails, the shell script
that manages their insertion will cause GBS build to fail too.

Without this change, on Tizen 7.0+ the certs databse of cert-svc
was emtpy, becasue sqlite3 couldn't parse the sql script adding
each certificate AND GBS didn't fail due to the way sh script was
written.

Change-Id: I6a0266936b317a119dbe08fd3817883ab1b2fcec

etc/db/CMakeLists.txt
etc/db/initialize_store_db.sh

index daa819b..74c116d 100644 (file)
@@ -28,7 +28,7 @@ EXECUTE_PROCESS(
        )
 
 IF (${CURRENT_DIGEST} STREQUAL ${CA_BUNDLE_DIGEST})
-       MESSAGE("ca-certificate digest is match with static db.")
+       MESSAGE("ca-certificate digest matches with static db.")
 
        INSTALL(FILES
                resource/certs-meta-0.0.4.db
@@ -37,7 +37,7 @@ IF (${CURRENT_DIGEST} STREQUAL ${CA_BUNDLE_DIGEST})
                )
 
 ELSE (${CURRENT_DIGEST} STREQUAL ${CA_BUNDLE_DIGEST})
-       MESSAGE("${CURRENT_DIGEST} digest is not match with static db.")
+       MESSAGE("${CURRENT_DIGEST} digest does not match with static db.")
        MESSAGE("Add ssl table to certs-meta.db")
 
        EXECUTE_PROCESS(
index 3d1fd63..918a553 100755 (executable)
@@ -54,12 +54,10 @@ function initialize_store_data()
                subject_hash=`openssl x509 -in $fname -subject_hash -noout`
                subject_hash_old=`openssl x509 -in $fname -subject_hash_old -noout`
                common_name=`get_common_name $fname`
-
-               echo "INSERT INTO ssl \
-                               (gname, certificate, file_hash, subject_hash, \
-                               common_name, enabled, is_root_app_enabled) VALUES \
-                               (\"$gname\", \"$cert\", \"$subject_hash\", \"$subject_hash_old\", \
-                               \"$common_name\", 1, 1);" >> $ROOT_CERT_SQL
+               echo "INSERT INTO ssl (gname, certificate, file_hash, subject_hash,\
+common_name, enabled, is_root_app_enabled) VALUES\
+('$gname', '$cert', '$subject_hash', '$subject_hash_old','$common_name', \
+1, 1);" >> $ROOT_CERT_SQL
        done
        echo "END TRANSACTION;" >> $ROOT_CERT_SQL
 }
@@ -69,6 +67,4 @@ touch $ROOT_CERT_SQL
 initialize_store_version
 initialize_store_data
 
-cat $ROOT_CERT_SQL | sqlite3 $DB_PATH
-
-rm $ROOT_CERT_SQL
+sqlite3 $DB_PATH ".read $ROOT_CERT_SQL" && rm $ROOT_CERT_SQL