Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions makecrx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ VERSION=`python -c "import json ; print(json.loads(open('chromium/manifest.json'
echo "Building chrome version" $VERSION

if [ -f utils/trivial-validate.py ]; then
VALIDATE="./utils/trivial-validate.py --ignoredups google --ignoredups facebook"
VALIDATE="./utils/trivial-validate.py --ignoredups google --ignoredups facebook"
elif [ -x utils/trivial-validate ] ; then
# This case probably never happens
VALIDATE=./utils/trivial-validate
VALIDATE=./utils/trivial-validate
else
VALIDATE=./trivial-validate
VALIDATE=./trivial-validate
fi

if $VALIDATE src/chrome/content/rules >&2
Expand All @@ -54,7 +54,8 @@ else
exit 1
fi

if [ -f utils/relaxng.xml -a -x "$(which xmllint)" ] >&2
command -v xmllint > /dev/null
if [ "$?" -eq 0 -a -f utils/relaxng.xml ] >&2
then
# Use find and xargs to avoid "too many args" error on Mac OS X
if find src/chrome/content/rules/ -name "*.xml" | xargs xmllint --noout --relaxng utils/relaxng.xml
Expand Down Expand Up @@ -117,7 +118,7 @@ trap 'rm -f "$pub" "$sig" "$zip"' EXIT
# zip up the crx dir
cwd=$(pwd -P)
(cd "$dir" && ../../utils/create_xpi.py -n "$cwd/$zip" -x "../../.build_exclusions" .)
echo >&2 "Unsigned package has shasum: `shasum "$cwd/$zip"`"
echo >&2 "Unsigned package has shasum: `openssl dgst -sha1 "$cwd/$zip" | cut -d ' ' -f 2`"

# signature
openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig"
Expand Down
33 changes: 16 additions & 17 deletions makexpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ RULESETS_SQLITE="$PWD/src/defaults/rulesets.sqlite"

# If the command line argument is a tag name, check that out and build it
if [ -n "$1" ] && [ "$2" != "--no-recurse" ] && [ "$1" != "--fast" ] ; then
BRANCH=`git branch | head -n 1 | cut -d \ -f 2-`
SUBDIR=checkout
[ -d $SUBDIR ] || mkdir $SUBDIR
cp -r -f -a .git $SUBDIR
cd $SUBDIR
git reset --hard "$1"
BRANCH=`git branch | head -n 1 | cut -d \ -f 2-`
SUBDIR=checkout
[ -d $SUBDIR ] || mkdir $SUBDIR
cp -r -f -a .git $SUBDIR
cd $SUBDIR
git reset --hard "$1"
# This is an optimization to get the OS reading the rulesets into RAM ASAP;
# it's useful on machines with slow disk seek times; there might be something
# better (vmtouch? readahead?) that tells the IO subsystem to read the files
Expand All @@ -42,7 +42,7 @@ if [ -n "$1" ] && [ "$2" != "--no-recurse" ] && [ "$1" != "--fast" ] ; then

# Now escape from the horrible mess we've made
cd ..
XPI_NAME="$APP_NAME-$1.xpi"
XPI_NAME="$APP_NAME-$1.xpi"
# In this mad recursive situation, sometimes old buggy build scripts make
# the xpi as ./pkg :(
if ! cp $SUBDIR/pkg/$XPI_NAME pkg/ ; then
Expand All @@ -63,9 +63,7 @@ nohup cat src/chrome/content/rules/*.xml >/dev/null 2>/dev/null &

if [ "$1" != "--fast" ] ; then
if [ -f utils/trivial-validate.py ]; then
VALIDATE="python2.7 ./utils/trivial-validate.py --ignoredups google --ignoredups facebook"
elif [ -f trivial-validate.py ] ; then
VALIDATE="python2.7 trivial-validate.py --ignoredups google --ignoredups facebook"
VALIDATE="./utils/trivial-validate.py --ignoredups google --ignoredups facebook"
elif [ -x utils/trivial-validate ] ; then
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the purpose of this line is to allow using a recent makexpi to build an older release, but I'm not sure. @pde, do you know?

In any case, please leave the python2.7 call as-is. There was an earlier issue filed where someone explained how it's slightly more secure to call python explicitly when you can.

# This case probably never happens
VALIDATE=./utils/trivial-validate
Expand All @@ -82,7 +80,8 @@ if [ "$1" != "--fast" ] ; then
exit 1
fi

if [ -f utils/relaxng.xml -a -x "$(which xmllint)" ] >&2
command -v xmllint > /dev/null
if [ "$?" -eq 0 -a -f utils/relaxng.xml ] >&2
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better expressed as:

if command -v xmllint > /dev/null && [ -f utils/relaxng.xml ]

You can drop the >&2.

then
if find src/chrome/content/rules -name "*.xml" | xargs xmllint --noout --relaxng utils/relaxng.xml
then
Expand Down Expand Up @@ -110,15 +109,15 @@ fi

if [ "$1" != "--fast" -o ! -f "$RULESETS_SQLITE" ] ; then
echo "Generating sqlite DB"
python2.7 ./utils/make-sqlite.py src/chrome/content/rules
./utils/make-sqlite.py src/chrome/content/rules
fi

# The name/version of the XPI we're building comes from src/install.rdf
XPI_NAME="pkg/$APP_NAME-`grep em:version src/install.rdf | sed -e 's/[<>]/ /g' | cut -f3`"
if [ "$1" ] && [ "$1" != "--fast" ] ; then
XPI_NAME="$XPI_NAME.xpi"
XPI_NAME="$XPI_NAME.xpi"
else
XPI_NAME="$XPI_NAME~pre.xpi"
XPI_NAME="$XPI_NAME~pre.xpi"
fi

[ -d pkg ] || mkdir pkg
Expand All @@ -127,7 +126,7 @@ fi
GIT_OBJECT_FILE=".git/refs/heads/master"
export GIT_COMMIT_ID="HEAD"
if [ -e "$GIT_OBJECT_FILE" ]; then
export GIT_COMMIT_ID=$(cat "$GIT_OBJECT_FILE")
export GIT_COMMIT_ID=$(cat "$GIT_OBJECT_FILE")
fi

cd src
Expand All @@ -136,10 +135,10 @@ cd src
rm -f "../$XPI_NAME"
#zip -q -X -9r "../$XPI_NAME" . "-x@../.build_exclusions"

python2.7 ../utils/create_xpi.py -n "../$XPI_NAME" -x "../.build_exclusions" "."
../utils/create_xpi.py -n "../$XPI_NAME" -x "../.build_exclusions" "."

ret="$?"
if [ "$ret" != 0 ]; then
if [ "$ret" -ne 0 ]; then
rm -f "../$XPI_NAME"
exit "$?"
else
Expand Down
2 changes: 1 addition & 1 deletion utils/create_xpi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/env python2.7

# Uses the Python zip implementation to create deterministic XPI's
# Author: Yan Zhu, yan@mit.edu
Expand Down
2 changes: 1 addition & 1 deletion utils/make-sqlite.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/env python2.7
#
# Builds an sqlite DB containing all the rulesets, indexed by target.

Expand Down
2 changes: 1 addition & 1 deletion utils/trivial-validate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/env python2.7

import argparse
import sys, re, os
Expand Down