|
1 | 1 | #!/bin/bash |
2 | | -# We use the immutable filesystem attribute as a workaround for the fact that |
3 | | -# the build scripts are not currently idempotent. |
4 | 2 |
|
5 | | -# The fact that the package is marked immutable means that it has been built |
6 | | -# for release. |
7 | | - |
8 | | -if ! lsattr $PREPKG | cut -f 1 -d" " | grep -q i ; then |
9 | | - |
10 | | - if [ -f $PREPKG ] ; then |
11 | | - echo $PREPKG is not immutable, rebuilding it for release! |
12 | | - else |
13 | | - echo building $PREPKG for the first time... |
14 | | - fi |
15 | | - |
16 | | - if ! release-utils/make-eff-zip.sh $GITTAG ; then |
17 | | - echo "Failed to build target $GITTAG" |
18 | | - exit 1 |
19 | | - fi |
20 | | - |
21 | | - if ! [ -f "$PREPKG" -a -f "$PREPKGCWS" ] ; then |
22 | | - echo "Failed to find package $PREPKG after build" |
23 | | - exit 1 |
24 | | - fi |
25 | | - |
26 | | - # Verification and testing of build goes here! |
27 | | - |
28 | | - echo Marking $PREPKG immutable... |
29 | | - if ! sudo true ; then |
30 | | - echo "Failed to sudo :(" |
31 | | - exit 1 |
32 | | - fi |
33 | | - if ! sudo chattr +i $PREPKG $PREPKGCWS; then |
34 | | - echo "" |
35 | | - echo "WARNING: FAILED TO MARK $PREPKG or $PREPKGCWS IMMUTABLE." |
36 | | - echo "DO NOT RERUN THIS SCRIPT AFTER SIGNING" |
37 | | - echo "" |
38 | | - read -p "(Press Enter to acknowledge)" |
39 | | - fi |
40 | | - chmod a-w $PREPKG |
41 | | -else |
42 | | - echo "$PREPKG is immutable; good, not rebuilding it..." |
| 3 | +if [ $# -ne 3 ]; then |
| 4 | + echo "$0 TAG KEY DESTINATION" |
| 5 | + exit |
43 | 6 | fi |
44 | 7 |
|
45 | | -function sayhash { # $1 <-- HASH ; $2 <---SIGFILEBALL |
46 | | - echo "Generating hash for CHROME" |
47 | | - while read -p "Please enter a pastebin ID once the signature is pasted, or press Enter to read the hash aloud: " INP && [ "$INP" = "" ] ; do |
48 | | - cat $1 | (echo "(Parameter.set 'Duration_Stretch 1.5)"; \ |
49 | | - echo -n '(SayText "'; \ |
50 | | - sha1sum | sed 's/\(.\{5\}\)/\1./g' | cut -c1-48 | fold -1 | sed 's/^a$/alpha/; s/^b$/bravo/; s/^c$/charlie/; s/^d$/delta/; s/^e$/echo/; s/^f$/foxtrot/; s/^9$/niner/; s/^8$/ate/'; \ |
51 | | - echo '")' ) | festival |
52 | | - done |
53 | | - if [ $INP = "skip" ] ; then |
54 | | - return |
55 | | - fi |
56 | | - if ! wget "http://pastebin.com/raw?i=$INP" --output-document="$2" ; then |
57 | | - echo "Failed to wget http://pastebin.com/raw?i=$INP" |
58 | | - exit 1 |
59 | | - fi |
60 | | -} |
61 | | - |
62 | | -function offlinesign { # $1 <-- PREPKG ; $2 <---SIGFILE |
63 | | - echo HASH FOR SIGNING: |
64 | | - SIGFILEBALL="$2.lzma.base64" |
65 | | - #echo "(place the resulting raw binary signature in $SIGFILEBALL)" |
66 | | - sha1sum $1 |
67 | | - echo metahash for confirmation only $(sha1sum $1 |cut -d' ' -f1 | tr -d '\n' | sha1sum | cut -c1-6) ... |
68 | | - echo |
69 | | - sayhash $1 $SIGFILEBALL |
70 | | -} |
71 | | - |
72 | | -# let the user sign both things before putting them on the filesystem |
73 | | -function oncesigned { |
74 | | - SIGFILEBALL="$2.lzma.base64" |
75 | | - cat $SIGFILEBALL | tr -d '\r' | base64 -d | unlzma -c > $2 || exit 1 |
76 | | - if ! [ -f $2 ] ; then |
77 | | - echo "Failed to find $2"'!' |
78 | | - exit 1 |
79 | | - fi |
80 | | - |
81 | | - if file $2 | grep -qv " data" ; then |
82 | | - echo "WARNING WARNING $2 does not look like a binary signature:" |
83 | | - echo `file $2` |
84 | | - #exit 1 |
85 | | - fi |
86 | | -} |
87 | | - |
88 | | - |
89 | | -#offlinesign $PREPKG $SIGFILE |
90 | | -offlinesign $PREPKGCWS $SIGFILECWS |
91 | | - |
92 | | -#oncesigned $PREPKG $SIGFILE |
93 | | -oncesigned $PREPKGCWS $SIGFILECWS |
94 | | - |
95 | | - |
96 | | -UPDATETMP=pkg/$UPDATEFILE |
97 | | -#unzip -p $PREPKG $UPDATEFILE > $UPDATETMP |
98 | | -sed -e "s/VERSION/$TARGET/g" release-utils/updates-master.xml > $UPDATETMP |
99 | | - |
100 | | -MENTIONS=`grep $TARGET $UPDATETMP | wc -l` |
101 | | -if [ $MENTIONS -eq 0 ] ; then |
102 | | - echo $UPDATEFILE inside $PREPKG does not appear to specify an upgrade to $TARGET |
103 | | - exit 1 |
104 | | -elif [ $MENTIONS -ne 1 ] ; then |
105 | | - echo $UPDATEFILE inside $PREPKG contains $TARGET a strange number of times "($MENTIONS)" |
106 | | - exit 1 |
107 | | -fi |
| 8 | +SUBDIR=checkout |
| 9 | +[ -d $SUBDIR ] && rm -rf $SUBDIR |
| 10 | +mkdir $SUBDIR |
| 11 | +cp -r -f -a .git $SUBDIR |
| 12 | +cd $SUBDIR |
| 13 | +git reset --hard "$1" |
108 | 14 |
|
109 | | -function combinetocrx { # $1 <- PREPKG $2 <- SIGFILE $3 <-POSTPKG |
110 | | - if ! release-utils/make-eff-crx-from-zip.sh $1 $2 ; then |
111 | | - echo failed to make signed $3 |
112 | | - exit 1 |
113 | | - fi |
114 | | - if ! [ -f $3 ] ; then |
115 | | - echo $3 mysteriously does not exist |
116 | | - exit 1 |
117 | | - fi |
118 | | -} |
| 15 | +# clean up |
| 16 | +rm -rf src/tests # remove unit tests |
| 17 | +rm src/data/dnt-policy.txt # only used by unit tests |
| 18 | +cp LICENSE src/ # include LICENSE in build |
119 | 19 |
|
120 | | -#combinetocrx $PREPKG $SIGFILE $POSTPKG |
121 | | -combinetocrx $PREPKGCWS $SIGFILECWS $POSTPKGCWS |
| 20 | +echo "Building chrome version" "$1" |
122 | 21 |
|
| 22 | +chromium --pack-extension="src/" --pack-extension-key="$2" |
| 23 | +cd - |
| 24 | +mv checkout/src.crx $3 |
| 25 | +rm -rf checkout |
0 commit comments