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

Side by Side Diff: chrome/test/data/extensions/unpacker/bad_path/bad_path.sh

Issue 10870116: Adding binary test files in advance of CL landing, so tryjobs can run (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed copyright notices Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 #!/bin/bash -e
2
3 ## Copyright (c) 2012 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # Purpose: Create a Chromium crx even if paths are invalid.
8 if test $# -ne 2; then
9 echo "Usage: bad_path.sh <extension dir> <pem path>"
10 exit 1
11 fi
12 dir=$1
13 key=$2
14 name=$(basename "$dir")
15 crx="$name.crx"
16 pub="$name.pub"
17 sig="$name.sig"
18 zip="$name.zip"
19 trap 'rm -f "$pub" "$sig" "$zip"' EXIT
20 # zip up the crx dir
21 cwd=$(pwd -P)
22 (cd "$dir" && zip -qr -9 -X "$cwd/$zip" .)
23 # signature
24 openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig"
25 # public key
26 openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null
27 byte_swap () {
28 # Take "abcdefgh" and return it as "ghefcdab"
29 echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}"
30 }
31 crmagic_hex="4372 3234" # Cr24
32 version_hex="0200 0000" # 2
33 pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}')))
34 sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}')))
35 (
36 echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p
37 cat "$pub" "$sig" "$zip"
38 ) > "$crx"
39 echo "Wrote $crx with possibly invalid path"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698