diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 000000000..e8f7c343d Binary files /dev/null and b/.DS_Store differ diff --git a/contributors/.DS_Store b/contributors/.DS_Store new file mode 100644 index 000000000..43f63badb Binary files /dev/null and b/contributors/.DS_Store differ diff --git a/contributors/arunagri82.md b/contributors/arunagri82.md new file mode 100644 index 000000000..2af320027 --- /dev/null +++ b/contributors/arunagri82.md @@ -0,0 +1,7 @@ +--- +name: Arunkumar +github_user_name: arunagri82 +url_of_github_issue: https://github.com/scaleracademy/scaler-open-source-september-challenge/issues/1010 +your_favorite_programming_language: Javascript +profile-link: https://github.com/arunagri82/progress/blob/main/Arunkumar-Profile.html +--- \ No newline at end of file diff --git a/contributors/arunagri82/.DS_Store b/contributors/arunagri82/.DS_Store new file mode 100644 index 000000000..4a3fdace2 Binary files /dev/null and b/contributors/arunagri82/.DS_Store differ diff --git a/contributors/arunagri82/gist-solution.md b/contributors/arunagri82/gist-solution.md new file mode 100644 index 000000000..89d61a99a --- /dev/null +++ b/contributors/arunagri82/gist-solution.md @@ -0,0 +1,6 @@ +# Gist Solutions + +Here are my Gists for today's task: + +- [Software Development Topic]https://gist.github.com/arunagri82/07bba82f022878456a646ec5447f47c2 +- [Code Snippet]https://gist.github.com/arunagri82/b599d6cc15d4365e4cd9214768e8c50b#file-gist-solution-js \ No newline at end of file diff --git a/hello.js b/hello.js new file mode 100644 index 000000000..e69de29bb diff --git a/install-master/.github/ISSUE_TEMPLATE.md b/install-master/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..561830734 --- /dev/null +++ b/install-master/.github/ISSUE_TEMPLATE.md @@ -0,0 +1 @@ +# Please fill out one of the templates on: https://github.com/Homebrew/install/issues/new/choose or we will close it without comment. diff --git a/install-master/.github/ISSUE_TEMPLATE/bug.md b/install-master/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 000000000..d3a6e4448 --- /dev/null +++ b/install-master/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,37 @@ +--- +name: New issue for Reproducible Bug +about: "If you're sure it's reproducible and not just your machine: submit an issue so we can investigate." + +--- + +# Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again. + +- [ ] your problem was from running the official `install` or `uninstall` script? +- [ ] after installation: ran `brew config` and `brew doctor` and included their output with your issue? If you couldn't install: provided your OS version with the output of your issue? + + + +## What you were trying to do (and why) + + + +## What happened (include command output) + + + +
+ Command output +
+
+  
+
+  
+
+ +## What you expected to happen + + + +## Step-by-step reproduction instructions (by running `brew` commands) + + diff --git a/install-master/.github/ISSUE_TEMPLATE/config.yml b/install-master/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 000000000..c7873e094 --- /dev/null +++ b/install-master/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,15 @@ +blank_issues_enabled: false + +contact_links: +- name: Get help in GitHub Discussions + url: https://github.com/Homebrew/discussions/discussions + about: Have a question? Not sure if your issue affects everyone reproducibly? The quickest way to get help is on Homebrew's GitHub Discussions! +- name: New issue on Homebrew/brew + url: https://github.com/Homebrew/brew/issues/new/choose + about: Having a `brew` problem that's not from a `brew install` or `brew upgrade` of a single formula/package? +- name: New issue on Homebrew/homebrew-core + url: https://github.com/Homebrew/homebrew-core/issues/new/choose + about: Having a `brew` problem with a `brew install` or `brew upgrade` of a single formula/package? Report it to Homebrew/homebrew-core (the core tap/repository). +- name: New issue on Homebrew/homebrew-cask + url: https://github.com/Homebrew/homebrew-cask/issues/new/choose + about: Having a `brew --cask` problem? Report it to Homebrew/homebrew-cask (the cask tap/repository). diff --git a/install-master/.github/dependabot.yml b/install-master/.github/dependabot.yml new file mode 100644 index 000000000..203f3c889 --- /dev/null +++ b/install-master/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/install-master/.github/workflows/tests.yml b/install-master/.github/workflows/tests.yml new file mode 100644 index 000000000..15fbde60c --- /dev/null +++ b/install-master/.github/workflows/tests.yml @@ -0,0 +1,113 @@ +name: CI +on: + push: + branches: + - master + pull_request: +permissions: + contents: read + +jobs: + tests: + strategy: + matrix: + os: + - macOS-latest + - ubuntu-latest + - windows-latest + include: + - os: macOS-latest + shell: bash + - os: ubuntu-latest + shell: bash + - os: windows-latest + shell: "wsl-bash {0}" + runs-on: ${{matrix.os}} + defaults: + run: + shell: ${{ matrix.shell }} + steps: + - name: Set up WSL + if: runner.os == 'windows' + shell: powershell + run: | + git config --global core.autocrlf false + git config --global core.eol lf + + - name: Set up Git repository + uses: actions/checkout@main + + - name: Cleanup macOS + if: runner.os == 'macOS' + run: | + sudo rm -rf /Applications/Xcode.app \ + /Library/Developer/CommandLineTools + sudo xcode-select --reset + + - name: Install WSL + if: runner.os == 'windows' + uses: Vampire/setup-wsl@188b420ddc69713cdd990715aba161526aed7f6d + with: + distribution: Ubuntu-22.04 + wsl-shell-user: runner + additional-packages: build-essential + + - name: Check Bash 3.x syntax + if: runner.os == 'macOS' + run: | + /bin/bash -u -n install.sh + /bin/bash -u -O extglob -n uninstall.sh + + - name: Set up Homebrew PATH + if: runner.os != 'windows' + run: | + if [[ "${{ runner.os }}" = "macOS" ]] + then + echo "/usr/local/bin:/usr/bin:/bin" >> "${GITHUB_PATH}" + else + echo "/home/linuxbrew/.linuxbrew/bin:/usr/bin:/bin" >> "${GITHUB_PATH}" + fi + + - name: Uninstall GitHub Actions Homebrew + run: | + if which brew &>/dev/null + then + /bin/bash uninstall.sh -n >/dev/null + /bin/bash uninstall.sh -f >/dev/null + fi + + - name: Set up WSL environment + if: runner.os == 'windows' + shell: "wsl-bash -u root {0}" + run: | + echo "runner ALL=(ALL) NOPASSWD:ALL" | tee /etc/sudoers.d/runner + chmod 644 /etc/sudoers.d/runner + echo -e "#!/bin/bash\nexec /home/linuxbrew/.linuxbrew/bin/brew \"\$@\"" | tee /usr/local/bin/brew + chmod 755 /usr/local/bin/brew + + - run: /bin/bash -c "$(cat install.sh)" + + - run: brew config + + - run: brew install ack + + - run: /bin/bash uninstall.sh -f >/dev/null + + - run: /bin/bash -c "$(cat install.sh)" + + - name: Uninstall and reinstall with sudo NOPASSWD + if: runner.os == 'linux' + run: | + echo "${USER} ALL=(ALL) NOPASSWD:ALL" | sudo tee "/etc/sudoers.d/${USER}" + /bin/bash uninstall.sh -f >/dev/null + /bin/bash -c "$(cat install.sh)" + + - name: Check code styles + if: runner.os != 'windows' + run: | + brew install shellcheck shfmt diffutils + brew style *.sh + + - run: /bin/bash uninstall.sh -n >/dev/null + + - run: /bin/bash uninstall.sh -f >/dev/null diff --git a/install-master/.github/workflows/triage-issues.yml b/install-master/.github/workflows/triage-issues.yml new file mode 100644 index 000000000..69f338379 --- /dev/null +++ b/install-master/.github/workflows/triage-issues.yml @@ -0,0 +1,83 @@ +# This file is synced from the `.github` repository, do not modify it directly. +name: Triage issues + +on: + push: + paths: + - .github/workflows/triage-issues.yml + branches-ignore: + - dependabot/** + schedule: + # Once every day at midnight UTC + - cron: "0 0 * * *" + issue_comment: + +permissions: + issues: write + pull-requests: write + +concurrency: + group: triage-issues + cancel-in-progress: ${{ github.event_name != 'issue_comment' }} + +jobs: + stale: + if: > + startsWith(github.repository, 'Homebrew/') && ( + github.event_name != 'issue_comment' || ( + contains(github.event.issue.labels.*.name, 'stale') || + contains(github.event.pull_request.labels.*.name, 'stale') + ) + ) + runs-on: ubuntu-latest + steps: + - name: Mark/Close Stale Issues and Pull Requests + uses: actions/stale@v8 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-stale: 21 + days-before-close: 7 + stale-issue-message: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. + stale-pr-message: > + This pull request has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. + exempt-issue-labels: "gsoc-outreachy,help wanted,in progress" + exempt-pr-labels: "gsoc-outreachy,help wanted,in progress" + + bump-pr-stale: + if: > + startsWith(github.repository, 'Homebrew/') && ( + github.event_name != 'issue_comment' || ( + contains(github.event.issue.labels.*.name, 'stale') || + contains(github.event.pull_request.labels.*.name, 'stale') + ) + ) + runs-on: ubuntu-latest + steps: + - name: Mark/Close Stale `bump-formula-pr` and `bump-cask-pr` Pull Requests + uses: actions/stale@v8 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-stale: 2 + days-before-close: 1 + stale-pr-message: > + This pull request has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. To keep this + pull request open, add a `help wanted` or `in progress` label. + exempt-pr-labels: "help wanted,in progress" + any-of-labels: "bump-formula-pr,bump-cask-pr" + + lock-threads: + if: startsWith(github.repository, 'Homebrew/') && github.event_name != 'issue_comment' + runs-on: ubuntu-latest + steps: + - name: Lock Outdated Threads + uses: dessant/lock-threads@be8aa5be94131386884a6da4189effda9b14aa21 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + issue-inactive-days: 30 + add-issue-labels: outdated + pr-inactive-days: 30 + add-pr-labels: outdated diff --git a/install-master/LICENSE.txt b/install-master/LICENSE.txt new file mode 100644 index 000000000..12500f7e5 --- /dev/null +++ b/install-master/LICENSE.txt @@ -0,0 +1,25 @@ +BSD 2-Clause License + +Copyright (c) 2009-present, Homebrew contributors +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/install-master/README.md b/install-master/README.md new file mode 100644 index 000000000..1ab48e7ce --- /dev/null +++ b/install-master/README.md @@ -0,0 +1,45 @@ +# Homebrew (un)installer + +## Install Homebrew (on macOS or Linux) + +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +More installation information and options: . + +If you're on macOS, try out our new `.pkg` installer. Download it from [Homebrew's latest GitHub release](https://github.com/Homebrew/brew/releases/latest). + +If you are running Linux or WSL, [there are some pre-requisite packages to install](https://docs.brew.sh/Homebrew-on-Linux#requirements). + +You can set `HOMEBREW_NO_INSTALL_FROM_API` to tap Homebrew/homebrew-core; by default, it will not be tapped as it is no longer necessary. + +You can set `HOMEBREW_BREW_GIT_REMOTE` and/or `HOMEBREW_CORE_GIT_REMOTE` in your shell environment to use geolocalized Git mirrors to speed up Homebrew's installation with this script and, after installation, `brew update`. + +```bash +export HOMEBREW_BREW_GIT_REMOTE="..." # put your Git mirror of Homebrew/brew here +export HOMEBREW_CORE_GIT_REMOTE="..." # put your Git mirror of Homebrew/homebrew-core here +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +The default Git remote will be used if the corresponding environment variable is unset. + +If you want to run the Homebrew installer non-interactively without prompting for passwords (e.g. in automation scripts), you can use: + +```bash +NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +``` + +## Uninstall Homebrew + +```bash +/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" +``` + +If you want to run the Homebrew uninstaller non-interactively, you can use: + +```bash +NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" +``` + +Download the uninstall script and run `/bin/bash uninstall.sh --help` to view more uninstall options. diff --git a/install-master/install.sh b/install-master/install.sh new file mode 100755 index 000000000..7bd50e35d --- /dev/null +++ b/install-master/install.sh @@ -0,0 +1,1093 @@ +#!/bin/bash + +# We don't need return codes for "$(command)", only stdout is needed. +# Allow `[[ -n "$(command)" ]]`, `func "$(command)"`, pipes, etc. +# shellcheck disable=SC2312 + +set -u + +abort() { + printf "%s\n" "$@" >&2 + exit 1 +} + +# Fail fast with a concise message when not using bash +# Single brackets are needed here for POSIX compatibility +# shellcheck disable=SC2292 +if [ -z "${BASH_VERSION:-}" ] +then + abort "Bash is required to interpret this script." +fi + +# Check if script is run with force-interactive mode in CI +if [[ -n "${CI-}" && -n "${INTERACTIVE-}" ]] +then + abort "Cannot run force-interactive mode in CI." +fi + +# Check if both `INTERACTIVE` and `NONINTERACTIVE` are set +# Always use single-quoted strings with `exp` expressions +# shellcheck disable=SC2016 +if [[ -n "${INTERACTIVE-}" && -n "${NONINTERACTIVE-}" ]] +then + abort 'Both `$INTERACTIVE` and `$NONINTERACTIVE` are set. Please unset at least one variable and try again.' +fi + +# Check if script is run in POSIX mode +if [[ -n "${POSIXLY_CORRECT+1}" ]] +then + abort 'Bash must not run in POSIX mode. Please unset POSIXLY_CORRECT and try again.' +fi + +usage() { + cat <${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")" +} + +warn() { + printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")" >&2 +} + +# Check if script is run non-interactively (e.g. CI) +# If it is run non-interactively we should not prompt for passwords. +# Always use single-quoted strings with `exp` expressions +# shellcheck disable=SC2016 +if [[ -z "${NONINTERACTIVE-}" ]] +then + if [[ -n "${CI-}" ]] + then + warn 'Running in non-interactive mode because `$CI` is set.' + NONINTERACTIVE=1 + elif [[ ! -t 0 ]] + then + if [[ -z "${INTERACTIVE-}" ]] + then + warn 'Running in non-interactive mode because `stdin` is not a TTY.' + NONINTERACTIVE=1 + else + warn 'Running in interactive mode despite `stdin` not being a TTY because `$INTERACTIVE` is set.' + fi + fi +else + ohai 'Running in non-interactive mode because `$NONINTERACTIVE` is set.' +fi + +# USER isn't always set so provide a fall back for the installer and subprocesses. +if [[ -z "${USER-}" ]] +then + USER="$(chomp "$(id -un)")" + export USER +fi + +# First check OS. +OS="$(uname)" +if [[ "${OS}" == "Linux" ]] +then + HOMEBREW_ON_LINUX=1 +elif [[ "${OS}" == "Darwin" ]] +then + HOMEBREW_ON_MACOS=1 +else + abort "Homebrew is only supported on macOS and Linux." +fi + +# Required installation paths. To install elsewhere (which is unsupported) +# you can untar https://github.com/Homebrew/brew/tarball/master +# anywhere you like. +if [[ -n "${HOMEBREW_ON_MACOS-}" ]] +then + UNAME_MACHINE="$(/usr/bin/uname -m)" + + if [[ "${UNAME_MACHINE}" == "arm64" ]] + then + # On ARM macOS, this script installs to /opt/homebrew only + HOMEBREW_PREFIX="/opt/homebrew" + HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}" + else + # On Intel macOS, this script installs to /usr/local only + HOMEBREW_PREFIX="/usr/local" + HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}/Homebrew" + fi + HOMEBREW_CACHE="${HOME}/Library/Caches/Homebrew" + + STAT_PRINTF=("stat" "-f") + PERMISSION_FORMAT="%A" + CHOWN=("/usr/sbin/chown") + CHGRP=("/usr/bin/chgrp") + GROUP="admin" + TOUCH=("/usr/bin/touch") + INSTALL=("/usr/bin/install" -d -o "root" -g "wheel" -m "0755") +else + UNAME_MACHINE="$(uname -m)" + + # On Linux, this script installs to /home/linuxbrew/.linuxbrew only + HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew" + HOMEBREW_REPOSITORY="${HOMEBREW_PREFIX}/Homebrew" + HOMEBREW_CACHE="${HOME}/.cache/Homebrew" + + STAT_PRINTF=("stat" "--printf") + PERMISSION_FORMAT="%a" + CHOWN=("/bin/chown") + CHGRP=("/bin/chgrp") + GROUP="$(id -gn)" + TOUCH=("/bin/touch") + INSTALL=("/usr/bin/install" -d -o "${USER}" -g "${GROUP}" -m "0755") +fi +CHMOD=("/bin/chmod") +MKDIR=("/bin/mkdir" "-p") +HOMEBREW_BREW_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/brew" +HOMEBREW_CORE_DEFAULT_GIT_REMOTE="https://github.com/Homebrew/homebrew-core" + +# Use remote URLs of Homebrew repositories from environment if set. +HOMEBREW_BREW_GIT_REMOTE="${HOMEBREW_BREW_GIT_REMOTE:-"${HOMEBREW_BREW_DEFAULT_GIT_REMOTE}"}" +HOMEBREW_CORE_GIT_REMOTE="${HOMEBREW_CORE_GIT_REMOTE:-"${HOMEBREW_CORE_DEFAULT_GIT_REMOTE}"}" +# The URLs with and without the '.git' suffix are the same Git remote. Do not prompt. +if [[ "${HOMEBREW_BREW_GIT_REMOTE}" == "${HOMEBREW_BREW_DEFAULT_GIT_REMOTE}.git" ]] +then + HOMEBREW_BREW_GIT_REMOTE="${HOMEBREW_BREW_DEFAULT_GIT_REMOTE}" +fi +if [[ "${HOMEBREW_CORE_GIT_REMOTE}" == "${HOMEBREW_CORE_DEFAULT_GIT_REMOTE}.git" ]] +then + HOMEBREW_CORE_GIT_REMOTE="${HOMEBREW_CORE_DEFAULT_GIT_REMOTE}" +fi +export HOMEBREW_{BREW,CORE}_GIT_REMOTE + +# TODO: bump version when new macOS is released or announced +MACOS_NEWEST_UNSUPPORTED="15.0" +# TODO: bump version when new macOS is released +MACOS_OLDEST_SUPPORTED="12.0" + +# For Homebrew on Linux +REQUIRED_RUBY_VERSION=2.6 # https://github.com/Homebrew/brew/pull/6556 +REQUIRED_GLIBC_VERSION=2.13 # https://docs.brew.sh/Homebrew-on-Linux#requirements +REQUIRED_CURL_VERSION=7.41.0 # HOMEBREW_MINIMUM_CURL_VERSION in brew.sh in Homebrew/brew +REQUIRED_GIT_VERSION=2.7.0 # HOMEBREW_MINIMUM_GIT_VERSION in brew.sh in Homebrew/brew + +# no analytics during installation +export HOMEBREW_NO_ANALYTICS_THIS_RUN=1 +export HOMEBREW_NO_ANALYTICS_MESSAGE_OUTPUT=1 + +unset HAVE_SUDO_ACCESS # unset this from the environment + +have_sudo_access() { + if [[ ! -x "/usr/bin/sudo" ]] + then + return 1 + fi + + local -a SUDO=("/usr/bin/sudo") + if [[ -n "${SUDO_ASKPASS-}" ]] + then + SUDO+=("-A") + elif [[ -n "${NONINTERACTIVE-}" ]] + then + SUDO+=("-n") + fi + + if [[ -z "${HAVE_SUDO_ACCESS-}" ]] + then + if [[ -n "${NONINTERACTIVE-}" ]] + then + "${SUDO[@]}" -l mkdir &>/dev/null + else + "${SUDO[@]}" -v && "${SUDO[@]}" -l mkdir &>/dev/null + fi + HAVE_SUDO_ACCESS="$?" + fi + + if [[ -n "${HOMEBREW_ON_MACOS-}" ]] && [[ "${HAVE_SUDO_ACCESS}" -ne 0 ]] + then + abort "Need sudo access on macOS (e.g. the user ${USER} needs to be an Administrator)!" + fi + + return "${HAVE_SUDO_ACCESS}" +} + +execute() { + if ! "$@" + then + abort "$(printf "Failed during: %s" "$(shell_join "$@")")" + fi +} + +execute_sudo() { + local -a args=("$@") + if have_sudo_access + then + if [[ -n "${SUDO_ASKPASS-}" ]] + then + args=("-A" "${args[@]}") + fi + ohai "/usr/bin/sudo" "${args[@]}" + execute "/usr/bin/sudo" "${args[@]}" + else + ohai "${args[@]}" + execute "${args[@]}" + fi +} + +getc() { + local save_state + save_state="$(/bin/stty -g)" + /bin/stty raw -echo + IFS='' read -r -n 1 -d '' "$@" + /bin/stty "${save_state}" +} + +ring_bell() { + # Use the shell's audible bell. + if [[ -t 1 ]] + then + printf "\a" + fi +} + +wait_for_user() { + local c + echo + echo "Press ${tty_bold}RETURN${tty_reset}/${tty_bold}ENTER${tty_reset} to continue or any other key to abort:" + getc c + # we test for \r and \n because some stuff does \r instead + if ! [[ "${c}" == $'\r' || "${c}" == $'\n' ]] + then + exit 1 + fi +} + +major_minor() { + echo "${1%%.*}.$( + x="${1#*.}" + echo "${x%%.*}" + )" +} + +version_gt() { + [[ "${1%.*}" -gt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -gt "${2#*.}" ]] +} +version_ge() { + [[ "${1%.*}" -gt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -ge "${2#*.}" ]] +} +version_lt() { + [[ "${1%.*}" -lt "${2%.*}" ]] || [[ "${1%.*}" -eq "${2%.*}" && "${1#*.}" -lt "${2#*.}" ]] +} + +check_run_command_as_root() { + [[ "${EUID:-${UID}}" == "0" ]] || return + + # Allow Azure Pipelines/GitHub Actions/Docker/Concourse/Kubernetes to do everything as root (as it's normal there) + [[ -f /.dockerenv ]] && return + [[ -f /run/.containerenv ]] && return + [[ -f /proc/1/cgroup ]] && grep -E "azpl_job|actions_job|docker|garden|kubepods" -q /proc/1/cgroup && return + + abort "Don't run this as root!" +} + +should_install_command_line_tools() { + if [[ -n "${HOMEBREW_ON_LINUX-}" ]] + then + return 1 + fi + + if version_gt "${macos_version}" "10.13" + then + ! [[ -e "/Library/Developer/CommandLineTools/usr/bin/git" ]] + else + ! [[ -e "/Library/Developer/CommandLineTools/usr/bin/git" ]] || + ! [[ -e "/usr/include/iconv.h" ]] + fi +} + +get_permission() { + "${STAT_PRINTF[@]}" "${PERMISSION_FORMAT}" "$1" +} + +user_only_chmod() { + [[ -d "$1" ]] && [[ "$(get_permission "$1")" != 75[0145] ]] +} + +exists_but_not_writable() { + [[ -e "$1" ]] && ! [[ -r "$1" && -w "$1" && -x "$1" ]] +} + +get_owner() { + "${STAT_PRINTF[@]}" "%u" "$1" +} + +file_not_owned() { + [[ "$(get_owner "$1")" != "$(id -u)" ]] +} + +get_group() { + "${STAT_PRINTF[@]}" "%g" "$1" +} + +file_not_grpowned() { + [[ " $(id -G "${USER}") " != *" $(get_group "$1") "* ]] +} + +# Please sync with 'test_ruby()' in 'Library/Homebrew/utils/ruby.sh' from the Homebrew/brew repository. +test_ruby() { + if [[ ! -x "$1" ]] + then + return 1 + fi + + "$1" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt -rrubygems -e \ + "abort if Gem::Version.new(RUBY_VERSION.to_s.dup).to_s.split('.').first(2) != \ + Gem::Version.new('${REQUIRED_RUBY_VERSION}').to_s.split('.').first(2)" 2>/dev/null +} + +test_curl() { + if [[ ! -x "$1" ]] + then + return 1 + fi + + local curl_version_output curl_name_and_version + curl_version_output="$("$1" --version 2>/dev/null)" + curl_name_and_version="${curl_version_output%% (*}" + version_ge "$(major_minor "${curl_name_and_version##* }")" "$(major_minor "${REQUIRED_CURL_VERSION}")" +} + +test_git() { + if [[ ! -x "$1" ]] + then + return 1 + fi + + local git_version_output + git_version_output="$("$1" --version 2>/dev/null)" + if [[ "${git_version_output}" =~ "git version "([^ ]*).* ]] + then + version_ge "$(major_minor "${BASH_REMATCH[1]}")" "$(major_minor "${REQUIRED_GIT_VERSION}")" + else + abort "Unexpected Git version: '${git_version_output}'!" + fi +} + +# Search for the given executable in PATH (avoids a dependency on the `which` command) +which() { + # Alias to Bash built-in command `type -P` + type -P "$@" +} + +# Search PATH for the specified program that satisfies Homebrew requirements +# function which is set above +# shellcheck disable=SC2230 +find_tool() { + if [[ $# -ne 1 ]] + then + return 1 + fi + + local executable + while read -r executable + do + if [[ "${executable}" != /* ]] + then + warn "Ignoring ${executable} (relative paths don't work)" + elif "test_$1" "${executable}" + then + echo "${executable}" + break + fi + done < <(which -a "$1") +} + +no_usable_ruby() { + [[ -z "$(find_tool ruby)" ]] +} + +outdated_glibc() { + local glibc_version + glibc_version="$(ldd --version | head -n1 | grep -o '[0-9.]*$' | grep -o '^[0-9]\+\.[0-9]\+')" + version_lt "${glibc_version}" "${REQUIRED_GLIBC_VERSION}" +} + +if [[ -n "${HOMEBREW_ON_LINUX-}" ]] && no_usable_ruby && outdated_glibc +then + abort "$( + cat </dev/null +then + trap '/usr/bin/sudo -k' EXIT +fi + +# Things can fail later if `pwd` doesn't exist. +# Also sudo prints a warning message for no good reason +cd "/usr" || exit 1 + +####################################################################### script + +# shellcheck disable=SC2016 +ohai 'Checking for `sudo` access (which may request your password)...' + +if [[ -n "${HOMEBREW_ON_MACOS-}" ]] +then + have_sudo_access +elif ! [[ -w "${HOMEBREW_PREFIX}" ]] && + ! [[ -w "/home/linuxbrew" ]] && + ! [[ -w "/home" ]] && + ! have_sudo_access +then + abort "$( + cat </dev/null +then + abort "$( + cat </dev/null || return + + # we do it in four steps to avoid merge errors when reinstalling + execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" + + # "git remote add" will fail if the remote is defined in the global config + execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_BREW_GIT_REMOTE}" + execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" + + # ensure we don't munge line endings on checkout + execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" + + # make sure symlinks are saved as-is + execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" + + execute "${USABLE_GIT}" "fetch" "--force" "origin" + execute "${USABLE_GIT}" "fetch" "--force" "--tags" "origin" + + execute "${USABLE_GIT}" "reset" "--hard" "origin/master" + + if [[ "${HOMEBREW_REPOSITORY}" != "${HOMEBREW_PREFIX}" ]] + then + if [[ "${HOMEBREW_REPOSITORY}" == "${HOMEBREW_PREFIX}/Homebrew" ]] + then + execute "ln" "-sf" "../Homebrew/bin/brew" "${HOMEBREW_PREFIX}/bin/brew" + else + abort "The Homebrew/brew repository should be placed in the Homebrew prefix directory." + fi + fi + + if [[ -n "${HOMEBREW_NO_INSTALL_FROM_API-}" && ! -d "${HOMEBREW_CORE}" ]] + then + # Always use single-quoted strings with `exp` expressions + # shellcheck disable=SC2016 + ohai 'Tapping homebrew/core because `$HOMEBREW_NO_INSTALL_FROM_API` is set.' + ( + execute "${MKDIR[@]}" "${HOMEBREW_CORE}" + cd "${HOMEBREW_CORE}" >/dev/null || return + + execute "${USABLE_GIT}" "-c" "init.defaultBranch=master" "init" "--quiet" + execute "${USABLE_GIT}" "config" "remote.origin.url" "${HOMEBREW_CORE_GIT_REMOTE}" + execute "${USABLE_GIT}" "config" "remote.origin.fetch" "+refs/heads/*:refs/remotes/origin/*" + execute "${USABLE_GIT}" "config" "--bool" "core.autocrlf" "false" + execute "${USABLE_GIT}" "config" "--bool" "core.symlinks" "true" + execute "${USABLE_GIT}" "fetch" "--force" "origin" "refs/heads/master:refs/remotes/origin/master" + execute "${USABLE_GIT}" "remote" "set-head" "origin" "--auto" >/dev/null + execute "${USABLE_GIT}" "reset" "--hard" "origin/master" + + cd "${HOMEBREW_REPOSITORY}" >/dev/null || return + ) || exit 1 + fi + + execute "${HOMEBREW_PREFIX}/bin/brew" "update" "--force" "--quiet" +) || exit 1 + +if [[ ":${PATH}:" != *":${HOMEBREW_PREFIX}/bin:"* ]] +then + warn "${HOMEBREW_PREFIX}/bin is not in your PATH. + Instructions on how to configure your shell for Homebrew + can be found in the 'Next steps' section below." +fi + +ohai "Installation successful!" +echo + +ring_bell + +# Use an extra newline and bold to avoid this being missed. +ohai "Homebrew has enabled anonymous aggregate formulae and cask analytics." +echo "$( + cat </dev/null || return + execute "${USABLE_GIT}" "config" "--replace-all" "homebrew.analyticsmessage" "true" + execute "${USABLE_GIT}" "config" "--replace-all" "homebrew.caskanalyticsmessage" "true" +) || exit 1 + +ohai "Next steps:" +case "${SHELL}" in + */bash*) + if [[ -r "${HOME}/.bash_profile" ]] + then + shell_profile="${HOME}/.bash_profile" + else + shell_profile="${HOME}/.profile" + fi + ;; + */zsh*) + shell_profile="${HOME}/.zprofile" + ;; + *) + shell_profile="${HOME}/.profile" + ;; +esac + +if grep -qs "eval \"\$(${HOMEBREW_PREFIX}/bin/brew shellenv)\"" "${shell_profile}" +then + if ! [[ -x "$(command -v brew)" ]] + then + cat <> ${shell_profile} + eval "\$(${HOMEBREW_PREFIX}/bin/brew shellenv)" +EOS +fi + +if [[ -n "${non_default_repos}" ]] +then + plural="" + if [[ "${#additional_shellenv_commands[@]}" -gt 1 ]] + then + plural="s" + fi + printf -- "- Run these commands in your terminal to add the non-default Git remote%s for %s:\n" "${plural}" "${non_default_repos}" + printf " echo '# Set PATH, MANPATH, etc., for Homebrew.' >> %s\n" "${shell_profile}" + printf " echo '%s' >> ${shell_profile}\n" "${additional_shellenv_commands[@]}" + printf " %s\n" "${additional_shellenv_commands[@]}" +fi + +if [[ -n "${HOMEBREW_ON_LINUX-}" ]] +then + echo "- Install Homebrew's dependencies if you have sudo access:" + + if [[ -x "$(command -v apt-get)" ]] + then + echo " sudo apt-get install build-essential" + elif [[ -x "$(command -v yum)" ]] + then + echo " sudo yum groupinstall 'Development Tools'" + elif [[ -x "$(command -v pacman)" ]] + then + echo " sudo pacman -S base-devel" + elif [[ -x "$(command -v apk)" ]] + then + echo " sudo apk add build-base" + fi + + cat <&2 + exit 1 +} + +# Fail fast with a concise message when not using bash +# Single brackets are needed here for POSIX compatibility +# shellcheck disable=SC2292 +if [ -z "${BASH_VERSION:-}" ] +then + abort "Bash is required to interpret this script." +fi + +# Check if script is run in POSIX mode +if [[ -n "${POSIXLY_CORRECT+1}" ]] +then + abort 'Bash must not run in POSIX mode. Please unset POSIXLY_CORRECT and try again.' +fi + +shopt -s extglob + +strip_s() { + local s + for s in "$@" + do + s="${s## }" + echo "${s%% }" + done +} + +dir_children() { + local p + for p in "$@" + do + [[ -d "${p}" ]] || continue + find "${p}" -mindepth 1 -maxdepth 1 + done +} + +# Set up temp dir +tmpdir="/tmp/uninstall.$$" +mkdir -p "${tmpdir}" || abort "Unable to create temp dir '${tmpdir}'" +trap ' + rm -fr "${tmpdir}" + # Invalidate sudo timestamp before exiting + /usr/bin/sudo -k +' EXIT + +# Default options +opt_force="" +opt_quiet="" +opt_dry_run="" +opt_skip_cache_and_logs="" + +# global status to indicate whether there is anything wrong. +failed=false + +un="$(uname)" +case "${un}" in + Linux) + ostype=linux + homebrew_prefix_default=/home/linuxbrew/.linuxbrew + ;; + Darwin) + ostype=macos + if [[ "$(uname -m)" == "arm64" ]] + then + homebrew_prefix_default=/opt/homebrew + else + homebrew_prefix_default=/usr/local + fi + realpath() { + cd "$(dirname "$1")" && echo "$(pwd -P)/$(basename "$1")" + } + ;; + *) + abort "Unsupported system type '${un}'" + ;; +esac + +# string formatters +if [[ -t 1 ]] +then + tty_escape() { printf "\033[%sm" "$1"; } +else + tty_escape() { :; } +fi +tty_mkbold() { tty_escape "1;${1:-39}"; } +tty_blue="$(tty_mkbold 34)" +tty_red="$(tty_mkbold 31)" +tty_bold="$(tty_mkbold 39)" +tty_reset="$(tty_escape 0)" + +unset HAVE_SUDO_ACCESS # unset this from the environment + +have_sudo_access() { + if [[ ! -x "/usr/bin/sudo" ]] + then + return 1 + fi + + local -a SUDO=("/usr/bin/sudo") + if [[ -n "${SUDO_ASKPASS-}" ]] + then + SUDO+=("-A") + fi + + if [[ -z "${HAVE_SUDO_ACCESS-}" ]] + then + "${SUDO[@]}" -l mkdir &>/dev/null + HAVE_SUDO_ACCESS="$?" + fi + + if [[ -z "${HOMEBREW_ON_LINUX-}" ]] && [[ "${HAVE_SUDO_ACCESS}" -ne 0 ]] + then + abort "Need sudo access on macOS (e.g. the user ${USER} needs to be an administrator)!" + fi + + return "${HAVE_SUDO_ACCESS}" +} + +shell_join() { + local arg + printf "%s" "$1" + shift + for arg in "$@" + do + printf " " + printf "%s" "${arg// /\ }" + done +} + +resolved_pathname() { realpath "$1"; } + +pretty_print_pathnames() { + local p + for p in "$@" + do + if [[ -L "${p}" ]] + then + printf '%s -> %s\n' "${p}" "$(resolved_pathname "${p}")" + elif [[ -d "${p}" ]] + then + echo "${p}/" + else + echo "${p}" + fi + done +} + +chomp() { + printf "%s" "${1/"$'\n'"/}" +} + +ohai() { + printf "${tty_blue}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")" +} + +warn() { + printf "${tty_red}Warning${tty_reset}: %s\n" "$(chomp "$1")" +} + +execute() { + if ! "$@" + then + abort "$(printf "Failed during: %s" "$(shell_join "$@")")" + fi +} + +execute_sudo() { + local -a args=("$@") + if have_sudo_access + then + if [[ -n "${SUDO_ASKPASS-}" ]] + then + args=("-A" "${args[@]}") + fi + ohai "/usr/bin/sudo" "${args[@]}" + system "/usr/bin/sudo" "${args[@]}" + else + ohai "${args[@]}" + system "${args[@]}" + fi +} + +system() { + if ! "$@" + then + warn "Failed during: $(shell_join "$@")" + failed=true + fi +} + +####################################################################### script + +homebrew_prefix_candidates=() + +usage() { + cat <&2 && continue + echo "${HOMEBREW_REPOSITORY}/${l}" + done <<<"${gitignore}" + + if [[ "${HOMEBREW_PREFIX}" != "${HOMEBREW_REPOSITORY}" ]] + then + echo "${HOMEBREW_REPOSITORY}" + directories=( + bin/brew + etc/bash_completion.d/brew + share/doc/homebrew + share/man/man1/brew.1 + share/man/man1/brew-cask.1 + share/man/man1/README.md + share/zsh/site-functions/_brew + share/zsh/site-functions/_brew_cask + share/fish/vendor_completions.d/brew.fish + var/homebrew + ) + for p in "${directories[@]}" + do + echo "${HOMEBREW_PREFIX}/${p}" + done + else + echo "${HOMEBREW_REPOSITORY}/.git" + fi + echo "${HOMEBREW_CELLAR}" + echo "${HOMEBREW_PREFIX}/Caskroom" + + [[ -n ${opt_skip_cache_and_logs} ]] || cat <<-EOS +${HOME}/Library/Caches/Homebrew +${HOME}/Library/Logs/Homebrew +/Library/Caches/Homebrew +${HOME}/.cache/Homebrew +${HOMEBREW_CACHE:-} +${HOMEBREW_LOGS:-} +EOS + + if [[ "${ostype}" == macos ]] + then + dir_children "/Applications" "${HOME}/Applications" | while read -r p2; do + [[ $(resolved_pathname "${p2}") == "${HOMEBREW_CELLAR}"/* ]] && echo "${p2}" + done + fi +} | while read -r l; do + [[ -e "${l}" ]] && echo "${l}" +done | sort -u >"${tmpdir}/homebrew_files" +homebrew_files=() +while read -r l +do + homebrew_files+=("${l}") +done <"${tmpdir}/homebrew_files" + +if [[ -z "${opt_quiet}" ]] +then + dry_str="${opt_dry_run:+would}" + warn "This script ${dry_str:-will} remove:" + pretty_print_pathnames "${homebrew_files[@]}" +fi + +# Always use single-quoted strings with `exp` expressions +# shellcheck disable=SC2016 +if [[ -n "${NONINTERACTIVE-}" ]] +then + ohai 'Running in non-interactive mode because `$NONINTERACTIVE` is set.' + opt_force=1 +fi + +if [[ -t 0 && -z "${opt_force}" && -z "${opt_dry_run}" ]] +then + read -rp "Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] " + [[ "${REPLY}" == [yY]* ]] || abort +fi + +[[ -n "${opt_quiet}" ]] || ohai "Removing Homebrew installation..." +paths=() +for p in Frameworks bin etc include lib opt sbin share var +do + p="${HOMEBREW_PREFIX}/${p}" + [[ -e "${p}" ]] && paths+=("${p}") +done +if [[ "${#paths[@]}" -gt 0 ]] +then + args=("${paths[@]}" -type l -lname '*/Cellar/*') + if [[ -n "${opt_dry_run}" ]] + then + args+=(-print) + else + args+=(-exec unlink '{}' ';') + fi + [[ -n "${opt_dry_run}" ]] && echo "Would delete:" + system /usr/bin/find "${args[@]}" +fi + +for file in "${homebrew_files[@]}" +do + if [[ -n "${opt_dry_run}" ]] + then + echo "Would delete ${file}" + else + if ! err="$(rm -fr "${file}" 2>&1)" + then + warn "Failed to delete ${file}" + echo "${err}" + fi + fi +done + +[[ -n "${opt_quiet}" ]] || ohai "Removing empty directories..." +paths=() +for p in bin etc include lib opt sbin share var Caskroom Cellar Homebrew Frameworks +do + p="${HOMEBREW_PREFIX}/${p}" + [[ -e "${p}" ]] && paths+=("${p}") +done +if [[ "${#paths[@]}" -gt 0 ]] +then + if [[ "${ostype}" == macos ]] + then + args=("${paths[@]}" -name .DS_Store) + if [[ -n "${opt_dry_run}" ]] + then + args+=(-print) + echo "Would delete:" + else + args+=(-delete) + fi + execute_sudo /usr/bin/find "${args[@]}" + fi + args=("${paths[@]}" -depth -type d -empty) + if [[ -n "${opt_dry_run}" ]] + then + args+=(-print) + echo "Would remove directories:" + else + args+=(-exec rmdir '{}' ';') + fi + execute_sudo /usr/bin/find "${args[@]}" +fi + +[[ -n "${opt_dry_run}" ]] && exit +if [[ "${HOMEBREW_PREFIX}" != "${homebrew_prefix_default}" && -e "${HOMEBREW_PREFIX}" ]] +then + execute_sudo rmdir "${HOMEBREW_PREFIX}" +fi +if [[ "${HOMEBREW_PREFIX}" != "${HOMEBREW_REPOSITORY}" && -e "${HOMEBREW_REPOSITORY}" ]] +then + execute_sudo rmdir "${HOMEBREW_REPOSITORY}" +fi + +if [[ -z "${opt_quiet}" ]] +then + if [[ "${failed}" == true ]] + then + warn "Homebrew partially uninstalled (but there were steps that failed)!" + echo "To finish uninstalling rerun this script with \`sudo\`." + else + ohai "Homebrew uninstalled!" + fi +fi + +dir_children "${HOMEBREW_REPOSITORY}" "${HOMEBREW_PREFIX}" | + sort -u >"${tmpdir}/residual_files" + +if [[ -s "${tmpdir}/residual_files" && -z "${opt_quiet}" ]] +then + echo "The following possible Homebrew files were not deleted:" + while read -r f + do + pretty_print_pathnames "${f}" + done <"${tmpdir}/residual_files" + echo -e "You may wish to remove them yourself.\n" +fi + +[[ "${failed}" != true ]] diff --git a/new-file.txt b/new-file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/scaler-open-source-september-challenge b/scaler-open-source-september-challenge new file mode 160000 index 000000000..1c6341319 --- /dev/null +++ b/scaler-open-source-september-challenge @@ -0,0 +1 @@ +Subproject commit 1c6341319b0bb8dbab37b920bd1b6104becec0b5