File: //snap/chromium/3307/snap/snapcraft.yaml
name: chromium
adopt-info: chromium
summary: Chromium web browser, open-source version of Chrome
source-code: https://code.launchpad.net/~chromium-team/chromium-browser/+git/snap-from-source/+ref/stable
description: |
An open-source browser project that aims to build a safer, faster, and more
stable way for all Internet users to experience the web.
confinement: strict
base: core24
assumes:
- snapd2.55 # >=2.55 needed for the cups interface
compression: lzo
apps:
chromium:
extensions: [gnome]
command: bin/chromium.launcher
desktop: bin/chromium.desktop
common-id: chromium-browser.desktop
environment:
CHROME_DESKTOP: chromium.desktop
CHROME_CONFIG_HOME: $SNAP_USER_COMMON
GTK_USE_PORTAL: 1
plugs:
- audio-playback
- audio-record
- bluez # for Web Bluetooth (https://launchpad.net/bugs/1887201)
- camera
- cups
- hardware-observe
- hidraw
- home
- joystick
- mount-observe
- network
- network-manager
- password-manager-service
- pcscd
- raw-usb # for WebUSB (https://launchpad.net/bugs/1780678)
- removable-media
- screen-inhibit-control
- serial-port
- system-packages-doc
- timezone-control
- u2f-devices
- unity7 # required for xdg-open to work
- upower-observe
slots:
- mpris
chromedriver:
extensions: [gnome]
command: usr/lib/chromium-browser/chromedriver
plugs:
- network-bind
# + all the plugs required by chromium, so that when chromedriver
# executes chromium it inherits the correct set of permissions
- audio-playback
- audio-record
- bluez
- camera
- cups
- hardware-observe
- hidraw
- home
- joystick
- mount-observe
- network
- network-manager
- password-manager-service
- pcscd
- raw-usb
- removable-media
- screen-inhibit-control
- serial-port
- system-packages-doc
- timezone-control
- u2f-devices
- unity7
- upower-observe
slots:
- mpris
daemon:
extensions: [gnome]
daemon: simple
command: bin/chromium.launcher
command-chain:
- bin/daemon.wrapper
- snap/command-chain/desktop-launch
desktop: bin/daemon.desktop
restart-delay: 3s
install-mode: disable
environment:
CHROME_CONFIG_HOME: $SNAP_USER_COMMON
plugs:
- audio-playback
- audio-record
- bluez # for Web Bluetooth (https://launchpad.net/bugs/1887201)
- camera
- cups
- home
- joystick
- mount-observe
- network
- network-manager
- password-manager-service
- raw-usb # for WebUSB (https://launchpad.net/bugs/1780678)
- removable-media
- screen-inhibit-control
- system-packages-doc
- u2f-devices
- unity7 # required for xdg-open to work
- upower-observe
plugs:
# This is not used or needed for anything other than to trigger automatic
# installation of the cups snap via "default-provider: cups"
install-cups-runtime-dependency:
interface: content
content: foo
default-provider: cups
target: $SNAP_DATA/foo
browser-sandbox:
interface: browser-support
allow-sandbox: true
dot-local-share-applications:
interface: personal-files
write: [$HOME/.local/share/applications]
dot-local-share-icons:
interface: personal-files
write: [$HOME/.local/share/icons]
chromium-config:
interface: personal-files
read: [$HOME/.config/chromium, $HOME/.chromium-browser.init]
etc-chromium-browser-policies:
interface: system-files
read: [/etc/chromium-browser/policies]
layout:
/usr/lib/man-db:
bind: $SNAP/usr/lib/man-db
/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/opensc-pkcs11.so:
bind-file: $SNAP/usr/lib/$CRAFT_ARCH_TRIPLET_BUILD_FOR/opensc-pkcs11.so
parts:
chromium:
plugin: nil
build-environment:
- RUSTC_BOOTSTRAP: 1
- CC: /snap/llvm-chromium/current/bin/clang
- CXX: /snap/llvm-chromium/current/bin/clang++
- AR: /snap/llvm-chromium/current/bin/llvm-ar
after:
- launcher
- manpage
- va-drivers
build-snaps:
- llvm-chromium/candidate
build-packages:
- chrpath
- cmake
- default-jre-headless
- elfutils
- git
- gperf
- gzip
- libasound2-dev
- libcap-dev
- libcups2-dev
- libcurl4-openssl-dev
- libdrm-dev
- libevdev-dev
- libffi-dev
- libicu-dev
- libkrb5-dev
- libnss3-dev
- libpam0g-dev
- libpci-dev
- libpipewire-0.3-dev
- libssl-dev
- libsystemd-dev
- libva-dev
- libwayland-dev
- libxshmfence-dev
- libxss-dev
- lsb-release
- make
- mesa-common-dev
- ninja-build
- pkg-config
- python3-pkg-resources
- python3-xcbgen
- quilt
- qtbase5-dev
- rustc-1.82
- sed
- wget
- xcb-proto
- yasm
- ubuntu-dev-tools
stage-packages:
- libnss3
- libpci3
- libxss1
- libsecret-1-0
- opensc-pkcs11
override-pull: |
set -eux
craftctl default
# First option: Build with local source
if ! tar -x --strip-components=1 -f $CRAFT_PROJECT_DIR/chromium-*; then
# Second option: Pull source directly from the Internet
wget -nv -O- https://commondatastorage.googleapis.com/chromium-browser-official/chromium-142.0.7444.162.tar.xz \
| xz -dT0 | tar -x --strip-components=1
fi
. chrome/VERSION
craftctl set version="$MAJOR.$MINOR.$BUILD.$PATCH"
override-build: |
set -ex +u
trap failed 0
failed(){
find / -name '*libadler*'
}
pull-lp-debs bindgen resolute
apt install -y ./bindgen*.deb
# Otherwise who really can claim to know what they contain?
printf '%s\n' \
"$CRAFT_STAGE" \
"$CRAFT_PART_INSTALL" \
"$CRAFT_PART_BUILD" \
"$CRAFT_PART_SRC" \
"$CRAFT_PART_SRC_WORK" \
"$CRAFT_PART_BUILD_WORK" \
"$CRAFT_PROJECT_DIR" \
"$CRAFT_PRIME"
set -u
ln -sf /usr/bin/rustc-1.82 /usr/bin/rustc
ln -sf /usr/bin/rust-1.82-clang /usr/bin/rust-clang
ln -sf /usr/bin/rust-1.82-lld /usr/bin/rust-lld
ln -sf /usr/bin/rust-1.82-llvm-dwp /usr/bin/rust-llvm-dwp
ln -sf /usr/bin/rustdoc-1.82 /usr/bin/rustdoc
rustc --version
# Launchpad's builder gets out of space because of the duplication of
# SRC->BUILD. Remove SRC then.
# https://forum.snapcraft.io/t/duplicated-directories-src-and-build-are-a-space-issue/44618
if snap info snapcraft | grep 'tracking: *launchpad-buildd'; then
rm -rf "$CRAFT_PART_SRC"
fi
# Find all patches that don't apply anymore before running Quilt, as it
# stops at the 1st unappliable and doesn't tells us how the file looks.
d=$CRAFT_PROJECT_DIR/patches
pDump=$(mktemp -d)
while IFS= read -r p; do
pOut="$pDump/$(basename "$p").out"
< "$d/$p" patch --dry-run -p1 -o "$pOut" || cat "$pOut"
done < "$d/series"
QUILT_PATCHES=$d quilt push -a
# Get the Node.js binaries needed to build chromium's WebUI
third_party/node/update_node_binaries
cp tools/gn/bootstrap/last_commit_position.h tools/gn/src/
python3 tools/gn/bootstrap/bootstrap.py --skip-generate-buildfiles
# Build chromium
OUT=out/Release
mkdir -p $OUT
cp $CRAFT_PROJECT_DIR/args.gn $OUT/
if [ $CRAFT_TARGET_ARCH = "armhf" ]; then
# Do not build with ThinLTO either, because it requires lld
echo "use_thin_lto = false"
# Do not build with NEON on armhf (https://launchpad.net/bugs/1884856)
echo "arm_use_neon = false"
fi >> $OUT/args.gn
$OUT/gn gen $OUT
# Add -v to see the exact command used for each build step.
ninja -C $OUT chrome chrome_sandbox chromedriver
# Strip debug symbols off the chrome binary
eu-strip $OUT/chrome
# Install to $CRAFT_PART_INSTALL
mkdir -p $CRAFT_PART_INSTALL
cp chrome/app/theme/chromium/linux/product_logo_256.png $CRAFT_PART_INSTALL/chromium.png
T=$CRAFT_PART_INSTALL/usr/lib/chromium-browser
mkdir -p $T
cd $OUT
cp chrome chromedriver chrome_crashpad_handler \
chrome_*.pak resources.pak \
icudtl.dat \
libEGL.so libGLESv2.so libffmpeg.so \
libvk_swiftshader.so libvulkan.so.1 vk_swiftshader_icd.json \
v8_context_snapshot.bin \
$T/
cp chrome_sandbox $T/chrome-sandbox
mkdir $T/locales
cp locales/*.pak $T/locales/
if [ -d swiftshader ]; then
# not built on arm*
mkdir $T/swiftshader
cp swiftshader/*.so $T/swiftshader/
fi
# Fix setuid bits on the sandbox executable
# (ref: https://forum.snapcraft.io/t/call-for-testing-chromium-snap/1714/16)
chmod 4555 $CRAFT_PART_INSTALL/usr/lib/chromium-browser/chrome-sandbox
# Generate and install the man page (see the "manpage" part)
mkdir -p $CRAFT_PART_INSTALL/man1
sed \
-e "s/@@PACKAGE@@/chromium/g" \
-e "s/@@MENUNAME@@/chromium/g" \
-e "s:\$HOME/.config:\$SNAP_USER_DATA/.config:g" \
-e "s:\$HOME/.cache:\$SNAP_USER_COMMON/.cache:g" \
$CRAFT_PART_SRC/chrome/app/resources/manpage.1.in \
> $CRAFT_PART_INSTALL/man1/chrome.1
gzip -f9n $CRAFT_PART_INSTALL/man1/chrome.1
prime:
- -etc/init.d
- -etc/xdg
- -usr/include
- -usr/share/doc
- -usr/share/lintian
- -usr/share/man
launcher:
plugin: dump
source: launcher
organize:
'*': bin/
firstrun:
plugin: dump
source: firstrun
organize:
'*': firstrun/
# Stage packages required for the "man" binary, which is invoked when
# chromium is called with the "-h" (or "--help") argument
# (see https://launchpad.net/bugs/1848083).
manpage:
plugin: nil
stage-packages:
- groff-base
- libgdbm6t64
- libpipeline1
- man-db
prime:
- -etc
- -usr/lib/tmpfiles.d
- -usr/share/bug
- -usr/share/calendar
- -usr/share/doc
- -usr/share/doc-base
- -usr/share/lintian
- -usr/share/man
- -usr/share/man-db
- -var
# Create a symlink xdg-email -> xdg-open, as the latter is perfectly able to
# handle mailto: URLs (see https://launchpad.net/bugs/1849774).
# xdg-open is a wrapper provided by the core snap.
xdg-email:
plugin: nil
override-pull: ""
override-prime: |
set -eux
mkdir -p usr/bin
cd usr/bin
ln -s /usr/bin/xdg-open xdg-email
# So that Chromium can install icons for progressive web applications.
xdg-icon-resource:
plugin: nil
stage-packages: [xdg-utils]
stage: [usr/bin/xdg-icon-resource]
override-prime: |
sed -i '/^xdg_user_dir="$XDG_DATA_HOME"$/s|".*"|$SNAP_REAL_HOME/.local/share|' $CRAFT_STAGE/usr/bin/xdg-icon-resource
craftctl default
# VA-API drivers for HW-accelerated video decoding
va-drivers:
plugin: nil
stage-packages:
- mesa-va-drivers
- on amd64:
- i965-va-driver
- intel-media-va-driver
stage:
- usr/lib/*/dri/*_video.so