~jdstrand/+junk/firefox-snap.jdstrand

« back to all changes in this revision

Viewing changes to fabricate-google-chrome-snap

  • Committer: Chad MILLER
  • Date: 2016-06-01 18:12:27 UTC
  • Revision ID: chad.miller@canonical.com-20160601181227-uofv3m00rfj43u1r
Wrap it for GUI env vars.

Put Dependencies in snapcraftyaml.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
 
3
 
set -eu
4
 
 
5
 
#rm -rf pkg-root snapcraft.yaml deb
6
 
 
7
 
#cp snapcraft.yaml.in snapcraft.yaml
8
 
cat >snapcraft.yaml <<EOF
9
 
name: google-chrome
 
1
#!/bin/bash -eu
 
2
# https://code.launchpad.net/~cmiller/+junk/gcsnap
 
3
# Canonical, 2016. Questions to chad.miller@canonical.com
 
4
 
 
5
cat >gcenv <<"EOF"
 
6
#!/bin/sh -u
 
7
 
 
8
# Chrome specific values
 
9
export ENV=
 
10
export BASH_ENV=
 
11
export CDPATH=
 
12
export GLOBIGNORE=
 
13
 
 
14
# Not implemented by snap interfaces yet
 
15
export XDG_DATA_HOME=$SNAP/usr/share
 
16
export FONTCONFIG_PATH=$SNAP/etc/fonts/config.d
 
17
export FONTCONFIG_FILE=$SNAP/etc/fonts/fonts.conf
 
18
 
 
19
exec "$@"
 
20
EOF
 
21
chmod +x gcenv
 
22
 
 
23
cat >snapcraft.yaml <<"EOF"
 
24
name: chrome
10
25
version: UPSTREAMVERSION
11
26
summary: The web browser from Google
12
 
description: Google Chrome is a browser that combines a minimal design with
 
27
description: |
 
28
  Google Chrome is a browser that combines a minimal design with
13
29
  sophisticated technology to make the web faster, safer, and easier
14
30
 
15
31
apps:
16
 
  chromium:
17
 
    command: usr/bin/google-chrome-stable
18
 
    plugs: [ network, x11, home, unity7 ]
 
32
  chrome:
 
33
    command: bin/gcenv $SNAP/opt/google/chrome/google-chrome
 
34
    plugs: 
 
35
      - network
 
36
      - network-observe
 
37
      - home
 
38
      - x11
 
39
      - unity7
19
40
 
20
41
parts:
21
42
  deb:
22
43
    plugin: copy
23
 
    stage-packages: [ libgl1-mesa-glx, libgl1-mesa-dri, libexif12, fontconfig, fonts-dejavu, xfonts-base, xfonts-encodings, xfonts-scalable, xfonts-utils, ttf-bitstream-vera, ttf-ubuntu-font-family, gconf-service, libasound2 , libatk1.0-0 , libc6 , libcairo2 , libcups2 , libdbus-1-3 , libexpat1 , libfontconfig1 , libfreetype6 , libgcc1 , libgconf-2-4 , libgdk-pixbuf2.0-0 , libglib2.0-0 , libgtk2.0-0 , libnspr4 , libnss3 , libpango1.0-0 , libstdc++6 , libx11-6 , libxcomposite1 , libxcursor1 , libxdamage1 , libxext6, libxfixes3, libxi6 , libxrandr2 , libxrender1, libxss1, libxtst6, ca-certificates, fonts-liberation, libappindicator1, libcurl3, lsb-base , xdg-utils , wget ]
 
44
    stage-packages: [ libgl1-mesa-glx, libgl1-mesa-dri, libexif12, fontconfig, fonts-dejavu, xfonts-base, xfonts-encodings, xfonts-scalable, xfonts-utils, ttf-bitstream-vera, ttf-ubuntu-font-family, DEPENDENCIES ]
24
45
    files:
25
 
       pkg-root/usr/bin: usr/bin
26
 
       pkg-root/opt: opt
 
46
      pkg-root/opt: opt
 
47
      gcenv: bin/gcenv
27
48
EOF
28
49
 
29
50
 
30
 
wget -nv -O - https://dl.google.com/linux/chrome/deb/dists/stable/Release |grep ^\ |grep Packages$ |head -1 |
31
 
while read hash size place; do
32
 
wget -nv -O - https://dl.google.com/linux/chrome/deb/dists/stable/$place |sed -e '1,/^Package: google-chrome-stable$/d' -e '/^$/,$d' |
33
 
while read key val; do
34
 
if test "$key" = Depends:; then
35
 
        sed -i -e "s;DEPENDENCIES;$(echo $val |perl -p -e 's/\(.*?\)//g');" snapcraft.yaml
36
 
elif test "$key" = Version:; then
37
 
        sed -i -e "s;UPSTREAMVERSION;$val;" snapcraft.yaml
38
 
elif test "$key" = Filename:; then
39
 
        wget -nv --show-progress -O deb https://dl.google.com/linux/chrome/deb/$val
 
51
wget -nv -O - https://dl.google.com/linux/chrome/deb/dists/stable/Release |grep ^\ |grep Packages$ |head -1 |while read hash size place; do
 
52
        wget -nv -O - https://dl.google.com/linux/chrome/deb/dists/stable/$place |sed -e '1,/^Package: google-chrome-stable$/d' -e '/^$/,$d' |while read key val; do
 
53
                if test "$key" = Depends:; then
 
54
                        sed -i -e "s;DEPENDENCIES;$(echo $val |perl -p -e 's/\(.*?\)//g');" snapcraft.yaml
 
55
                elif test "$key" = Version:; then
 
56
                        sed -i -e "s;UPSTREAMVERSION;$val;" snapcraft.yaml
 
57
                elif test "$key" = Filename:; then
 
58
                        wget -nv --show-progress -O deb https://dl.google.com/linux/chrome/deb/$val
 
59
                        trap "rm deb" EXIT
 
60
                fi
 
61
        done
 
62
done
 
63
 
 
64
test -f deb || echo "Failed to download chrome package."
 
65
 
 
66
mkdir -p pkg-root
 
67
ar x deb data.tar.xz
 
68
rm deb
 
69
tar xf data.tar.xz -C pkg-root
 
70
rm data.tar.xz
 
71
 
 
72
if which lxc &>/dev/null && false; then
 
73
        snapcraft cleanbuild --debug
 
74
else
 
75
        snapcraft snap --debug
 
76
        snapcraft clean
40
77
fi
41
 
done
42
 
done
43
 
 
44
 
rm -rf pkg-root
45
 
mkdir pkg-root
46
 
ar x deb data.tar.xz
47
 
cd pkg-root; tar xvf ../data.tar.xz
48
 
rm -f data.tar.xz
49
 
 
50
 
snapcraft clean || true
51
 
snapcraft
52
 
 
53
 
rm -rf pkg-root deb
54
 
 
 
78
 
 
79
echo "The Snap security policies are not ready yet. Install with '--devmode'."
 
80
 
 
81
rm -fr pkg-root gcenv snapcraft.yaml