Skip to content

Instantly share code, notes, and snippets.

@lemanschik
Last active October 29, 2023 10:39
Show Gist options
  • Save lemanschik/4786e99ac6399b025f9522545b25bd03 to your computer and use it in GitHub Desktop.
Save lemanschik/4786e99ac6399b025f9522545b25bd03 to your computer and use it in GitHub Desktop.
install google-chrome-stable linux

Translated via mistral from https://aur.archlinux.org/packages/google-chrome current snapshort as tar.gz PKGBUILD File done by [email protected] note: shasum got not translated correct got shortned. fixed by hand

// Maintainer: Christian Heusel <[email protected]>
// Contributor: Knut Ahlers <knut at ahlers dot me>
// Contributor: Det <nimetonmaili g-mail>
// Contributors: t3ddy, Lex Rivera aka x-demon, ruario, Abdullah

// Check for new Linux releases in: http://googlechromereleases.blogspot.com/search/label/Stable%20updates
// or use: $ curl -sSf https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages | grep -A1 "Package: google-chrome-stable" | awk '/Version/{print $2}' | cut -d '-' -f1

const pkgname = "google-chrome";
const pkgver =  (await fetch("https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages").then(R=>R.text())).split("google-chrome-stable\nVersion:")[1].split("-1\n")[0];
const pkgrel = 1;
const pkgdesc = "The popular web browser by Google (Stable Channel)";
const arch = ['x86_64'];
const url = "https://www.google.com/chrome";
const license = ['custom:chrome'];
const depends = [
  'alsa-lib',
  'gtk3',
  'libcups',
  'libxss',
  'libxtst',
  'nss',
  'ttf-liberation',
  'xdg-utils'
];
const optdepends = [
  'pipewire: WebRTC desktop sharing under Wayland',
  'kdialog: for file dialogs in KDE',
  'gnome-keyring: for storing passwords in GNOME keyring',
  'kwallet: for storing passwords in KWallet'
];
const options = ['!emptydirs', '!strip'];
const install = `${pkgname}.install`;
const _channel = "stable";
const source = [
  `google-chrome-${_channel}_${pkgver}-1_amd64.deb`,
  'eula_text.html',
  `google-chrome-${_channel}.sh`
];
const sha512sums = [
'028375ea49a04b04ff6c369b22b40a1a4545201277eef977ba8fa29123d664f29a01a56cabf2418b60d6c65fecd5d567f35e1504271490a8ba5b377df37ecec6',
'a225555c06b7c32f9f2657004558e3f996c981481dbb0d3cd79b1d59fa3f05d591af88399422d3ab29d9446c103e98d567aeafe061d9550817ab6e7eb0498396',
'de02b498a4b5b93e21622c8dba57befe795d733a04656be911cc38e28bfef0e20470450f44be523bbde8d4de28f79c10434846ca01fc2a2f4e67707b79332f94'
];

function package() {
  // Arch would download the source files as single data.tar.xz file.
  // we fetch and store the files directly
  // bsdtar.extractSync('data.tar.xz', { cwd: pkgdir });
  source.forEach(fileName=>fetch(`https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-${_channel}/${fileName}`).then( (res) =>
    fs.promises.writeFile(`${pkgdir}/${fileName}`, res.body)));
  
  // Launcher
  fs.chmodSync(`google-chrome-${_channel}.sh`, `${pkgdir}/usr/bin/google-chrome-${_channel}`);

  // Icons
  const iconSizes = ['16x16', '24x24', '32x32', '48x48', '64x64', '128x128', '256x256'];
  for (const size of iconSizes) {
    fs.copyFileSync(`${pkgdir}/opt/google/chrome/product_logo_${size.replace('x', '')}.png`, `${pkgdir}/usr/share/icons/hicolor/${size}/apps/google-chrome.png`);
  }

  // License
  fs.copyFileSync('eula_text.html', `${pkgdir}/usr/share/licenses/google-chrome/eula_text.html`);
  fs.copyFileSync(`${pkgdir}/opt/google/chrome/WidevineCdm/LICENSE`, `${pkgdir}/usr/share/licenses/google-chrome-${_channel}/WidevineCdm-LICENSE.txt`);

  // Fix the Chrome desktop entry
  const desktopFile = `${pkgdir}/usr/share/applications/google-chrome.desktop`;
  const desktopEntry = fs.readFileSync(desktopFile, 'utf8');
  const updatedDesktopEntry = desktopEntry
    .replace(/Exec=/, 'StartupWMClass=Google-chrome\nExec=')
    .replace(/x-scheme-handler\/ftp;\?/g, '');
  fs.writeFileSync(desktopFile, updatedDesktopEntry);

  // Remove the Debian Cron job, duplicate product logos, and menu directory
  fs.rm(`${pkgdir}/etc/cron.daily/`, { recursive: true });
  fs.rm(`${pkgdir}/opt/google/chrome/cron/`, { recursive: true });
  fs.rm(`${pkgdir}/opt/google/chrome/product_logo_*.png`, { recursive: true });
  fs.rm(`${pkgdir}/usr/share/menu/`, { recursive: true });
}

Notes

note "Custom flags should be put directly in: ~/.config/chrome-flags.conf"
note "The launcher is called: 'google-chrome-stable'"

google-chrome-stable.sh

#!/bin/bash

XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-~/.config}

# Allow users to override command-line options
if [[ -f $XDG_CONFIG_HOME/chrome-flags.conf ]]; then
    CHROME_USER_FLAGS="$(grep -v '^#' $XDG_CONFIG_HOME/chrome-flags.conf)"
fi

# Launch
exec /opt/google/chrome/google-chrome $CHROME_USER_FLAGS "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment