Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Shellcheck
name: test

on:
pull_request:
Expand All @@ -9,8 +9,8 @@ permissions:
pull-requests: write

jobs:
shellcheck:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- run: "make shellcheck"
- run: "make -j"
48 changes: 3 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,56 +1,14 @@
# Select the Browser channel

CHANNEL ?= release
$(if $(filter $(CHANNEL),release beta nightly),,$(error Unknown browser channel `$(CHANNEL)'))

# Distros to test install.sh on

unsupported := alpine voidlinux/voidlinux-musl ubuntu_16.04 debian_9 linuxmintd/mint18-amd64 fedora_26 opensuse/leap_42.3
supported := ubuntu_18.04 ubuntu_25.04 debian_11 linuxmintd/mint19-amd64 fedora_27 fedora_41 opensuse/leap_15 opensuse/tumbleweed rockylinux_9 $(if $(CHANNEL:release=),,manjarolinux/base)
distros := $(unsupported) $(supported)

test: shellcheck ut $(distros)

# Output per target, use bash in recipes, fail on errors, be quiet by default

MAKEFLAGS := -rRO
SHELL := $(shell command -v bash)
MAYBE_SUDO := $(shell id -nG|grep -qw 'docker\|root' && echo || echo sudo)
.SHELLFLAGS := -eEo pipefail -c
.ONESHELL:
$(V).SILENT:
.PHONY: clean shellcheck test ut $(distros) $(distros:%=%_clean)

# Test install.sh on different distributions via docker

$(distros): distro = $(subst _,:,$@)
$(distros) $(distros:%=%_clean): log = $(subst /,_,$(subst _,:,$(@:%_clean=%))).log

$(unsupported):
printf "Testing $(CHANNEL) on unsupported distribution $(distro)... "
if ! docker run --rm -e CHANNEL="$(CHANNEL)" -v "$$PWD/install.sh:/install.sh" "$(distro)" /install.sh >"$(log)" 2>&1 &&\
grep -q "Unsupported glibc version" "$(log)"; then
echo OK
else
printf "Failed\n\n" && tail -v "$(log)" && false
fi

opensuse/tumbleweed: setup = zypper --non-interactive install libglib-2_0-0
manjarolinux/base: setup = mv /etc/pacman.conf{.pacnew,} || true

$(supported):
printf "Testing $(CHANNEL) on supported distribution $(distro)... "
dashCHANNEL="$$([[ "$(CHANNEL)" == release ]] && echo || echo "-$(CHANNEL)")"
if docker run --rm -e CHANNEL="$(CHANNEL)" -v "$$PWD/install.sh:/install.sh" "$(distro)" \
sh -c '$(or $(setup),true) && /install.sh && "brave-browser$$dashCHANNEL" --version || "brave$$dashCHANNEL" --version' >"$(log)" 2>&1; then
echo OK
else
printf "Failed\n\n" && tail -v "$(log)" && false
fi

clean: $(distros:%=%_clean)

$(distros:%=%_clean):
rm -f "$(log)"
.PHONY: shellcheck test ut

# Test helper functions from install.sh in an alpine container

Expand All @@ -66,7 +24,7 @@ ut_supported: test = supported foo 1.12 1.9

$(uts): ut_%:
printf "Testing function $*()... "
docker run --rm -v "$$PWD/install.sh:/install.sh" alpine \
$(MAYBE_SUDO) docker run --rm -v "$$PWD/install.sh:/install.sh" alpine \
sh -$(if $(V),x,)ec 'source <(grep -x "\w\w*() {.*}" /install.sh) && $(test)'
echo OK

Expand Down
28 changes: 14 additions & 14 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
# Copyright (c) 2024 The Brave Authors
# SPDX-License-Identifier: BSD-3-Clause
#
# This script installs the Brave browser using the OS's package manager
# This script installs Brave Browser, or Brave Origin using the OS's package manager
# Requires: coreutils, grep, sh and one of sudo/doas/run0/pkexec/sudo-rs
# Source: https://github.com/brave/install.sh

GLIBC_VER_MIN="2.26"
APT_VER_MIN="1.1"

CHANNEL="${CHANNEL:-release}"
FLAVOR="${FLAVOR:-browser}"
CHANNEL="${CHANNEL:-release}"

main() {
## Check if the browser can run on this system
Expand All @@ -26,18 +26,6 @@ main() {
*) error "Unsupported architecture $(uname -m). Only 64-bit x86 or ARM machines are supported.";;
esac

## Locate the necessary tools

case "$(whoami)" in
root) sudo="";;
*) sudo="$(first_of sudo doas run0 pkexec sudo-rs)" || error "Please install sudo/doas/run0/pkexec/sudo-rs to proceed.";;
esac

case "$(first_of curl wget)" in
wget) curl="wget -qO-";;
*) curl="curl -fsS";;
esac

## Validate the flavor and channel

case "$FLAVOR" in
Expand All @@ -52,6 +40,18 @@ main() {
*) error "Invalid channel $CHANNEL. Only release, beta and nightly are supported.";;
esac

## Locate the necessary tools

case "$(whoami)" in
root) sudo="";;
*) sudo="$(first_of sudo doas run0 pkexec sudo-rs)" || error "Please install sudo/doas/run0/pkexec/sudo-rs to proceed.";;
esac

case "$(first_of curl wget)" in
wget) curl="wget -qO-";;
*) curl="curl -fsS";;
esac

## Install the browser

echo "Installing $FLAVOR_LABEL ($CHANNEL)"
Expand Down
Loading