Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(478)

Unified Diff: scripts/image_signing/common.sh

Issue 3066034: Add a script to generate builds signed using the official keys. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: . Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/image_signing/customize_image.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/image_signing/common.sh
diff --git a/scripts/image_signing/common.sh b/scripts/image_signing/common.sh
new file mode 100644
index 0000000000000000000000000000000000000000..0d15cb4f2e4a354d906ab81b5151ee6ab8c69add
--- /dev/null
+++ b/scripts/image_signing/common.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Determine script directory
+SCRIPT_DIR=$(dirname $0)
+GPT=cgpt
+
+# Read GPT table to find the starting location of a specific partition.
+# Args: DEVICE PARTNUM
+# Returns: offset (in sectors) of partition PARTNUM
+partoffset() {
+ sudo $GPT show -b -i $2 $1
+}
+
+# Read GPT table to find the size of a specific partition.
+# Args: DEVICE PARTNUM
+# Returns: size (in sectors) of partition PARTNUM
+partsize() {
+ sudo $GPT show -s -i $2 $1
+}
+
+# Mount a partition from an image into a local directory
+# Args: IMAGE PARTNUM MOUNTDIRECTORY
+mount_image_partition() {
+ local image=$1
+ local partnum=$2
+ local mount_dir=$3
+ local offset=$(partoffset "$image" "$partnum")
+ sudo mount -o loop,offset=$((offset * 512)) "$image" "$mount_dir"
+}
+
+# Extract a partition to a file
+# Args: IMAGE PARTNUM OUTPUTFILE
+extract_image_partition() {
+ local image=$1
+ local partnum=$2
+ local output_file=$3
+ local offset=$(partoffset "$image" "$partnum")
+ local size=$(partsize "$image" "$partnum")
+ dd if=$image of=$output_file bs=512 skip=$offset count=$size
+}
+
« no previous file with comments | « no previous file | scripts/image_signing/customize_image.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698