From ca95457c00e2177fa2bb3ccd76c599f594dd57d0 Mon Sep 17 00:00:00 2001 From: Thomas Wunner Date: Tue, 23 Jun 2026 11:37:58 +0200 Subject: [PATCH 1/2] feat(chrome): support installing on rpm-based Linux Detect the distribution from /etc/os-release and branch the Chrome install between apt/.deb (Ubuntu/Debian) and rpm-based package managers: zypper (openSUSE/SLES/SLED) and dnf or yum (Fedora, RHEL, CentOS, Rocky, AlmaLinux, Amazon Linux, Oracle Linux, ...). Google's signing key is imported so the package manager trusts the downloaded rpm. For distributions without an official Google Chrome package (Arch, CachyOS, Alpine, Gentoo, NixOS, ...) print actionable guidance pointing to the native package or Playwright's bundled Chromium, instead of a generic "unsupported distribution" error. The Ubuntu/Debian apt path and PLAYWRIGHT_HOST_PLATFORM_OVERRIDE behaviour are unchanged. --- .../bin/reinstall_chrome_beta_linux.sh | 99 ++++++++++++++++++- .../bin/reinstall_chrome_stable_linux.sh | 99 ++++++++++++++++++- 2 files changed, 192 insertions(+), 6 deletions(-) diff --git a/packages/playwright-core/bin/reinstall_chrome_beta_linux.sh b/packages/playwright-core/bin/reinstall_chrome_beta_linux.sh index 13d55dfaacaae..dd9fe9090a92b 100755 --- a/packages/playwright-core/bin/reinstall_chrome_beta_linux.sh +++ b/packages/playwright-core/bin/reinstall_chrome_beta_linux.sh @@ -7,6 +7,10 @@ if [[ $(arch) == "aarch64" ]]; then exit 1 fi +# Default to the Debian/Ubuntu (apt) installation path. When the host platform is +# overridden we keep this default to preserve the previous behaviour. +PKG_MANAGER="apt" + if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then if [[ ! -f "/etc/os-release" ]]; then echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)" @@ -14,12 +18,101 @@ if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then fi ID=$(bash -c 'source /etc/os-release && echo $ID') - if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then - echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported" - exit 1 + ID_LIKE=$(bash -c 'source /etc/os-release && echo $ID_LIKE') + case "${ID}" in + ubuntu|debian) + PKG_MANAGER="apt" + ;; + opensuse*|sles|sled) + PKG_MANAGER="zypper" + ;; + fedora|rhel|centos|rocky|almalinux|amzn) + PKG_MANAGER="redhat" + ;; + *) + if [[ "${ID_LIKE}" == *debian* ]]; then + PKG_MANAGER="apt" + elif [[ "${ID_LIKE}" == *suse* ]]; then + PKG_MANAGER="zypper" + elif [[ "${ID_LIKE}" == *rhel* || "${ID_LIKE}" == *fedora* ]]; then + PKG_MANAGER="redhat" + else + echo "ERROR: 'npx playwright install chrome' only supports distributions with an official" + echo "Google Chrome package: Ubuntu/Debian (.deb) and openSUSE/Fedora/RHEL (.rpm)." + echo "Google does not ship a native package for '$ID'." + case "${ID} ${ID_LIKE}" in + *arch*|*cachyos*) + echo "On Arch-based systems install Chrome from the AUR ('yay -S google-chrome') or use" + echo "Chromium ('pacman -S chromium'). Playwright's bundled Chromium also works." + ;; + *alpine*) + echo "Alpine uses musl libc; Google Chrome and Playwright's bundled browsers require glibc" + echo "and do not run here. Use the system Chromium instead ('apk add chromium')." + ;; + *gentoo*) + echo "On Gentoo install Chrome via Portage ('emerge www-client/google-chrome') or use" + echo "Playwright's bundled Chromium." + ;; + *nixos*) + echo "On NixOS add 'google-chrome' to your configuration declaratively, or use Playwright's" + echo "bundled Chromium. Imperative installation into /opt is not supported." + ;; + *) + echo "Use Playwright's bundled Chromium, which works on most glibc-based Linux distributions." + ;; + esac + exit 1 + fi + ;; + esac + + # The Red Hat family ships dnf on current releases and yum on older ones (e.g. RHEL 7). + if [[ "${PKG_MANAGER}" == "redhat" ]]; then + if command -v dnf >/dev/null; then + PKG_MANAGER="dnf" + else + PKG_MANAGER="yum" + fi fi fi +if [[ "${PKG_MANAGER}" != "apt" ]]; then + # RPM-based distributions (openSUSE via zypper, Fedora/RHEL via dnf or yum) all + # consume the same x86_64 package from dl.google.com. + case "${PKG_MANAGER}" in + zypper) + PKG_REMOVE=(zypper --non-interactive remove) + PKG_INSTALL=(zypper --non-interactive install) + ;; + *) + PKG_REMOVE=("${PKG_MANAGER}" remove -y) + PKG_INSTALL=("${PKG_MANAGER}" install -y) + ;; + esac + + # 1. make sure to remove old beta if any. + if rpm -q google-chrome-beta >/dev/null 2>&1; then + "${PKG_REMOVE[@]}" google-chrome-beta + fi + + # 2. Install curl to download chrome + if ! command -v curl >/dev/null; then + "${PKG_INSTALL[@]}" curl + fi + + # 3. Trust Google's signing key so the package manager accepts the package. + rpm --import https://dl.google.com/linux/linux_signing_key.pub + + # 4. download chrome beta from dl.google.com and install it. + cd /tmp + curl -L -O https://dl.google.com/linux/direct/google-chrome-beta_current_x86_64.rpm + "${PKG_INSTALL[@]}" ./google-chrome-beta_current_x86_64.rpm + rm -rf ./google-chrome-beta_current_x86_64.rpm + cd - + google-chrome-beta --version + exit 0 +fi + # 1. make sure to remove old beta if any. if dpkg --get-selections | grep -q "^google-chrome-beta[[:space:]]*install$" >/dev/null; then apt-get remove -y google-chrome-beta diff --git a/packages/playwright-core/bin/reinstall_chrome_stable_linux.sh b/packages/playwright-core/bin/reinstall_chrome_stable_linux.sh index 64bc1393556c3..b197ddc8975ce 100755 --- a/packages/playwright-core/bin/reinstall_chrome_stable_linux.sh +++ b/packages/playwright-core/bin/reinstall_chrome_stable_linux.sh @@ -7,6 +7,10 @@ if [[ $(arch) == "aarch64" ]]; then exit 1 fi +# Default to the Debian/Ubuntu (apt) installation path. When the host platform is +# overridden we keep this default to preserve the previous behaviour. +PKG_MANAGER="apt" + if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then if [[ ! -f "/etc/os-release" ]]; then echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)" @@ -14,12 +18,101 @@ if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then fi ID=$(bash -c 'source /etc/os-release && echo $ID') - if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then - echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported" - exit 1 + ID_LIKE=$(bash -c 'source /etc/os-release && echo $ID_LIKE') + case "${ID}" in + ubuntu|debian) + PKG_MANAGER="apt" + ;; + opensuse*|sles|sled) + PKG_MANAGER="zypper" + ;; + fedora|rhel|centos|rocky|almalinux|amzn) + PKG_MANAGER="redhat" + ;; + *) + if [[ "${ID_LIKE}" == *debian* ]]; then + PKG_MANAGER="apt" + elif [[ "${ID_LIKE}" == *suse* ]]; then + PKG_MANAGER="zypper" + elif [[ "${ID_LIKE}" == *rhel* || "${ID_LIKE}" == *fedora* ]]; then + PKG_MANAGER="redhat" + else + echo "ERROR: 'npx playwright install chrome' only supports distributions with an official" + echo "Google Chrome package: Ubuntu/Debian (.deb) and openSUSE/Fedora/RHEL (.rpm)." + echo "Google does not ship a native package for '$ID'." + case "${ID} ${ID_LIKE}" in + *arch*|*cachyos*) + echo "On Arch-based systems install Chrome from the AUR ('yay -S google-chrome') or use" + echo "Chromium ('pacman -S chromium'). Playwright's bundled Chromium also works." + ;; + *alpine*) + echo "Alpine uses musl libc; Google Chrome and Playwright's bundled browsers require glibc" + echo "and do not run here. Use the system Chromium instead ('apk add chromium')." + ;; + *gentoo*) + echo "On Gentoo install Chrome via Portage ('emerge www-client/google-chrome') or use" + echo "Playwright's bundled Chromium." + ;; + *nixos*) + echo "On NixOS add 'google-chrome' to your configuration declaratively, or use Playwright's" + echo "bundled Chromium. Imperative installation into /opt is not supported." + ;; + *) + echo "Use Playwright's bundled Chromium, which works on most glibc-based Linux distributions." + ;; + esac + exit 1 + fi + ;; + esac + + # The Red Hat family ships dnf on current releases and yum on older ones (e.g. RHEL 7). + if [[ "${PKG_MANAGER}" == "redhat" ]]; then + if command -v dnf >/dev/null; then + PKG_MANAGER="dnf" + else + PKG_MANAGER="yum" + fi fi fi +if [[ "${PKG_MANAGER}" != "apt" ]]; then + # RPM-based distributions (openSUSE via zypper, Fedora/RHEL via dnf or yum) all + # consume the same x86_64 package from dl.google.com. + case "${PKG_MANAGER}" in + zypper) + PKG_REMOVE=(zypper --non-interactive remove) + PKG_INSTALL=(zypper --non-interactive install) + ;; + *) + PKG_REMOVE=("${PKG_MANAGER}" remove -y) + PKG_INSTALL=("${PKG_MANAGER}" install -y) + ;; + esac + + # 1. make sure to remove old stable if any. + if rpm -q google-chrome-stable >/dev/null 2>&1; then + "${PKG_REMOVE[@]}" google-chrome-stable + fi + + # 2. Install curl to download chrome + if ! command -v curl >/dev/null; then + "${PKG_INSTALL[@]}" curl + fi + + # 3. Trust Google's signing key so the package manager accepts the package. + rpm --import https://dl.google.com/linux/linux_signing_key.pub + + # 4. download chrome stable from dl.google.com and install it. + cd /tmp + curl -L -O https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm + "${PKG_INSTALL[@]}" ./google-chrome-stable_current_x86_64.rpm + rm -rf ./google-chrome-stable_current_x86_64.rpm + cd - + google-chrome --version + exit 0 +fi + # 1. make sure to remove old stable if any. if dpkg --get-selections | grep -q "^google-chrome[[:space:]]*install$" >/dev/null; then apt-get remove -y google-chrome From e979ed96c08d068eb3594c2a9c3acfff0dd428f3 Mon Sep 17 00:00:00 2001 From: Thomas Wunner Date: Tue, 23 Jun 2026 12:55:46 +0200 Subject: [PATCH 2/2] feat(msedge): support installing on rpm-based Linux Mirror the Chrome install scripts: detect the distribution from /etc/os-release and, on rpm-based systems (openSUSE via zypper, Fedora and RHEL via dnf or yum), register Microsoft's Edge rpm repository at packages.microsoft.com and install microsoft-edge-{stable,beta,dev} from there. On distributions without an official Edge package, print a short hint (AUR on Arch, otherwise Playwright's bundled Chromium). The Ubuntu/Debian apt path and PLAYWRIGHT_HOST_PLATFORM_OVERRIDE behaviour are unchanged. --- .../bin/reinstall_msedge_beta_linux.sh | 90 ++++++++++++++++++- .../bin/reinstall_msedge_dev_linux.sh | 90 ++++++++++++++++++- .../bin/reinstall_msedge_stable_linux.sh | 90 ++++++++++++++++++- 3 files changed, 261 insertions(+), 9 deletions(-) diff --git a/packages/playwright-core/bin/reinstall_msedge_beta_linux.sh b/packages/playwright-core/bin/reinstall_msedge_beta_linux.sh index e1f156a08f74e..78cf52054e380 100755 --- a/packages/playwright-core/bin/reinstall_msedge_beta_linux.sh +++ b/packages/playwright-core/bin/reinstall_msedge_beta_linux.sh @@ -8,6 +8,10 @@ if [[ $(arch) == "aarch64" ]]; then exit 1 fi +# Default to the Debian/Ubuntu (apt) installation path. When the host platform is +# overridden we keep this default to preserve the previous behaviour. +PKG_MANAGER="apt" + if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then if [[ ! -f "/etc/os-release" ]]; then echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)" @@ -15,10 +19,90 @@ if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then fi ID=$(bash -c 'source /etc/os-release && echo $ID') - if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then - echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported" - exit 1 + ID_LIKE=$(bash -c 'source /etc/os-release && echo $ID_LIKE') + case "${ID}" in + ubuntu|debian) + PKG_MANAGER="apt" + ;; + opensuse*|sles|sled) + PKG_MANAGER="zypper" + ;; + fedora|rhel|centos|rocky|almalinux|amzn) + PKG_MANAGER="redhat" + ;; + *) + if [[ "${ID_LIKE}" == *debian* ]]; then + PKG_MANAGER="apt" + elif [[ "${ID_LIKE}" == *suse* ]]; then + PKG_MANAGER="zypper" + elif [[ "${ID_LIKE}" == *rhel* || "${ID_LIKE}" == *fedora* ]]; then + PKG_MANAGER="redhat" + else + echo "ERROR: 'npx playwright install msedge-beta' only supports distributions with an official" + echo "Microsoft Edge package: Ubuntu/Debian (.deb) and openSUSE/Fedora/RHEL (.rpm)." + echo "Microsoft does not ship a native package for '$ID'." + case "${ID} ${ID_LIKE}" in + *arch*|*cachyos*) + echo "On Arch-based systems install Microsoft Edge from the AUR ('yay -S microsoft-edge-beta-bin')." + ;; + *) + echo "Use Playwright's bundled Chromium, which works on most glibc-based Linux distributions." + ;; + esac + exit 1 + fi + ;; + esac + + # The Red Hat family ships dnf on current releases and yum on older ones (e.g. RHEL 7). + if [[ "${PKG_MANAGER}" == "redhat" ]]; then + if command -v dnf >/dev/null; then + PKG_MANAGER="dnf" + else + PKG_MANAGER="yum" + fi + fi +fi + +if [[ "${PKG_MANAGER}" != "apt" ]]; then + # RPM-based distributions (openSUSE via zypper, Fedora/RHEL via dnf or yum) install + # Microsoft Edge from the same rpm repository at packages.microsoft.com. + case "${PKG_MANAGER}" in + zypper) + PKG_REMOVE=(zypper --non-interactive remove) + PKG_INSTALL=(zypper --non-interactive --gpg-auto-import-keys install) + REPO_DIR="/etc/zypp/repos.d" + ;; + *) + PKG_REMOVE=("${PKG_MANAGER}" remove -y) + PKG_INSTALL=("${PKG_MANAGER}" install -y) + REPO_DIR="/etc/yum.repos.d" + ;; + esac + + # 1. Trust Microsoft's signing key and register the Edge repository. + rpm --import https://packages.microsoft.com/keys/microsoft.asc + cat > "${REPO_DIR}/microsoft-edge.repo" <<'REPO' +[microsoft-edge] +name=Microsoft Edge +baseurl=https://packages.microsoft.com/yumrepos/edge +enabled=1 +gpgcheck=1 +gpgkey=https://packages.microsoft.com/keys/microsoft.asc +REPO + + # 2. make sure to remove old beta if any. + if rpm -q microsoft-edge-beta >/dev/null 2>&1; then + "${PKG_REMOVE[@]}" microsoft-edge-beta + fi + + # 3. refresh metadata (zypper) and install. + if [[ "${PKG_MANAGER}" == "zypper" ]]; then + zypper --non-interactive --gpg-auto-import-keys refresh fi + "${PKG_INSTALL[@]}" microsoft-edge-beta + microsoft-edge-beta --version + exit 0 fi # 1. make sure to remove old beta if any. diff --git a/packages/playwright-core/bin/reinstall_msedge_dev_linux.sh b/packages/playwright-core/bin/reinstall_msedge_dev_linux.sh index 6c1a151cc404a..f07143e8f82b1 100755 --- a/packages/playwright-core/bin/reinstall_msedge_dev_linux.sh +++ b/packages/playwright-core/bin/reinstall_msedge_dev_linux.sh @@ -8,6 +8,10 @@ if [[ $(arch) == "aarch64" ]]; then exit 1 fi +# Default to the Debian/Ubuntu (apt) installation path. When the host platform is +# overridden we keep this default to preserve the previous behaviour. +PKG_MANAGER="apt" + if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then if [[ ! -f "/etc/os-release" ]]; then echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)" @@ -15,10 +19,90 @@ if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then fi ID=$(bash -c 'source /etc/os-release && echo $ID') - if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then - echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported" - exit 1 + ID_LIKE=$(bash -c 'source /etc/os-release && echo $ID_LIKE') + case "${ID}" in + ubuntu|debian) + PKG_MANAGER="apt" + ;; + opensuse*|sles|sled) + PKG_MANAGER="zypper" + ;; + fedora|rhel|centos|rocky|almalinux|amzn) + PKG_MANAGER="redhat" + ;; + *) + if [[ "${ID_LIKE}" == *debian* ]]; then + PKG_MANAGER="apt" + elif [[ "${ID_LIKE}" == *suse* ]]; then + PKG_MANAGER="zypper" + elif [[ "${ID_LIKE}" == *rhel* || "${ID_LIKE}" == *fedora* ]]; then + PKG_MANAGER="redhat" + else + echo "ERROR: 'npx playwright install msedge-dev' only supports distributions with an official" + echo "Microsoft Edge package: Ubuntu/Debian (.deb) and openSUSE/Fedora/RHEL (.rpm)." + echo "Microsoft does not ship a native package for '$ID'." + case "${ID} ${ID_LIKE}" in + *arch*|*cachyos*) + echo "On Arch-based systems install Microsoft Edge from the AUR ('yay -S microsoft-edge-dev-bin')." + ;; + *) + echo "Use Playwright's bundled Chromium, which works on most glibc-based Linux distributions." + ;; + esac + exit 1 + fi + ;; + esac + + # The Red Hat family ships dnf on current releases and yum on older ones (e.g. RHEL 7). + if [[ "${PKG_MANAGER}" == "redhat" ]]; then + if command -v dnf >/dev/null; then + PKG_MANAGER="dnf" + else + PKG_MANAGER="yum" + fi + fi +fi + +if [[ "${PKG_MANAGER}" != "apt" ]]; then + # RPM-based distributions (openSUSE via zypper, Fedora/RHEL via dnf or yum) install + # Microsoft Edge from the same rpm repository at packages.microsoft.com. + case "${PKG_MANAGER}" in + zypper) + PKG_REMOVE=(zypper --non-interactive remove) + PKG_INSTALL=(zypper --non-interactive --gpg-auto-import-keys install) + REPO_DIR="/etc/zypp/repos.d" + ;; + *) + PKG_REMOVE=("${PKG_MANAGER}" remove -y) + PKG_INSTALL=("${PKG_MANAGER}" install -y) + REPO_DIR="/etc/yum.repos.d" + ;; + esac + + # 1. Trust Microsoft's signing key and register the Edge repository. + rpm --import https://packages.microsoft.com/keys/microsoft.asc + cat > "${REPO_DIR}/microsoft-edge.repo" <<'REPO' +[microsoft-edge] +name=Microsoft Edge +baseurl=https://packages.microsoft.com/yumrepos/edge +enabled=1 +gpgcheck=1 +gpgkey=https://packages.microsoft.com/keys/microsoft.asc +REPO + + # 2. make sure to remove old dev if any. + if rpm -q microsoft-edge-dev >/dev/null 2>&1; then + "${PKG_REMOVE[@]}" microsoft-edge-dev + fi + + # 3. refresh metadata (zypper) and install. + if [[ "${PKG_MANAGER}" == "zypper" ]]; then + zypper --non-interactive --gpg-auto-import-keys refresh fi + "${PKG_INSTALL[@]}" microsoft-edge-dev + microsoft-edge-dev --version + exit 0 fi # 1. make sure to remove old dev if any. diff --git a/packages/playwright-core/bin/reinstall_msedge_stable_linux.sh b/packages/playwright-core/bin/reinstall_msedge_stable_linux.sh index 93bd766bc3e8d..5dff11e88d9f6 100755 --- a/packages/playwright-core/bin/reinstall_msedge_stable_linux.sh +++ b/packages/playwright-core/bin/reinstall_msedge_stable_linux.sh @@ -8,6 +8,10 @@ if [[ $(arch) == "aarch64" ]]; then exit 1 fi +# Default to the Debian/Ubuntu (apt) installation path. When the host platform is +# overridden we keep this default to preserve the previous behaviour. +PKG_MANAGER="apt" + if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then if [[ ! -f "/etc/os-release" ]]; then echo "ERROR: cannot install on unknown linux distribution (/etc/os-release is missing)" @@ -15,10 +19,90 @@ if [ -z "$PLAYWRIGHT_HOST_PLATFORM_OVERRIDE" ]; then fi ID=$(bash -c 'source /etc/os-release && echo $ID') - if [[ "${ID}" != "ubuntu" && "${ID}" != "debian" ]]; then - echo "ERROR: cannot install on $ID distribution - only Ubuntu and Debian are supported" - exit 1 + ID_LIKE=$(bash -c 'source /etc/os-release && echo $ID_LIKE') + case "${ID}" in + ubuntu|debian) + PKG_MANAGER="apt" + ;; + opensuse*|sles|sled) + PKG_MANAGER="zypper" + ;; + fedora|rhel|centos|rocky|almalinux|amzn) + PKG_MANAGER="redhat" + ;; + *) + if [[ "${ID_LIKE}" == *debian* ]]; then + PKG_MANAGER="apt" + elif [[ "${ID_LIKE}" == *suse* ]]; then + PKG_MANAGER="zypper" + elif [[ "${ID_LIKE}" == *rhel* || "${ID_LIKE}" == *fedora* ]]; then + PKG_MANAGER="redhat" + else + echo "ERROR: 'npx playwright install msedge' only supports distributions with an official" + echo "Microsoft Edge package: Ubuntu/Debian (.deb) and openSUSE/Fedora/RHEL (.rpm)." + echo "Microsoft does not ship a native package for '$ID'." + case "${ID} ${ID_LIKE}" in + *arch*|*cachyos*) + echo "On Arch-based systems install Microsoft Edge from the AUR ('yay -S microsoft-edge-stable-bin')." + ;; + *) + echo "Use Playwright's bundled Chromium, which works on most glibc-based Linux distributions." + ;; + esac + exit 1 + fi + ;; + esac + + # The Red Hat family ships dnf on current releases and yum on older ones (e.g. RHEL 7). + if [[ "${PKG_MANAGER}" == "redhat" ]]; then + if command -v dnf >/dev/null; then + PKG_MANAGER="dnf" + else + PKG_MANAGER="yum" + fi + fi +fi + +if [[ "${PKG_MANAGER}" != "apt" ]]; then + # RPM-based distributions (openSUSE via zypper, Fedora/RHEL via dnf or yum) install + # Microsoft Edge from the same rpm repository at packages.microsoft.com. + case "${PKG_MANAGER}" in + zypper) + PKG_REMOVE=(zypper --non-interactive remove) + PKG_INSTALL=(zypper --non-interactive --gpg-auto-import-keys install) + REPO_DIR="/etc/zypp/repos.d" + ;; + *) + PKG_REMOVE=("${PKG_MANAGER}" remove -y) + PKG_INSTALL=("${PKG_MANAGER}" install -y) + REPO_DIR="/etc/yum.repos.d" + ;; + esac + + # 1. Trust Microsoft's signing key and register the Edge repository. + rpm --import https://packages.microsoft.com/keys/microsoft.asc + cat > "${REPO_DIR}/microsoft-edge.repo" <<'REPO' +[microsoft-edge] +name=Microsoft Edge +baseurl=https://packages.microsoft.com/yumrepos/edge +enabled=1 +gpgcheck=1 +gpgkey=https://packages.microsoft.com/keys/microsoft.asc +REPO + + # 2. make sure to remove old stable if any. + if rpm -q microsoft-edge-stable >/dev/null 2>&1; then + "${PKG_REMOVE[@]}" microsoft-edge-stable + fi + + # 3. refresh metadata (zypper) and install. + if [[ "${PKG_MANAGER}" == "zypper" ]]; then + zypper --non-interactive --gpg-auto-import-keys refresh fi + "${PKG_INSTALL[@]}" microsoft-edge-stable + microsoft-edge-stable --version + exit 0 fi # 1. make sure to remove old stable if any.