-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchromiumer.sh
More file actions
executable file
·130 lines (105 loc) · 2.7 KB
/
chromiumer.sh
File metadata and controls
executable file
·130 lines (105 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/bin/bash
# much of this is from https://gist.github.com/1093476
log() {
echo " chromium: $1"
}
OS=`uname -s 2>/dev/null`
if [[ "$OS" == "Linux" ]]; then
APP="chrome-linux.zip"
elif [[ "$OS" == "Darwin" ]]; then
OS="Mac"
APP="chrome-mac.zip"
else
log "ERROR"
log "Couldn't figure out the OS or doesn't support it"
exit 1
fi
log "OS type: $OS"
for option in "$@"; do
case ${option} in
-f) FORCE=1;;
-d) DELETE=1;;
-t) TEST=1;;
esac
done
URLBASE="http://commondatastorage.googleapis.com/chromium-browser-continuous/$OS"
DEV="devtools_frontend.zip"
REV=$1
REV="106933" # remove this later
INSTALLPATH="$HOME/.devsync/$REV"
if [ "$DELETE" ]; then
log "Deleting chromium build $REV"
rm -rf "$INSTALLPATH"
exit 0
fi
if [ ! "$REV" ]; then
log "Checking latest Chromium version..."
REV=$(curl -s "$URLBASE/LAST_CHANGE")
if [[ "$REV" =~ ^[0-9]+$ ]]; then
log "Done"
else
log "ERROR"
log "Error loading revision data from $URLBASE/LAST_CHANGE, aborting update."
exit 1
fi
fi
log "Attempting to update Chromium to revision $REV..."
CPATH="$INSTALLPATH/chromium"
DPATH="$INSTALLPATH/devtools"
exec_app() {
if [[ "$OS" == "Linux" ]]; then
BIN="$CPATH/chrome"
elif [[ "$OS" == "Mac" ]]; then
BIN="$CPATH/Chromium.app/Contents/MacOS/Chromium"
fi
log "Executing chrome with patched devtools. bin: $BIN, devtools: $DPATH"
# --remote-debugging-port=9222
"$BIN" --debug-devtools-frontend="$DPATH" &
}
if [[ -d "$CPATH" && -d "$DPATH" && ! "$FORCE" ]]; then
log "Build $REV of chromium already exists"
exec_app
exit 0
fi
TMP=$(mktemp -d "/tmp/chromiumer.XXXXX")
if [[ ! "$TEST" ]]; then
curl "$URLBASE/$REV/{$APP,$DEV}" --progress-bar --location --output "$TMP/#1"
else
cp "/tmp/$APP" "$TMP/$APP"
cp "/tmp/$DEV" "$TMP/$DEV"
fi
if [ ! -f "$TMP/$APP" ]; then
log "Error downloading $APP, aborting update."
rm -rf "$TMP"
exit 1
fi
if [ ! -f "$TMP/$DEV" ]; then
log "Error downloading $DEV, aborting update."
rm -rf "$TMP"
exit 1
fi
log "Deleting existing files..."
rm -rf "$INSTALLPATH"
log "Done"
log "Creating new files... at $INSTALLPATH"
# mkdir -p "$CPATH" # later move takes care of this
mkdir -p "$DPATH"
unzip -qo "$TMP/$DEV" -d "$DPATH"
unzip -qo "$TMP/$APP" -d "$TMP"
log "Done"
# path devtools
WD=`pwd`
PD="$PWD/patch-devtools"
log "Patching $PD/ to $DPATH"
cp "$PD/devsync.js" "$DPATH/"
cp "$PD/socket.io.min.js" "$DPATH/"
cd "$DPATH"
patch -p1 < "$PD/patch.diff"
cd -
APPBASE=$(basename "$APP" .zip)
log "Moving $TMP/$APPBASE to $CPATH"
mv "$TMP/$APPBASE" "$CPATH"
exec_app
log "Cleaning up..."
rm -rf "$TMP"
log "All Done"