[Replicant] [vendor_replicant] [PATCH] Update key-migration.sh to sync with vendor_replicant-scripts

Denis 'GNUtoo' Carikli GNUtoo at cyberdimension.org
Sun Oct 11 18:07:46 UTC 2020


The gen_key_migration_script script was modified to generate a
key-migration.sh script that can run multiple times.

So we need to update the generated script as well for the change
to be taken into account.

This modified version was generated with the following command in
the top directory of the replicant-6.0 source code:
    $ ./vendor/replicant-scripts/images/gen_key_migration_script/gen_key_migration_script.py \
      gen-script \
      vendor/replicant/prebuilt/common/bin/key-migration.sh \
      vendor/replicant-data/distros/releases/certificates/ \
      vendor/replicant-security/

Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
 prebuilt/common/bin/key-migration.sh | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/prebuilt/common/bin/key-migration.sh b/prebuilt/common/bin/key-migration.sh
index 9f04960b..8b537367 100644
--- a/prebuilt/common/bin/key-migration.sh
+++ b/prebuilt/common/bin/key-migration.sh
@@ -14,9 +14,19 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+get_git_blob_hash()
+{
+    path="$1"
+
+    # We need to do a sha1sum of 'blob <size>\0<file content>' without
+    # introducing new newlines.
+    { printf 'blob %s\0' $(wc -c < ${path}); cat ${path}; } | \
+	sha1sum | awk '{print $1}'
+}
+
 PACKAGES=/data/system/packages.xml
 PACKAGES_BACKUP=/data/system/packages-backup.xml
-MIGRATION_DONE=/data/system/.key-migration-done
+MIGRATION_DONE="/data/system/.key-migration-$(get_git_blob_hash $(realpath ${0}))-done"
 
 if [ -f ${MIGRATION_DONE} ]; then
 	exit 0
-- 
2.28.0



More information about the Replicant mailing list