├── .github ├── ISSUE_TEMPLATE │ └── bug-report.md └── workflows │ └── shunit2.yml ├── .gitignore ├── CONTRIBUTING.md ├── ChangeLog.md ├── LICENSE.txt ├── Makefile ├── README.md ├── bin └── ruby-install ├── doc └── man │ └── ruby-install.1.md ├── homebrew └── ruby-install.rb ├── pkg ├── ruby-install-0.1.0.tar.gz.asc ├── ruby-install-0.1.1.tar.gz.asc ├── ruby-install-0.1.2.tar.gz.asc ├── ruby-install-0.1.3.tar.gz.asc ├── ruby-install-0.1.4.tar.gz.asc ├── ruby-install-0.10.0.tar.gz.asc ├── ruby-install-0.10.1.tar.gz.asc ├── ruby-install-0.2.0.tar.gz.asc ├── ruby-install-0.2.1.tar.gz.asc ├── ruby-install-0.3.0.tar.gz.asc ├── ruby-install-0.3.1.tar.gz.asc ├── ruby-install-0.3.2.tar.gz.asc ├── ruby-install-0.3.3.tar.gz.asc ├── ruby-install-0.3.4.tar.gz.asc ├── ruby-install-0.4.0.tar.gz.asc ├── ruby-install-0.4.1.tar.gz.asc ├── ruby-install-0.4.2.tar.gz.asc ├── ruby-install-0.4.3.tar.gz.asc ├── ruby-install-0.5.0.tar.gz.asc ├── ruby-install-0.6.0.tar.gz.asc ├── ruby-install-0.6.1.tar.gz.asc ├── ruby-install-0.7.0.tar.gz.asc ├── ruby-install-0.7.1.tar.gz.asc ├── ruby-install-0.8.0.tar.gz.asc ├── ruby-install-0.8.1.tar.gz.asc ├── ruby-install-0.8.2.tar.gz.asc ├── ruby-install-0.8.3.tar.gz.asc ├── ruby-install-0.8.4.tar.gz.asc ├── ruby-install-0.8.5.tar.gz.asc ├── ruby-install-0.9.0.tar.gz.asc ├── ruby-install-0.9.1.tar.gz.asc ├── ruby-install-0.9.2.tar.gz.asc ├── ruby-install-0.9.3.tar.gz.asc └── ruby-install-0.9.4.tar.gz.asc ├── rpm ├── ruby-install.spec └── sources ├── setup.sh ├── share ├── man │ └── man1 │ │ └── ruby-install.1 └── ruby-install │ ├── checksums.sh │ ├── functions.sh │ ├── jruby │ ├── dependencies.sh │ └── functions.sh │ ├── logging.sh │ ├── mruby │ ├── dependencies.sh │ └── functions.sh │ ├── package_manager.sh │ ├── ruby-install.sh │ ├── ruby-versions.sh │ ├── ruby │ ├── dependencies.sh │ └── functions.sh │ ├── system.sh │ ├── truffleruby-graalvm │ ├── dependencies.sh │ └── functions.sh │ ├── truffleruby │ ├── dependencies.sh │ └── functions.sh │ ├── util.sh │ └── versions.sh └── test ├── checksums_test.sh ├── cli-tests └── no_reinstall_test.sh ├── functions-tests ├── apply_patches_test.sh ├── download_patches_test.sh └── load_dependencies_test.sh ├── helper.sh ├── jruby-tests ├── dependencies_tests.sh └── functions_tests.sh ├── logging ├── debug_test.sh └── run_test.sh ├── mruby-tests ├── dependencies_tests.sh └── functions_tests.sh ├── package_manager-tests └── set_package_manager_test.sh ├── ruby-install-tests ├── init_test.sh ├── list_rubies_test.sh ├── parse_options_test.sh ├── parse_ruby_test.sh └── variables_test.sh ├── ruby-tests ├── dependencies_tests.sh └── functions_tests.sh ├── ruby-versions-tests ├── are_ruby_versions_missing_test.sh ├── download_ruby_versions_file_test.sh ├── download_ruby_versions_test.sh ├── is_known_ruby_version_test.sh ├── is_unknown_ruby_version_test.sh ├── latest_ruby_version_test.sh ├── lookup_ruby_version_test.sh ├── ruby_checksum_for_test.sh └── stable_ruby_versions_test.sh ├── runner ├── src └── .gitkeep ├── system-tests ├── cpu_count_test.sh ├── detect_downloader_test.sh ├── detect_os_test.sh ├── detect_package_manager_test.sh ├── detect_sudo_test.sh └── source_test.sh ├── truffleruby-graalvm-tests ├── dependencies_tests.sh └── functions_tests.sh ├── truffleruby-tests ├── dependencies_tests.sh └── functions_tests.sh ├── util-tests ├── absolute_path_test.sh ├── check_write_permissions_test.sh └── download_test.sh └── versions_test.sh /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a bug 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 42 | 43 | ## Description 44 | 45 | 46 | 47 | ## Steps To Reproduce 48 | 49 | Steps to reproduce the bug: 50 | 1. `$ ruby-install ...` 51 | 2. ??? 52 | 53 | ## Expected Behavior 54 | 55 | 56 | 57 | ## Actual Behavior 58 | 59 | 60 | 61 | ## Environment 62 | 63 | $ ruby-install --version 64 | ... 65 | $ uname -a 66 | ... 67 | $ cc --version 68 | ... 69 | $ openssl version 70 | ... 71 | 72 | 77 | -------------------------------------------------------------------------------- /.github/workflows/shunit2.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [ push, pull_request ] 4 | 5 | jobs: 6 | ubuntu: 7 | runs-on: ubuntu-latest 8 | name: "Run tests on Ubuntu" 9 | steps: 10 | - uses: actions/checkout@v4 11 | - name: Install dependencies 12 | run: sudo apt-get update -qq -y && sudo apt-get install -qq -y wget curl shunit2 13 | - name: Run tests 14 | run: make test 15 | 16 | fedora: 17 | runs-on: ubuntu-latest 18 | container: fedora:latest 19 | name: "Run tests on Fedora" 20 | steps: 21 | - uses: actions/checkout@v4 22 | - name: Install dependencies 23 | run: dnf update -q -y && dnf install -q -y make patch wget curl shunit2 24 | - name: Run tests 25 | run: | 26 | useradd user 27 | chown -R user:user . 28 | sudo -u user make test 29 | 30 | opensuse: 31 | runs-on: ubuntu-latest 32 | container: opensuse/tumbleweed:latest 33 | name: "Run tests on OpenSUSE" 34 | steps: 35 | - name: Install dependencies 36 | run: zypper ref && zypper --non-interactive in sudo tar gzip findutils make patch wget shunit2 37 | - uses: actions/checkout@v4 38 | - name: Run tests 39 | run: | 40 | useradd user 41 | chown -R user:user . 42 | sudo -u user make test 43 | 44 | archlinux: 45 | runs-on: ubuntu-latest 46 | container: archlinux:latest 47 | name: "Run tests on ArchLinux" 48 | steps: 49 | - uses: actions/checkout@v4 50 | - name: Install dependencies 51 | run: | 52 | pacman-key --init && \ 53 | pacman -Syu --noconfirm && \ 54 | pacman -Sy --noconfirm git base base-devel make patch wget curl && \ 55 | useradd -d /home/makepkg makepkg && \ 56 | mkdir -p /home/makepkg/{.config/pacman,.gnupg,out} && \ 57 | chown -R makepkg:users /home/makepkg && \ 58 | sudo -u makepkg /bin/bash -c "cd /home/makepkg && git clone --quiet --depth 1 https://aur.archlinux.org/shunit2.git && cd shunit2/ && makepkg" && \ 59 | pacman -U --noconfirm /home/makepkg/shunit2/shunit2-*.pkg.tar.zst 60 | - name: Run tests 61 | run: | 62 | useradd user 63 | chown -R user:user . 64 | sudo -u user make test 65 | 66 | macos: 67 | runs-on: macos-latest 68 | name: "Run tests on macOS" 69 | steps: 70 | - uses: actions/checkout@v4 71 | - name: Install dependencies 72 | run: brew install wget shunit2 73 | - name: Run tests 74 | run: make test 75 | 76 | freebsd: 77 | runs-on: ubuntu-latest 78 | name: "Run tests on FreeBSD" 79 | steps: 80 | - uses: actions/checkout@v4 81 | - name: Run tests 82 | id: freebsd 83 | uses: vmactions/freebsd-vm@v1 84 | with: 85 | usesh: true 86 | copyback: false 87 | prepare: | 88 | pkg install -y wget curl shunit2 89 | run: | 90 | pw useradd user 91 | chown -R user:user . 92 | su -m user -c "make test" 93 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /test/src/ 2 | /test/home/ 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## New Versions 4 | 5 | **All new versions or checksums should be submitted to the [ruby-versions] 6 | repository.** 7 | 8 | ## Code Style 9 | 10 | * Tab indent code. 11 | * Spaces may be used to align multi-line commands. 12 | * (Try to) Keep code within 80 columns. 13 | * Use [bash] <= 3.x features. 14 | * Quote all String variables. 15 | * Use `(( ))` for arithmetic expressions and `[[ ]]` otherwise. 16 | * Use `$(...)` instead of back-ticks. 17 | * Use `${path##*/}` instead of `$(basename $path)`. 18 | * Use `${path%/*}` instead of `$(dirname $path)`. 19 | * Always use `"$@"` and `${array[@]}` instead of `$*` or `${arry[*]}`, 20 | respectively. 21 | * Prefer single-line expressions where appropriate: 22 | 23 | [[ -n "$foo" ]] && other command 24 | 25 | if [[ "$foo" == "bar" ]]; then command 26 | elif [[ "$foo" == "baz" ]]; then other_command 27 | fi 28 | 29 | case "$foo" in 30 | bar) command ;; 31 | baz) other_command ;; 32 | esac 33 | 34 | * Use the `function` keyword for functions. 35 | * Put curly braces on a new line so they align. 36 | * Load function arguments into local variables for readability: 37 | 38 | function do_stuff() 39 | { 40 | local ruby="$1" 41 | local version="$2" 42 | # ... 43 | } 44 | 45 | * Explicitly return error codes with `|| return $?`. 46 | * Keep branching logic to a minimum. 47 | * Code should be declarative and easy to understand. 48 | 49 | ## Pull Request Guidelines 50 | 51 | * Utility functions should go into `share/ruby-install/ruby-install.sh`. 52 | * Generic installation steps should go into `share/ruby-install/functions.sh`. 53 | * Ruby specific installation steps should go into 54 | `share/ruby-install/$ruby/functions.sh` and may override the generic steps in 55 | `share/ruby-install/functions.sh`. 56 | * Ruby build dependencies should go into 57 | `share/ruby-install/$ruby/dependencies.txt`. 58 | * All new code must have [shunit2] unit-tests. 59 | 60 | ### What Will Not Be Accepted 61 | 62 | * Options for Ruby specific `./configure` options. You can pass additional 63 | configuration options like so: 64 | 65 | ruby-install ruby 2.0 -- --foo --bar 66 | 67 | * Excessive version or environment checks. This is the job of a `./configure` 68 | script. 69 | * Excessive OS specific workarounds. We should strive to fix any Ruby build 70 | issues or OS environment issues at their source. 71 | * Building Rubies from HEAD. This is risky and may result in a buggy/broken 72 | version of Ruby. The user should build development versions of Ruby by hand 73 | and report any bugs to upstream. 74 | 75 | [Makefile]: https://gist.github.com/3224049 76 | [shunit2]: http://code.google.com/p/shunit2/ 77 | 78 | [bash]: http://www.gnu.org/software/bash/ 79 | [ruby-versions]: https://github.com/postmodern/ruby-versions 80 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2025 Hal Brodigan 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | 'Software'), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | SHELL=/usr/bin/env bash 2 | NAME=ruby-install 3 | VERSION=0.10.1 4 | AUTHOR=postmodern 5 | URL=https://github.com/$(AUTHOR)/$(NAME) 6 | 7 | DIRS=bin share 8 | INSTALL_DIRS=`find $(DIRS) -type d` 9 | INSTALL_FILES=`find $(DIRS) -type f` 10 | DOC_FILES=*.md *.txt 11 | 12 | PKG_DIR=pkg 13 | PKG_NAME=$(NAME)-$(VERSION) 14 | PKG=$(PKG_DIR)/$(PKG_NAME).tar.gz 15 | SIG=$(PKG_DIR)/$(PKG_NAME).asc 16 | 17 | PREFIX?=/usr/local 18 | SHARE_DIR=share 19 | DOC_DIR=$(SHARE_DIR)/doc/$(PKG_NAME) 20 | 21 | all: 22 | 23 | pkg: 24 | mkdir $(PKG_DIR) 25 | 26 | share/man/man1/ruby-install.1: doc/man/ruby-install.1.md 27 | kramdown-man doc/man/ruby-install.1.md > share/man/man1/ruby-install.1 28 | 29 | man: doc/man/ruby-install.1.md share/man/man1/ruby-install.1 30 | git add doc/man/ruby-install.1.md share/man/man1/ruby-install.1 31 | git commit 32 | 33 | build: pkg 34 | git archive --output=$(PKG) --prefix=$(PKG_NAME)/ HEAD 35 | 36 | sign: $(PKG) 37 | gpg --sign --detach-sign --armor $(PKG) 38 | git add $(PKG).asc 39 | git commit $(PKG).asc -m "Added PGP signature for v$(VERSION)" 40 | git push origin master 41 | 42 | verify: $(PKG) $(SIG) 43 | gpg --verify $(SIG) $(PKG) 44 | 45 | clean: 46 | rm -f $(PKG) $(SIG) 47 | 48 | check: 49 | shellcheck --exclude SC2034 \ 50 | --exclude SC2154 \ 51 | --exclude SC1090 \ 52 | --exclude SC1091 \ 53 | --exclude SC2242 \ 54 | share/$(NAME)/*.sh bin/* 55 | 56 | lint: 57 | # Check dependencies are consistent for truffleruby/truffleruby-graalvm 58 | diff share/ruby-install/truffleruby-graalvm/dependencies.txt share/ruby-install/truffleruby/dependencies.txt 59 | 60 | test: 61 | ./test/runner 62 | 63 | tag: 64 | git push 65 | git tag -s -m "Releasing $(VERSION)" v$(VERSION) 66 | git push --tags 67 | 68 | release: build sign tag 69 | 70 | rpm: 71 | rpmdev-setuptree 72 | spectool -g -R rpm/ruby-install.spec 73 | rpmbuild -ba rpm/ruby-install.spec 74 | 75 | install: 76 | for dir in $(INSTALL_DIRS); do mkdir -p $(DESTDIR)$(PREFIX)/$$dir; done 77 | for file in $(INSTALL_FILES); do cp $$file $(DESTDIR)$(PREFIX)/$$file; done 78 | mkdir -p $(DESTDIR)$(PREFIX)/$(DOC_DIR) 79 | cp -r $(DOC_FILES) $(DESTDIR)$(PREFIX)/$(DOC_DIR)/ 80 | 81 | uninstall: 82 | for file in $(INSTALL_FILES); do rm -f $(DESTDIR)$(PREFIX)/$$file; done 83 | rm -rf $(DESTDIR)$(PREFIX)/$(DOC_DIR) 84 | 85 | .PHONY: build man sign verify clean check test tag release rpm install uninstall all 86 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ruby-install 2 | 3 | Installs [Ruby], [JRuby], [TruffleRuby] (native / GraalVM), or [mruby]. 4 | 5 | ## Features 6 | 7 | * Supports downloading the latest versions and checksums from [ruby-versions]. 8 | * Supports installing into `/opt/rubies/` for root and `~/.rubies/` for users 9 | by default. 10 | * Supports installing into arbitrary directories. 11 | * Supports downloading from arbitrary URLs. 12 | * Supports downloading from mirrors. 13 | * Supports downloading/applying patches. 14 | * Supports passing in arbitrary `./configure` options. 15 | * Supports downloading archives using `wget` or `curl`. 16 | * Supports verifying downloaded archives via MD5, SHA1, SHA256 or SHA512 17 | checksums. 18 | * Supports installing build dependencies from the package manager 19 | ([apt], [dnf], [yum], [pacman], [zypper], [xbps], [brew], [macports], and 20 | [pkg]). 21 | * Supports many different OSes: 22 | * Linux 23 | * [Ubuntu] 24 | * [Debian] 25 | * [Fedora] 26 | * [OpenSUSE] 27 | * [Arch Linux] 28 | * [Void Linux] 29 | * [macOS] 30 | * [FreeBSD] 31 | * Has unit tests. 32 | 33 | ## Anti-Features 34 | 35 | * Does not require upgrading every time a new Ruby version comes out. 36 | * Does not require recipes for each individual Ruby version or configuration. 37 | * Does not support installing trunk/HEAD or nightly rolling releases. 38 | * Does not support installing unsupported/unmaintained versions of Ruby. 39 | 40 | ## Requirements 41 | 42 | * [bash] >= 3.x 43 | * `grep` 44 | * [wget] > 1.12 or [curl] 45 | * `md5sum` or `md5` 46 | * `sha1sum` or `sha1` 47 | * `sha256sum` or `sha256` 48 | * `sha512sum` or `sha512` 49 | * `tar` 50 | * `bzip2` 51 | * `xz` 52 | * `patch` (if `--patch` is specified) 53 | * [gcc] >= 4.2 or [clang] 54 | 55 | ## Synopsis 56 | 57 | List supported Rubies and their current stable versions: 58 | 59 | ```shell 60 | $ ruby-install 61 | ``` 62 | 63 | Updates then list the supported Rubies and their current stable versions: 64 | 65 | ```shell 66 | $ ruby-install --update 67 | ``` 68 | 69 | Install the current stable version of Ruby: 70 | 71 | ```shell 72 | $ ruby-install ruby 73 | ``` 74 | 75 | Install the latest version of Ruby: 76 | 77 | ```shell 78 | $ ruby-install --update ruby 79 | ``` 80 | 81 | Install a stable version of Ruby: 82 | 83 | ```shell 84 | $ ruby-install ruby 3.1 85 | ``` 86 | 87 | Install a specific version of Ruby: 88 | 89 | ```shell 90 | $ ruby-install ruby 3.1.2 91 | ``` 92 | 93 | Install a Ruby into a specific directory: 94 | 95 | ```shell 96 | $ ruby-install --install-dir /path/to/dir ruby 97 | ``` 98 | 99 | Install a Ruby into a specific `rubies` directory: 100 | 101 | ```shell 102 | $ ruby-install --rubies-dir /path/to/rubies/ ruby 103 | ``` 104 | 105 | Install a Ruby into `/usr/local`: 106 | 107 | ```shell 108 | $ sudo ruby-install --system ruby 3.1.2 109 | ``` 110 | 111 | Install a Ruby from a mirror: 112 | 113 | ```shell 114 | $ ruby-install -M http://www.mirrorservice.org/sites/ftp.ruby-lang.org/pub/ruby ruby 3.1.2 115 | ``` 116 | 117 | Install a Ruby with a specific patch: 118 | 119 | ```shell 120 | $ ruby-install -p https://raw.github.com/gist/4136373/falcon-gc.diff ruby 1.9.3-p551 121 | ``` 122 | 123 | Install a Ruby with a specific C compiler: 124 | 125 | ```shell 126 | $ ruby-install ruby 3.1.2 -- CC=clang 127 | ``` 128 | 129 | Install a Ruby with specific configuration: 130 | 131 | ```shell 132 | $ ruby-install ruby 3.1.2 -- --enable-shared --enable-dtrace CFLAGS="-O3" 133 | ``` 134 | 135 | Install CRuby with jemalloc support: 136 | 137 | ```shell 138 | $ ruby-install ruby 3.1.2 -- --with-jemalloc 139 | ``` 140 | 141 | Install CRuby with YJIT support: 142 | 143 | ```shell 144 | $ ruby-install ruby 3.2.0 -- --enable-yjit 145 | ``` 146 | 147 | Install a Ruby without installing dependencies first: 148 | 149 | ```shell 150 | $ ruby-install --no-install-deps ruby 3.1.2 151 | ``` 152 | 153 | Uninstall a Ruby version: 154 | 155 | ```shell 156 | $ rm -rf ~/.rubies/ruby-3.1.2 157 | ``` 158 | 159 | ### Integration 160 | 161 | Using ruby-install with [RVM]: 162 | 163 | ```shell 164 | $ ruby-install --rubies-dir ~/.rvm/rubies ruby-3.2.0-preview3 165 | ``` 166 | 167 | Using ruby-install with [rbenv]: 168 | 169 | ```shell 170 | $ ruby-install --install-dir ~/.rbenv/versions/3.2.0-preview3 ruby-3.2.0-preview3 171 | ``` 172 | 173 | ruby-install can even be used with [Chef]. 174 | 175 | ## Install 176 | 177 | ```shell 178 | wget https://github.com/postmodern/ruby-install/releases/download/v0.10.1/ruby-install-0.10.1.tar.gz 179 | tar -xzvf ruby-install-0.10.1.tar.gz 180 | cd ruby-install-0.10.1/ 181 | sudo make install 182 | ``` 183 | 184 | ### PGP 185 | 186 | All releases are [PGP] signed for security. Instructions on how to import my 187 | PGP key can be found on my [blog][1]. To verify that a release was not tampered 188 | with: 189 | 190 | ```shell 191 | wget https://github.com/postmodern/ruby-install/releases/download/v0.10.1/ruby-install-0.10.1.tar.gz.asc 192 | gpg --verify ruby-install-0.10.1.tar.gz.asc ruby-install-0.10.1.tar.gz 193 | ``` 194 | 195 | ### Homebrew 196 | 197 | ruby-install can also be installed with [homebrew]: 198 | 199 | ```shell 200 | brew install ruby-install 201 | ``` 202 | 203 | Or the absolute latest ruby-install can be installed from source: 204 | 205 | ```shell 206 | brew install ruby-install --HEAD 207 | ``` 208 | 209 | ### Arch Linux 210 | 211 | ruby-install is already included in the [AUR]: 212 | 213 | ```shell 214 | yaourt -S ruby-install 215 | ``` 216 | 217 | ### Fedora Linux 218 | 219 | ruby-install is available on [Fedora Copr](https://copr.fedorainfracloud.org/coprs/duritong/chruby/). 220 | 221 | ### FreeBSD 222 | 223 | ruby-install is included in the official [FreeBSD ports collection]: 224 | 225 | ```shell 226 | cd /usr/ports/devel/ruby-install/ && make install clean 227 | ``` 228 | 229 | ## Known Issues 230 | 231 | Please see the [wiki](https://github.com/postmodern/ruby-install/wiki/Known-Issues). 232 | 233 | ## Alternatives 234 | 235 | * [RVM] 236 | * [ruby-build] 237 | 238 | ## Endorsements 239 | 240 | > I like the approach you're taking. Curious to see how it plays out. 241 | 242 | -- [Sam Stephenson](https://twitter.com/sstephenson/status/334461494668443649) 243 | of [rbenv] 244 | 245 | [ruby-versions]: https://github.com/postmodern/ruby-versions#readme 246 | 247 | [Ruby]: https://www.ruby-lang.org/ 248 | [JRuby]: https://jruby.org/ 249 | [TruffleRuby]: https://github.com/oracle/truffleruby 250 | [mruby]: https://github.com/mruby/mruby#readme 251 | 252 | [Ubuntu]: https://ubuntu.com/ 253 | [Debian]: https://www.debian.org/ 254 | [Fedora]: https://fedoraproject.org/ 255 | [OpenSUSE]: https://www.opensuse.org/ 256 | [Arch Linux]: https://archlinux.org/ 257 | [Void Linux]: https://voidlinux.org/ 258 | [macOS]: https://www.apple.com/macos/ 259 | [FreeBSD]: https://www.freebsd.org/ 260 | 261 | [apt]: https://wiki.debian.org/Apt 262 | [dnf]: https://fedoraproject.org/wiki/Features/DNF 263 | [yum]: http://yum.baseurl.org/ 264 | [pacman]: https://wiki.archlinux.org/index.php/Pacman 265 | [zypper]: https://en.opensuse.org/Portal:Zypper 266 | [xbps]: https://docs.voidlinux.org/xbps/index.html 267 | [pkg]: https://wiki.freebsd.org/pkgng 268 | [macports]: https://www.macports.org/ 269 | [brew]: https://brew.sh 270 | 271 | [bash]: https://www.gnu.org/software/bash/ 272 | [wget]: https://www.gnu.org/software/wget/ 273 | [curl]: https://curl.se/ 274 | 275 | [gcc]: https://gcc.gnu.org/ 276 | [clang]: https://clang.llvm.org/ 277 | 278 | [RVM]: https://rvm.io/ 279 | [rbenv]: https://github.com/sstephenson/rbenv#readme 280 | [ruby-build]: https://github.com/sstephenson/ruby-build#readme 281 | [Chef]: https://github.com/rosstimson/chef-ruby_install#readme 282 | 283 | [PGP]: https://en.wikipedia.org/wiki/Pretty_Good_Privacy 284 | [1]: https://postmodern.github.io/pgp/ 285 | 286 | [homebrew]: https://brew.sh/ 287 | [AUR]: https://aur.archlinux.org/packages/ruby-install/ 288 | [FreeBSD ports collection]: https://www.freshports.org/devel/ruby-install/ 289 | -------------------------------------------------------------------------------- /bin/ruby-install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source "${0%/*}/../share/ruby-install/ruby-install.sh" 4 | 5 | parse_options "$@" || exit $? 6 | 7 | if [[ -z "$ruby" ]]; then 8 | list_rubies 9 | exit $? 10 | fi 11 | 12 | if [[ $force_update -eq 1 ]] || 13 | are_ruby_versions_missing "$ruby" || 14 | is_unknown_ruby_version "$ruby" "$ruby_version"; then 15 | log "Updating $ruby versions ..." 16 | download_ruby_versions "$ruby" || fail "Failed to download $ruby versions!" 17 | fi 18 | 19 | init || exit $? 20 | 21 | if [[ $no_reinstall -eq 1 ]] && [[ -x "$install_dir/bin/ruby" ]]; then 22 | log "Ruby is already installed into $install_dir" 23 | exit 24 | fi 25 | 26 | if ! check_write_permissions "$install_dir"; then 27 | fail "Cannot write to the installation directory: $install_dir" 28 | fi 29 | 30 | log "Installing $ruby $ruby_version into $install_dir ..." 31 | 32 | pre_install || fail "Pre-install tasks failed!" 33 | 34 | if [[ ! $no_install_deps -eq 1 ]]; then 35 | install_deps || fail "Installing dependencies failed!" 36 | fi 37 | 38 | if [[ ! $no_download -eq 1 ]]; then 39 | download_ruby || fail "Download of $ruby_url failed!" 40 | fi 41 | 42 | if [[ ! $no_verify -eq 1 ]]; then 43 | verify_ruby || fail "Verification of $ruby_archive failed!" 44 | fi 45 | 46 | if [[ ! $no_extract -eq 1 ]]; then 47 | extract_ruby || fail "Unpacking of $ruby_archive failed!" 48 | fi 49 | 50 | download_patches || fail "Fetching patches $patches failed!" 51 | apply_patches || fail "Patching $ruby $ruby_version failed!" 52 | 53 | cd "$ruby_build_dir" || fail "ruby build directory is missing: $ruby_build_dir" 54 | 55 | configure_ruby || fail "Configuration of $ruby $ruby_version failed!" 56 | clean_ruby || fail "Cleaning $ruby $ruby_version failed!" 57 | compile_ruby || fail "Compiling $ruby $ruby_version failed!" 58 | install_ruby || fail "Installation of $ruby $ruby_version failed!" 59 | post_install || fail "Post-install tasks failed!" 60 | 61 | if [[ $cleanup -eq 1 ]]; then 62 | cleanup_source || fail "Cleanup of archive and unpacked source in $src_dir/ failed!" 63 | fi 64 | 65 | log "Successfully installed $ruby $ruby_version into $install_dir" 66 | -------------------------------------------------------------------------------- /doc/man/ruby-install.1.md: -------------------------------------------------------------------------------- 1 | # ruby-install 1 "Aug 2018" ruby-install "User Manuals" 2 | 3 | ## NAME 4 | 5 | ronin-install - Installs Ruby, JRuby, TruffleRuby, or mruby 6 | 7 | ## SYNOPSIS 8 | 9 | `ruby-install` [*options*] [[*RUBY* \| *VERSION* \| *RUBY-VERSION*] [-- *CONFIGURE_OPTS* ...]] 10 | 11 | ## DESCRIPTION 12 | 13 | Installs a version of Ruby, JRuby, TruffleRuby, or mruby. 14 | 15 | https://github.com/postmodern/ruby-install#readme 16 | 17 | ## ARGUMENTS 18 | 19 | *RUBY* 20 | : Install Ruby by name. Must be either `ruby`, `jruby`, `truffleruby`, or 21 | `mruby`. 22 | 23 | *VERSION* 24 | : Optionally select the version of selected Ruby. 25 | 26 | *CONFIGURE_OPTS* 27 | : Additional optional configure arguments. 28 | 29 | ## OPTIONS 30 | 31 | `-r`, `--rubies-dir` *DIR* 32 | : Specifies the alternate directory where other Ruby directories are 33 | installed, such as *~/.rvm/rubies* or *~/.rbenv/versions*. 34 | Defaults to */opt/rubies* for root and *~/.rubies* for normal users. 35 | 36 | `-i`, `--install-dir` *DIR* 37 | : Specifies the directory where Ruby will be installed. 38 | Defaults to */opt/rubies/$ruby-$version* for root and 39 | *~/.rubies/$ruby-$version* for normal users. 40 | 41 | `--prefix` *DIR* 42 | : Alias for `-i DIR`. 43 | 44 | `--system` 45 | : Alias for `-i /usr/local`. 46 | 47 | `-s`, `--src-dir` *DIR* 48 | : Specifies the directory for downloading and unpacking Ruby source. 49 | 50 | `-c`, `--cleanup` 51 | : Remove the downloaded Ruby archive and unpacked source-code after 52 | installation. 53 | 54 | `-j`, `--jobs` *NUM*, `-j`*NUM*, `--jobs=`*NUM* 55 | : Specifies the number of *make* jobs to run in parallel when compiling 56 | Ruby. If the `-j` option is provided without an argument, *make* will 57 | allow an unlimited number of simultaneous jobs. 58 | 59 | `-p`, `--patch` {*FILE* \| *URL*} 60 | : Specifies any additional patches to apply. 61 | 62 | `-M`, `--mirror` *URL* 63 | : Specifies an alternate mirror to download the Ruby archive from. 64 | 65 | `-u`, `--url` *URL* 66 | : Alternate URL to download the Ruby archive from. 67 | 68 | `-m`, `--md5` *MD5* 69 | : Specifies the MD5 checksum for the Ruby archive. 70 | 71 | `--sha1` *SHA1* 72 | : Specifies the SHA1 checksum for the Ruby archive. 73 | 74 | `--sha256` *SHA256* 75 | : Specifies the SHA256 checksum for the Ruby archive. 76 | 77 | `--sha512` *SHA512* 78 | : Specifies the SHA512 checksum for the Ruby archive. 79 | 80 | `--package-manager` [`apt`\|`dnf`\|`yum`\|`pacman`\|`zypper`\|`brew`\|`pkg`\|`port`] 81 | : Use an alternative package manager. 82 | 83 | `--no-download` 84 | : Use the previously downloaded Ruby archive. 85 | 86 | `--no-verify` 87 | : Do not verify the downloaded Ruby archive. 88 | 89 | `--no-extract` 90 | : Do not extract the downloaded Ruby archive. Implies `--no-download` and 91 | `--no-verify`. 92 | 93 | `--no-install-deps` 94 | : Do not install build dependencies before installing Ruby. 95 | 96 | `--no-reinstall` 97 | : Skip installation if another Ruby is detected in same location. 98 | 99 | `-U`, `--update` 100 | : Downloads the latest ruby versions and checksums from the ruby-versions 101 | repository (https://github.com/postmodern/ruby-versions#readme). 102 | 103 | `-D`, `--debug` 104 | : Enable debugging messages. 105 | 106 | `-V`, `--version` 107 | : Prints the current ruby-install version. 108 | 109 | `-h`, `--help` 110 | : Prints a synopsis of ruby-install usage. 111 | 112 | ## EXAMPLES 113 | 114 | List supported Rubies and their major versions: 115 | 116 | $ ruby-install 117 | 118 | List the latest versions: 119 | 120 | $ ruby-install --latest 121 | 122 | Install the current stable version of Ruby: 123 | 124 | $ ruby-install ruby 125 | 126 | Install the latest version of Ruby: 127 | 128 | $ ruby-install --latest ruby 129 | 130 | Install a latest version of Ruby: 131 | 132 | $ ruby-install ruby 3.1 133 | 134 | Install a specific version of Ruby: 135 | 136 | $ ruby-install ruby 3.1.2 137 | 138 | Install a Ruby into a specific directory: 139 | 140 | $ ruby-install --install-dir /path/to/dir ruby 141 | 142 | Install a Ruby into a specific `rubies` directory: 143 | 144 | $ ruby-install --rubies-dir /path/to/rubies/ ruby 145 | 146 | Install a Ruby into `/usr/local`: 147 | 148 | $ sudo ruby-install --system ruby 3.1.2 149 | 150 | Install a Ruby from a mirror: 151 | 152 | $ ruby-install -M http://www.mirrorservice.org/sites/ftp.ruby-lang.org/pub/ruby ruby 2.4.0 153 | 154 | Install a Ruby with a specific patch: 155 | 156 | $ ruby-install -p https://raw.github.com/gist/4136373/falcon-gc.diff ruby 1.9.3-p551 157 | 158 | Install a Ruby with specific configuration: 159 | 160 | $ ruby-install ruby 3.1.2 -- --enable-shared --enable-dtrace CFLAGS="-O3" 161 | 162 | Install CRuby with jemalloc support: 163 | 164 | $ ruby-install ruby 3.1.2 -- --with-jemalloc 165 | 166 | Install CRuby with YJIT support: 167 | 168 | $ ruby-install ruby 3.2.0 -- --enable-yjit 169 | 170 | Using ruby-install with [RVM]: 171 | 172 | $ ruby-install --rubies-dir ~/.rvm/rubies ruby 3.1.2 173 | 174 | Using ruby-install with [rbenv]: 175 | 176 | $ ruby-install -i ~/.rbenv/versions/2.4.0 ruby 3.1.2 177 | 178 | Uninstall a Ruby version: 179 | 180 | $ rm -rf ~/.rubies/ruby-3.1.2 181 | 182 | ## FILES 183 | 184 | */usr/local/src* 185 | : Default root user source directory. 186 | 187 | *~/src* 188 | : Default non-root user source directory. 189 | 190 | */opt/rubies/$ruby-$version* 191 | : Default root user installation directory. 192 | 193 | *~/.rubies/$ruby-$version* 194 | : Default non-root user installation directory. 195 | 196 | ## ENVIRONMENT 197 | 198 | *RUBY_INSTALL_SRC_DIR* 199 | : Overrides the default source directory. 200 | 201 | *RUBY_INSTALL_RUBIES_DIR* 202 | : Overrides the default installation directory. 203 | 204 | *RUBY_INSTALL_PKG_MANAGER* 205 | : Explicitly sets the package manager to use. 206 | 207 | ## AUTHOR 208 | 209 | Postmodern 210 | 211 | ## SEE ALSO 212 | 213 | [ruby(1)](man:ruby.1), [gem(1)](man:gem.1), [chruby(1)](man:chruby.1), [chruby-exec(1)](man:chruby-exec.1) 214 | -------------------------------------------------------------------------------- /homebrew/ruby-install.rb: -------------------------------------------------------------------------------- 1 | class RubyInstall < Formula 2 | desc "Install Ruby, JRuby, TruffleRuby, or mruby" 3 | homepage "https://github.com/postmodern/ruby-install#readme" 4 | url "https://github.com/postmodern/ruby-install/releases/download/v0.10.1/ruby-install-0.10.1.tar.gz" 5 | sha256 "7f563af2bae257c006a5dba0b1976e0885d3814332cc4391eeaa88d702753289" 6 | license "MIT" 7 | head "https://github.com/postmodern/ruby-install.git", branch: "master" 8 | 9 | bottle do 10 | sha256 cellar: :any_skip_relocation, arm64_big_sur: "d19d4a89f08d447d522387e362b5e4627de5438e06396e2035fe735dc192d7de" 11 | sha256 cellar: :any_skip_relocation, big_sur: "cd1ffd6780ab70d0701e812784ed7a7bb2276c6fc8f3303570fbf200a4f2ccde" 12 | sha256 cellar: :any_skip_relocation, catalina: "cd1ffd6780ab70d0701e812784ed7a7bb2276c6fc8f3303570fbf200a4f2ccde" 13 | sha256 cellar: :any_skip_relocation, mojave: "cd1ffd6780ab70d0701e812784ed7a7bb2276c6fc8f3303570fbf200a4f2ccde" 14 | sha256 cellar: :any_skip_relocation, x86_64_linux: "d19d4a89f08d447d522387e362b5e4627de5438e06396e2035fe735dc192d7de" 15 | end 16 | 17 | def install 18 | system "make", "install", "PREFIX=#{prefix}" 19 | end 20 | 21 | test do 22 | system "#{bin}/ruby-install" 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.1.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.13 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlGkgGIACgkQVMPZ6blRXnetLwCeOS+SQEwozkAkiPat2g3NKyRK 5 | ILMAnjOkwm53EsTqVdfL4+y/1LgbWUOp 6 | =w0Le 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.1.1.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.13 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlGlOJUACgkQVMPZ6blRXnd+HACeMs6/BJbTvgwrySaIMnlOXxOJ 5 | MZ4AoJb45wCCIgVhxSMPC6XhzISVQd3Q 6 | =qZ86 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.1.2.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.13 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlGm+/cACgkQVMPZ6blRXncXdQCeKqz08Gzv8E+iVxQaO2uMT5Q0 5 | nL8AniuWB0eZEMJOz6qECfIq10Kay8pS 6 | =XkBf 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.1.3.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.13 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlGn0bkACgkQVMPZ6blRXneA7ACeMWxxyrBpgtLotvHg5KDSH3Ld 5 | 6S8AnjXTfXukkf3/KKDHm9ohbgs7BBGC 6 | =DnlY 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.1.4.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.13 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlGoSsAACgkQVMPZ6blRXnflFQCZAT6AHY42qsK8cEdhg0CoaYF1 5 | FlkAmwXXDSszMlq5B34kTeDri6ipyUiO 6 | =E0za 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.10.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCZ6Pk0wAKCRBUw9npuVFe 4 | d806AJ42Lk2a9xZgowG50aQBPzJT0Xt53ACdFpkT8L6kZDgDY8ZV3Cj9qWbh3Po= 5 | =VxPX 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.10.1.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCZ6UFFQAKCRBUw9npuVFe 4 | d3pmAJ9IOA3tPz6lfxGKlWHyfLlQOmEXIACdGSXyfkzk9Q2zUzjML0nPJc8W4yU= 5 | =cc3L 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.2.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.13 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlHHx1wACgkQVMPZ6blRXnczKgCfSjHlSSaQZikrbs98WxMignRa 5 | kQoAnj0MuIDws5K0yHAKbcA29bN+aDwf 6 | =fqJs 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.2.1.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.13 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlHPpP0ACgkQVMPZ6blRXndtGgCgkZmU3AGyostt/0bFaa6Zvbux 5 | vRUAoITSXMLGNXf+SebG8XmeRgTszxpJ 6 | =42ba 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.3.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.13 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlIBxWgACgkQVMPZ6blRXnd3wgCfWFEC8pC2O8z/j1ygIGXNPZQ8 5 | gZMAoJNfYYp5rQ2ilRUHvFC2Lc84GysU 6 | =Mlqj 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.3.1.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.15 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlJiD74ACgkQVMPZ6blRXndcdwCfVCVbVEm3uAsmgIw+i/rToSbu 5 | 6uwAniwgxjAIFxBVK25zVpQ52HWUxxyI 6 | =zeXo 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.3.2.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.15 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlKP4nAACgkQVMPZ6blRXncRAQCeLZy69T4Q6wZAMCYRgRZ86B71 5 | mrAAnRLzrwlyR7HYT8WiL3WxtOUjOhAY 6 | =Xijx 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.3.3.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.15 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlKfmpAACgkQVMPZ6blRXndWlgCdHrgJ/n7L83bYWQ1ci8EEthcg 5 | E8YAoIbl16sB2K+HFOCBjbEgith67UHQ 6 | =BnIW 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.3.4.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1.4.15 (GNU/Linux) 3 | 4 | iEYEABECAAYFAlK7bFYACgkQVMPZ6blRXnfPwwCfdmmBnD8Qgw5OWK5mU8dqlXhq 5 | f4YAniT3ryvECMdV9/ZLF2EShmRFrclS 6 | =jEED 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.4.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1 3 | 4 | iEYEABECAAYFAlL9tssACgkQVMPZ6blRXnfprgCfZpgfIP+/Odof80lCnzXO/bla 5 | ACcAn2Luc+6orth1x2P+AIq1pmPD3L+7 6 | =SZsY 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.4.1.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1 3 | 4 | iEYEABECAAYFAlMVQtcACgkQVMPZ6blRXncs0ACfZHF39K7V92EYHlBRyPaSKVfU 5 | iYQAoIZFkMrsj92lQN3lDiiFh5HTC0I0 6 | =p6RE 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.4.2.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1 3 | 4 | iEYEABECAAYFAlNQgd4ACgkQVMPZ6blRXnc+xQCghxTVjYGYpoREpYiKIOfgbBOW 5 | 3gMAnAvUZ+/qxh/z4zhC6lPqS6b0ifzc 6 | =6DeP 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.4.3.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1 3 | 4 | iEYEABECAAYFAlNsdn0ACgkQVMPZ6blRXnefcgCdF5vW7a807Jec5E8+AcMNm4aj 5 | 6vYAniSccN4/ggxSJnDo7GD0ijzn1GqZ 6 | =4ua7 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.5.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1 3 | 4 | iEYEABECAAYFAlRDDH0ACgkQVMPZ6blRXncARwCfaH9v1DTokLdO4u+V0EMk/wLA 5 | D54An2aTcoBUzjwghsDwzb036bprqxZl 6 | =Vh1e 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.6.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | Version: GnuPG v1 3 | 4 | iEYEABECAAYFAlZ9GY4ACgkQVMPZ6blRXndPKwCgkzxWZswMODxu2WrXk6PFATjf 5 | bv0An39aXlrsa0nkWyXOP2KW070RDDco 6 | =n2TZ 7 | -----END PGP SIGNATURE----- 8 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.6.1.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iEYEABECAAYFAlhfTLQACgkQVMPZ6blRXnfOWwCgjT0xF1CQqZOefkaBr2x+5fh0 4 | Lv0AnjieiwCHI+pwqY8VgeS7N/AWqr4d 5 | =jS7F 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.7.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iEYEABECAAYFAltmWicACgkQVMPZ6blRXnf0+gCfebjxS/jaV/Rn2WEUKH6mcUMY 4 | t18An1yBy53lDLiqOtsiHBHVl3tPIV0C 5 | =olKL 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.7.1.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCXxfoQAAKCRBUw9npuVFe 4 | d51IAJsFSPZoCkTJSM/SjJgLiTXzPsVANACfd5QhkVmYKe3dTeA8r+TQey5s6Zs= 5 | =n6xR 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.8.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCX9G2RwAKCRBUw9npuVFe 4 | dx6MAJ0dKw/TK7NkYS+pM8yCW/XXJMTAEgCdG7SYLfqMMq+tjYo4ALSKPFPcTxM= 5 | =73IR 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.8.1.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCX9//UAAKCRBUw9npuVFe 4 | d88pAJ9dkJ9rdWUOd9CBUR8a1fzPShD8GgCgj54WCfVQK5AM3vhtGrp1MAKzoOw= 5 | =7Mm3 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.8.2.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCYOJn/QAKCRBUw9npuVFe 4 | d8zgAKCLDrEfLZoaaJyWBK5vKPGjznbikwCeJ6SOnnIsdp28Xi4i82mJZQDeW7c= 5 | =pYrv 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.8.3.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCYU7d5wAKCRBUw9npuVFe 4 | d8CBAKCCyWJdK0JU5ahF1DdfYNSDrHvtIgCfePlni87xTCUXhIvmJ30d4TOkmn4= 5 | =eFS/ 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.8.4.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCYug1PQAKCRBUw9npuVFe 4 | d/J9AJwL3p+fUx9EvLqC7U2bKWu8/I/KSACffc4I1EoE8EZdBDmg7gQjGEtzW3o= 5 | =ka1x 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.8.5.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCYwQL0gAKCRBUw9npuVFe 4 | d0i/AJ9opbW130LKmruskUlvYbZo1/5gHQCfbmmvZGJSmA17aJku9Rz1TIvnSKo= 5 | =CH9V 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.9.0.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCY9hkigAKCRBUw9npuVFe 4 | dy0CAJ48Q4nNCuXAfiM1Ig11XRhXEw/uWgCbBViRxK0y1gM29a+z93YYWUX61HQ= 5 | =gd7+ 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.9.1.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCZJXHbwAKCRBUw9npuVFe 4 | d3YcAJ4xtyakjpt2y6o7tSdsacMrAp0tBACgikhZQWfPQQkxAwYGOqEsv+CZxmY= 5 | =Z5Jz 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.9.2.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCZQoBkgAKCRBUw9npuVFe 4 | d++uAJ4h6YZ+zxA3VYj4CJ31bV5bsKKTvQCfZOkSipHrE0dLagBjnQ2FR+tBxco= 5 | =XfFz 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.9.3.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCZWpMmAAKCRBUw9npuVFe 4 | d+rhAKCUyzG5OlpEplnIQNCSd4uuSujsggCfZVbf2HPTcwW6VHbLd9aGdm0TWa8= 5 | =PEcH 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /pkg/ruby-install-0.9.4.tar.gz.asc: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP SIGNATURE----- 2 | 3 | iF0EABECAB0WIQQEsvPqZUFAvMfaG1dUw9npuVFedwUCZ1y7JAAKCRBUw9npuVFe 4 | dzpbAJ9tVIHlVTLFe+G/SGVlgOLFnGseawCeLV0qQkX5NsPodf26+Kxfjg08QWs= 5 | =75VU 6 | -----END PGP SIGNATURE----- 7 | -------------------------------------------------------------------------------- /rpm/ruby-install.spec: -------------------------------------------------------------------------------- 1 | %define name ruby-install 2 | %define version 0.10.1 3 | %define release 1 4 | 5 | %define buildroot %{_topdir}/BUILDROOT 6 | 7 | BuildRoot: %{buildroot} 8 | Source0: https://github.com/postmodern/%{name}/releases/download/v%{version}/%{name}-%{version}.tar.gz 9 | Summary: Installs Ruby, JRuby, TruffleRuby (native / GraalVM), or mruby 10 | Name: %{name} 11 | Version: %{version} 12 | Release: %{release} 13 | License: MIT 14 | URL: https://github.com/postmodern/ruby-install#readme 15 | AutoReqProv: no 16 | BuildArch: noarch 17 | Requires: bash, grep, wget > 1.12, tar, bzip2, xz, patch 18 | 19 | %description 20 | Installs Ruby, JRuby, TruffleRuby (native / GraalVM), or mruby 21 | 22 | %prep 23 | %setup -q 24 | 25 | %build 26 | 27 | %install 28 | make install PREFIX=%{buildroot}/usr 29 | 30 | %files 31 | %defattr(-,root,root) 32 | %{_bindir}/ruby-install 33 | %{_datadir}/%{name}/* 34 | %{_mandir}/man1/* 35 | %doc 36 | %{_defaultdocdir}/%{name}-%{version}/* 37 | 38 | %changelog 39 | * Thu Feb 06 2025 Postmodern - 0.10.1-1 40 | - Rebuilt for version 0.10.1. 41 | 42 | * Wed Feb 05 2025 Postmodern - 0.10.0-1 43 | - Rebuilt for version 0.10.0. 44 | 45 | * Fri Dec 13 2024 Postmodern - 0.9.4-1 46 | - Rebuilt for version 0.9.4. 47 | 48 | * Fri Dec 01 2023 Postmodern - 0.9.3-1 49 | - Rebuilt for version 0.9.3. 50 | 51 | * Tue Sep 19 2023 Postmodern - 0.9.2-1 52 | - Rebuilt for version 0.9.2. 53 | 54 | * Fri Jun 23 2023 Postmodern - 0.9.1-1 55 | - Rebuilt for version 0.9.1. 56 | 57 | * Mon Jan 30 2023 Postmodern - 0.9.0-1 58 | - Rebuilt for version 0.9.0. 59 | 60 | * Mon Aug 22 2022 Postmodern - 0.8.5-1 61 | - Rebuilt for version 0.8.5. 62 | 63 | * Mon Aug 03 2022 Postmodern - 0.8.4-2 64 | - Added xz as a dependency. 65 | 66 | * Mon Aug 01 2022 Postmodern - 0.8.4-1 67 | - Rebuilt for version 0.8.4. 68 | 69 | * Sat Sep 25 2021 Postmodern - 0.8.3-1 70 | - Rebuilt for version 0.8.3. 71 | 72 | * Sun Jul 04 2021 Postmodern - 0.8.2-1 73 | - Rebuilt for version 0.8.2. 74 | - Updated the package summary and description. 75 | - Added grep as a dependency. 76 | 77 | * Sun Dec 20 2020 Postmodern - 0.8.1-1 78 | - Rebuilt for version 0.8.1. 79 | 80 | * Wed Dec 09 2020 Postmodern - 0.8.0-1 81 | - Rebuilt for version 0.8.0. 82 | 83 | * Wed Jul 22 2020 Postmodern - 0.7.1-1 84 | - Rebuilt for version 0.7.1. 85 | 86 | * Sat Aug 04 2018 Postmodern - 0.7.0-1 87 | - Rebuilt for version 0.7.0. 88 | 89 | * Sat Dec 24 2016 Postmodern - 0.6.1-1 90 | - Rebuilt for version 0.6.1. 91 | - Added patch as dependency. 92 | 93 | * Fri Dec 25 2015 Postmodern - 0.6.0-1 94 | - Rebuilt for version 0.6.0. 95 | 96 | * Thu May 08 2014 Postmodern - 0.4.3-1 97 | - Rebuilt for version 0.4.3. 98 | 99 | * Thu Apr 17 2014 Postmodern - 0.4.2-1 100 | - Rebuilt for version 0.4.2. 101 | 102 | * Mon Mar 03 2014 Postmodern - 0.4.1-1 103 | - Rebuilt for version 0.4.1. 104 | 105 | * Thu Feb 13 2014 Postmodern - 0.4.0-1 106 | - Rebuilt for version 0.4.0. 107 | 108 | * Wed Dec 25 2013 Postmodern - 0.3.4-1 109 | - Rebuilt for version 0.3.4. 110 | 111 | * Wed Dec 04 2013 Postmodern - 0.3.3-1 112 | - Rebuilt for version 0.3.3. 113 | 114 | * Fri Nov 22 2013 Postmodern - 0.3.2-1 115 | - Rebuilt for version 0.3.2. 116 | 117 | * Fri Oct 18 2013 Postmodern - 0.3.1-1 118 | - Rebuilt for version 0.3.1. 119 | 120 | * Tue Aug 06 2013 Postmodern - 0.3.0-1 121 | - Rebuilt for version 0.3.0. 122 | 123 | * Sat Jun 29 2013 Postmodern - 0.2.1-1 124 | - Rebuilt for version 0.2.1. 125 | 126 | * Mon Jun 24 2013 Postmodern - 0.2.0-1 127 | - Rebuilt for version 0.2.0. 128 | -------------------------------------------------------------------------------- /rpm/sources: -------------------------------------------------------------------------------- 1 | e522629fbe0950f488ad893949c7fc68 ruby-install-0.10.1.tar.gz 2 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sudo make install 4 | ruby-install ruby 5 | ruby-install jruby 6 | ruby-install truffleruby 7 | -------------------------------------------------------------------------------- /share/man/man1/ruby-install.1: -------------------------------------------------------------------------------- 1 | .\" Generated by kramdown-man 1.0.1 2 | .\" https://github.com/postmodern/kramdown-man#readme 3 | .TH ruby-install 1 "Aug 2018" ruby-install "User Manuals" 4 | .SH NAME 5 | .PP 6 | ronin\-install \- Installs Ruby, JRuby, TruffleRuby, or mruby 7 | .SH SYNOPSIS 8 | .PP 9 | \fBruby\-install\fR \[lB]\fIoptions\fP\[rB] \[lB]\[lB]\fIRUBY\fP \[or] \fIVERSION\fP \[or] \fIRUBY\-VERSION\fP\[rB] \[lB]\-\- \fICONFIGURE\[ru]OPTS\fP \.\.\.\[rB]\[rB] 10 | .SH DESCRIPTION 11 | .PP 12 | Installs a version of Ruby, JRuby, TruffleRuby, or mruby\. 13 | .PP 14 | https:\[sl]\[sl]github\.com\[sl]postmodern\[sl]ruby\-install\[sh]readme 15 | .SH ARGUMENTS 16 | .TP 17 | \fIRUBY\fP 18 | Install Ruby by name\. Must be either \fBruby\fR, \fBjruby\fR, \fBtruffleruby\fR, or 19 | \fBmruby\fR\. 20 | .TP 21 | \fIVERSION\fP 22 | Optionally select the version of selected Ruby\. 23 | .TP 24 | \fICONFIGURE\[ru]OPTS\fP 25 | Additional optional configure arguments\. 26 | .SH OPTIONS 27 | .TP 28 | \fB\-r\fR, \fB\-\-rubies\-dir\fR \fIDIR\fP 29 | Specifies the alternate directory where other Ruby directories are 30 | installed, such as \fI\[ti]\[sl]\.rvm\[sl]rubies\fP or \fI\[ti]\[sl]\.rbenv\[sl]versions\fP\. 31 | Defaults to \fI\[sl]opt\[sl]rubies\fP for root and \fI\[ti]\[sl]\.rubies\fP for normal users\. 32 | .TP 33 | \fB\-i\fR, \fB\-\-install\-dir\fR \fIDIR\fP 34 | Specifies the directory where Ruby will be installed\. 35 | Defaults to \fI\[sl]opt\[sl]rubies\[sl]\[Do]ruby\-\[Do]version\fP for root and 36 | \fI\[ti]\[sl]\.rubies\[sl]\[Do]ruby\-\[Do]version\fP for normal users\. 37 | .TP 38 | \fB\-\-prefix\fR \fIDIR\fP 39 | Alias for \fB\-i DIR\fR\. 40 | .TP 41 | \fB\-\-system\fR 42 | Alias for \fB\-i \[sl]usr\[sl]local\fR\. 43 | .TP 44 | \fB\-s\fR, \fB\-\-src\-dir\fR \fIDIR\fP 45 | Specifies the directory for downloading and unpacking Ruby source\. 46 | .TP 47 | \fB\-c\fR, \fB\-\-cleanup\fR 48 | Remove the downloaded Ruby archive and unpacked source\-code after 49 | installation\. 50 | .TP 51 | \fB\-j\fR, \fB\-\-jobs\fR \fINUM\fP, \fB\-j\fR\fINUM\fP, \fB\-\-jobs\[eq]\fR\fINUM\fP 52 | Specifies the number of \fImake\fP jobs to run in parallel when compiling 53 | Ruby\. If the \fB\-j\fR option is provided without an argument, \fImake\fP will 54 | allow an unlimited number of simultaneous jobs\. 55 | .TP 56 | \fB\-p\fR, \fB\-\-patch\fR \[lC]\fIFILE\fP \[or] \fIURL\fP\[rC] 57 | Specifies any additional patches to apply\. 58 | .TP 59 | \fB\-M\fR, \fB\-\-mirror\fR \fIURL\fP 60 | Specifies an alternate mirror to download the Ruby archive from\. 61 | .TP 62 | \fB\-u\fR, \fB\-\-url\fR \fIURL\fP 63 | Alternate URL to download the Ruby archive from\. 64 | .TP 65 | \fB\-m\fR, \fB\-\-md5\fR \fIMD5\fP 66 | Specifies the MD5 checksum for the Ruby archive\. 67 | .TP 68 | \fB\-\-sha1\fR \fISHA1\fP 69 | Specifies the SHA1 checksum for the Ruby archive\. 70 | .TP 71 | \fB\-\-sha256\fR \fISHA256\fP 72 | Specifies the SHA256 checksum for the Ruby archive\. 73 | .TP 74 | \fB\-\-sha512\fR \fISHA512\fP 75 | Specifies the SHA512 checksum for the Ruby archive\. 76 | .TP 77 | \fB\-\-package\-manager\fR \[lB]\fBapt\fR\[or]\fBdnf\fR\[or]\fByum\fR\[or]\fBpacman\fR\[or]\fBzypper\fR\[or]\fBbrew\fR\[or]\fBpkg\fR\[or]\fBport\fR\[rB] 78 | Use an alternative package manager\. 79 | .TP 80 | \fB\-\-no\-download\fR 81 | Use the previously downloaded Ruby archive\. 82 | .TP 83 | \fB\-\-no\-verify\fR 84 | Do not verify the downloaded Ruby archive\. 85 | .TP 86 | \fB\-\-no\-extract\fR 87 | Do not extract the downloaded Ruby archive\. Implies \fB\-\-no\-download\fR and 88 | \fB\-\-no\-verify\fR\. 89 | .TP 90 | \fB\-\-no\-install\-deps\fR 91 | Do not install build dependencies before installing Ruby\. 92 | .TP 93 | \fB\-\-no\-reinstall\fR 94 | Skip installation if another Ruby is detected in same location\. 95 | .TP 96 | \fB\-U\fR, \fB\-\-update\fR 97 | Downloads the latest ruby versions and checksums from the ruby\-versions 98 | repository (https:\[sl]\[sl]github\.com\[sl]postmodern\[sl]ruby\-versions\[sh]readme)\. 99 | .TP 100 | \fB\-D\fR, \fB\-\-debug\fR 101 | Enable debugging messages\. 102 | .TP 103 | \fB\-V\fR, \fB\-\-version\fR 104 | Prints the current ruby\-install version\. 105 | .TP 106 | \fB\-h\fR, \fB\-\-help\fR 107 | Prints a synopsis of ruby\-install usage\. 108 | .SH EXAMPLES 109 | .PP 110 | List supported Rubies and their major versions: 111 | .PP 112 | .RS 4 113 | .EX 114 | \[Do] ruby\-install 115 | .EE 116 | .RE 117 | .PP 118 | List the latest versions: 119 | .PP 120 | .RS 4 121 | .EX 122 | \[Do] ruby\-install \-\-latest 123 | .EE 124 | .RE 125 | .PP 126 | Install the current stable version of Ruby: 127 | .PP 128 | .RS 4 129 | .EX 130 | \[Do] ruby\-install ruby 131 | .EE 132 | .RE 133 | .PP 134 | Install the latest version of Ruby: 135 | .PP 136 | .RS 4 137 | .EX 138 | \[Do] ruby\-install \-\-latest ruby 139 | .EE 140 | .RE 141 | .PP 142 | Install a latest version of Ruby: 143 | .PP 144 | .RS 4 145 | .EX 146 | \[Do] ruby\-install ruby 3\.1 147 | .EE 148 | .RE 149 | .PP 150 | Install a specific version of Ruby: 151 | .PP 152 | .RS 4 153 | .EX 154 | \[Do] ruby\-install ruby 3\.1\.2 155 | .EE 156 | .RE 157 | .PP 158 | Install a Ruby into a specific directory: 159 | .PP 160 | .RS 4 161 | .EX 162 | \[Do] ruby\-install \-\-install\-dir \[sl]path\[sl]to\[sl]dir ruby 163 | .EE 164 | .RE 165 | .PP 166 | Install a Ruby into a specific \fBrubies\fR directory: 167 | .PP 168 | .RS 4 169 | .EX 170 | \[Do] ruby\-install \-\-rubies\-dir \[sl]path\[sl]to\[sl]rubies\[sl] ruby 171 | .EE 172 | .RE 173 | .PP 174 | Install a Ruby into \fB\[sl]usr\[sl]local\fR: 175 | .PP 176 | .RS 4 177 | .EX 178 | \[Do] sudo ruby\-install \-\-system ruby 3\.1\.2 179 | .EE 180 | .RE 181 | .PP 182 | Install a Ruby from a mirror: 183 | .PP 184 | .RS 4 185 | .EX 186 | \[Do] ruby\-install \-M http:\[sl]\[sl]www\.mirrorservice\.org\[sl]sites\[sl]ftp\.ruby\-lang\.org\[sl]pub\[sl]ruby ruby 2\.4\.0 187 | .EE 188 | .RE 189 | .PP 190 | Install a Ruby with a specific patch: 191 | .PP 192 | .RS 4 193 | .EX 194 | \[Do] ruby\-install \-p https:\[sl]\[sl]raw\.github\.com\[sl]gist\[sl]4136373\[sl]falcon\-gc\.diff ruby 1\.9\.3\-p551 195 | .EE 196 | .RE 197 | .PP 198 | Install a Ruby with specific configuration: 199 | .PP 200 | .RS 4 201 | .EX 202 | \[Do] ruby\-install ruby 3\.1\.2 \-\- \-\-enable\-shared \-\-enable\-dtrace CFLAGS\[eq]\[dq]\-O3\[dq] 203 | .EE 204 | .RE 205 | .PP 206 | Install CRuby with jemalloc support: 207 | .PP 208 | .RS 4 209 | .EX 210 | \[Do] ruby\-install ruby 3\.1\.2 \-\- \-\-with\-jemalloc 211 | .EE 212 | .RE 213 | .PP 214 | Install CRuby with YJIT support: 215 | .PP 216 | .RS 4 217 | .EX 218 | \[Do] ruby\-install ruby 3\.2\.0 \-\- \-\-enable\-yjit 219 | .EE 220 | .RE 221 | .PP 222 | Using ruby\-install with \[lB]RVM\[rB]: 223 | .PP 224 | .RS 4 225 | .EX 226 | \[Do] ruby\-install \-\-rubies\-dir \[ti]\[sl]\.rvm\[sl]rubies ruby 3\.1\.2 227 | .EE 228 | .RE 229 | .PP 230 | Using ruby\-install with \[lB]rbenv\[rB]: 231 | .PP 232 | .RS 4 233 | .EX 234 | \[Do] ruby\-install \-i \[ti]\[sl]\.rbenv\[sl]versions\[sl]2\.4\.0 ruby 3\.1\.2 235 | .EE 236 | .RE 237 | .PP 238 | Uninstall a Ruby version: 239 | .PP 240 | .RS 4 241 | .EX 242 | \[Do] rm \-rf \[ti]\[sl]\.rubies\[sl]ruby\-3\.1\.2 243 | .EE 244 | .RE 245 | .SH FILES 246 | .TP 247 | \fI\[sl]usr\[sl]local\[sl]src\fP 248 | Default root user source directory\. 249 | .TP 250 | \fI\[ti]\[sl]src\fP 251 | Default non\-root user source directory\. 252 | .TP 253 | \fI\[sl]opt\[sl]rubies\[sl]\[Do]ruby\-\[Do]version\fP 254 | Default root user installation directory\. 255 | .TP 256 | \fI\[ti]\[sl]\.rubies\[sl]\[Do]ruby\-\[Do]version\fP 257 | Default non\-root user installation directory\. 258 | .SH ENVIRONMENT 259 | .TP 260 | \fIRUBY\[ru]INSTALL\[ru]SRC\[ru]DIR\fP 261 | Overrides the default source directory\. 262 | .TP 263 | \fIRUBY\[ru]INSTALL\[ru]RUBIES\[ru]DIR\fP 264 | Overrides the default installation directory\. 265 | .TP 266 | \fIRUBY\[ru]INSTALL\[ru]PKG\[ru]MANAGER\fP 267 | Explicitly sets the package manager to use\. 268 | .SH AUTHOR 269 | .PP 270 | Postmodern 271 | .MT postmodern\.mod3\[at]gmail\.com 272 | .ME 273 | .SH SEE ALSO 274 | .PP 275 | .BR ruby (1) 276 | , 277 | .BR gem (1) 278 | , 279 | .BR chruby (1) 280 | , 281 | .BR chruby\-exec (1) 282 | -------------------------------------------------------------------------------- /share/ruby-install/checksums.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | unset GREP_OPTIONS GREP_COLOR GREP_COLORS 4 | 5 | if command -v md5sum > /dev/null; then md5sum="md5sum" 6 | elif command -v md5 > /dev/null; then md5sum="md5 -r" 7 | fi 8 | 9 | if command -v sha1sum > /dev/null; then sha1sum="sha1sum" 10 | elif command -v sha1 > /dev/null; then sha1sum="sha1 -r" 11 | elif command -v shasum > /dev/null; then sha1sum="shasum" 12 | fi 13 | 14 | if command -v sha256sum > /dev/null; then sha256sum="sha256sum" 15 | elif command -v sha256 > /dev/null; then sha256sum="sha256 -r" 16 | elif command -v shasum > /dev/null; then sha256sum="shasum -a 256" 17 | fi 18 | 19 | if command -v sha512sum > /dev/null; then sha512sum="sha512sum" 20 | elif command -v sha512 > /dev/null; then sha512sum="sha512 -r" 21 | elif command -v shasum > /dev/null; then sha512sum="shasum -a 512" 22 | fi 23 | 24 | function lookup_checksum() 25 | { 26 | local checksums="$1" 27 | local file="${2##*/}" 28 | 29 | if [[ ! -f "$checksums" ]]; then 30 | return 1 31 | fi 32 | 33 | local output="$(grep " $file" "$checksums")" 34 | 35 | echo -n "${output%% *}" 36 | } 37 | 38 | function compute_checksum() 39 | { 40 | local algorithm="$1" 41 | local file="$2" 42 | local program 43 | 44 | case "$algorithm" in 45 | md5) program="$md5sum" ;; 46 | sha1) program="$sha1sum" ;; 47 | sha256) program="$sha256sum" ;; 48 | sha512) program="$sha512sum" ;; 49 | *) return 1 ;; 50 | esac 51 | 52 | if [[ -z "$program" ]]; then 53 | error "could not find $algorithm checksum utility" 54 | return 1 55 | fi 56 | 57 | debug "$program $file" 58 | local output="$($program "$file")" 59 | 60 | echo -n "${output%% *}" 61 | } 62 | 63 | function verify_checksum() 64 | { 65 | local file="$1" 66 | local algorithm="$2" 67 | local expected_checksum="$3" 68 | 69 | if [[ -z "$expected_checksum" ]]; then 70 | warn "No $algorithm checksum for $file" 71 | return 72 | fi 73 | 74 | local actual_checksum="$(compute_checksum "$algorithm" "$file")" 75 | 76 | if [[ "$actual_checksum" != "$expected_checksum" ]]; then 77 | error "Invalid $algorithm checksum for $file" 78 | error " expected: $expected_checksum" 79 | error " actual: $actual_checksum" 80 | return 1 81 | fi 82 | } 83 | -------------------------------------------------------------------------------- /share/ruby-install/functions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source "$ruby_install_dir/checksums.sh" 4 | 5 | # 6 | # Place holder for pre-install tasks 7 | # 8 | function pre_install() { return; } 9 | 10 | # 11 | # Loads the dependencies.sh file for the ruby and sets $ruby_dependencies. 12 | # 13 | function load_dependencies() 14 | { 15 | source "$ruby_install_dir/$ruby/dependencies.sh" 16 | } 17 | 18 | # 19 | # Install the ruby's dependencies. 20 | # 21 | function install_deps() 22 | { 23 | load_dependencies 24 | 25 | if (( ${#ruby_dependencies[@]} > 0 )); then 26 | log "Installing dependencies for $ruby $ruby_version ..." 27 | install_packages "${ruby_dependencies[@]}" || return $? 28 | fi 29 | } 30 | 31 | # 32 | # Download the Ruby archive 33 | # 34 | function download_ruby() 35 | { 36 | log "Downloading $ruby_url into $src_dir ..." 37 | download "$ruby_url" "$src_dir/$ruby_archive" || return $? 38 | } 39 | 40 | # 41 | # Verifies the Ruby archive against all known checksums. 42 | # 43 | function verify_ruby() 44 | { 45 | log "Verifying $ruby_archive ..." 46 | 47 | local file="$src_dir/$ruby_archive" 48 | 49 | verify_checksum "$file" md5 "$ruby_md5" || return $? 50 | verify_checksum "$file" sha1 "$ruby_sha1" || return $? 51 | verify_checksum "$file" sha256 "$ruby_sha256" || return $? 52 | verify_checksum "$file" sha512 "$ruby_sha512" || return $? 53 | } 54 | 55 | # 56 | # Extract the Ruby archive 57 | # 58 | function extract_ruby() 59 | { 60 | log "Extracting $ruby_archive to $ruby_build_dir ..." 61 | extract "$src_dir/$ruby_archive" "$src_dir" || return $? 62 | } 63 | 64 | # 65 | # Download any additional patches 66 | # 67 | function download_patches() 68 | { 69 | local i patch dest 70 | 71 | for (( i=0; i<${#patches[@]}; i++ )) do 72 | patch="${patches[$i]}" 73 | 74 | if [[ "$patch" == "http://"* || "$patch" == "https://"* ]]; then 75 | dest="${ruby_build_dir}/${patch##*/}" 76 | 77 | log "Downloading patch $patch ..." 78 | download "$patch" "$dest" || return $? 79 | patches[$i]="$dest" 80 | fi 81 | done 82 | } 83 | 84 | # 85 | # Apply any additional patches 86 | # 87 | function apply_patches() 88 | { 89 | local patch name 90 | 91 | for patch in "${patches[@]}"; do 92 | name="${patch##*/}" 93 | 94 | log "Applying patch $name ..." 95 | run patch -p1 -d "$ruby_build_dir" < "$patch" || return $? 96 | done 97 | } 98 | 99 | # 100 | # Place holder function for configuring Ruby. 101 | # 102 | function configure_ruby() { return; } 103 | 104 | # 105 | # Place holder function for cleaning Ruby. 106 | # 107 | function clean_ruby() { return; } 108 | 109 | # 110 | # Place holder function for compiling Ruby. 111 | # 112 | function compile_ruby() { return; } 113 | 114 | # 115 | # Place holder function for installing Ruby. 116 | # 117 | function install_ruby() { return; } 118 | 119 | # 120 | # Place holder function for post-install tasks. 121 | # 122 | function post_install() { return; } 123 | 124 | # 125 | # Remove downloaded archive and unpacked source. 126 | # 127 | function cleanup_source() { 128 | log "Removing $src_dir/$ruby_archive ..." 129 | run rm "$src_dir/$ruby_archive" || return $? 130 | 131 | log "Removing $ruby_build_dir..." 132 | run rm -rf "$ruby_build_dir" || return $? 133 | } 134 | -------------------------------------------------------------------------------- /share/ruby-install/jruby/dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ruby_dependencies=() 4 | 5 | # NOTE: only install OpenJDK JRE if java isn't already installed. 6 | if ! command -v java >/dev/null; then 7 | case "$package_manager" in 8 | apt) ruby_dependencies+=(default-jre) ;; 9 | dnf|yum)ruby_dependencies+=(java-latest-openjdk) ;; 10 | pacman) ruby_dependencies+=(jre21-openjdk) ;; 11 | zypper) ruby_dependencies+=(java-21-openjdk) ;; 12 | xbps) ruby_dependencies+=(openjdk-jre) ;; 13 | brew) ruby_dependencies+=(openjdk) ;; 14 | port) ruby_dependencies+=(openjdk21) ;; 15 | pkg) ruby_dependencies+=(openjdk21-jre) ;; 16 | esac 17 | fi 18 | -------------------------------------------------------------------------------- /share/ruby-install/jruby/functions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ruby_archive="${ruby_archive:-jruby-dist-$ruby_version-bin.tar.gz}" 4 | ruby_dir_name="jruby-$ruby_version" 5 | ruby_mirror="${ruby_mirror:-https://repo1.maven.org/maven2/org/jruby/jruby-dist}" 6 | ruby_url="${ruby_url:-$ruby_mirror/$ruby_version/$ruby_archive}" 7 | 8 | # 9 | # Install JRuby into $install_dir. 10 | # 11 | function install_ruby() 12 | { 13 | log "Installing jruby $ruby_version ..." 14 | copy_into "$ruby_build_dir" "$install_dir" || return $? 15 | } 16 | 17 | # 18 | # Post-install tasks. 19 | # 20 | function post_install() 21 | { 22 | log "Symlinking bin/ruby to bin/jruby ..." 23 | run ln -fs jruby "$install_dir/bin/ruby" || return $? 24 | } 25 | -------------------------------------------------------------------------------- /share/ruby-install/logging.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Prints a log message. 5 | # 6 | function log() 7 | { 8 | if [[ -t 1 ]]; then 9 | echo -e "\x1b[1m\x1b[32m>>>\x1b[0m \x1b[1m$1\x1b[0m" 10 | else 11 | echo ">>> $1" 12 | fi 13 | } 14 | 15 | # 16 | # Prints a warn message. 17 | # 18 | function warn() 19 | { 20 | if [[ -t 1 ]]; then 21 | echo -e "\x1b[1m\x1b[33m***\x1b[0m \x1b[1m$1\x1b[0m" >&2 22 | else 23 | echo "*** $1" >&2 24 | fi 25 | } 26 | 27 | # 28 | # Prints an error message. 29 | # 30 | function error() 31 | { 32 | if [[ -t 1 ]]; then 33 | echo -e "\x1b[1m\x1b[31m!!!\x1b[0m \x1b[1m$1\x1b[0m" >&2 34 | else 35 | echo "!!! $1" >&2 36 | fi 37 | } 38 | 39 | unset enable_debug 40 | 41 | # 42 | # Prints a debugging message, only if enable_debug is enabled. 43 | # 44 | function debug() 45 | { 46 | if [[ ! $enable_debug -eq 1 ]]; then 47 | return 48 | fi 49 | 50 | if [[ -t 1 ]]; then 51 | echo -e "\x1b[1m\x1b[33m[DEBUG]\x1b[0m \x1b[1m$1\x1b[0m" >&2 52 | else 53 | echo "[DEBUG] $1" >&2 54 | fi 55 | } 56 | 57 | # 58 | # Runs the command and prints the full command if debugging is enabled. 59 | # 60 | function run() 61 | { 62 | debug "$*" 63 | "$@" 64 | } 65 | 66 | # 67 | # Prints an error message and exists with -1. 68 | # 69 | function fail() 70 | { 71 | error "$*" 72 | exit -1 73 | } 74 | -------------------------------------------------------------------------------- /share/ruby-install/mruby/dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | case "$package_manager" in 4 | apt) 5 | ruby_dependencies=( 6 | build-essential 7 | bison 8 | ) 9 | ;; 10 | dnf|yum|pacman|zypper) 11 | ruby_dependencies=( 12 | gcc 13 | make 14 | bison 15 | ) 16 | ;; 17 | pkg) 18 | ruby_dependencies=( 19 | gcc 20 | automake 21 | bison 22 | ) 23 | ;; 24 | brew|port) ruby_dependencies=(bison) ;; 25 | xbps) ruby_dependencies=(base-devel) ;; 26 | esac 27 | -------------------------------------------------------------------------------- /share/ruby-install/mruby/functions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ruby_archive="${ruby_archive:-mruby-$ruby_version.tar.gz}" 4 | ruby_dir_name="mruby-$ruby_version" 5 | ruby_mirror="${ruby_mirror:-https://github.com/mruby/mruby/archive}" 6 | ruby_url="${ruby_url:-$ruby_mirror/$ruby_version/$ruby_archive}" 7 | 8 | # 9 | # Cleans mruby. 10 | # 11 | function clean_ruby() 12 | { 13 | log "Cleaning mruby $ruby_version ..." 14 | run make clean || return $? 15 | } 16 | 17 | # 18 | # Compile mruby. 19 | # 20 | function compile_ruby() 21 | { 22 | log "Compiling mruby $ruby_version ..." 23 | run make -j "${make_jobs:-$(cpu_count)}" || return $? 24 | } 25 | 26 | # 27 | # Install mruby into $install_dir. 28 | # 29 | function install_ruby() 30 | { 31 | log "Installing mruby $ruby_version ..." 32 | run cp -R "$ruby_build_dir" "$install_dir" || return $? 33 | } 34 | 35 | # 36 | # Post-install tasks. 37 | # 38 | function post_install() 39 | { 40 | log "Symlinking bin/ruby to bin/mruby ..." 41 | run ln -fs mruby "$install_dir/bin/ruby" || return $? 42 | 43 | log "Symlinking bin/irb to bin/mirb ..." 44 | run ln -fs mirb "$install_dir/bin/irb" || return $? 45 | } 46 | -------------------------------------------------------------------------------- /share/ruby-install/package_manager.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function set_package_manager() 4 | { 5 | case "$1" in 6 | zypper|apt|dnf|yum|pkg|port|brew|pacman|xbps) 7 | package_manager="$1" 8 | ;; 9 | *) 10 | error "Unsupported package manager: $1" 11 | return 1 12 | ;; 13 | esac 14 | } 15 | 16 | function install_packages() 17 | { 18 | case "$package_manager" in 19 | apt) 20 | run $sudo apt install -y "$@" || return $? 21 | ;; 22 | dnf|yum) 23 | run $sudo "$package_manager" install -y "$@" || return $? 24 | ;; 25 | port) 26 | run $sudo port install "$@" || return $? 27 | ;; 28 | pkg) 29 | run $sudo pkg install -y "$@" || return $? 30 | ;; 31 | brew) 32 | local brew_sudo="" 33 | 34 | if (( UID == 0 )) && [[ -n "$SUDO_USER" ]]; then 35 | # Note: to avoid running homebrew as root, 36 | # drop privileges back to the original sudo user 37 | brew_sudo="sudo -u \"$SUDO_USER\"" 38 | fi 39 | 40 | run $brew_sudo brew install "$@" || 41 | run $brew_sudo brew upgrade "$@" || return $? 42 | ;; 43 | pacman) 44 | local missing_pkgs=($(pacman -T "$@")) 45 | 46 | if (( ${#missing_pkgs[@]} > 0 )); then 47 | run $sudo pacman -S "${missing_pkgs[@]}" || return $? 48 | fi 49 | ;; 50 | zypper) 51 | run $sudo zypper -n in -l "$@" || return $? 52 | ;; 53 | xbps) 54 | run $sudo xbps-install -Sy "$@" || return $? 55 | ;; 56 | "") 57 | warn "Could not determine Package Manager. Proceeding anyway." 58 | ;; 59 | esac 60 | } 61 | -------------------------------------------------------------------------------- /share/ruby-install/ruby-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | shopt -s extglob 4 | 5 | ruby_install_version="0.10.1" 6 | ruby_install_dir="${BASH_SOURCE[0]%/*}" 7 | ruby_install_cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/ruby-install" 8 | 9 | rubies=(ruby jruby truffleruby truffleruby-graalvm mruby) 10 | patches=() 11 | configure_opts=() 12 | 13 | system_dir="/usr/local" 14 | 15 | if (( UID == 0 )); then 16 | src_dir="${RUBY_INSTALL_SRC_DIR:-$system_dir/src}" 17 | rubies_dir="${RUBY_INSTALL_RUBIES_DIR:-/opt/rubies}" 18 | else 19 | src_dir="${RUBY_INSTALL_SRC_DIR:-$HOME/src}" 20 | rubies_dir="${RUBY_INSTALL_RUBIES_DIR:-$HOME/.rubies}" 21 | fi 22 | 23 | source "$ruby_install_dir/logging.sh" 24 | source "$ruby_install_dir/system.sh" 25 | source "$ruby_install_dir/package_manager.sh" 26 | source "$ruby_install_dir/util.sh" 27 | source "$ruby_install_dir/ruby-versions.sh" 28 | 29 | # 30 | # Prints usage information for ruby-install. 31 | # 32 | function usage() 33 | { 34 | cat <&2 103 | return 1 104 | fi 105 | } 106 | 107 | # 108 | # Parses command-line options for ruby-install. 109 | # 110 | function parse_options() 111 | { 112 | local argv=() 113 | 114 | while [[ $# -gt 0 ]]; do 115 | case "$1" in 116 | -r|--rubies-dir) 117 | rubies_dir="$(absolute_path "$2")" 118 | shift 2 119 | ;; 120 | -i|--install-dir|--prefix) 121 | install_dir="$(absolute_path "$2")" 122 | shift 2 123 | ;; 124 | --system) 125 | install_dir="$system_dir" 126 | shift 1 127 | ;; 128 | -s|--src-dir) 129 | src_dir="$(absolute_path "$2")" 130 | shift 2 131 | ;; 132 | -c|--cleanup) 133 | cleanup=1 134 | shift 135 | ;; 136 | -j|--jobs) 137 | make_jobs="$2" 138 | shift 2 139 | ;; 140 | -j+([0-9])) 141 | make_jobs="${1#-j}" 142 | shift 143 | ;; 144 | --jobs=+([0-9])) 145 | make_jobs="${1#--jobs=}" 146 | shift 147 | ;; 148 | -p|--patch) 149 | if [[ "$2" == "http://"* || "$2" == "https://"* ]]; then 150 | patches+=("$2") 151 | else 152 | patches+=("$(absolute_path "$2")") 153 | fi 154 | shift 2 155 | ;; 156 | -M|--mirror) 157 | ruby_mirror="$2" 158 | shift 2 159 | ;; 160 | -u|--url) 161 | ruby_url="$2" 162 | ruby_archive="${ruby_url##*/}" 163 | shift 2 164 | ;; 165 | -m|--md5) 166 | ruby_md5="$2" 167 | shift 2 168 | ;; 169 | --sha1) 170 | ruby_sha1="$2" 171 | shift 2 172 | ;; 173 | --sha256) 174 | ruby_sha256="$2" 175 | shift 2 176 | ;; 177 | --sha512) 178 | ruby_sha512="$2" 179 | shift 2 180 | ;; 181 | --package-manager) 182 | set_package_manager "$2" 183 | shift 2 184 | ;; 185 | --no-download) 186 | no_download=1 187 | shift 188 | ;; 189 | --no-verify) 190 | no_verify=1 191 | shift 192 | ;; 193 | --no-extract) 194 | no_download=1 195 | no_verify=1 196 | no_extract=1 197 | shift 198 | ;; 199 | --no-install-deps) 200 | no_install_deps=1 201 | shift 202 | ;; 203 | --no-reinstall) 204 | no_reinstall=1 205 | shift 206 | ;; 207 | -L|--latest) 208 | warn "DEPRECATION: -L,--latest is deprecated. Please use -U,--update instead." 209 | force_update=1 210 | shift 211 | ;; 212 | -U|--update) 213 | force_update=1 214 | shift 215 | ;; 216 | -D|--debug) 217 | enable_debug=1 218 | shift 219 | ;; 220 | -V|--version) 221 | echo "ruby-install: $ruby_install_version" 222 | exit 223 | ;; 224 | -h|--help) 225 | usage 226 | exit 227 | ;; 228 | --) 229 | shift 230 | configure_opts=("$@") 231 | break 232 | ;; 233 | -*) 234 | echo "ruby-install: unrecognized option $1" >&2 235 | return 1 236 | ;; 237 | *) 238 | argv+=("$1") 239 | shift 240 | ;; 241 | esac 242 | done 243 | 244 | case ${#argv[*]} in 245 | 2) parse_ruby "${argv[0]}-${argv[1]}" || return $? ;; 246 | 1) parse_ruby "${argv[0]}" || return $? ;; 247 | 0) return 0 ;; 248 | *) 249 | echo "ruby-install: too many arguments: ${argv[*]}" >&2 250 | usage 1>&2 251 | return 1 252 | ;; 253 | esac 254 | } 255 | 256 | # 257 | # Prints Rubies supported by ruby-install. 258 | # 259 | function list_rubies() 260 | { 261 | local ruby 262 | 263 | for ruby in "${rubies[@]}"; do 264 | if [[ $force_update -eq 1 ]] || 265 | are_ruby_versions_missing "$ruby"; then 266 | log "Downloading latest $ruby versions ..." 267 | download_ruby_versions "$ruby" 268 | fi 269 | done 270 | 271 | echo "Stable ruby versions:" 272 | for ruby in "${rubies[@]}"; do 273 | echo " $ruby:" 274 | stable_ruby_versions "$ruby" | sed -e 's/^/ /' || return $? 275 | done 276 | } 277 | 278 | # 279 | # Initializes variables. 280 | # 281 | function init() 282 | { 283 | local fully_qualified_version="$(lookup_ruby_version "$ruby" "$ruby_version")" 284 | 285 | if [[ -n "$fully_qualified_version" ]]; then 286 | ruby_version="$fully_qualified_version" 287 | else 288 | warn "Unknown $ruby version $ruby_version. Proceeding anyways ..." 289 | fi 290 | 291 | source "$ruby_install_dir/functions.sh" || return $? 292 | source "$ruby_install_dir/$ruby/functions.sh" || return $? 293 | 294 | ruby_cache_dir="$ruby_install_cache_dir/$ruby" 295 | install_dir="${install_dir:-$rubies_dir/$ruby-$ruby_version}" 296 | ruby_build_dir="$src_dir/$ruby_dir_name" 297 | 298 | ruby_md5="${ruby_md5:-$(ruby_checksum_for "$ruby" md5 "$ruby_archive")}" 299 | ruby_sha1="${ruby_sha1:-$(ruby_checksum_for "$ruby" sha1 "$ruby_archive")}" 300 | ruby_sha256="${ruby_sha256:-$(ruby_checksum_for "$ruby" sha256 "$ruby_archive")}" 301 | ruby_sha512="${ruby_sha512:-$(ruby_checksum_for "$ruby" sha512 "$ruby_archive")}" 302 | } 303 | -------------------------------------------------------------------------------- /share/ruby-install/ruby-versions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | source "$ruby_install_dir/versions.sh" 4 | source "$ruby_install_dir/checksums.sh" 5 | 6 | ruby_versions_url="https://raw.githubusercontent.com/postmodern/ruby-versions/master" 7 | ruby_versions_files=({versions,stable}.txt checksums.{md5,sha1,sha256,sha512}) 8 | 9 | # 10 | # Determines if the ruby-versions files are missing for a ruby. 11 | # 12 | function are_ruby_versions_missing() 13 | { 14 | local dir="$ruby_install_cache_dir/$ruby" 15 | 16 | if [[ ! -d "$dir" ]]; then 17 | return 0 18 | fi 19 | 20 | local file 21 | 22 | for file in "${ruby_versions_files[@]}"; do 23 | if [[ ! -f "$dir/$file" ]]; then 24 | return 0 25 | fi 26 | done 27 | 28 | return 1 29 | } 30 | 31 | # 32 | # Downloads a file from the ruby-versions repository. 33 | # 34 | function download_ruby_versions_file() 35 | { 36 | local ruby="$1" 37 | 38 | local file="$2" 39 | local dir="$ruby_install_cache_dir/$ruby" 40 | local dest="$dir/$file" 41 | 42 | local url="$ruby_versions_url/$ruby/$file" 43 | 44 | if [[ -f "$dest" ]]; then rm "$dest" || return $? 45 | else mkdir -p "$dir" || return $? 46 | fi 47 | 48 | local ret 49 | 50 | if [[ -n "$enable_debug" ]]; then 51 | download "$url" "$dest" 52 | ret=$? 53 | else 54 | download "$url" "$dest" >/dev/null 2>&1 55 | ret=$? 56 | fi 57 | 58 | if (( ret > 0 )); then 59 | error "Failed to download $url to $dest!" 60 | return $ret 61 | fi 62 | } 63 | 64 | # 65 | # Downloads all ruby-versions files for a ruby. 66 | # 67 | function download_ruby_versions() 68 | { 69 | local ruby="$1" 70 | 71 | for file in "${ruby_versions_files[@]}"; do 72 | download_ruby_versions_file "$ruby" "$file" || return $? 73 | done 74 | } 75 | 76 | # 77 | # Lists all current stable versions. 78 | # 79 | function stable_ruby_versions() 80 | { 81 | local ruby="$1" 82 | 83 | cat "$ruby_install_cache_dir/$ruby/stable.txt" 84 | } 85 | 86 | # 87 | # Finds the closest matching stable version. 88 | # 89 | function latest_ruby_version() 90 | { 91 | local ruby="$1" 92 | local version="$2" 93 | 94 | latest_version "$ruby_install_cache_dir/$ruby/stable.txt" "$version" 95 | } 96 | 97 | # 98 | # Determines if the given version is a known version. 99 | # 100 | function is_known_ruby_version() 101 | { 102 | local ruby="$1" 103 | local version="$2" 104 | 105 | is_known_version "$ruby_install_cache_dir/$ruby/versions.txt" "$version" 106 | } 107 | 108 | # 109 | # Determines if the given version is an unknown version. 110 | # 111 | function is_unknown_ruby_version() 112 | { 113 | ! is_known_ruby_version "$1" "$2" 114 | } 115 | 116 | # 117 | # Looks up a checksum for $ruby_archive. 118 | # 119 | function ruby_checksum_for() 120 | { 121 | local ruby="$1" 122 | local algorithm="$2" 123 | local archive="$3" 124 | local checksums="checksums.$algorithm" 125 | 126 | lookup_checksum "$ruby_install_cache_dir/$ruby/$checksums" "$archive" 127 | } 128 | 129 | # 130 | # Resolves a short-hand ruby version to a fully qualified version. 131 | # 132 | function lookup_ruby_version() 133 | { 134 | local ruby="$1" 135 | local version="$2" 136 | 137 | if is_known_ruby_version "$ruby" "$version"; then 138 | echo -n "$version" 139 | else 140 | latest_ruby_version "$ruby" "$version" 141 | fi 142 | } 143 | -------------------------------------------------------------------------------- /share/ruby-install/ruby/dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | case "$package_manager" in 4 | apt) 5 | ruby_dependencies=( 6 | xz-utils 7 | build-essential 8 | bison 9 | zlib1g-dev 10 | libyaml-dev 11 | libssl-dev 12 | libreadline-dev 13 | libncurses-dev 14 | libffi-dev 15 | ) 16 | ;; 17 | dnf|yum) 18 | ruby_dependencies=( 19 | xz 20 | gcc 21 | automake 22 | bison 23 | zlib-devel 24 | libyaml-devel 25 | openssl-devel 26 | readline-devel 27 | ncurses-devel 28 | libffi-devel 29 | ) 30 | ;; 31 | pacman) 32 | ruby_dependencies=( 33 | xz 34 | gcc 35 | make 36 | bison 37 | zlib 38 | ncurses 39 | openssl 40 | readline 41 | libyaml 42 | libffi 43 | ) 44 | ;; 45 | zypper) 46 | ruby_dependencies=( 47 | xz 48 | gcc 49 | make 50 | automake 51 | zlib-devel 52 | libyaml-devel 53 | libopenssl-devel 54 | readline-devel 55 | ncurses-devel 56 | libffi-devel 57 | ) 58 | ;; 59 | brew|port) 60 | ruby_dependencies=( 61 | xz 62 | automake 63 | bison 64 | readline 65 | libyaml 66 | libffi 67 | ) 68 | ;; 69 | pkg) 70 | ruby_dependencies=( 71 | openssl 72 | readline 73 | libyaml 74 | libffi 75 | ) 76 | ;; 77 | xbps) 78 | ruby_dependencies=( 79 | base-devel 80 | openssl-devel 81 | zlib-devel 82 | libyaml-devel 83 | readline-devel 84 | ncurses-devel 85 | libffi-devel 86 | ) 87 | ;; 88 | esac 89 | 90 | if [[ "$ruby_version" < "3.1.0" ]]; then 91 | case "$package_manager" in 92 | apt) ruby_dependencies+=(libgdbm-dev) ;; 93 | dnf|yum|zypper|xbps) ruby_dependencies+=(gdbm-devel) ;; 94 | *) ruby_dependencies+=(gdbm) ;; 95 | esac 96 | fi 97 | 98 | case "$package_manager" in 99 | brew|port) 100 | case "$ruby_version" in 101 | 2.*|3.0.*) openssl_version="1.1" ;; 102 | *) openssl_version="3" ;; 103 | esac 104 | ;; 105 | esac 106 | 107 | # 108 | # Install openssl@1.1 or openssl@3.0 depending on the Ruby version, 109 | # only for homebrew. 110 | # 111 | case "$package_manager" in 112 | brew) ruby_dependencies+=("openssl@${openssl_version}") ;; 113 | port) ruby_dependencies+=("openssl${openssl_version/./}") ;; 114 | esac 115 | 116 | # 117 | # Install libjemalloc and C header files for --with-jemalloc support. 118 | # 119 | if [[ " ${configure_opts[*]} " == *" --with-jemalloc "* ]]; then 120 | case "$package_manager" in 121 | apt) 122 | ruby_dependencies+=(libjemalloc-dev) 123 | ;; 124 | dnf|yum|port|xbps) 125 | ruby_dependencies+=(jemalloc-devel) 126 | ;; 127 | zypper) 128 | ruby_dependencies+=(libjemalloc2) 129 | ;; 130 | *) 131 | ruby_dependencies+=(jemalloc) 132 | ;; 133 | esac 134 | fi 135 | 136 | # 137 | # Install Rust if YJIT support is explicitly enabled. 138 | # 139 | if [[ " ${configure_opts[*]} " == *" --enable-yjit "* ]]; then 140 | # NOTE: YJIT is written in Rust, thus requires rustc 141 | if ! command -v rustc >/dev/null; then 142 | case "$package_manager" in 143 | apt) ruby_dependencies+=(rustc) ;; 144 | *) ruby_dependencies+=(rust) ;; 145 | esac 146 | fi 147 | fi 148 | -------------------------------------------------------------------------------- /share/ruby-install/ruby/functions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ruby_version_family="${ruby_version:0:3}" 4 | 5 | if [[ "$ruby_version_family" < "2.0" ]]; then 6 | ruby_archive_ext="tar.bz2" 7 | else 8 | ruby_archive_ext="tar.xz" 9 | fi 10 | 11 | ruby_archive="${ruby_archive:-ruby-$ruby_version.$ruby_archive_ext}" 12 | ruby_dir_name="ruby-$ruby_version" 13 | ruby_mirror="${ruby_mirror:-https://cache.ruby-lang.org/pub/ruby}" 14 | ruby_url="${ruby_url:-$ruby_mirror/$ruby_version_family/$ruby_archive}" 15 | 16 | # 17 | # Configures Ruby. 18 | # 19 | function configure_ruby() 20 | { 21 | if [[ ! -s configure || configure.in -nt configure ]]; then 22 | log "Regenerating ./configure script ..." 23 | autoreconf || return $? 24 | fi 25 | 26 | local opt_dir 27 | local openssl_dir 28 | 29 | log "Configuring ruby $ruby_version ..." 30 | case "$package_manager" in 31 | brew) 32 | opt_dir="$(brew --prefix readline):$(brew --prefix libyaml):$(brew --prefix libffi)" 33 | openssl_dir="$(brew --prefix "openssl@${openssl_version}")" 34 | 35 | if [[ "${ruby_dependencies[*]}" == *"gdbm"* ]]; then 36 | opt_dir="${opt_dir}:$(brew --prefix gdbm)" 37 | fi 38 | 39 | if [[ "${ruby_dependencies[*]}" == *"jemalloc"* ]]; then 40 | opt_dir="${opt_dir}:$(brew --prefix jemalloc)" 41 | fi 42 | ;; 43 | port) 44 | opt_dir="/opt/local" 45 | openssl_dir="/opt/local" 46 | ;; 47 | esac 48 | 49 | run ./configure --prefix="$install_dir" \ 50 | "${opt_dir:+--with-opt-dir="$opt_dir"}" \ 51 | "${openssl_dir:+--with-openssl-dir="$openssl_dir"}" \ 52 | "${configure_opts[@]}" || return $? 53 | } 54 | 55 | # 56 | # Cleans Ruby. 57 | # 58 | function clean_ruby() 59 | { 60 | log "Cleaning ruby $ruby_version ..." 61 | run make clean || return $? 62 | } 63 | 64 | # 65 | # Compiles Ruby. 66 | # 67 | function compile_ruby() 68 | { 69 | log "Compiling ruby $ruby_version ..." 70 | run make -j "${make_jobs:-$(cpu_count)}" || return $? 71 | } 72 | 73 | # 74 | # Installs Ruby into $install_dir 75 | # 76 | function install_ruby() 77 | { 78 | log "Installing ruby $ruby_version ..." 79 | run make install || return $? 80 | } 81 | -------------------------------------------------------------------------------- /share/ruby-install/system.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Sets os_platform and os_arch. 5 | # 6 | function detect_os() 7 | { 8 | os_platform="$(uname -s)" 9 | os_arch="$(uname -m)" 10 | } 11 | 12 | # 13 | # Don't use sudo if already root. 14 | # 15 | function detect_sudo() 16 | { 17 | if (( UID == 0 )); then sudo="" 18 | else sudo="sudo" 19 | fi 20 | } 21 | 22 | # 23 | # Auto-detect the package manager. 24 | # 25 | function detect_package_manager() 26 | { 27 | if [[ -n "$RUBY_INSTALL_PKG_MANAGER" ]]; then 28 | package_manager="$RUBY_INSTALL_PKG_MANAGER" 29 | return 30 | fi 31 | 32 | case "$os_platform" in 33 | Linux) 34 | if [[ -f /etc/redhat-release ]]; then 35 | if command -v dnf >/dev/null; then 36 | package_manager="dnf" 37 | elif command -v yum >/dev/null; then 38 | package_manager="yum" 39 | fi 40 | elif [[ -f /etc/debian_version ]]; then 41 | if command -v apt >/dev/null; then 42 | package_manager="apt" 43 | fi 44 | elif [[ -f /etc/SuSE-release ]]; then 45 | if command -v zypper >/dev/null; then 46 | package_manager="zypper" 47 | fi 48 | elif [[ -f /etc/arch-release ]]; then 49 | if command -v pacman >/dev/null; then 50 | package_manager="pacman" 51 | fi 52 | elif [[ -x /bin/lsb_release ]] && lsb_release -c|grep -q void; then 53 | if command -v xbps-install >/dev/null; then 54 | package_manager="xbps" 55 | fi 56 | fi 57 | ;; 58 | Darwin) 59 | if command -v brew >/dev/null; then 60 | package_manager="brew" 61 | elif command -v port >/dev/null; then 62 | package_manager="port" 63 | fi 64 | ;; 65 | *BSD) 66 | if command -v pkg >/dev/null; then 67 | package_manager="pkg" 68 | fi 69 | ;; 70 | esac 71 | } 72 | 73 | # 74 | # Auto-detect the downloader. 75 | # 76 | function detect_downloader() 77 | { 78 | case "$os_platform" in 79 | Darwin) 80 | if command -v curl >/dev/null; then 81 | downloader="curl" 82 | elif command -v wget >/dev/null; then 83 | downloader="wget" 84 | fi 85 | ;; 86 | *) 87 | if command -v wget >/dev/null; then 88 | downloader="wget" 89 | elif command -v curl >/dev/null; then 90 | downloader="curl" 91 | fi 92 | ;; 93 | esac 94 | } 95 | 96 | # 97 | # Gets the number of CPU cores. 98 | # 99 | function cpu_count() 100 | { 101 | local count 102 | 103 | case "$os_platform" in 104 | Darwin|*BSD) 105 | count="$(sysctl -n hw.ncpu)" 106 | ;; 107 | *) 108 | count="$(getconf _NPROCESSORS_ONLN || grep -c ^processor /proc/cpuinfo)" 109 | ;; 110 | esac 111 | 112 | echo -n "$count" 113 | } 114 | 115 | detect_os 116 | detect_sudo 117 | detect_package_manager 118 | detect_downloader 119 | -------------------------------------------------------------------------------- /share/ruby-install/truffleruby-graalvm/dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | case "$package_manager" in 4 | apt) 5 | ruby_dependencies=( 6 | make 7 | gcc 8 | zlib1g-dev 9 | libssl-dev 10 | libxml2 11 | libyaml-dev 12 | ) 13 | ;; 14 | dnf|yum) 15 | ruby_dependencies=( 16 | make 17 | gcc 18 | zlib-devel 19 | openssl-devel 20 | libxml2 21 | libyaml-devel 22 | ) 23 | ;; 24 | pacman) 25 | ruby_dependencies=( 26 | make 27 | gcc 28 | zlib 29 | openssl 30 | libxml2 31 | libyaml 32 | ) 33 | ;; 34 | zypper) 35 | ruby_dependencies=( 36 | make 37 | gcc 38 | zlib-devel 39 | libopenssl-devel 40 | libxml2 41 | libyaml-devel 42 | ) 43 | ;; 44 | pkg) 45 | ruby_dependencies=( 46 | gmake 47 | gcc 48 | openssl 49 | libxml2 50 | libyaml 51 | ) 52 | ;; 53 | brew) 54 | ruby_dependencies=( 55 | openssl@3 56 | libyaml 57 | ) 58 | ;; 59 | port) 60 | ruby_dependencies=( 61 | openssl 62 | libyaml 63 | ) 64 | ;; 65 | xbps) 66 | ruby_dependencies=( 67 | base-devel 68 | openssl-devel 69 | zlib-devel 70 | libxml2 71 | libyaml-devel 72 | ) 73 | ;; 74 | esac 75 | -------------------------------------------------------------------------------- /share/ruby-install/truffleruby-graalvm/functions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | case "$os_platform" in 4 | Linux) graalvm_platform="linux" ;; 5 | Darwin) graalvm_platform="darwin" ;; 6 | *) fail "Unsupported platform $os_platform" ;; 7 | esac 8 | 9 | case "$os_arch" in 10 | x86_64) graalvm_arch="amd64" ;; 11 | aarch64) graalvm_arch="aarch64" ;; 12 | arm64) graalvm_arch="aarch64" ;; 13 | *) fail "Unsupported platform $os_arch" ;; 14 | esac 15 | 16 | truffleruby_major="${ruby_version%%.*}" 17 | truffleruby_without_major="${ruby_version#*.}" 18 | truffleruby_minor="${truffleruby_without_major%%.*}" 19 | 20 | if [[ "$ruby_version" == "23.0.0" ]]; then 21 | log "TruffleRuby-GraalVM 23.0 and later installed by ruby-install use the faster Oracle GraalVM distribution" 22 | log "Oracle GraalVM uses the GFTC license, which is free for development and production use, see https://medium.com/graalvm/161527df3d76" 23 | 24 | ruby_dir_name="graalvm-jdk-17.0.7+8.1" 25 | ruby_archive="${ruby_archive:-graalvm-jdk-17.0.7_${graalvm_platform/darwin/macos}-${graalvm_arch/amd64/x64}_bin.tar.gz}" 26 | ruby_mirror="${ruby_mirror:-https://download.oracle.com/graalvm/17/archive}" 27 | ruby_url="${ruby_url:-$ruby_mirror/$ruby_archive}" 28 | elif (( truffleruby_major > 23 || (truffleruby_major == 23 && truffleruby_minor >= 1) )); then # 23.1+ 29 | ruby_dir_name="truffleruby-$ruby_version-${graalvm_platform/darwin/macos}-$graalvm_arch" 30 | ruby_archive="${ruby_archive:-truffleruby-jvm-$ruby_version-${graalvm_platform/darwin/macos}-$graalvm_arch.tar.gz}" 31 | ruby_mirror="${ruby_mirror:-https://github.com/oracle/truffleruby/releases/download}" 32 | ruby_url="${ruby_url:-$ruby_mirror/graal-$ruby_version/$ruby_archive}" 33 | else 34 | ruby_dir_name="graalvm-ce-java11-$ruby_version" 35 | ruby_archive="${ruby_archive:-graalvm-ce-java11-$graalvm_platform-$graalvm_arch-$ruby_version.tar.gz}" 36 | ruby_mirror="${ruby_mirror:-https://github.com/graalvm/graalvm-ce-builds/releases/download}" 37 | ruby_url="${ruby_url:-$ruby_mirror/vm-$ruby_version/$ruby_archive}" 38 | fi 39 | 40 | # 41 | # Install TruffleRuby GraalVM into $install_dir. 42 | # 43 | function install_ruby() 44 | { 45 | if [[ "$install_dir" == '/usr/local' ]]; then 46 | error "Unsupported see https://github.com/oracle/truffleruby/issues/1389" 47 | return 1 48 | fi 49 | 50 | log "Installing TruffleRuby GraalVM $ruby_version ..." 51 | 52 | if (( truffleruby_major > 23 || (truffleruby_major == 23 && truffleruby_minor >= 1) )); then # 23.1+ 53 | copy_into "$ruby_build_dir" "$install_dir" || return $? 54 | else 55 | copy_into "$ruby_build_dir" "$install_dir/graalvm" || return $? 56 | fi 57 | } 58 | 59 | # 60 | # Post-install tasks. 61 | # 62 | function post_install() 63 | { 64 | if (( truffleruby_major > 23 || (truffleruby_major == 23 && truffleruby_minor >= 1) )); then # 23.1+ 65 | log "Running truffleruby post-install hook ..." 66 | run "$install_dir/lib/truffle/post_install_hook.sh" || return $? 67 | else 68 | cd "$install_dir/graalvm" || return $? 69 | 70 | if [[ "$graalvm_platform" == "darwin" ]]; then 71 | run cd Contents/Home || return $? 72 | fi 73 | 74 | log "Installing the Ruby component ..." 75 | run ./bin/gu install ruby || return $? 76 | 77 | local ruby_home="$(./bin/ruby -e 'print RbConfig::CONFIG["prefix"]')" 78 | 79 | if [[ -z "$ruby_home" ]]; then 80 | error "Could not determine TruffleRuby home" 81 | return 1 82 | fi 83 | 84 | # Make gu available in PATH (useful to install other languages) 85 | run ln -fs "$PWD/bin/gu" "$ruby_home/bin/gu" || return $? 86 | 87 | run cd "$install_dir" || return $? 88 | run ln -fs "${ruby_home#"$install_dir/"}/bin" . || return $? 89 | 90 | log "Running truffleruby post-install hook ..." 91 | run "$ruby_home/lib/truffle/post_install_hook.sh" || return $? 92 | fi 93 | } 94 | -------------------------------------------------------------------------------- /share/ruby-install/truffleruby/dependencies.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | case "$package_manager" in 4 | apt) 5 | ruby_dependencies=( 6 | make 7 | gcc 8 | zlib1g-dev 9 | libssl-dev 10 | libxml2 11 | libyaml-dev 12 | ) 13 | ;; 14 | dnf|yum) 15 | ruby_dependencies=( 16 | make 17 | gcc 18 | zlib-devel 19 | openssl-devel 20 | libxml2 21 | libyaml-devel 22 | ) 23 | ;; 24 | pacman) 25 | ruby_dependencies=( 26 | make 27 | gcc 28 | zlib 29 | openssl 30 | libxml2 31 | libyaml 32 | ) 33 | ;; 34 | zypper) 35 | ruby_dependencies=( 36 | make 37 | gcc 38 | zlib-devel 39 | libopenssl-devel 40 | libxml2 41 | libyaml-devel 42 | ) 43 | ;; 44 | port) 45 | ruby_dependencies=( 46 | openssl 47 | libyaml 48 | ) 49 | ;; 50 | brew) 51 | ruby_dependencies=( 52 | openssl@3 53 | libyaml 54 | ) 55 | ;; 56 | pkg) 57 | ruby_dependencies=( 58 | gmake 59 | gcc 60 | openssl 61 | libxml2 62 | libyaml 63 | ) 64 | ;; 65 | xbps) 66 | ruby_dependencies=( 67 | base-devel 68 | openssl-devel 69 | zlib-devel 70 | libxml2 71 | libyaml-devel 72 | ) 73 | ;; 74 | esac 75 | -------------------------------------------------------------------------------- /share/ruby-install/truffleruby/functions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | case "$os_platform" in 4 | Linux) truffleruby_platform="linux" ;; 5 | Darwin) truffleruby_platform="macos" ;; 6 | *) fail "Unsupported platform $os_platform" ;; 7 | esac 8 | 9 | case "$os_arch" in 10 | x86_64) truffleruby_arch="amd64" ;; 11 | aarch64) truffleruby_arch="aarch64" ;; 12 | arm64) truffleruby_arch="aarch64" ;; 13 | *) fail "Unsupported platform $os_arch" ;; 14 | esac 15 | 16 | ruby_dir_name="truffleruby-$ruby_version-$truffleruby_platform-$truffleruby_arch" 17 | ruby_archive="${ruby_archive:-$ruby_dir_name.tar.gz}" 18 | truffleruby_major="${ruby_version%%.*}" 19 | truffleruby_without_major="${ruby_version#*.}" 20 | truffleruby_minor="${truffleruby_without_major%%.*}" 21 | 22 | if [[ "$ruby_version" == "23.0.0" ]]; then 23 | log "TruffleRuby 23.0 and later installed by ruby-install use the faster Oracle GraalVM distribution" 24 | log "Oracle GraalVM uses the GFTC license, which is free for development and production use, see https://medium.com/graalvm/161527df3d76" 25 | 26 | ruby_mirror="${ruby_mirror:-https://gds.oracle.com/api/20220101/artifacts}" 27 | truffleruby_artifact_id="" 28 | 29 | case "$truffleruby_platform-$truffleruby_arch" in 30 | linux-amd64) truffleruby_artifact_id="FD4AB182EA4CEDFDE0531518000AF13E" ;; 31 | linux-aarch64) truffleruby_artifact_id="FD40BA2367C226B6E0531518000AE71A" ;; 32 | macos-amd64) truffleruby_artifact_id="FD4AB182EA51EDFDE0531518000AF13E" ;; 33 | macos-aarch64) truffleruby_artifact_id="FD40BBF6750C366CE0531518000ABEAF" ;; 34 | *) fail "Unsupported platform $truffleruby_platform-$truffleruby_arch" ;; 35 | esac 36 | 37 | ruby_url="${ruby_url:-$ruby_mirror/$truffleruby_artifact_id/content}" 38 | elif (( truffleruby_major > 23 || (truffleruby_major == 23 && truffleruby_minor >= 1) )); then # 23.1+ 39 | ruby_mirror="${ruby_mirror:-https://github.com/oracle/truffleruby/releases/download}" 40 | ruby_url="${ruby_url:-$ruby_mirror/graal-$ruby_version/$ruby_archive}" 41 | else 42 | ruby_mirror="${ruby_mirror:-https://github.com/oracle/truffleruby/releases/download}" 43 | ruby_url="${ruby_url:-$ruby_mirror/vm-$ruby_version/$ruby_archive}" 44 | fi 45 | 46 | # 47 | # Install TruffleRuby into $install_dir. 48 | # 49 | function install_ruby() 50 | { 51 | if [[ "$install_dir" == '/usr/local' ]]; then 52 | error "Unsupported see https://github.com/oracle/truffleruby/issues/1389" 53 | return 1 54 | fi 55 | 56 | log "Installing truffleruby $ruby_version ..." 57 | copy_into "$ruby_build_dir" "$install_dir" || return $? 58 | } 59 | 60 | # 61 | # Post-install tasks. 62 | # 63 | function post_install() 64 | { 65 | log "Running truffleruby post-install hook ..." 66 | run "$install_dir/lib/truffle/post_install_hook.sh" || return $? 67 | } 68 | -------------------------------------------------------------------------------- /share/ruby-install/util.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Convert a path to an absolute path. 5 | # 6 | function absolute_path() 7 | { 8 | local path="$1" 9 | 10 | if [[ "$path" == "/"* ]]; then 11 | echo -n "$path" 12 | else 13 | echo -n "${PWD}/${path}" 14 | fi 15 | } 16 | 17 | # 18 | # Checks if a path is "writable". 19 | # 20 | function check_write_permissions() 21 | { 22 | local path="$1" 23 | 24 | while [[ -n "$path" ]]; do 25 | if [[ -e "$path" ]] && [[ -w "$path" ]]; then 26 | return 27 | fi 28 | 29 | path="${path%/*}" 30 | done 31 | 32 | return 1 33 | } 34 | 35 | # 36 | # Downloads a URL. 37 | # 38 | function download() 39 | { 40 | local url="$1" 41 | local dest="$2" 42 | 43 | if [[ -z "$downloader" ]]; then 44 | error "Could not find wget or curl" 45 | return 1 46 | fi 47 | 48 | local quiet 49 | 50 | if [[ ! -t 1 ]]; then 51 | quiet=1 52 | fi 53 | 54 | [[ -d "$dest" ]] && dest="$dest/${url##*/}" 55 | [[ -f "$dest" ]] && return 56 | 57 | mkdir -p "${dest%/*}" || return $? 58 | 59 | case "$downloader" in 60 | wget) 61 | run wget ${quiet:+-q} -c -O "$dest.part" "$url" || return $? 62 | ;; 63 | curl) 64 | run curl ${quiet:+-s -S} -f -L -C - -o "$dest.part" "$url" || return $? 65 | ;; 66 | esac 67 | 68 | mv "$dest.part" "$dest" || return $? 69 | } 70 | 71 | # 72 | # Extracts an archive. 73 | # 74 | function extract() 75 | { 76 | local archive="$1" 77 | local dest="${2:-${archive%/*}}" 78 | 79 | mkdir -p "$dest" || return $? 80 | 81 | case "$archive" in 82 | *.tgz|*.tar.gz) 83 | run tar -xzf "$archive" -C "$dest" || return $? 84 | ;; 85 | *.tbz|*.tbz2|*.tar.bz2) 86 | run tar -xjf "$archive" -C "$dest" || return $? 87 | ;; 88 | *.txz|*.tar.xz) 89 | debug "xzcat $archive | tar -xf - -C $dest" 90 | xzcat "$archive" | tar -xf - -C "$dest" || return $? 91 | ;; 92 | *.zip) 93 | run unzip "$archive" -d "$dest" || return $? 94 | ;; 95 | *) 96 | error "Unknown archive format: $archive" 97 | return 1 98 | ;; 99 | esac 100 | } 101 | 102 | # 103 | # Copies files from within a source directory into a destination directory. 104 | # 105 | function copy_into() 106 | { 107 | local src="$1" 108 | local dest="$2" 109 | 110 | mkdir -p "$dest" || return $? 111 | run cp -R "$src"/* "$dest" || return $? 112 | } 113 | -------------------------------------------------------------------------------- /share/ruby-install/versions.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | unset GREP_OPTIONS GREP_COLOR GREP_COLORS 4 | 5 | function is_known_version() 6 | { 7 | local file="$1" 8 | local version="$2" 9 | 10 | if [[ ! -f "$file" ]] || [[ -z "$version" ]]; then 11 | return 1 12 | fi 13 | 14 | grep -q -x "$version" "$file" 15 | } 16 | 17 | function latest_version() 18 | { 19 | local file="$1" 20 | local key="$2" 21 | 22 | if [[ ! -f "$file" ]]; then 23 | return 1 24 | fi 25 | 26 | if [[ -z "$key" ]]; then 27 | tail -n 1 "$file" 28 | return 29 | fi 30 | 31 | local version match="" 32 | 33 | while IFS="" read -r version; do 34 | if [[ "$version" == "$key".* || "$version" == "$key"-* ]]; then 35 | match="$version" 36 | fi 37 | done < "$file" 38 | 39 | if [[ -n "$match" ]]; then 40 | echo -n "$match" 41 | else 42 | return 1 43 | fi 44 | } 45 | -------------------------------------------------------------------------------- /test/checksums_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/checksums.sh 5 | 6 | test_dir="$test_fixtures_dir/checksums_test" 7 | 8 | data="hello world" 9 | file="$test_dir/file.txt" 10 | 11 | md5="5eb63bbbe01eeed093cb22bb8f5acdc3" 12 | sha1="2aae6c35c94fcfb415dbe95f408b9ce91ee846ed" 13 | sha256="b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" 14 | sha512="309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f" 15 | 16 | checksums_md5="$test_dir/checksums.md5" 17 | checksums_sha1="$test_dir/checksums.sha1" 18 | checksums_sha256="$test_dir/checksums.sha256" 19 | checksums_sha512="$test_dir/checksums.sha512" 20 | 21 | function oneTimeSetUp() 22 | { 23 | mkdir -p "$test_dir" 24 | 25 | echo -n "$data" > "$file" 26 | 27 | cat < "$checksums_md5" 28 | eacf2ed066d1c5c3ba074cebb933d388 foo.txt 29 | $md5 $(basename "$file") 30 | 4c80727cee7493fec3db112793d55221 bar.txt 31 | EOS 32 | 33 | cat < "$checksums_sha1" 34 | 3fd8717137c578f6ea05486c6c6c9b633e77a0ab foo.txt 35 | $sha1 $(basename "$file") 36 | 8203a446206c774b4673a62d1e92fd45df69c9b9 bar.txt 37 | EOS 38 | 39 | cat < "$checksums_sha256" 40 | d8e6b6a5760ebae82c446f46441eeaee10d5034e8f0ec35871ecccaede7183e8 foo.txt 41 | $sha256 $(basename "$file") 42 | 0610cff587f7eed38c5787ed880940c10efab6fd8ea92ebeeb00c1a6ae048119 bar.txt 43 | EOS 44 | 45 | cat < "$checksums_sha512" 46 | 879d5302f2041e0318b2e0f573e23c14f8022fcac4814ad74a59ab0a11456941f3476a0699e8bb5f84ca4c762d10a2fefe1f73e590e3b920b76079db4d326b52 foo.txt 47 | $sha512 $(basename "$file") 48 | a934e1875d4c38df432bc704265f0c16404bd06db96246aee85737b682bc0a0af6489177e703a5109448a837e1a48d43465a7ae0704d7a0a076b7438993bdb3f bar.txt 49 | EOS 50 | } 51 | 52 | function test_supported_checksums() 53 | { 54 | assertNotNull "did not detect the md5 checksum utilility" "$md5sum" 55 | assertNotNull "did not detect the sha1 checksum utilility" "$sha1sum" 56 | assertNotNull "did not detect the sha256 checksum utilility" "$sha256sum" 57 | assertNotNull "did not detect the sha512 checksum utilility" "$sha512sum" 58 | } 59 | 60 | function test_lookup_checksum_md5() 61 | { 62 | assertEquals "did not return the expected md5 checksum" \ 63 | "$md5" \ 64 | "$(lookup_checksum "$checksums_md5" "$file")" 65 | } 66 | 67 | function test_lookup_checksum_sha1() 68 | { 69 | assertEquals "did not return the expected sha1 checksum" \ 70 | "$sha1" \ 71 | "$(lookup_checksum "$checksums_sha1" "$file")" 72 | } 73 | 74 | function test_lookup_checksum_sha256() 75 | { 76 | assertEquals "did not return the expected sha256 checksum" \ 77 | "$sha256" \ 78 | "$(lookup_checksum "$checksums_sha256" "$file")" 79 | } 80 | 81 | function test_lookup_checksum_sha512() 82 | { 83 | assertEquals "did not return the expected sha512 checksum" \ 84 | "$sha512" \ 85 | "$(lookup_checksum "$checksums_sha512" "$file")" 86 | } 87 | 88 | function test_lookup_checksum_with_missing_file() 89 | { 90 | assertEquals "returned data when it should not have" \ 91 | "" \ 92 | "$(lookup_checksum "$checksums_sha512" "missing.txt")" 93 | } 94 | 95 | function test_lookup_checksum_with_duplicate_entries() 96 | { 97 | cat < duplicate_checksums.md5 98 | $md5 $(basename "$file") 99 | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa $(basename "$file") 100 | EOS 101 | 102 | assertEquals "did not return the first checksum for the file" \ 103 | "$md5" \ 104 | "$(lookup_checksum duplicate_checksums.md5 "$file")" 105 | 106 | rm duplicate_checksums.md5 107 | } 108 | 109 | function test_compute_checksum_md5() 110 | { 111 | assertEquals "did not return the expected md5 checksum" \ 112 | "$md5" \ 113 | "$(compute_checksum md5 "$file")" 114 | } 115 | 116 | function test_compute_checksum_sha1() 117 | { 118 | assertEquals "did not return the expected sha1 checksum" \ 119 | "$sha1" \ 120 | "$(compute_checksum sha1 "$file")" 121 | } 122 | 123 | function test_compute_checksum_sha256() 124 | { 125 | assertEquals "did not return the expected sha256 checksum" \ 126 | "$sha256" \ 127 | "$(compute_checksum sha256 "$file")" 128 | } 129 | 130 | function test_compute_checksum_sha512() 131 | { 132 | assertEquals "did not return the expected sha512 checksum" \ 133 | "$sha512" \ 134 | "$(compute_checksum sha512 "$file")" 135 | } 136 | 137 | function test_compute_checksum_with_missing_file() 138 | { 139 | assertEquals "returned data when it should not have" \ 140 | "" \ 141 | "$(compute_checksum md5 "missing.txt" 2>/dev/null)" 142 | } 143 | 144 | function test_verify_checksum_md5() 145 | { 146 | verify_checksum "$file" md5 "$md5" 147 | 148 | assertEquals "checksum was not valid" 0 $? 149 | } 150 | 151 | function test_verify_checksum_sha1() 152 | { 153 | verify_checksum "$file" sha1 "$sha1" 154 | 155 | assertEquals "checksum was not valid" 0 $? 156 | } 157 | 158 | function test_verify_checksum_sha256() 159 | { 160 | verify_checksum "$file" sha256 "$sha256" 161 | 162 | assertEquals "checksum was not valid" 0 $? 163 | } 164 | 165 | function test_verify_checksum_sha512() 166 | { 167 | verify_checksum "$file" sha512 "$sha512" 168 | 169 | assertEquals "checksum was not valid" 0 $? 170 | } 171 | 172 | function oneTimeTearDown() 173 | { 174 | rm -rf "$test_dir" 175 | } 176 | 177 | SHUNIT_PARENT=$0 . $SHUNIT2 178 | -------------------------------------------------------------------------------- /test/cli-tests/no_reinstall_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | 5 | test_install_dir="$test_fixtures_dir/no_reinstall_test" 6 | 7 | function setUp() 8 | { 9 | mkdir -p "$test_install_dir/bin" 10 | touch -m "$test_install_dir/bin/ruby" 11 | chmod +x "$test_install_dir/bin/ruby" 12 | } 13 | 14 | function test_no_reinstall_when_ruby_executable_exists() 15 | { 16 | local output="$(ruby-install --install-dir "$test_install_dir" --no-reinstall ruby)" 17 | 18 | assertEquals "did not return 0" 0 $? 19 | assertTrue "did not print a message to STDOUT" \ 20 | '[[ "$output" == *"already installed"* ]]' 21 | } 22 | 23 | function tearDown() 24 | { 25 | rm -rf "$test_install_dir" 26 | } 27 | 28 | SHUNIT_PARENT=$0 . $SHUNIT2 29 | -------------------------------------------------------------------------------- /test/functions-tests/apply_patches_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/functions.sh 5 | 6 | src_dir="$test_fixtures_dir/apply_patches_test" 7 | ruby_dir_name="ruby-1.9.3-p448" 8 | ruby_build_dir="$src_dir/$ruby_dir_name" 9 | 10 | patches=("$ruby_build_dir/falcon-gc.diff") 11 | 12 | function setUp() 13 | { 14 | mkdir -p "$ruby_build_dir" 15 | echo "diff -Naur $ruby_dir_name.orig/test $ruby_dir_name/test 16 | --- $ruby_dir_name.orig/test 1970-01-01 01:00:00.000000000 +0100 17 | +++ $ruby_dir_name/test 2013-08-02 20:57:08.055843749 +0200 18 | @@ -0,0 +1 @@ 19 | +patch 20 | " > "${patches[0]}" 21 | } 22 | 23 | function test_apply_patches() 24 | { 25 | cd "$ruby_build_dir" 26 | apply_patches >/dev/null 27 | cd $OLDPWD 28 | 29 | assertTrue "did not apply downloaded patches" \ 30 | '[[ -f "${ruby_build_dir}/test" ]]' 31 | } 32 | 33 | function tearDown() 34 | { 35 | rm -rf "$src_dir" 36 | } 37 | 38 | SHUNIT_PARENT=$0 . $SHUNIT2 39 | -------------------------------------------------------------------------------- /test/functions-tests/download_patches_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/functions.sh 5 | 6 | src_dir="$test_fixtures_dir/download_patches_test" 7 | ruby_dir_name="ruby-1.9.3-p448" 8 | ruby_build_dir="$src_dir/$ruby_dir_name" 9 | 10 | patches=("https://gist.github.com/funny-falcon/2981959/raw/ary-queue.diff" "local.patch") 11 | 12 | function setUp() 13 | { 14 | mkdir -p "$ruby_build_dir" 15 | } 16 | 17 | function test_download_patches() 18 | { 19 | download_patches 2>/dev/null 20 | 21 | assertTrue "did not download patches to \$src_dir/\$ruby_dir_name" \ 22 | '[[ -f "${ruby_build_dir}/ary-queue.diff" ]]' 23 | 24 | assertEquals "did not update \$patches" \ 25 | "${patches[0]}" "$ruby_build_dir/ary-queue.diff" 26 | } 27 | 28 | function tearDown() 29 | { 30 | rm -rf "$src_dir" 31 | } 32 | 33 | SHUNIT_PARENT=$0 . $SHUNIT2 34 | -------------------------------------------------------------------------------- /test/functions-tests/load_dependencies_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/functions.sh 5 | 6 | function setUp() 7 | { 8 | ruby="ruby" 9 | ruby_version="3.3.0" 10 | package_manager="dnf" 11 | } 12 | 13 | function test_load_dependencies() 14 | { 15 | load_dependencies 16 | 17 | assertEquals "did not correctly set \$ruby_dependencies from \$ruby/dependencies.sh for \$package_manager" \ 18 | "xz gcc automake bison zlib-devel libyaml-devel openssl-devel readline-devel ncurses-devel libffi-devel" \ 19 | "${ruby_dependencies[*]}" 20 | } 21 | 22 | function tearDown() 23 | { 24 | unset ruby ruby_version package_manager 25 | } 26 | 27 | SHUNIT_PARENT=$0 . $SHUNIT2 28 | -------------------------------------------------------------------------------- /test/helper.sh: -------------------------------------------------------------------------------- 1 | if [[ -z "$SHUNIT2" ]]; then 2 | if [[ -f /usr/share/shunit2/shunit2 ]]; then 3 | SHUNIT2=/usr/share/shunit2/shunit2 4 | elif shunit2="$(command -v shunit2)"; then 5 | SHUNIT2="$shunit2" 6 | else 7 | echo "$0: shunit2 is not installed." >&2 8 | exit 1 9 | fi 10 | fi 11 | 12 | test_fixtures_dir="$PWD/test/fixtures" 13 | 14 | export HOME="$test_fixtures_dir/home" 15 | export PATH="$PWD/bin:$PATH" 16 | 17 | mkdir -p "$HOME" 18 | 19 | . $PWD/share/ruby-install/ruby-install.sh 20 | 21 | function oneTimeSetUp() { return; } 22 | function setUp() { return; } 23 | function tearDown() { return; } 24 | function oneTimeTearDown() { return; } 25 | -------------------------------------------------------------------------------- /test/jruby-tests/dependencies_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="jruby" 9 | ruby_version="9.4.3.0" 10 | } 11 | 12 | function test_when_java_is_not_installed_and_package_manager_is_apt() 13 | { 14 | command -v java >/dev/null && return 15 | 16 | local original_package_manager="$package_manager" 17 | package_manager="apt" 18 | 19 | source "$ruby_install_dir/$ruby/dependencies.sh" 20 | 21 | assertEquals "did not correctly set \$ruby_dependencies" \ 22 | "${ruby_dependencies[*]}" \ 23 | "default-jre" 24 | 25 | package_manager="$original_package_manager" 26 | } 27 | 28 | function test_when_java_is_not_installed_and_package_manager_is_dnf() 29 | { 30 | command -v java >/dev/null && return 31 | 32 | local original_package_manager="$package_manager" 33 | package_manager="dnf" 34 | 35 | source "$ruby_install_dir/$ruby/dependencies.sh" 36 | 37 | assertEquals "did not correctly set \$ruby_dependencies" \ 38 | "${ruby_dependencies[*]}" \ 39 | "java-latest-openjdk" 40 | 41 | package_manager="$original_package_manager" 42 | } 43 | 44 | function test_when_java_is_not_installed_and_package_manager_is_yum() 45 | { 46 | command -v java >/dev/null && return 47 | 48 | local original_package_manager="$package_manager" 49 | package_manager="yum" 50 | 51 | source "$ruby_install_dir/$ruby/dependencies.sh" 52 | 53 | assertEquals "did not correctly set \$ruby_dependencies" \ 54 | "${ruby_dependencies[*]}" \ 55 | "java-latest-openjdk" 56 | 57 | package_manager="$original_package_manager" 58 | } 59 | 60 | function test_when_java_is_not_installed_and_package_manager_is_pacman() 61 | { 62 | command -v java >/dev/null && return 63 | 64 | local original_package_manager="$package_manager" 65 | package_manager="pacman" 66 | 67 | source "$ruby_install_dir/$ruby/dependencies.sh" 68 | 69 | assertEquals "did not correctly set \$ruby_dependencies" \ 70 | "${ruby_dependencies[*]}" \ 71 | "jre21-openjdk" 72 | 73 | package_manager="$original_package_manager" 74 | } 75 | 76 | function test_when_java_is_not_installed_and_package_manager_is_zypper() 77 | { 78 | command -v java >/dev/null && return 79 | 80 | local original_package_manager="$package_manager" 81 | package_manager="zypper" 82 | 83 | source "$ruby_install_dir/$ruby/dependencies.sh" 84 | 85 | assertEquals "did not correctly set \$ruby_dependencies" \ 86 | "${ruby_dependencies[*]}" \ 87 | "java-21-openjdk" 88 | 89 | package_manager="$original_package_manager" 90 | } 91 | 92 | function test_when_java_is_not_installed_and_package_manager_is_xbps() 93 | { 94 | command -v java >/dev/null && return 95 | 96 | local original_package_manager="$package_manager" 97 | package_manager="xbps" 98 | 99 | source "$ruby_install_dir/$ruby/dependencies.sh" 100 | 101 | assertEquals "did not correctly set \$ruby_dependencies" \ 102 | "${ruby_dependencies[*]}" \ 103 | "openjdk-jre" 104 | 105 | package_manager="$original_package_manager" 106 | } 107 | 108 | function test_when_java_is_not_installed_and_package_manager_is_brew() 109 | { 110 | command -v java >/dev/null && return 111 | 112 | local original_package_manager="$package_manager" 113 | package_manager="brew" 114 | 115 | source "$ruby_install_dir/$ruby/dependencies.sh" 116 | 117 | assertEquals "did not correctly set \$ruby_dependencies" \ 118 | "${ruby_dependencies[*]}" \ 119 | "openjdk" 120 | 121 | package_manager="$original_package_manager" 122 | } 123 | 124 | function test_when_java_is_not_installed_and_package_manager_is_port() 125 | { 126 | command -v java >/dev/null && return 127 | 128 | local original_package_manager="$package_manager" 129 | package_manager="port" 130 | 131 | source "$ruby_install_dir/$ruby/dependencies.sh" 132 | 133 | assertEquals "did not correctly set \$ruby_dependencies" \ 134 | "${ruby_dependencies[*]}" \ 135 | "openjdk21" 136 | 137 | package_manager="$original_package_manager" 138 | } 139 | 140 | function test_when_java_is_not_installed_and_package_manager_is_pkg() 141 | { 142 | command -v java >/dev/null && return 143 | 144 | local original_package_manager="$package_manager" 145 | package_manager="pkg" 146 | 147 | source "$ruby_install_dir/$ruby/dependencies.sh" 148 | 149 | assertEquals "did not correctly set \$ruby_dependencies" \ 150 | "${ruby_dependencies[*]}" \ 151 | "openjdk21-jre" 152 | 153 | package_manager="$original_package_manager" 154 | } 155 | 156 | function test_when_java_is_installed() 157 | { 158 | command -v java >/dev/null || return 159 | 160 | source "$ruby_install_dir/$ruby/dependencies.sh" 161 | 162 | assertEquals "did accidentally populated \$ruby_dependencies" \ 163 | "${ruby_dependencies[*]}" \ 164 | "" 165 | } 166 | 167 | function tearDown() 168 | { 169 | unset ruby ruby_version ruby_dependencies 170 | } 171 | 172 | SHUNIT_PARENT=$0 . $SHUNIT2 173 | -------------------------------------------------------------------------------- /test/jruby-tests/functions_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="jruby" 9 | ruby_version="9.4.5.0" 10 | 11 | source "$ruby_install_dir/functions.sh" 12 | source "$ruby_install_dir/jruby/functions.sh" 13 | } 14 | 15 | function test_ruby_archive_default_value() 16 | { 17 | assertEquals "did not correctly set \$ruby_archive" \ 18 | "jruby-dist-${ruby_version}-bin.tar.gz" \ 19 | "$ruby_archive" 20 | } 21 | 22 | function test_ruby_archive_when_its_already_set() 23 | { 24 | ruby_archive="jruby-custom-1.2.3.tar.bz2" 25 | 26 | source "$ruby_install_dir/functions.sh" 27 | source "$ruby_install_dir/jruby/functions.sh" 28 | 29 | assertEquals "did not preserve the \$ruby_archive value" \ 30 | "jruby-custom-1.2.3.tar.bz2" \ 31 | "$ruby_archive" 32 | } 33 | 34 | function test_ruby_dir_name() 35 | { 36 | assertEquals "did not correctly set \$ruby_dir_name" \ 37 | "jruby-$ruby_version" \ 38 | "$ruby_dir_name" 39 | } 40 | 41 | function test_ruby_mirror_default_value() 42 | { 43 | assertEquals "did not correctly set \$ruby_mirror" \ 44 | "https://repo1.maven.org/maven2/org/jruby/jruby-dist" \ 45 | "$ruby_mirror" 46 | } 47 | 48 | function test_ruby_mirror_when_its_already_set() 49 | { 50 | ruby_mirror="https://example.com/pub/jruby" 51 | 52 | source "$ruby_install_dir/functions.sh" 53 | source "$ruby_install_dir/jruby/functions.sh" 54 | 55 | assertEquals "did not preserve the \$ruby_mirror value" \ 56 | "https://example.com/pub/jruby" \ 57 | "$ruby_mirror" 58 | } 59 | 60 | function test_ruby_url_default_value() 61 | { 62 | assertEquals "did not correctly set \$ruby_url" \ 63 | "https://repo1.maven.org/maven2/org/jruby/jruby-dist/$ruby_version/$ruby_archive" \ 64 | "$ruby_url" 65 | } 66 | 67 | function test_ruby_url_when_its_already_set() 68 | { 69 | ruby_url="https://example.com/pub/jruby/jruby-1.2.3.tar.gz" 70 | 71 | source "$ruby_install_dir/functions.sh" 72 | source "$ruby_install_dir/jruby/functions.sh" 73 | 74 | assertEquals "did not preserve the \$ruby_url value" \ 75 | "https://example.com/pub/jruby/jruby-1.2.3.tar.gz" \ 76 | "$ruby_url" 77 | } 78 | 79 | function tearDown() 80 | { 81 | unset ruby ruby_version ruby_archive ruby_dir_name ruby_mirror ruby_url 82 | } 83 | 84 | SHUNIT_PARENT=$0 . $SHUNIT2 85 | -------------------------------------------------------------------------------- /test/logging/debug_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/logging.sh 5 | 6 | function test_debug_when_enable_debug_is_not_set() 7 | { 8 | assertEquals "did not silence debug messages" \ 9 | "" "$(debug "$message" 2>&1)" 10 | } 11 | 12 | function test_debug_when_enable_debug_is_set() 13 | { 14 | enable_debug=1 15 | 16 | local message="foo bar baz" 17 | local expected_output="[DEBUG] $message" 18 | 19 | assertEquals "did not output '[DEBUG] ...' to stderr" \ 20 | "$expected_output" "$(debug "$message" 2>&1)" 21 | } 22 | 23 | function tearDown() 24 | { 25 | unset enable_debug 26 | } 27 | 28 | SHUNIT_PARENT=$0 . $SHUNIT2 29 | -------------------------------------------------------------------------------- /test/logging/run_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/logging.sh 5 | 6 | function test_run_when_enable_debug_is_not_set() 7 | { 8 | local command=(echo foo bar baz) 9 | local expected_output="foo bar baz" 10 | 11 | assertEquals "did not silence debug messages" \ 12 | "$expected_output" "$(run "${command[@]}" 2>&1)" 13 | } 14 | 15 | function test_run_with_implicit_string_splitting() 16 | { 17 | local command=(echo "foo bar baz") 18 | local expected_output="foo bar baz" 19 | 20 | assertEquals "did not preserve spaces in the command's arguments" \ 21 | "$expected_output" "$(run "${command[@]}" 2>&1)" 22 | } 23 | 24 | function test_run_when_enable_debug_is_set() 25 | { 26 | enable_debug=1 27 | 28 | local command=("echo" "foo" "bar" "baz") 29 | local command_output="foo bar baz" 30 | local expected_output="[DEBUG] ${command[@]} 31 | $command_output" 32 | 33 | assertEquals "did not output '[DEBUG] ...' to stderr" \ 34 | "$expected_output" "$(run "${command[@]}" 2>&1)" 35 | } 36 | 37 | function test_run_when_the_command_fails() 38 | { 39 | local command=("false") 40 | 41 | run "${command[@]}" 42 | 43 | assertEquals "did not return the exit status" 1 $? 44 | } 45 | 46 | function tearDown() 47 | { 48 | unset enable_debug 49 | } 50 | 51 | SHUNIT_PARENT=$0 . $SHUNIT2 52 | -------------------------------------------------------------------------------- /test/mruby-tests/dependencies_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="mruby" 9 | ruby_version="3.3.0" 10 | } 11 | 12 | function test_when_package_manager_is_apt() 13 | { 14 | local original_package_manager="$package_manager" 15 | package_manager="apt" 16 | 17 | source "$ruby_install_dir/$ruby/dependencies.sh" 18 | 19 | assertEquals "did not correctly set \$ruby_dependencies" \ 20 | "${ruby_dependencies[*]}" \ 21 | "build-essential bison" 22 | 23 | package_manager="$original_package_manager" 24 | } 25 | 26 | function test_when_package_manager_is_dnf() 27 | { 28 | local original_package_manager="$package_manager" 29 | package_manager="dnf" 30 | 31 | source "$ruby_install_dir/$ruby/dependencies.sh" 32 | 33 | assertEquals "did not correctly set \$ruby_dependencies" \ 34 | "${ruby_dependencies[*]}" \ 35 | "gcc make bison" 36 | 37 | package_manager="$original_package_manager" 38 | } 39 | 40 | function test_when_package_manager_is_yum() 41 | { 42 | local original_package_manager="$package_manager" 43 | package_manager="yum" 44 | 45 | source "$ruby_install_dir/$ruby/dependencies.sh" 46 | 47 | assertEquals "did not correctly set \$ruby_dependencies" \ 48 | "${ruby_dependencies[*]}" \ 49 | "gcc make bison" 50 | 51 | package_manager="$original_package_manager" 52 | } 53 | 54 | function test_when_package_manager_is_port() 55 | { 56 | local original_package_manager="$package_manager" 57 | package_manager="port" 58 | 59 | source "$ruby_install_dir/$ruby/dependencies.sh" 60 | 61 | assertEquals "did not correctly set \$ruby_dependencies" \ 62 | "${ruby_dependencies[*]}" \ 63 | "bison" 64 | 65 | package_manager="$original_package_manager" 66 | } 67 | 68 | function test_when_package_manager_is_brew() 69 | { 70 | local original_package_manager="$package_manager" 71 | package_manager="brew" 72 | 73 | source "$ruby_install_dir/$ruby/dependencies.sh" 74 | 75 | assertEquals "did not correctly set \$ruby_dependencies" \ 76 | "${ruby_dependencies[*]}" \ 77 | "bison" 78 | 79 | package_manager="$original_package_manager" 80 | } 81 | 82 | function test_when_package_manager_is_pacman() 83 | { 84 | local original_package_manager="$package_manager" 85 | package_manager="pacman" 86 | 87 | source "$ruby_install_dir/$ruby/dependencies.sh" 88 | 89 | assertEquals "did not correctly set \$ruby_dependencies" \ 90 | "${ruby_dependencies[*]}" \ 91 | "gcc make bison" 92 | 93 | package_manager="$original_package_manager" 94 | } 95 | 96 | function test_when_package_manager_is_zypper() 97 | { 98 | local original_package_manager="$package_manager" 99 | package_manager="zypper" 100 | 101 | source "$ruby_install_dir/$ruby/dependencies.sh" 102 | 103 | assertEquals "did not correctly set \$ruby_dependencies" \ 104 | "${ruby_dependencies[*]}" \ 105 | "gcc make bison" 106 | 107 | package_manager="$original_package_manager" 108 | } 109 | 110 | function test_when_package_manager_is_pkg() 111 | { 112 | local original_package_manager="$package_manager" 113 | package_manager="pkg" 114 | 115 | source "$ruby_install_dir/$ruby/dependencies.sh" 116 | 117 | assertEquals "did not correctly set \$ruby_dependencies" \ 118 | "${ruby_dependencies[*]}" \ 119 | "gcc automake bison" 120 | 121 | package_manager="$original_package_manager" 122 | } 123 | 124 | function test_when_package_manager_is_xbps() 125 | { 126 | local original_package_manager="$package_manager" 127 | package_manager="xbps" 128 | 129 | source "$ruby_install_dir/$ruby/dependencies.sh" 130 | 131 | assertEquals "did not correctly set \$ruby_dependencies" \ 132 | "${ruby_dependencies[*]}" \ 133 | "base-devel" 134 | 135 | package_manager="$original_package_manager" 136 | } 137 | 138 | function tearDown() 139 | { 140 | unset ruby ruby_version ruby_dependencies 141 | } 142 | 143 | SHUNIT_PARENT=$0 . $SHUNIT2 144 | -------------------------------------------------------------------------------- /test/mruby-tests/functions_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="mruby" 9 | ruby_version="3.0.0" 10 | 11 | source "$ruby_install_dir/functions.sh" 12 | source "$ruby_install_dir/mruby/functions.sh" 13 | } 14 | 15 | function test_ruby_archive_default_value() 16 | { 17 | assertEquals "did not correctly set \$ruby_archive" \ 18 | "mruby-${ruby_version}.tar.gz" \ 19 | "$ruby_archive" 20 | } 21 | 22 | function test_ruby_archive_when_its_already_set() 23 | { 24 | ruby_archive="ruby-custom-1.2.3.tar.bz2" 25 | 26 | source "$ruby_install_dir/functions.sh" 27 | source "$ruby_install_dir/mruby/functions.sh" 28 | 29 | assertEquals "did not preserve the \$ruby_archive value" \ 30 | "ruby-custom-1.2.3.tar.bz2" \ 31 | "$ruby_archive" 32 | } 33 | 34 | function test_ruby_dir_name() 35 | { 36 | assertEquals "did not correctly set \$ruby_dir_name" \ 37 | "mruby-$ruby_version" \ 38 | "$ruby_dir_name" 39 | } 40 | 41 | function test_ruby_mirror_default_value() 42 | { 43 | assertEquals "did not correctly set \$ruby_mirror" \ 44 | "https://github.com/mruby/mruby/archive" \ 45 | "$ruby_mirror" 46 | } 47 | 48 | function test_ruby_mirror_when_its_already_set() 49 | { 50 | ruby_mirror="https://example.com/pub/mruby" 51 | 52 | source "$ruby_install_dir/functions.sh" 53 | source "$ruby_install_dir/mruby/functions.sh" 54 | 55 | assertEquals "did not preserve the \$ruby_mirror value" \ 56 | "https://example.com/pub/mruby" \ 57 | "$ruby_mirror" 58 | } 59 | 60 | function test_ruby_url_default_value() 61 | { 62 | assertEquals "did not correctly set \$ruby_url" \ 63 | "https://github.com/mruby/mruby/archive/$ruby_version/$ruby_archive" \ 64 | "$ruby_url" 65 | } 66 | 67 | function test_ruby_url_when_its_already_set() 68 | { 69 | ruby_url="https://example.com/pub/mruby/mruby-1.2.3.tar.gz" 70 | 71 | source "$ruby_install_dir/functions.sh" 72 | source "$ruby_install_dir/mruby/functions.sh" 73 | 74 | assertEquals "did not preserve the \$ruby_url value" \ 75 | "https://example.com/pub/mruby/mruby-1.2.3.tar.gz" \ 76 | "$ruby_url" 77 | } 78 | 79 | function tearDown() 80 | { 81 | unset ruby ruby_version ruby_archive ruby_dir_name ruby_mirror ruby_url 82 | } 83 | 84 | SHUNIT_PARENT=$0 . $SHUNIT2 85 | -------------------------------------------------------------------------------- /test/package_manager-tests/set_package_manager_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/package_manager.sh 5 | 6 | function test_set_package_manager_with_apt() 7 | { 8 | local arg1="apt" 9 | 10 | set_package_manager "$arg1" 11 | 12 | assertEquals "did not return 0" $? 0 13 | assertEquals "did not set package_manager to $arg1" "$arg1" "$package_manager" 14 | } 15 | 16 | function test_set_package_manager_with_dnf() 17 | { 18 | local arg1="dnf" 19 | 20 | set_package_manager "$arg1" 21 | 22 | assertEquals "did not return 0" $? 0 23 | assertEquals "did not set package_manager to $arg1" "$arg1" "$package_manager" 24 | } 25 | 26 | function test_set_package_manager_with_yum() 27 | { 28 | local arg1="yum" 29 | 30 | set_package_manager "$arg1" 31 | 32 | assertEquals "did not return 0" $? 0 33 | assertEquals "did not set package_manager to $arg1" "$arg1" "$package_manager" 34 | } 35 | 36 | function test_set_package_manager_with_zypper() 37 | { 38 | local arg1="zypper" 39 | 40 | set_package_manager "$arg1" 41 | 42 | assertEquals "did not return 0" $? 0 43 | assertEquals "did not set package_manager to $arg1" "$arg1" "$package_manager" 44 | } 45 | 46 | function test_set_package_manager_with_pacman() 47 | { 48 | local arg1="pacman" 49 | 50 | set_package_manager "$arg1" 51 | 52 | assertEquals "did not return 0" $? 0 53 | assertEquals "did not set package_manager to $arg1" "$arg1" "$package_manager" 54 | } 55 | 56 | function test_set_package_manager_with_pkg() 57 | { 58 | local arg1="pkg" 59 | 60 | set_package_manager "$arg1" 61 | 62 | assertEquals "did not return 0" $? 0 63 | assertEquals "did not set package_manager to $arg1" "$arg1" "$package_manager" 64 | } 65 | 66 | function test_set_package_manager_with_homebrew() 67 | { 68 | local arg1="brew" 69 | 70 | set_package_manager "$arg1" 71 | 72 | assertEquals "did not return 0" $? 0 73 | assertEquals "did not set package_manager to $arg1" "$arg1" "$package_manager" 74 | } 75 | 76 | 77 | function test_set_package_manager_with_macports() 78 | { 79 | local arg1="port" 80 | 81 | set_package_manager "$arg1" 82 | 83 | assertEquals "did not return 0" $? 0 84 | assertEquals "did not set package_manager to $arg1" "$arg1" "$package_manager" 85 | } 86 | 87 | function test_set_package_manager_with_xbps() 88 | { 89 | local arg1="xbps" 90 | 91 | set_package_manager "$arg1" 92 | 93 | assertEquals "did not return 0" $? 0 94 | assertEquals "did not set package_manager to $arg1" "$arg1" "$package_manager" 95 | } 96 | 97 | function test_set_package_manager_with_unknown_package_manager() 98 | { 99 | set_package_manager "foo" 2>/dev/null 100 | 101 | assertEquals "did not return 1" $? 1 102 | } 103 | 104 | SHUNIT_PARENT=$0 . $SHUNIT2 105 | -------------------------------------------------------------------------------- /test/ruby-install-tests/init_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | 5 | function oneTimeSetUp() 6 | { 7 | ruby="ruby" 8 | 9 | download_ruby_versions "$ruby" 10 | } 11 | 12 | function setUp() 13 | { 14 | ruby="ruby" 15 | ruby_version="3.3" 16 | 17 | expected_ruby_version="$(latest_version "$ruby_install_cache_dir/$ruby/stable.txt" "$ruby_version")" 18 | } 19 | 20 | function test_init() 21 | { 22 | init 23 | 24 | assertEquals "did not return 0" 0 $? 25 | } 26 | 27 | function test_init_when_ruby_is_unknown() 28 | { 29 | ruby="foo" 30 | 31 | init 2>/dev/null 32 | 33 | assertEquals "did not return 1" 1 $? 34 | } 35 | 36 | function test_ruby_version() 37 | { 38 | init 39 | 40 | assertEquals "did not expand ruby_version" \ 41 | "$expected_ruby_version" \ 42 | "$ruby_version" 43 | } 44 | 45 | function test_ruby_version_with_unknown_version() 46 | { 47 | local expected_ruby_version="9000" 48 | 49 | ruby_version="$expected_ruby_version" 50 | 51 | local output=$(init 2>&1) 52 | 53 | assertTrue "did not print a warning" \ 54 | '[[ $output == *"*** Unknown ruby version $expected_ruby_version."* ]]' 55 | assertEquals "did not preserve ruby_version" \ 56 | "$expected_ruby_version" \ 57 | "$ruby_version" 58 | } 59 | 60 | function test_init_with_ruby_url() 61 | { 62 | local url="http://mirror.s3.amazonaws.com/downloads/ruby-1.2.3.tar.gz" 63 | 64 | ruby_url="$url" 65 | init 66 | 67 | assertEquals "did not preserve ruby_url" "$url" "$ruby_url" 68 | } 69 | 70 | function test_init_ruby_md5() 71 | { 72 | init 73 | 74 | assertNotNull "did not set ruby_md5" $ruby_md5 75 | } 76 | 77 | function test_init_ruby_sha1() 78 | { 79 | init 80 | 81 | assertNotNull "did not set ruby_sha1" $ruby_sha1 82 | } 83 | 84 | function test_init_ruby_sha256() 85 | { 86 | init 87 | 88 | assertNotNull "did not set ruby_sha256" $ruby_sha256 89 | } 90 | 91 | function test_init_ruby_sha512() 92 | { 93 | init 94 | 95 | assertNotNull "did not set ruby_sha512" $ruby_sha512 96 | } 97 | 98 | function test_init_with_ruby_md5() 99 | { 100 | local md5="b1946ac92492d2347c6235b4d2611184" 101 | 102 | ruby_md5="$md5" 103 | init 104 | 105 | assertEquals "did not preserve ruby_md5" "$md5" "$ruby_md5" 106 | } 107 | 108 | function test_init_with_ruby_sha1() 109 | { 110 | local sha1="4e1243bd22c66e76c2ba9eddc1f91394e57f9f83" 111 | 112 | ruby_sha1="$sha1" 113 | init 114 | 115 | assertEquals "did not preserve ruby_sha1" "$sha1" "$ruby_sha1" 116 | } 117 | 118 | function test_init_with_ruby_sha256() 119 | { 120 | local sha256="f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2" 121 | 122 | ruby_sha256="$sha256" 123 | init 124 | 125 | assertEquals "did not preserve ruby_sha256" "$sha256" "$ruby_sha256" 126 | } 127 | 128 | function test_init_with_ruby_sha512() 129 | { 130 | local sha512="0cf9180a764aba863a67b6d72f0918bc131c6772642cb2dce5a34f0a702f9470ddc2bf125c12198b1995c233c34b4afd346c54a2334c350a948a51b6e8b4e6b6" 131 | 132 | ruby_sha512="$sha512" 133 | init 134 | 135 | assertEquals "did not preserve ruby_sha512" "$sha512" "$ruby_sha512" 136 | } 137 | 138 | function test_rubies_dir() 139 | { 140 | init 141 | 142 | if (( UID == 0 )); then 143 | assertEquals "did not correctly default rubies_dir" \ 144 | "/opt/rubies" \ 145 | "$rubies_dir" 146 | else 147 | assertEquals "did not correctly default rubies_dir" \ 148 | "$HOME/.rubies" \ 149 | "$rubies_dir" 150 | fi 151 | } 152 | 153 | function test_ruby_cache_dir() 154 | { 155 | init 156 | 157 | assertEquals "did not correctly set ruby_cache_dir" \ 158 | "$ruby_install_cache_dir/$ruby" \ 159 | "$ruby_cache_dir" 160 | } 161 | 162 | function test_install_dir() 163 | { 164 | init 165 | 166 | assertEquals "did not correctly default install_dir" \ 167 | "$rubies_dir/$ruby-$expected_ruby_version" \ 168 | "$install_dir" 169 | } 170 | 171 | function tearDown() 172 | { 173 | unset install_dir ruby_cache_dir 174 | unset ruby ruby_version ruby_md5 ruby_archive ruby_url 175 | } 176 | 177 | SHUNIT_PARENT=$0 . $SHUNIT2 178 | -------------------------------------------------------------------------------- /test/ruby-install-tests/list_rubies_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | 5 | function test_list_rubies() 6 | { 7 | local output="$(list_rubies)" 8 | 9 | assertTrue "did not include ruby" '[[ "$output" == *ruby:* ]]' 10 | assertTrue "did not include jruby" '[[ "$output" == *jruby:* ]]' 11 | assertTrue "did not include truffleruby" '[[ "$output" == *truffleruby:* ]]' 12 | assertTrue "did not include mruby" '[[ "$output" == *mruby:* ]]' 13 | } 14 | 15 | SHUNIT_PARENT=$0 . $SHUNIT2 16 | -------------------------------------------------------------------------------- /test/ruby-install-tests/parse_options_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | 5 | function setUp() 6 | { 7 | patches=() 8 | configure_opts=() 9 | 10 | unset ruby 11 | unset ruby_version 12 | unset src_dir 13 | unset install_dir 14 | unset make_jobs 15 | } 16 | 17 | function test_parse_options_with_no_arguments() 18 | { 19 | parse_options 20 | 21 | assertEquals "did not return 0" 0 $? 22 | assertNull "did not leave \$ruby blank" "$ruby" 23 | assertNull "did not leave \$ruby_version blank" "$ruby_version" 24 | } 25 | 26 | function test_parse_options_with_invalid_options() 27 | { 28 | parse_options "--foo" "ruby" >/dev/null 2>&1 29 | 30 | assertEquals "did not return 1" 1 $? 31 | } 32 | 33 | function test_parse_options_with_one_argument() 34 | { 35 | local expected="jruby" 36 | 37 | parse_options "$expected" 38 | 39 | assertEquals "did not set \$ruby" "$expected" "$ruby" 40 | } 41 | 42 | function test_parse_options_with_two_arguments() 43 | { 44 | local expected_ruby="jruby" 45 | local expected_version="1.7.4" 46 | 47 | parse_options "$expected_ruby" "$expected_version" 48 | 49 | assertEquals "did not set \$ruby" "$expected_ruby" "$ruby" 50 | assertEquals "did not set \$ruby_version" "$expected_version" \ 51 | "$ruby_version" 52 | } 53 | 54 | function test_parse_options_with_more_than_two_arguments() 55 | { 56 | parse_options "jruby" "1.7.4" "foo" >/dev/null 2>&1 57 | 58 | assertEquals "did not return 1" 1 $? 59 | } 60 | 61 | function test_parse_options_with_install_dir() 62 | { 63 | local expected="/usr/local/" 64 | 65 | parse_options "--install-dir" "$expected" "ruby" 66 | 67 | assertEquals "did not set \$install_dir" "$expected" "$install_dir" 68 | } 69 | 70 | function test_parse_options_with_prefix() 71 | { 72 | local expected="/usr/local/" 73 | 74 | parse_options "--prefix" "$expected" "ruby" 75 | 76 | assertEquals "did not set \$install_dir" "$expected" "$install_dir" 77 | } 78 | 79 | function test_parse_options_with_system() 80 | { 81 | local expected="/usr/local" 82 | 83 | parse_options "--system" 84 | 85 | assertEquals "did not set \$install_dir to $expected" "$expected" \ 86 | "$install_dir" 87 | } 88 | 89 | function test_parse_options_with_src_dir() 90 | { 91 | local expected="/tmp" 92 | 93 | parse_options "--src-dir" "$expected" "ruby" 94 | 95 | assertEquals "did not set \$src_dir" "$expected" "$src_dir" 96 | } 97 | 98 | function test_parse_options_with_jobs_with_an_argument() 99 | { 100 | local expected=4 101 | 102 | parse_options -j "$expected" "ruby" 103 | 104 | assertEquals "did not set \$make_jobs" "$expected" "$make_jobs" 105 | } 106 | 107 | function test_parse_options_with_jobs_as_single_option() 108 | { 109 | local expected=4 110 | 111 | parse_options "-j${expected}" "ruby" 112 | 113 | assertEquals "did not set \$make_jobs" "$expected" "$make_jobs" 114 | } 115 | 116 | function test_parse_options_with_jobs_with_equals() 117 | { 118 | local expected=4 119 | 120 | parse_options "--jobs=${expected}" "ruby" 121 | 122 | assertEquals "did not set \$make_jobs" "$expected" "$make_jobs" 123 | } 124 | 125 | function test_parse_options_with_patches() 126 | { 127 | local patch1=patch1.diff 128 | local patch2=patch2.diff 129 | local expected=("$PWD/$patch1" "$PWD/$patch2") 130 | 131 | parse_options "--patch" "$patch1" \ 132 | "--patch" "$patch2" "ruby" 133 | 134 | assertEquals "did not set \$patches" "${expected[*]}" "${patches[*]}" 135 | } 136 | 137 | function test_parse_options_with_mirror() 138 | { 139 | local mirror="http://www.mirrorservice.org/sites/ftp.ruby-lang.org/pub/ruby" 140 | 141 | parse_options "--mirror" "$mirror" "ruby" 142 | 143 | assertEquals "did not set \$ruby_mirror" "$mirror" "$ruby_mirror" 144 | } 145 | 146 | function test_parse_options_with_url() 147 | { 148 | local archive="ruby-1.2.3.tar.gz" 149 | local url="http://mirror.s3.amazonaws.com/downloads/$archive" 150 | 151 | parse_options "--url" "$url" "ruby" 152 | 153 | assertEquals "did not set \$ruby_url" "$url" "$ruby_url" 154 | assertEquals "did not also set \$ruby_archive" "$archive" "$ruby_archive" 155 | } 156 | 157 | function test_parse_options_with_md5() 158 | { 159 | local md5="5d41402abc4b2a76b9719d911017c592" 160 | 161 | parse_options "--md5" "$md5" "ruby" 162 | 163 | assertEquals "did not set \$ruby_md5" "$md5" "$ruby_md5" 164 | } 165 | 166 | function test_parse_options_with_sha1() 167 | { 168 | local sha1="2aae6c35c94fcfb415dbe95f408b9ce91ee846ed" 169 | 170 | parse_options "--sha1" "$sha1" "ruby" 171 | 172 | assertEquals "did not set \$ruby_sha1" "$sha1" "$ruby_sha1" 173 | } 174 | 175 | function test_parse_options_with_sha256() 176 | { 177 | local sha256="b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9" 178 | 179 | parse_options "--sha256" "$sha256" "ruby" 180 | 181 | assertEquals "did not set \$ruby_sha256" "$sha256" "$ruby_sha256" 182 | } 183 | 184 | function test_parse_options_with_sha512() 185 | { 186 | local sha512="309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f" 187 | 188 | parse_options "--sha512" "$sha512" "ruby" 189 | 190 | assertEquals "did not set \$ruby_sha512" "$sha512" "$ruby_sha512" 191 | } 192 | 193 | function test_parse_options_with_package_manager() 194 | { 195 | local new_package_manager="dnf" 196 | 197 | set_package_manager "apt" 198 | 199 | parse_options "--package-manager" "$new_package_manager" 200 | 201 | assertEquals "did not set \$package_manager" "$new_package_manager" "$package_manager" 202 | } 203 | 204 | function test_parse_options_with_no_download() 205 | { 206 | parse_options "--no-download" "ruby" 207 | 208 | assertEquals "did not set \$no_download" 1 $no_download 209 | } 210 | 211 | function test_parse_options_with_no_verify() 212 | { 213 | parse_options "--no-verify" "ruby" 214 | 215 | assertEquals "did not set \$no_verify" 1 $no_verify 216 | } 217 | 218 | function test_parse_options_with_no_verify() 219 | { 220 | parse_options "--no-extract" "ruby" 221 | 222 | assertEquals "did not set \$no_extract" 1 $no_extract 223 | assertEquals "did not set \$no_verify" 1 $no_verify 224 | assertEquals "did not set \$no_download" 1 $no_download 225 | } 226 | 227 | function test_parse_options_with_no_install_deps() 228 | { 229 | parse_options "--no-install-deps" "ruby" 230 | 231 | assertEquals "did not set \$no_install_deps" 1 $no_install_deps 232 | } 233 | 234 | function test_parse_options_with_no_reinstall() 235 | { 236 | parse_options "--no-reinstall" "ruby" 237 | 238 | assertEquals "did not set to \$no_reinstall" 1 $no_reinstall 239 | } 240 | 241 | function test_parse_options_with_latest() 242 | { 243 | parse_options "--latest" "ruby" 2>/dev/null 244 | 245 | assertEquals "did not set to \$force_update" 1 $force_update 246 | } 247 | 248 | function test_parse_option_with_latest_deprecation_warning() 249 | { 250 | local output="$(parse_options "--latest" "ruby" 2>&1)" 251 | 252 | assertEquals "*** DEPRECATION: -L,--latest is deprecated. Please use -U,--update instead." "$output" 253 | } 254 | 255 | function test_parse_options_with_update() 256 | { 257 | parse_options "--update" "ruby" 2>/dev/null 258 | 259 | assertEquals "did not set to \$force_update" 1 $force_update 260 | } 261 | 262 | function test_parse_options_with_additional_options() 263 | { 264 | local expected=(--enable-shared CFLAGS="-03") 265 | 266 | parse_options "ruby" "--" $expected 267 | 268 | assertEquals "did not set \$configure_opts" $expected $configure_opts 269 | } 270 | 271 | function test_parse_options_with_additional_options_with_spaces() 272 | { 273 | parse_options "ruby" "--" --enable-shared CFLAGS="-march=auto -O2" 274 | 275 | assertEquals "did not word-split \$configure_opts correctly" \ 276 | 'CFLAGS=-march=auto -O2' "${configure_opts[1]}" 277 | } 278 | 279 | SHUNIT_PARENT=$0 . $SHUNIT2 280 | -------------------------------------------------------------------------------- /test/ruby-install-tests/parse_ruby_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | 5 | function setUp() 6 | { 7 | unset ruby 8 | unset ruby_cache_dir 9 | } 10 | 11 | function test_parse_ruby_with_a_single_name() 12 | { 13 | local expected_ruby="jruby" 14 | 15 | parse_ruby "$expected_ruby" 16 | 17 | assertEquals "did not return successfully" 0 $? 18 | assertEquals "did not set \$ruby" "$expected_ruby" "$ruby" 19 | } 20 | 21 | function test_parse_ruby_with_a_name_dash_version() 22 | { 23 | local expected_ruby="jruby" 24 | local expected_version="9.0.0" 25 | 26 | parse_ruby "${expected_ruby}-${expected_version}" 27 | 28 | assertEquals "did not return successfully" 0 $? 29 | assertEquals "did not set \$ruby" "$ruby" "$expected_ruby" 30 | assertEquals "did not set \$ruby_version" "$expected_version" \ 31 | "$ruby_version" 32 | } 33 | 34 | function test_parse_ruby_with_just_a_version() 35 | { 36 | local expected_version="2.7.0" 37 | 38 | parse_ruby "$expected_version" 39 | 40 | assertEquals "did not return successfully" 0 $? 41 | assertEquals "did not set \$ruby to ruby" "$ruby" "ruby" 42 | assertEquals "did not set \$ruby_version" "$expected_version" \ 43 | "$ruby_version" 44 | } 45 | 46 | function test_parse_ruby_when_the_ruby_name_contains_multiple_dashes() 47 | { 48 | local expected_ruby="truffleruby-graalvm" 49 | local expected_version="1.2.3" 50 | 51 | parse_ruby "$expected_ruby-$expected_version" 52 | 53 | assertEquals "did not return successfully" 0 $? 54 | assertEquals "did not match the ruby name" "$expected_ruby" "$ruby" 55 | assertEquals "did not match the ruby version" "$expected_version" \ 56 | "$ruby_version" 57 | } 58 | 59 | function test_parse_ruby_with_an_unknown_ruby() 60 | { 61 | local unknown_ruby="foo" 62 | local output="$(parse_ruby "$unknown_ruby" 2>&1)" 63 | 64 | assertEquals "did not print an error for an unknwon ruby" \ 65 | "ruby-install: unknown ruby: $unknown_ruby" \ 66 | "$output" 67 | } 68 | 69 | SHUNIT_PARENT=$0 . $SHUNIT2 70 | -------------------------------------------------------------------------------- /test/ruby-install-tests/variables_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | 5 | function test_ruby_install_version() 6 | { 7 | assertTrue "did not set \$ruby_install_version" \ 8 | '[[ -n "$ruby_install_version" ]]' 9 | } 10 | 11 | function test_ruby_install_dir() 12 | { 13 | local expected_ruby_install_dir="$PWD/share/ruby-install" 14 | 15 | assertEquals "was not ./share/ruby-install" \ 16 | "$expected_ruby_install_dir" \ 17 | "$ruby_install_dir" 18 | } 19 | 20 | function test_ruby_install_cache_dir() 21 | { 22 | if [[ -n "$XDG_CACHE_HOME" ]]; then 23 | assertTrue "did not use \$XDG_CACHE_HOME/" \ 24 | '[[ "$ruby_install_cache_dir" == "$XDG_CACHE_HOME/"* ]]' 25 | else 26 | assertTrue "did not use \$HOME/.cache/" \ 27 | '[[ "$ruby_install_cache_dir" == "$HOME/.cache/"* ]]' 28 | fi 29 | } 30 | 31 | function test_rubies() 32 | { 33 | for ruby in ruby jruby truffleruby mruby; do 34 | assertTrue "did not contain $ruby" \ 35 | "[[ \" \${rubies[@]} \" == *\" $ruby \"* ]]" 36 | done 37 | } 38 | 39 | function test_patches() 40 | { 41 | assertEquals "\$patches was not empty" 0 "${#patches[@]}" 42 | } 43 | 44 | function test_configure_opts() 45 | { 46 | assertEquals "\$configure_opts was not empty" 0 "${#configure_opts[@]}" 47 | } 48 | 49 | function test_src_dir() 50 | { 51 | if (( UID == 0 )); then 52 | assertEquals "did not set \$src_dir correctly" \ 53 | "/usr/local/src" "$src_dir" 54 | else 55 | assertEquals "did not set \$src_dir correctly" \ 56 | "$HOME/src" "$src_dir" 57 | fi 58 | } 59 | 60 | function test_rubies_dir() 61 | { 62 | if (( UID == 0 )); then 63 | assertEquals "did not set \$rubies_dir correctly" \ 64 | "/opt/rubies" "$rubies_dir" 65 | else 66 | assertEquals "did not set \$rubies_dir correctly" \ 67 | "$HOME/.rubies" "$rubies_dir" 68 | fi 69 | } 70 | 71 | function test_src_dir_with_RUBY_INSTALL_SRC_DIR() 72 | { 73 | export RUBY_INSTALL_SRC_DIR="/path/to/src/dir" 74 | . ./share/ruby-install/ruby-install.sh 75 | 76 | assertEquals "did not set \$src_dir to \$RUBY_INSTALL_SRC_DIR" \ 77 | "$RUBY_INSTALL_SRC_DIR" "$src_dir" 78 | 79 | unset RUBY_INSTALL_SRC_DIR 80 | } 81 | 82 | function test_rubies_dir_with_RUBY_INSTALL_SRC_DIR() 83 | { 84 | export RUBY_INSTALL_RUBIES_DIR="/path/to/rubies/dir" 85 | . ./share/ruby-install/ruby-install.sh 86 | 87 | assertEquals "did not set \$rubies_dir to \$RUBY_INSTALL_RUBIES_DIR" \ 88 | "$RUBY_INSTALL_RUBIES_DIR" "$rubies_dir" 89 | 90 | unset RUBY_INSTALL_RUBIES_DIR 91 | } 92 | 93 | SHUNIT_PARENT=$0 . $SHUNIT2 94 | -------------------------------------------------------------------------------- /test/ruby-tests/dependencies_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="ruby" 9 | ruby_version="3.2.0" 10 | } 11 | 12 | function test_when_package_manager_is_apt() 13 | { 14 | local original_package_manager="$package_manager" 15 | package_manager="apt" 16 | 17 | source "$ruby_install_dir/$ruby/dependencies.sh" 18 | 19 | assertNull "accidentally set \$openssl_version" \ 20 | "$openssl_version" 21 | 22 | assertEquals "did not correctly set \$ruby_dependencies" \ 23 | "xz-utils build-essential bison zlib1g-dev libyaml-dev libssl-dev libreadline-dev libncurses-dev libffi-dev" \ 24 | "${ruby_dependencies[*]}" 25 | 26 | package_manager="$original_package_manager" 27 | } 28 | 29 | function test_when_package_manager_is_dnf() 30 | { 31 | local original_package_manager="$package_manager" 32 | package_manager="dnf" 33 | 34 | source "$ruby_install_dir/$ruby/dependencies.sh" 35 | 36 | assertNull "accidentally set \$openssl_version" \ 37 | "$openssl_version" 38 | 39 | assertEquals "did not correctly set \$ruby_dependencies" \ 40 | "xz gcc automake bison zlib-devel libyaml-devel openssl-devel readline-devel ncurses-devel libffi-devel" \ 41 | "${ruby_dependencies[*]}" 42 | 43 | package_manager="$original_package_manager" 44 | } 45 | 46 | function test_when_package_manager_is_yum() 47 | { 48 | local original_package_manager="$package_manager" 49 | package_manager="yum" 50 | 51 | source "$ruby_install_dir/$ruby/dependencies.sh" 52 | 53 | assertNull "accidentally set \$openssl_version" \ 54 | "$openssl_version" 55 | 56 | assertEquals "did not correctly set \$ruby_dependencies" \ 57 | "xz gcc automake bison zlib-devel libyaml-devel openssl-devel readline-devel ncurses-devel libffi-devel" \ 58 | "${ruby_dependencies[*]}" 59 | 60 | package_manager="$original_package_manager" 61 | } 62 | 63 | function test_when_package_manager_is_pacman() 64 | { 65 | local original_package_manager="$package_manager" 66 | package_manager="pacman" 67 | 68 | source "$ruby_install_dir/$ruby/dependencies.sh" 69 | 70 | assertNull "accidentally set \$openssl_version" \ 71 | "$openssl_version" 72 | 73 | assertEquals "did not correctly set \$ruby_dependencies" \ 74 | "xz gcc make bison zlib ncurses openssl readline libyaml libffi" \ 75 | "${ruby_dependencies[*]}" 76 | 77 | package_manager="$original_package_manager" 78 | } 79 | 80 | function test_when_package_manager_is_zypper() 81 | { 82 | local original_package_manager="$package_manager" 83 | package_manager="zypper" 84 | 85 | source "$ruby_install_dir/$ruby/dependencies.sh" 86 | 87 | assertNull "accidentally set \$openssl_version" \ 88 | "$openssl_version" 89 | 90 | assertEquals "did not correctly set \$ruby_dependencies" \ 91 | "xz gcc make automake zlib-devel libyaml-devel libopenssl-devel readline-devel ncurses-devel libffi-devel" \ 92 | "${ruby_dependencies[*]}" 93 | 94 | package_manager="$original_package_manager" 95 | } 96 | 97 | function test_when_package_manager_is_pkg() 98 | { 99 | local original_package_manager="$package_manager" 100 | package_manager="pkg" 101 | 102 | source "$ruby_install_dir/$ruby/dependencies.sh" 103 | 104 | assertNull "accidentally set \$openssl_version" \ 105 | "$openssl_version" 106 | 107 | assertEquals "did not correctly set \$ruby_dependencies" \ 108 | "openssl readline libyaml libffi" \ 109 | "${ruby_dependencies[*]}" 110 | 111 | package_manager="$original_package_manager" 112 | } 113 | 114 | function test_when_package_manager_is_xbps() 115 | { 116 | local original_package_manager="$package_manager" 117 | package_manager="xbps" 118 | 119 | source "$ruby_install_dir/$ruby/dependencies.sh" 120 | 121 | assertNull "accidentally set \$openssl_version" \ 122 | "$openssl_version" 123 | 124 | assertEquals "did not correctly set \$ruby_dependencies" \ 125 | "base-devel openssl-devel zlib-devel libyaml-devel readline-devel ncurses-devel libffi-devel" \ 126 | "${ruby_dependencies[*]}" 127 | 128 | package_manager="$original_package_manager" 129 | } 130 | 131 | function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_apt() 132 | { 133 | local original_package_manager="$package_manager" 134 | package_manager="apt" 135 | ruby_version="3.0.7" 136 | 137 | source "$ruby_install_dir/$ruby/dependencies.sh" 138 | 139 | assertTrue "did not add libgdbm-dev to \$ruby_dependencies" \ 140 | '[[ " ${ruby_dependencies[*]} " == *" libgdbm-dev "* ]]' 141 | 142 | package_manager="$original_package_manager" 143 | } 144 | 145 | function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_dnf() 146 | { 147 | local original_package_manager="$package_manager" 148 | package_manager="dnf" 149 | ruby_version="3.0.7" 150 | 151 | source "$ruby_install_dir/$ruby/dependencies.sh" 152 | 153 | assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ 154 | '[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]' 155 | 156 | package_manager="$original_package_manager" 157 | } 158 | 159 | function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_yum() 160 | { 161 | local original_package_manager="$package_manager" 162 | package_manager="yum" 163 | ruby_version="3.0.7" 164 | 165 | source "$ruby_install_dir/$ruby/dependencies.sh" 166 | 167 | assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ 168 | '[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]' 169 | 170 | package_manager="$original_package_manager" 171 | } 172 | 173 | function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_zypper() 174 | { 175 | local original_package_manager="$package_manager" 176 | package_manager="zypper" 177 | ruby_version="3.0.7" 178 | 179 | source "$ruby_install_dir/$ruby/dependencies.sh" 180 | 181 | assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ 182 | '[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]' 183 | 184 | package_manager="$original_package_manager" 185 | } 186 | 187 | function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_xbps() 188 | { 189 | local original_package_manager="$package_manager" 190 | package_manager="xbps" 191 | ruby_version="3.0.7" 192 | 193 | source "$ruby_install_dir/$ruby/dependencies.sh" 194 | 195 | assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ 196 | '[[ " ${ruby_dependencies[*]} " == *" gdbm-devel "* ]]' 197 | 198 | package_manager="$original_package_manager" 199 | } 200 | 201 | function test_when_ruby_version_is_less_than_3_1_0_and_package_manager_is_other() 202 | { 203 | local original_package_manager="$package_manager" 204 | package_manager="brew" 205 | ruby_version="3.0.7" 206 | 207 | source "$ruby_install_dir/$ruby/dependencies.sh" 208 | 209 | assertTrue "did not add gdbm-devel to \$ruby_dependencies" \ 210 | '[[ " ${ruby_dependencies[*]} " == *" gdbm "* ]]' 211 | 212 | package_manager="$original_package_manager" 213 | } 214 | 215 | function test_when_package_manager_is_brew_and_ruby_version_is_less_than_3_1_0() 216 | { 217 | local original_package_manager="$package_manager" 218 | package_manager="brew" 219 | ruby_version="3.0.0" 220 | 221 | source "$ruby_install_dir/$ruby/dependencies.sh" 222 | 223 | assertEquals "did not correctly set \$openssl_version" \ 224 | "1.1" \ 225 | "$openssl_version" 226 | 227 | assertTrue "did not add openssl@1.1 to \$ruby_dependencies" \ 228 | '[[ " ${ruby_dependencies[*]} " == *" openssl@1.1 "* ]]' 229 | 230 | package_manager="$original_package_manager" 231 | } 232 | 233 | function test_when_package_manager_is_brew_and_ruby_version_is_greater_equal_to_3_1_0() 234 | { 235 | local original_package_manager="$package_manager" 236 | package_manager="brew" 237 | ruby_version="3.1.0" 238 | 239 | source "$ruby_install_dir/$ruby/dependencies.sh" 240 | 241 | assertEquals "did not correctly set \$openssl_version" \ 242 | "3" \ 243 | "$openssl_version" 244 | 245 | assertTrue "did not add openssl@3 to \$ruby_dependencies" \ 246 | '[[ " ${ruby_dependencies[*]} " == *" openssl@3 "* ]]' 247 | 248 | package_manager="$original_package_manager" 249 | } 250 | 251 | function test_when_package_manager_is_port_and_ruby_version_is_less_than_3_1_0() 252 | { 253 | local original_package_manager="$package_manager" 254 | package_manager="port" 255 | ruby_version="3.0.0" 256 | 257 | source "$ruby_install_dir/$ruby/dependencies.sh" 258 | 259 | assertEquals "did not correctly set \$openssl_version" \ 260 | "1.1" \ 261 | "$openssl_version" 262 | 263 | assertTrue "did not add openssl11 to \$ruby_dependencies" \ 264 | '[[ " ${ruby_dependencies[*]} " == *" openssl11 "* ]]' 265 | 266 | package_manager="$original_package_manager" 267 | } 268 | 269 | function test_package_manager_is_port_and_ruby_version_is_greater_equal_to_3_1_0() 270 | { 271 | local original_package_manager="$package_manager" 272 | package_manager="port" 273 | ruby_version="3.1.0" 274 | 275 | source "$ruby_install_dir/$ruby/dependencies.sh" 276 | 277 | assertEquals "did not correctly set \$openssl_version" \ 278 | "3" \ 279 | "$openssl_version" 280 | 281 | assertTrue "did not add openssl3 to \$ruby_dependencies" \ 282 | '[[ " ${ruby_dependencies[*]} " == *" openssl3 "* ]]' 283 | 284 | package_manager="$original_package_manager" 285 | } 286 | 287 | function test_ruby_dependencies_when_with_jemalloc_is_given_and_package_manager_is_apt() 288 | { 289 | local original_package_manager="$package_manager" 290 | local original_configure_opts=("${configure_opts[@]}") 291 | 292 | package_manager="apt" 293 | configure_opts=(--with-jemalloc) 294 | 295 | source "$ruby_install_dir/$ruby/dependencies.sh" 296 | 297 | assertTrue "did not contain libjemalloc-dev" \ 298 | '[[ " ${ruby_dependencies[*]} " == *" libjemalloc-dev "* ]]' 299 | 300 | package_manager="$original_package_manager" 301 | configure_opts=("${original_configure_opts[@]}") 302 | } 303 | 304 | function test_ruby_dependencies_when_with_jemalloc_is_given_and_package_manager_is_dnf() 305 | { 306 | local original_package_manager="$package_manager" 307 | local original_configure_opts=("${configure_opts[@]}") 308 | 309 | package_manager="dnf" 310 | configure_opts=(--with-jemalloc) 311 | 312 | source "$ruby_install_dir/$ruby/dependencies.sh" 313 | 314 | assertTrue "did not contain jemalloc-devel" \ 315 | '[[ " ${ruby_dependencies[*]} " == *" jemalloc-devel "* ]]' 316 | 317 | package_manager="$original_package_manager" 318 | configure_opts=("${original_configure_opts[@]}") 319 | } 320 | 321 | function test_ruby_dependencies_when_with_jemalloc_is_given_and_package_manager_is_yum() 322 | { 323 | local original_package_manager="$package_manager" 324 | local original_configure_opts=("${configure_opts[@]}") 325 | 326 | package_manager="yum" 327 | configure_opts=(--with-jemalloc) 328 | 329 | source "$ruby_install_dir/$ruby/dependencies.sh" 330 | 331 | assertTrue "did not contain jemalloc-devel" \ 332 | '[[ " ${ruby_dependencies[*]} " == *" jemalloc-devel "* ]]' 333 | 334 | package_manager="$original_package_manager" 335 | configure_opts=("${original_configure_opts[@]}") 336 | } 337 | 338 | function test_ruby_dependencies_when_with_jemalloc_is_given_and_package_manager_is_port() 339 | { 340 | local original_package_manager="$package_manager" 341 | local original_configure_opts=("${configure_opts[@]}") 342 | 343 | package_manager="port" 344 | configure_opts=(--with-jemalloc) 345 | 346 | source "$ruby_install_dir/$ruby/dependencies.sh" 347 | 348 | assertTrue "did not contain jemalloc-devel" \ 349 | '[[ " ${ruby_dependencies[*]} " == *" jemalloc-devel "* ]]' 350 | 351 | package_manager="$original_package_manager" 352 | configure_opts=("${original_configure_opts[@]}") 353 | } 354 | 355 | function test_ruby_dependencies_when_with_jemalloc_is_given_and_package_manager_is_xbps() 356 | { 357 | local original_package_manager="$package_manager" 358 | local original_configure_opts=("${configure_opts[@]}") 359 | 360 | package_manager="xbps" 361 | configure_opts=(--with-jemalloc) 362 | 363 | source "$ruby_install_dir/$ruby/dependencies.sh" 364 | 365 | assertTrue "did not contain jemalloc-devel" \ 366 | '[[ " ${ruby_dependencies[*]} " == *" jemalloc-devel "* ]]' 367 | 368 | package_manager="$original_package_manager" 369 | configure_opts=("${original_configure_opts[@]}") 370 | } 371 | 372 | function test_ruby_dependencies_when_with_jemalloc_is_given_and_package_manager_is_zypper() 373 | { 374 | local original_package_manager="$package_manager" 375 | local original_configure_opts=("${configure_opts[@]}") 376 | 377 | package_manager="zypper" 378 | configure_opts=(--with-jemalloc) 379 | 380 | source "$ruby_install_dir/$ruby/dependencies.sh" 381 | 382 | assertTrue "did not contain libjemalloc2" \ 383 | '[[ " ${ruby_dependencies[*]} " == *" libjemalloc2"* ]]' 384 | 385 | package_manager="$original_package_manager" 386 | configure_opts=("${original_configure_opts[@]}") 387 | } 388 | 389 | function test_ruby_dependencies_when_with_jemalloc_is_given() 390 | { 391 | local original_package_manager="$package_manager" 392 | local original_configure_opts=("${configure_opts[@]}") 393 | 394 | package_manager="pkg" 395 | configure_opts=(--with-jemalloc) 396 | 397 | source "$ruby_install_dir/$ruby/dependencies.sh" 398 | 399 | assertTrue "did not contain jemalloc" \ 400 | '[[ " ${ruby_dependencies[*]} " == *" jemalloc"* ]]' 401 | 402 | package_manager="$original_package_manager" 403 | configure_opts=("${original_configure_opts[@]}") 404 | } 405 | 406 | function test_ruby_dependencies_when_enable_yjit_is_given_and_rustc_is_not_installed_and_the_package_manager_is_apt() 407 | { 408 | command -v rustc && return 409 | 410 | local original_package_manager="$package_manager" 411 | local original_configure_opts=("${configure_opts[@]}") 412 | 413 | package_manager="apt" 414 | configure_opts=(--enable-yjit) 415 | 416 | source "$ruby_install_dir/$ruby/dependencies.sh" 417 | 418 | assertTrue "did not contain rustc to the dependencies" \ 419 | '[[ " ${ruby_dependencies[*]} " == *" rustc "* ]]' 420 | 421 | package_manager="$original_package_manager" 422 | configure_opts=("${original_configure_opts[@]}") 423 | } 424 | 425 | function test_ruby_dependencies_when_enable_yjit_is_given_and_rustc_is_not_installed_and_the_package_manager_is_not_apt() 426 | { 427 | command -v rustc >/dev/null && return 428 | 429 | local original_package_manager="$package_manager" 430 | local original_configure_opts=("${configure_opts[@]}") 431 | 432 | package_manager="dnf" 433 | configure_opts=(--enable-yjit) 434 | 435 | source "$ruby_install_dir/$ruby/dependencies.sh" 436 | 437 | assertTrue "did not contain rust to the dependencies" \ 438 | '[[ " ${ruby_dependencies[*]} " == *" rust "* ]]' 439 | 440 | package_manager="$original_package_manager" 441 | configure_opts=("${original_configure_opts[@]}") 442 | } 443 | 444 | function test_ruby_dependencies_when_enable_yjit_is_given_but_rustc_is_installed() 445 | { 446 | command -v rustc >/dev/null || return 447 | 448 | local original_configure_opts=("${configure_opts[@]}") 449 | 450 | configure_opts=(--enable-yjit) 451 | 452 | source "$ruby_install_dir/$ruby/dependencies.sh" 453 | 454 | assertTrue "did accidentally add rustc to the dependencies" \ 455 | '[[ ! " ${ruby_dependencies[*]} " == *" rustc "* ]]' 456 | 457 | assertTrue "did accidentally add rust to the dependencies" \ 458 | '[[ ! " ${ruby_dependencies[*]} " == *" rust "* ]]' 459 | 460 | configure_opts=("${original_configure_opts[@]}") 461 | } 462 | 463 | function tearDown() 464 | { 465 | unset ruby ruby_version ruby_dependencies openssl_version 466 | } 467 | 468 | SHUNIT_PARENT=$0 . $SHUNIT2 469 | -------------------------------------------------------------------------------- /test/ruby-tests/functions_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="ruby" 9 | ruby_version="3.2.0" 10 | 11 | source "$ruby_install_dir/functions.sh" 12 | source "$ruby_install_dir/ruby/functions.sh" 13 | } 14 | 15 | function test_ruby_version_family() 16 | { 17 | assertEquals "did not correctly set \$ruby_version_family" \ 18 | "3.2" \ 19 | "$ruby_version_family" 20 | } 21 | 22 | function test_ruby_archive_ext() 23 | { 24 | assertEquals "did not set \$ruby_archive_ext to tar.xz" \ 25 | "tar.xz" \ 26 | "$ruby_archive_ext" 27 | } 28 | 29 | function test_ruby_archive_ext_for_ruby_1_x() 30 | { 31 | ruby_version="1.9.3-p551" 32 | 33 | source "$ruby_install_dir/functions.sh" 34 | source "$ruby_install_dir/ruby/functions.sh" 35 | 36 | assertEquals "did not set \$ruby_archive_ext to tar.bz2" \ 37 | "tar.bz2" \ 38 | "$ruby_archive_ext" 39 | } 40 | 41 | function test_ruby_archive_default_value() 42 | { 43 | assertEquals "did not preserve the \$ruby_archive value" \ 44 | "ruby-${ruby_version}.${ruby_archive_ext}" \ 45 | "$ruby_archive" 46 | } 47 | 48 | function test_ruby_archive_when_its_already_set() 49 | { 50 | ruby_archive="ruby-custom-1.2.3.tar.bz2" 51 | 52 | source "$ruby_install_dir/functions.sh" 53 | source "$ruby_install_dir/ruby/functions.sh" 54 | 55 | assertEquals "did not correctly set \$ruby_archive" \ 56 | "ruby-custom-1.2.3.tar.bz2" \ 57 | "$ruby_archive" 58 | } 59 | 60 | function test_ruby_dir_name() 61 | { 62 | assertEquals "did not correctly set \$ruby_dir_name" \ 63 | "ruby-$ruby_version" \ 64 | "$ruby_dir_name" 65 | } 66 | 67 | function test_ruby_mirror_default_value() 68 | { 69 | assertEquals "did not correctly set \$ruby_mirror" \ 70 | "https://cache.ruby-lang.org/pub/ruby" \ 71 | "$ruby_mirror" 72 | } 73 | 74 | function test_ruby_mirror_when_its_already_set() 75 | { 76 | ruby_mirror="https://example.com/pub/ruby" 77 | 78 | source "$ruby_install_dir/functions.sh" 79 | source "$ruby_install_dir/ruby/functions.sh" 80 | 81 | assertEquals "did not preserve the \$ruby_mirror value" \ 82 | "https://example.com/pub/ruby" \ 83 | "$ruby_mirror" 84 | } 85 | 86 | function test_ruby_url_default_value() 87 | { 88 | assertEquals "did not correctly set \$ruby_url" \ 89 | "https://cache.ruby-lang.org/pub/ruby/$ruby_version_family/$ruby_archive" \ 90 | "$ruby_url" 91 | } 92 | 93 | function test_ruby_url_when_its_already_set() 94 | { 95 | ruby_url="https://example.com/pub/ruby/ruby-1.2.3.tar.gz" 96 | 97 | source "$ruby_install_dir/functions.sh" 98 | source "$ruby_install_dir/ruby/functions.sh" 99 | 100 | assertEquals "did not preserve the \$ruby_url value" \ 101 | "https://example.com/pub/ruby/ruby-1.2.3.tar.gz" \ 102 | "$ruby_url" 103 | } 104 | 105 | function tearDown() 106 | { 107 | unset ruby ruby_version ruby_version_family ruby_archive ruby_dir_name \ 108 | ruby_mirror ruby_url 109 | } 110 | 111 | SHUNIT_PARENT=$0 . $SHUNIT2 112 | -------------------------------------------------------------------------------- /test/ruby-versions-tests/are_ruby_versions_missing_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-versions.sh 5 | 6 | ruby="ruby" 7 | 8 | function oneTimeSetUp() 9 | { 10 | rm -rf "$ruby_install_cache_dir" 11 | } 12 | 13 | function test_are_ruby_versions_missing_with_no_parent_dir() 14 | { 15 | are_ruby_versions_missing "$ruby" 16 | 17 | assertEquals "did not return 0" 0 $? 18 | } 19 | 20 | function test_are_ruby_versions_missing_with_no_ruby_dir() 21 | { 22 | mkdir -p "$ruby_install_cache_dir" 23 | 24 | are_ruby_versions_missing "$ruby" 25 | 26 | assertEquals "did not return 0" 0 $? 27 | } 28 | 29 | function test_are_ruby_versions_missing_with_no_files() 30 | { 31 | mkdir -p "$ruby_install_cache_dir/$ruby" 32 | 33 | are_ruby_versions_missing "$ruby" 34 | 35 | assertEquals "did not return 0" 0 $? 36 | } 37 | 38 | function test_are_ruby_versions_missing_with_some_files() 39 | { 40 | mkdir -p "$ruby_install_cache_dir/$ruby" 41 | touch "$ruby_install_cache_dir/$ruby/stable.txt" 42 | 43 | are_ruby_versions_missing "$ruby" 44 | 45 | assertEquals "did not return 0" 0 $? 46 | } 47 | 48 | function test_are_ruby_versions_missing_with_all_files() 49 | { 50 | mkdir -p "$ruby_install_cache_dir/$ruby" 51 | 52 | for file in "${ruby_versions_files[@]}"; do 53 | touch "$ruby_install_cache_dir/$ruby/$file" 54 | done 55 | 56 | are_ruby_versions_missing "$ruby" 57 | 58 | assertEquals "did not return 1" 1 $? 59 | } 60 | 61 | function tearDown() 62 | { 63 | rm -rf "$ruby_install_cache_dir" 64 | } 65 | 66 | SHUNIT_PARENT=$0 . $SHUNIT2 67 | -------------------------------------------------------------------------------- /test/ruby-versions-tests/download_ruby_versions_file_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-versions.sh 5 | 6 | ruby_install_cache_dir="$test_fixtures_dir/download_ruby_versions_file_test" 7 | 8 | ruby="ruby" 9 | file="stable.txt" 10 | 11 | expected_path="$ruby_install_cache_dir/$ruby/$file" 12 | 13 | function test_download_ruby_versions_file_with_no_parent_dir() 14 | { 15 | rm -rf "$ruby_install_cache_dir/$ruby" 16 | 17 | download_ruby_versions_file "$ruby" "$file" 18 | 19 | assertTrue "did not create the parent dir" \ 20 | '[[ -d "$ruby_install_cache_dir/$ruby" ]]' 21 | } 22 | 23 | function test_download_ruby_versions_file_first_time() 24 | { 25 | mkdir -p "$ruby_install_cache_dir/$ruby" 26 | 27 | download_ruby_versions_file "$ruby" "$file" 28 | 29 | assertTrue "did not create the file" \ 30 | '[[ -f "$expected_path" ]]' 31 | assertTrue "did not write data to the file" \ 32 | '[[ -s "$expected_path" ]]' 33 | } 34 | 35 | function test_download_ruby_versions_file_with_existing_file() 36 | { 37 | mkdir -p "$ruby_install_cache_dir/$ruby" 38 | touch "$ruby_install_cache_dir/$ruby/$file" 39 | 40 | download_ruby_versions_file "$ruby" "$file" 41 | 42 | assertTrue "did not write data to the file" \ 43 | '[[ -s "$expected_path" ]]' 44 | } 45 | 46 | function tearDown() 47 | { 48 | rm -rf "$ruby_install_cache_dir" 49 | } 50 | 51 | SHUNIT_PARENT=$0 . $SHUNIT2 52 | -------------------------------------------------------------------------------- /test/ruby-versions-tests/download_ruby_versions_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-versions.sh 5 | 6 | ruby="ruby" 7 | 8 | function setUp() 9 | { 10 | rm -rf "$ruby_install_cache_dir/$ruby" 11 | } 12 | 13 | function test_download_ruby_versions() 14 | { 15 | download_ruby_versions "$ruby" 16 | 17 | for file in {stable,versions}.txt checksums.{md5,sha1,sha256,sha512}; do 18 | assertTrue "did not create the $file file" \ 19 | "[[ -f \"\$ruby_install_cache_dir/\$ruby/$file\" ]]" 20 | assertTrue "did not write data to the $file file" \ 21 | "[[ -s \"\$ruby_install_cache_dir/\$ruby/$file\" ]]" 22 | done 23 | } 24 | 25 | function tearDown() 26 | { 27 | rm -rf "$ruby_install_cache_dir/$ruby" 28 | } 29 | 30 | SHUNIT_PARENT=$0 . $SHUNIT2 31 | -------------------------------------------------------------------------------- /test/ruby-versions-tests/is_known_ruby_version_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-versions.sh 5 | 6 | ruby="ruby" 7 | 8 | function oneTimeSetUp() 9 | { 10 | download_ruby_versions_file "$ruby" "versions.txt" 11 | } 12 | 13 | function test_is_known_ruby_version() 14 | { 15 | local version="2.7.2" 16 | 17 | is_known_ruby_version "$ruby" "$version" 18 | 19 | assertEquals "did not return 0" 0 $? 20 | } 21 | 22 | function test_is_known_ruby_version_with_unknown_version() 23 | { 24 | local version="9.9.9" 25 | 26 | is_known_ruby_version "$ruby" "$version" 27 | 28 | assertEquals "did not return 1" 1 $? 29 | } 30 | 31 | SHUNIT_PARENT=$0 . $SHUNIT2 32 | -------------------------------------------------------------------------------- /test/ruby-versions-tests/is_unknown_ruby_version_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-versions.sh 5 | 6 | ruby="ruby" 7 | 8 | function oneTimeSetUp() 9 | { 10 | download_ruby_versions_file "$ruby" "versions.txt" 11 | } 12 | 13 | function test_is_unknown_ruby_version_with_unknown_version() 14 | { 15 | local version="9.9.9" 16 | 17 | is_unknown_ruby_version "$ruby" "$version" 18 | 19 | assertEquals "did not return 0" 0 $? 20 | } 21 | 22 | function test_is_unknown_ruby_version_with_known_version() 23 | { 24 | local version="3.0.0" 25 | 26 | is_unknown_ruby_version "$ruby" "$version" 27 | 28 | assertEquals "did not return 1" 1 $? 29 | } 30 | 31 | SHUNIT_PARENT=$0 . $SHUNIT2 32 | -------------------------------------------------------------------------------- /test/ruby-versions-tests/latest_ruby_version_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-versions.sh 5 | 6 | ruby="ruby" 7 | stable_file="$ruby_install_cache_dir/$ruby/stable.txt" 8 | 9 | function oneTimeSetUp() 10 | { 11 | download_ruby_versions_file "$ruby" "stable.txt" 12 | } 13 | 14 | function test_latest_ruby_version_with_no_empty_string() 15 | { 16 | local last_version="$(tail -n 1 "$stable_file")" 17 | local output="$(latest_ruby_version "$ruby" "")" 18 | 19 | assertEquals "did not return the last version" \ 20 | "$last_version" \ 21 | "$output" 22 | } 23 | 24 | function test_latest_ruby_version_with_partial_version() 25 | { 26 | local expected_version="$(grep -E '^2\.2\.' "$stable_file")" 27 | local partial_version="2.2" 28 | local output="$(latest_ruby_version "$ruby" "$partial_version")" 29 | 30 | assertEquals "did not return the matching version" \ 31 | "$expected_version" \ 32 | "$output" 33 | } 34 | 35 | SHUNIT_PARENT=$0 . $SHUNIT2 36 | -------------------------------------------------------------------------------- /test/ruby-versions-tests/lookup_ruby_version_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-versions.sh 5 | 6 | ruby="ruby" 7 | stable_file="$ruby_install_cache_dir/$ruby/stable.txt" 8 | 9 | function oneTimeSetUp() 10 | { 11 | download_ruby_versions_file "$ruby" "stable.txt" 12 | download_ruby_versions_file "$ruby" "versions.txt" 13 | } 14 | 15 | function test_look_ruby_version_with_known_version() 16 | { 17 | local known_version="2.6.0" 18 | local output="$(lookup_ruby_version "$ruby" "$known_version")" 19 | 20 | assertEquals "did not return the same version" \ 21 | "$known_version" \ 22 | "$output" 23 | } 24 | 25 | function test_lookup_ruby_version_with_empty_string() 26 | { 27 | local last_version="$(tail -n 1 "$stable_file")" 28 | local output="$(lookup_ruby_version "$ruby" "")" 29 | 30 | assertEquals "did not return the latest version" \ 31 | "$last_version" \ 32 | "$output" 33 | } 34 | 35 | function test_lookup_ruby_version_with_partial_version() 36 | { 37 | local partial_version="2.7" 38 | local expected_version="$(grep -E '^2\.7\.' "$stable_file")" 39 | local output="$(lookup_ruby_version "$ruby" "$partial_version")" 40 | 41 | assertEquals "did not return the matching version" \ 42 | "$expected_version" \ 43 | "$output" 44 | } 45 | 46 | SHUNIT_PARENT=$0 . $SHUNIT2 47 | -------------------------------------------------------------------------------- /test/ruby-versions-tests/ruby_checksum_for_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-versions.sh 5 | 6 | ruby="ruby" 7 | ruby_archive="ruby-2.2.4.tar.bz2" 8 | 9 | function oneTimeSetUp() 10 | { 11 | download_ruby_versions_file "$ruby" "checksums.md5" 12 | download_ruby_versions_file "$ruby" "checksums.sha1" 13 | download_ruby_versions_file "$ruby" "checksums.sha256" 14 | download_ruby_versions_file "$ruby" "checksums.sha512" 15 | } 16 | 17 | function test_ruby_checksum_for_with_md5() 18 | { 19 | local expected_checksum="c3d65f6d2ebe90dda81a37885ea244f5" 20 | local output="$(ruby_checksum_for "$ruby" md5 "$ruby_archive")" 21 | 22 | assertEquals "did not return the correct checksum" \ 23 | "$expected_checksum" \ 24 | "$output" 25 | } 26 | 27 | function test_ruby_checksum_for_with_sha1() 28 | { 29 | local expected_checksum="6132840a859dbf2ac1498ba313021f299a870038" 30 | local output="$(ruby_checksum_for "$ruby" sha1 "$ruby_archive")" 31 | 32 | assertEquals "did not return the correct checksum" \ 33 | "$expected_checksum" \ 34 | "$output" 35 | } 36 | 37 | function test_ruby_checksum_for_with_sha256() 38 | { 39 | local expected_checksum="31203696adbfdda6f2874a2de31f7c5a1f3bcb6628f4d1a241de21b158cd5c76" 40 | local output="$(ruby_checksum_for "$ruby" sha256 "$ruby_archive")" 41 | 42 | assertEquals "did not return the correct checksum" \ 43 | "$expected_checksum" \ 44 | "$output" 45 | } 46 | 47 | function test_ruby_checksum_for_with_sha512() 48 | { 49 | local expected_checksum="d27ca2f19c214ce87f906b57edd41f2f8af35b2871c191470facded9cfda15ba46e5c3bc7d5540225a38da6bd65050fcc8aaa4ffbadbb6bf7dc891c1821da0df" 50 | local output="$(ruby_checksum_for "$ruby" sha512 "$ruby_archive")" 51 | 52 | assertEquals "did not return the correct checksum" \ 53 | "$expected_checksum" \ 54 | "$output" 55 | } 56 | 57 | SHUNIT_PARENT=$0 . $SHUNIT2 58 | -------------------------------------------------------------------------------- /test/ruby-versions-tests/stable_ruby_versions_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-versions.sh 5 | 6 | ruby="ruby" 7 | 8 | function oneTimeSetUp() 9 | { 10 | download_ruby_versions_file "$ruby" "stable.txt" 11 | } 12 | 13 | function test_stable_ruby_versions() 14 | { 15 | local expected_output="$(cat "$ruby_install_cache_dir/$ruby/stable.txt")" 16 | local output="$(stable_ruby_versions "$ruby")" 17 | 18 | assertEquals "did not read stable.txt" "$expected_output" "$output" 19 | } 20 | 21 | SHUNIT_PARENT=$0 . $SHUNIT2 22 | -------------------------------------------------------------------------------- /test/runner: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | function log() { 4 | if [[ -t 1 ]]; then 5 | echo -e "\x1b[1m\x1b[32m>>>\x1b[0m \x1b[1m$1\x1b[0m" 6 | else 7 | echo ">>> $1" 8 | fi 9 | } 10 | 11 | error=0 12 | for test in ${0%/*}/{,*-tests/}*_test.sh; do 13 | log "Running $test ..." 14 | $test || error=1 15 | echo 16 | done 17 | 18 | exit $error 19 | -------------------------------------------------------------------------------- /test/src/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/postmodern/ruby-install/1bc578085d6bec60c41de949bfb09bfa7348f9f2/test/src/.gitkeep -------------------------------------------------------------------------------- /test/system-tests/cpu_count_test.sh: -------------------------------------------------------------------------------- 1 | . ./test/helper.sh 2 | . ./share/ruby-install/system.sh 3 | 4 | function test_cpu_count() 5 | { 6 | assertTrue "did not return a number > 0" '(( $(cpu_count) > 0 ))' 7 | } 8 | 9 | SHUNIT_PARENT=$0 . $SHUNIT2 10 | -------------------------------------------------------------------------------- /test/system-tests/detect_downloader_test.sh: -------------------------------------------------------------------------------- 1 | . ./test/helper.sh 2 | . ./share/ruby-install/system.sh 3 | 4 | function oneTimeSetup() 5 | { 6 | detect_downloader 7 | } 8 | 9 | function test_downloader_with_wget_but_without_curl() 10 | { 11 | (command -v wget >/dev/null && ! command -v curl >/dev/null) || return 0 12 | 13 | assertEquals "did not detect wget" "wget" "$downloader" 14 | } 15 | 16 | function test_downloader_without_wget_but_with_curl() 17 | { 18 | (! command -v wget >/dev/null && command -v curl >/dev/null) || return 0 19 | 20 | assertEquals "did not detect curl" "curl" "$downloader" 21 | } 22 | 23 | SHUNIT_PARENT=$0 . $SHUNIT2 24 | -------------------------------------------------------------------------------- /test/system-tests/detect_os_test.sh: -------------------------------------------------------------------------------- 1 | . ./test/helper.sh 2 | . ./share/ruby-install/system.sh 3 | 4 | function oneTimeSetup() 5 | { 6 | detect_os 7 | } 8 | 9 | function test_os_platform() 10 | { 11 | assertNotEquals "did not set \$os_platform" "" "$os_platform" 12 | } 13 | 14 | function test_os_arch() 15 | { 16 | assertNotEquals "did not set \$os_arch" "" "$os_arch" 17 | } 18 | 19 | SHUNIT_PARENT=$0 . $SHUNIT2 20 | -------------------------------------------------------------------------------- /test/system-tests/detect_package_manager_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/system.sh 5 | 6 | function test_detect_package_manager_on_redhat_based_systems_with_dnf() 7 | { 8 | [[ -f /etc/redhat-release ]] && command -v dnf >/dev/null || return 0 9 | 10 | detect_package_manager 11 | 12 | assertEquals "did not prefer dnf over yum" "dnf" "$package_manager" 13 | } 14 | 15 | function test_detect_package_manager_on_redhat_based_systems_with_yum() 16 | { 17 | [[ -f /etc/redhat-release ]] && 18 | ! command -v dnf >/dev/null && 19 | command -v yum >/dev/null || return 0 20 | 21 | detect_package_manager 22 | 23 | assertEquals "did not fallback to yum" "yum" "$package_manager" 24 | } 25 | 26 | function test_detect_package_manager_on_debian_based_systems_with_apt() 27 | { 28 | [[ -f /etc/debian_version ]] && command -v apt >/dev/null || \ 29 | return 0 30 | 31 | detect_package_manager 32 | 33 | assertEquals "did not detect apt" "apt" "$package_manager" 34 | } 35 | 36 | function test_detect_package_manager_on_open_suse_systems_with_zypper() 37 | { 38 | [[ -f /etc/SuSE-release ]] && command -v zypper >/dev/null || return 0 39 | 40 | detect_package_manager 41 | 42 | assertEquals "did not detect zypper" "zypper" "$package_manager" 43 | } 44 | 45 | function test_detect_package_manager_on_void_systems_with_xbps() 46 | { 47 | command -v lsb_release >/dev/null && 48 | command -v xbps-install >/dev/null || return 0 49 | 50 | assertEquals "did not detect xbps-install" "xbps" "$package_manager" 51 | } 52 | 53 | function test_detect_package_manager_on_bsd_systems_with_pkg() 54 | { 55 | [[ "$os_platform" == *BSD ]] && command -v pkg >/dev/null || return 0 56 | 57 | detect_package_manager 58 | 59 | assertEquals "did not detect pkg" "pkg" "$package_manager" 60 | } 61 | 62 | function test_detect_package_manager_on_macos_systems_with_homebrew() 63 | { 64 | [[ "$os_platform" == *Darwin ]] && command -v brew >/dev/null || \ 65 | return 0 66 | 67 | detect_package_manager 68 | 69 | assertEquals "did not prefer brew over port" "brew" "$package_manager" 70 | } 71 | 72 | function test_detect_package_manager_on_macos_systems_with_macports() 73 | { 74 | [[ "$os_platform" == *Darwin ]] && 75 | ! command -v brew >/dev/null && 76 | command -v port >/dev/null || return 0 77 | 78 | detect_package_manager 79 | 80 | assertEquals "did not fallback to macports" "port" "$package_manager" 81 | } 82 | 83 | function test_detect_package_manager_when_RUBY_INSTALL_PKG_MANAGER_is_set() 84 | { 85 | RUBY_INSTALL_PKG_MANAGER="custom" 86 | 87 | detect_package_manager 88 | 89 | assertEquals "did not set package_manager to $$RUBY_INSTALL_PKG_MANAGER" \ 90 | "$RUBY_INSTALL_PKG_MANAGER" "$package_manager" 91 | 92 | 93 | unset RUBY_INSTALL_PKG_MANAGER 94 | } 95 | 96 | function tearDown() 97 | { 98 | unset package_manager 99 | } 100 | 101 | SHUNIT_PARENT=$0 . $SHUNIT2 102 | -------------------------------------------------------------------------------- /test/system-tests/detect_sudo_test.sh: -------------------------------------------------------------------------------- 1 | . ./test/helper.sh 2 | . ./share/ruby-install/system.sh 3 | 4 | function oneTimeSetUp() 5 | { 6 | detect_sudo 7 | } 8 | 9 | function test_sudo() 10 | { 11 | if (( UID == 0 )); then 12 | assertEquals "did not omit sudo" "" "$sudo" 13 | else 14 | assertEquals "did not enable sudo" "sudo" "$sudo" 15 | fi 16 | } 17 | 18 | SHUNIT_PARENT=$0 . $SHUNIT2 19 | -------------------------------------------------------------------------------- /test/system-tests/source_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/system.sh 5 | 6 | function test_os_platform() 7 | { 8 | assertNotEquals "did not set \$os_platform" "" "$os_platform" 9 | } 10 | 11 | function test_os_arch() 12 | { 13 | assertNotEquals "did not set \$os_arch" "" "$os_arch" 14 | } 15 | 16 | function test_downloader() 17 | { 18 | assertNotEquals "did not detect wget or curl" "" "$downloader" 19 | } 20 | 21 | function test_sudo() 22 | { 23 | (( UID == 0 )) && return 24 | 25 | assertEquals "did not enable sudo" "sudo" "$sudo" 26 | } 27 | 28 | SHUNIT_PARENT=$0 . $SHUNIT2 29 | -------------------------------------------------------------------------------- /test/truffleruby-graalvm-tests/dependencies_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="truffleruby-graalvm" 9 | ruby_version="23.1.2" 10 | } 11 | 12 | function test_when_package_manager_is_apt() 13 | { 14 | local original_package_manager="$package_manager" 15 | package_manager="apt" 16 | 17 | source "$ruby_install_dir/$ruby/dependencies.sh" 18 | 19 | assertEquals "did not correctly set \$ruby_dependencies" \ 20 | "${ruby_dependencies[*]}" \ 21 | "make gcc zlib1g-dev libssl-dev libxml2 libyaml-dev" 22 | 23 | package_manager="$original_package_manager" 24 | } 25 | 26 | function test_when_package_manager_is_dnf() 27 | { 28 | local original_package_manager="$package_manager" 29 | package_manager="dnf" 30 | 31 | source "$ruby_install_dir/$ruby/dependencies.sh" 32 | 33 | assertEquals "did not correctly set \$ruby_dependencies" \ 34 | "${ruby_dependencies[*]}" \ 35 | "make gcc zlib-devel openssl-devel libxml2 libyaml-devel" 36 | 37 | package_manager="$original_package_manager" 38 | } 39 | 40 | function test_when_package_manager_is_yum() 41 | { 42 | local original_package_manager="$package_manager" 43 | package_manager="yum" 44 | 45 | source "$ruby_install_dir/$ruby/dependencies.sh" 46 | 47 | assertEquals "did not correctly set \$ruby_dependencies" \ 48 | "${ruby_dependencies[*]}" \ 49 | "make gcc zlib-devel openssl-devel libxml2 libyaml-devel" 50 | 51 | package_manager="$original_package_manager" 52 | } 53 | 54 | function test_when_package_manager_is_port() 55 | { 56 | local original_package_manager="$package_manager" 57 | package_manager="port" 58 | 59 | source "$ruby_install_dir/$ruby/dependencies.sh" 60 | 61 | assertEquals "did not correctly set \$ruby_dependencies" \ 62 | "${ruby_dependencies[*]}" \ 63 | "openssl libyaml" 64 | 65 | package_manager="$original_package_manager" 66 | } 67 | 68 | function test_when_package_manager_is_brew() 69 | { 70 | local original_package_manager="$package_manager" 71 | package_manager="brew" 72 | 73 | source "$ruby_install_dir/$ruby/dependencies.sh" 74 | 75 | assertEquals "did not correctly set \$ruby_dependencies" \ 76 | "${ruby_dependencies[*]}" \ 77 | "openssl@1.1 libyaml" 78 | 79 | package_manager="$original_package_manager" 80 | } 81 | 82 | function test_when_package_manager_is_pacman() 83 | { 84 | local original_package_manager="$package_manager" 85 | package_manager="pacman" 86 | 87 | source "$ruby_install_dir/$ruby/dependencies.sh" 88 | 89 | assertEquals "did not correctly set \$ruby_dependencies" \ 90 | "${ruby_dependencies[*]}" \ 91 | "make gcc zlib openssl libxml2 libyaml" 92 | 93 | package_manager="$original_package_manager" 94 | } 95 | 96 | function test_when_package_manager_is_zypper() 97 | { 98 | local original_package_manager="$package_manager" 99 | package_manager="zypper" 100 | 101 | source "$ruby_install_dir/$ruby/dependencies.sh" 102 | 103 | assertEquals "did not correctly set \$ruby_dependencies" \ 104 | "${ruby_dependencies[*]}" \ 105 | "make gcc zlib-devel libopenssl-devel libxml2 libyaml-devel" 106 | 107 | package_manager="$original_package_manager" 108 | } 109 | 110 | function test_when_package_manager_is_pkg() 111 | { 112 | local original_package_manager="$package_manager" 113 | package_manager="pkg" 114 | 115 | source "$ruby_install_dir/$ruby/dependencies.sh" 116 | 117 | assertEquals "did not correctly set \$ruby_dependencies" \ 118 | "${ruby_dependencies[*]}" \ 119 | "gmake gcc openssl libxml2 libyaml" 120 | 121 | package_manager="$original_package_manager" 122 | } 123 | 124 | function test_when_package_manager_is_xbps() 125 | { 126 | local original_package_manager="$package_manager" 127 | package_manager="xbps" 128 | 129 | source "$ruby_install_dir/$ruby/dependencies.sh" 130 | 131 | assertEquals "did not correctly set \$ruby_dependencies" \ 132 | "${ruby_dependencies[*]}" \ 133 | "base-devel openssl-devel zlib-devel libxml2 libyaml-devel" 134 | 135 | package_manager="$original_package_manager" 136 | } 137 | 138 | function tearDown() 139 | { 140 | unset ruby ruby_version ruby_dependencies 141 | } 142 | 143 | SHUNIT_PARENT=$0 . $SHUNIT2 144 | -------------------------------------------------------------------------------- /test/truffleruby-graalvm-tests/functions_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="truffleruby-graalvm" 9 | ruby_version="23.1.0" 10 | 11 | source "$ruby_install_dir/functions.sh" 12 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 13 | } 14 | 15 | function test_graalvm_platform_when_os_platform_is_Linux() 16 | { 17 | local original_os_platform="$os_platform" 18 | os_platform="Linux" 19 | 20 | source "$ruby_install_dir/functions.sh" 21 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 22 | 23 | assertEquals "did not correctly set \$graalvm_platform" \ 24 | "linux" \ 25 | "$graalvm_platform" 26 | 27 | os_platform="$original_os_platform" 28 | } 29 | 30 | function test_graalvm_platform_when_os_platform_is_Darwin() 31 | { 32 | local original_os_platform="$os_platform" 33 | os_platform="Darwin" 34 | 35 | source "$ruby_install_dir/functions.sh" 36 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 37 | 38 | assertEquals "did not correctly set \$graalvm_platform" \ 39 | "darwin" \ 40 | "$graalvm_platform" 41 | 42 | os_platform="$original_os_platform" 43 | } 44 | 45 | function test_graalvm_arch_when_os_arch_is_x86_64() 46 | { 47 | local original_os_arch="$os_arch" 48 | os_arch="x86_64" 49 | 50 | source "$ruby_install_dir/functions.sh" 51 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 52 | 53 | assertEquals "did not correctly set \$graalvm_arch" \ 54 | "amd64" \ 55 | "$graalvm_arch" 56 | 57 | os_arch="$original_os_arch" 58 | } 59 | 60 | function test_graalvm_arch_when_os_arch_is_aarch64() 61 | { 62 | local original_os_arch="$os_arch" 63 | os_arch="aarch64" 64 | 65 | source "$ruby_install_dir/functions.sh" 66 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 67 | 68 | assertEquals "did not correctly set \$graalvm_arch" \ 69 | "aarch64" \ 70 | "$graalvm_arch" 71 | 72 | os_arch="$original_os_arch" 73 | } 74 | 75 | function test_graalvm_arch_when_os_arch_is_arm64() 76 | { 77 | local original_os_arch="$os_arch" 78 | os_arch="arm64" 79 | 80 | source "$ruby_install_dir/functions.sh" 81 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 82 | 83 | assertEquals "did not correctly set \$graalvm_arch" \ 84 | "aarch64" \ 85 | "$graalvm_arch" 86 | 87 | os_arch="$original_os_arch" 88 | } 89 | 90 | function test_truffleruby_major() 91 | { 92 | assertEquals "did not correctly set \$truffleruby_major" \ 93 | "23" \ 94 | "$truffleruby_major" 95 | } 96 | 97 | function test_truffleruby_without_major() 98 | { 99 | assertEquals "did not correctly set \$truffleruby_without_major" \ 100 | "1.0" \ 101 | "$truffleruby_without_major" 102 | } 103 | 104 | function test_truffleruby_minor() 105 | { 106 | assertEquals "did not correctly set \$truffleruby_minor" \ 107 | "1" \ 108 | "$truffleruby_minor" 109 | } 110 | 111 | function test_ruby_dir_name_when_ruby_version_is_23_0_0() 112 | { 113 | ruby_version="23.0.0" 114 | 115 | source "$ruby_install_dir/functions.sh" 116 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" >/dev/null 117 | 118 | assertEquals "did not correctly set \$ruby_dir_name" \ 119 | "graalvm-jdk-17.0.7+8.1" \ 120 | "$ruby_dir_name" 121 | } 122 | 123 | function test_ruby_dir_name_when_ruby_version_is_greater_or_equal_to_23_1_0() 124 | { 125 | ruby_version="23.1.0" 126 | 127 | source "$ruby_install_dir/functions.sh" 128 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 129 | 130 | assertEquals "did not correctly set \$ruby_dir_name" \ 131 | "truffleruby-$ruby_version-${graalvm_platform/darwin/macos}-$graalvm_arch" \ 132 | "$ruby_dir_name" 133 | } 134 | 135 | function test_ruby_dir_name_when_ruby_version_is_less_than_23_0_0() 136 | { 137 | ruby_version="22.1.0" 138 | 139 | source "$ruby_install_dir/functions.sh" 140 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 141 | 142 | assertEquals "did not correctly set \$ruby_dir_name" \ 143 | "graalvm-ce-java11-$ruby_version" \ 144 | "$ruby_dir_name" 145 | } 146 | 147 | function test_ruby_archive_default_value_when_ruby_version_is_23_0_0() 148 | { 149 | ruby_version="23.0.0" 150 | unset ruby_archive 151 | 152 | source "$ruby_install_dir/functions.sh" 153 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" >/dev/null 154 | 155 | assertEquals "did not preserve the \$ruby_archive value" \ 156 | "graalvm-jdk-17.0.7_${graalvm_platform/darwin/macos}-${graalvm_arch/amd64/x64}_bin.tar.gz" \ 157 | "$ruby_archive" 158 | } 159 | 160 | function test_ruby_archive_default_value_when_ruby_version_is_greater_or_equal_to_23_1_0() 161 | { 162 | ruby_version="23.1.0" 163 | unset ruby_archive 164 | 165 | source "$ruby_install_dir/functions.sh" 166 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 167 | 168 | assertEquals "did not preserve the \$ruby_archive value" \ 169 | "truffleruby-jvm-$ruby_version-${graalvm_platform/darwin/macos}-$graalvm_arch.tar.gz" \ 170 | "$ruby_archive" 171 | } 172 | 173 | function test_ruby_archive_default_value_when_ruby_version_is_less_than_23_0_0() 174 | { 175 | ruby_version="22.1.0" 176 | unset ruby_archive 177 | 178 | source "$ruby_install_dir/functions.sh" 179 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 180 | 181 | assertEquals "did not preserve the \$ruby_archive value" \ 182 | "graalvm-ce-java11-$graalvm_platform-$graalvm_arch-$ruby_version.tar.gz" \ 183 | "$ruby_archive" 184 | } 185 | 186 | function test_ruby_archive_when_its_already_set_and_when_ruby_version_is_23_0_0() 187 | { 188 | ruby_version="23.0.0" 189 | ruby_archive="truffleruby-graalvm-custom-1.2.3.tar.bz2" 190 | 191 | source "$ruby_install_dir/functions.sh" 192 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" >/dev/null 193 | 194 | assertEquals "did not correctly set \$ruby_archive" \ 195 | "truffleruby-graalvm-custom-1.2.3.tar.bz2" \ 196 | "$ruby_archive" 197 | } 198 | 199 | function test_ruby_archive_when_its_already_set_and_ruby_version_is_greater_or_equal_to_23_1_0() 200 | { 201 | ruby_version="23.1.0" 202 | ruby_archive="truffleruby-graalvm-custom-1.2.3.tar.bz2" 203 | 204 | source "$ruby_install_dir/functions.sh" 205 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 206 | 207 | assertEquals "did not correctly set \$ruby_archive" \ 208 | "truffleruby-graalvm-custom-1.2.3.tar.bz2" \ 209 | "$ruby_archive" 210 | } 211 | 212 | function test_ruby_archive_when_its_already_set_and_when_ruby_version_is_less_than_23_0_0() 213 | { 214 | ruby_version="22.0.0" 215 | ruby_archive="truffleruby-graalvm-custom-1.2.3.tar.bz2" 216 | 217 | source "$ruby_install_dir/functions.sh" 218 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 219 | 220 | assertEquals "did not correctly set \$ruby_archive" \ 221 | "truffleruby-graalvm-custom-1.2.3.tar.bz2" \ 222 | "$ruby_archive" 223 | } 224 | 225 | function test_ruby_mirror_default_value_when_ruby_version_is_23_0_0() 226 | { 227 | ruby_version="23.0.0" 228 | unset ruby_mirror 229 | 230 | source "$ruby_install_dir/functions.sh" 231 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" >/dev/null 232 | 233 | assertEquals "did not correctly set \$ruby_mirror" \ 234 | "https://download.oracle.com/graalvm/17/archive" \ 235 | "$ruby_mirror" 236 | } 237 | 238 | function test_ruby_mirror_default_value_when_ruby_version_is_greater_or_equal_to_23_1_0() 239 | { 240 | ruby_version="23.1.0" 241 | unset ruby_mirror 242 | 243 | source "$ruby_install_dir/functions.sh" 244 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 245 | 246 | assertEquals "did not correctly set \$ruby_mirror" \ 247 | "https://github.com/oracle/truffleruby/releases/download" \ 248 | "$ruby_mirror" 249 | } 250 | 251 | function test_ruby_mirror_default_value_when_ruby_version_is_less_than_23_0_0() 252 | { 253 | ruby_version="22.1.0" 254 | unset ruby_mirror 255 | 256 | source "$ruby_install_dir/functions.sh" 257 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 258 | 259 | assertEquals "did not correctly set \$ruby_mirror" \ 260 | "https://github.com/graalvm/graalvm-ce-builds/releases/download" \ 261 | "$ruby_mirror" 262 | } 263 | 264 | function test_ruby_mirror_when_its_already_set_and_when_ruby_version_is_greater_or_equal_to_23_1_0() 265 | { 266 | ruby_version="23.1.0" 267 | ruby_mirror="https://example.com/pub/truffleruby-graalvm" 268 | 269 | source "$ruby_install_dir/functions.sh" 270 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 271 | 272 | assertEquals "did not preserve the \$ruby_mirror value" \ 273 | "https://example.com/pub/truffleruby-graalvm" \ 274 | "$ruby_mirror" 275 | } 276 | 277 | function test_ruby_mirror_when_its_already_set_and_when_ruby_version_is_greater_or_equal_to_23_1_0() 278 | { 279 | ruby_version="22.0.0" 280 | ruby_mirror="https://example.com/pub/truffleruby-graalvm" 281 | 282 | source "$ruby_install_dir/functions.sh" 283 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 284 | 285 | assertEquals "did not preserve the \$ruby_mirror value" \ 286 | "https://example.com/pub/truffleruby-graalvm" \ 287 | "$ruby_mirror" 288 | } 289 | 290 | function test_ruby_url_default_value_when_ruby_version_is_23_0_0() 291 | { 292 | ruby_version="23.0.0" 293 | unset ruby_mirror ruby_url 294 | 295 | source "$ruby_install_dir/functions.sh" 296 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" >/dev/null 297 | 298 | assertEquals "did not correctly set \$ruby_url" \ 299 | "https://download.oracle.com/graalvm/17/archive/$ruby_archive" \ 300 | "$ruby_url" 301 | } 302 | 303 | function test_ruby_url_default_value_when_ruby_version_is_greater_or_equal_to_23_1_0() 304 | { 305 | ruby_version="23.1.0" 306 | unset ruby_mirror ruby_url 307 | 308 | source "$ruby_install_dir/functions.sh" 309 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 310 | 311 | assertEquals "did not correctly set \$ruby_url" \ 312 | "https://github.com/oracle/truffleruby/releases/download/graal-$ruby_version/$ruby_archive" \ 313 | "$ruby_url" 314 | } 315 | 316 | function test_ruby_url_default_value_when_ruby_version_is_less_than_23_0_0() 317 | { 318 | ruby_version="22.1.0" 319 | unset ruby_mirror ruby_url 320 | 321 | source "$ruby_install_dir/functions.sh" 322 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" >/dev/null 323 | 324 | assertEquals "did not correctly set \$ruby_url" \ 325 | "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-$ruby_version/$ruby_archive" \ 326 | "$ruby_url" 327 | } 328 | 329 | function test_ruby_url_when_its_already_set_and_when_ruby_version_is_23_0_0() 330 | { 331 | ruby_version="23.0.0" 332 | ruby_url="https://example.com/pub/truffleruby-graalvm/truffleruby-graalvm-1.2.3.tar.gz" 333 | 334 | source "$ruby_install_dir/functions.sh" 335 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" >/dev/null 336 | 337 | assertEquals "did not preserve the \$ruby_url value" \ 338 | "https://example.com/pub/truffleruby-graalvm/truffleruby-graalvm-1.2.3.tar.gz" \ 339 | "$ruby_url" 340 | } 341 | 342 | function test_ruby_url_when_its_already_set_and_when_ruby_version_is_greater_equal_to_23_1_0() 343 | { 344 | ruby_version="23.1.0" 345 | ruby_url="https://example.com/pub/truffleruby-graalvm/truffleruby-graalvm-1.2.3.tar.gz" 346 | 347 | source "$ruby_install_dir/functions.sh" 348 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 349 | 350 | assertEquals "did not preserve the \$ruby_url value" \ 351 | "https://example.com/pub/truffleruby-graalvm/truffleruby-graalvm-1.2.3.tar.gz" \ 352 | "$ruby_url" 353 | } 354 | 355 | function test_ruby_url_when_its_already_set_and_when_ruby_version_is_less_than_23_0_0() 356 | { 357 | ruby_version="22.0.0" 358 | ruby_url="https://example.com/pub/truffleruby-graalvm/truffleruby-graalvm-1.2.3.tar.gz" 359 | 360 | source "$ruby_install_dir/functions.sh" 361 | source "$ruby_install_dir/truffleruby-graalvm/functions.sh" 362 | 363 | assertEquals "did not preserve the \$ruby_url value" \ 364 | "https://example.com/pub/truffleruby-graalvm/truffleruby-graalvm-1.2.3.tar.gz" \ 365 | "$ruby_url" 366 | } 367 | 368 | function tearDown() 369 | { 370 | unset ruby ruby_version ruby_version_family ruby_archive ruby_dir_name \ 371 | ruby_mirror ruby_url 372 | } 373 | 374 | SHUNIT_PARENT=$0 . $SHUNIT2 375 | -------------------------------------------------------------------------------- /test/truffleruby-tests/dependencies_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="truffleruby" 9 | ruby_version="23.1.2" 10 | } 11 | 12 | function test_when_package_manager_is_apt() 13 | { 14 | local original_package_manager="$package_manager" 15 | package_manager="apt" 16 | 17 | source "$ruby_install_dir/$ruby/dependencies.sh" 18 | 19 | assertEquals "did not correctly set \$ruby_dependencies" \ 20 | "${ruby_dependencies[*]}" \ 21 | "make gcc zlib1g-dev libssl-dev libxml2 libyaml-dev" 22 | 23 | package_manager="$original_package_manager" 24 | } 25 | 26 | function test_when_package_manager_is_dnf() 27 | { 28 | local original_package_manager="$package_manager" 29 | package_manager="dnf" 30 | 31 | source "$ruby_install_dir/$ruby/dependencies.sh" 32 | 33 | assertEquals "did not correctly set \$ruby_dependencies" \ 34 | "${ruby_dependencies[*]}" \ 35 | "make gcc zlib-devel openssl-devel libxml2 libyaml-devel" 36 | 37 | package_manager="$original_package_manager" 38 | } 39 | 40 | function test_when_package_manager_is_yum() 41 | { 42 | local original_package_manager="$package_manager" 43 | package_manager="yum" 44 | 45 | source "$ruby_install_dir/$ruby/dependencies.sh" 46 | 47 | assertEquals "did not correctly set \$ruby_dependencies" \ 48 | "${ruby_dependencies[*]}" \ 49 | "make gcc zlib-devel openssl-devel libxml2 libyaml-devel" 50 | 51 | package_manager="$original_package_manager" 52 | } 53 | 54 | function test_when_package_manager_is_port() 55 | { 56 | local original_package_manager="$package_manager" 57 | package_manager="port" 58 | 59 | source "$ruby_install_dir/$ruby/dependencies.sh" 60 | 61 | assertEquals "did not correctly set \$ruby_dependencies" \ 62 | "${ruby_dependencies[*]}" \ 63 | "openssl libyaml" 64 | 65 | package_manager="$original_package_manager" 66 | } 67 | 68 | function test_when_package_manager_is_brew() 69 | { 70 | local original_package_manager="$package_manager" 71 | package_manager="brew" 72 | 73 | source "$ruby_install_dir/$ruby/dependencies.sh" 74 | 75 | assertEquals "did not correctly set \$ruby_dependencies" \ 76 | "${ruby_dependencies[*]}" \ 77 | "openssl@1.1 libyaml" 78 | 79 | package_manager="$original_package_manager" 80 | } 81 | 82 | function test_when_package_manager_is_pacman() 83 | { 84 | local original_package_manager="$package_manager" 85 | package_manager="pacman" 86 | 87 | source "$ruby_install_dir/$ruby/dependencies.sh" 88 | 89 | assertEquals "did not correctly set \$ruby_dependencies" \ 90 | "${ruby_dependencies[*]}" \ 91 | "make gcc zlib openssl libxml2 libyaml" 92 | 93 | package_manager="$original_package_manager" 94 | } 95 | 96 | function test_when_package_manager_is_zypper() 97 | { 98 | local original_package_manager="$package_manager" 99 | package_manager="zypper" 100 | 101 | source "$ruby_install_dir/$ruby/dependencies.sh" 102 | 103 | assertEquals "did not correctly set \$ruby_dependencies" \ 104 | "${ruby_dependencies[*]}" \ 105 | "make gcc zlib-devel libopenssl-devel libxml2 libyaml-devel" 106 | 107 | package_manager="$original_package_manager" 108 | } 109 | 110 | function test_when_package_manager_is_pkg() 111 | { 112 | local original_package_manager="$package_manager" 113 | package_manager="pkg" 114 | 115 | source "$ruby_install_dir/$ruby/dependencies.sh" 116 | 117 | assertEquals "did not correctly set \$ruby_dependencies" \ 118 | "${ruby_dependencies[*]}" \ 119 | "gmake gcc openssl libxml2 libyaml" 120 | 121 | package_manager="$original_package_manager" 122 | } 123 | 124 | function test_when_package_manager_is_xbps() 125 | { 126 | local original_package_manager="$package_manager" 127 | package_manager="xbps" 128 | 129 | source "$ruby_install_dir/$ruby/dependencies.sh" 130 | 131 | assertEquals "did not correctly set \$ruby_dependencies" \ 132 | "${ruby_dependencies[*]}" \ 133 | "base-devel openssl-devel zlib-devel libxml2 libyaml-devel" 134 | 135 | package_manager="$original_package_manager" 136 | } 137 | 138 | function tearDown() 139 | { 140 | unset ruby ruby_version ruby_dependencies 141 | } 142 | 143 | SHUNIT_PARENT=$0 . $SHUNIT2 144 | -------------------------------------------------------------------------------- /test/truffleruby-tests/functions_tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/ruby-install.sh 5 | 6 | function setUp() 7 | { 8 | ruby="truffleruby" 9 | ruby_version="23.1.0" 10 | 11 | source "$ruby_install_dir/functions.sh" 12 | source "$ruby_install_dir/truffleruby/functions.sh" 13 | } 14 | 15 | function test_truffleruby_platform_when_os_platform_is_Linux() 16 | { 17 | local original_os_platform="$os_platform" 18 | os_platform="Linux" 19 | 20 | source "$ruby_install_dir/functions.sh" 21 | source "$ruby_install_dir/truffleruby/functions.sh" 22 | 23 | assertEquals "did not correctly set \$truffleruby_platform" \ 24 | "linux" \ 25 | "$truffleruby_platform" 26 | 27 | os_platform="$original_os_platform" 28 | } 29 | 30 | function test_truffleruby_platform_when_os_platform_is_Darwin() 31 | { 32 | local original_os_platform="$os_platform" 33 | os_platform="Darwin" 34 | 35 | source "$ruby_install_dir/functions.sh" 36 | source "$ruby_install_dir/truffleruby/functions.sh" 37 | 38 | assertEquals "did not correctly set \$truffleruby_platform" \ 39 | "macos" \ 40 | "$truffleruby_platform" 41 | 42 | os_platform="$original_os_platform" 43 | } 44 | 45 | function test_truffleruby_arch_when_os_arch_is_x86_64() 46 | { 47 | local original_os_arch="$os_arch" 48 | os_arch="x86_64" 49 | 50 | source "$ruby_install_dir/functions.sh" 51 | source "$ruby_install_dir/truffleruby/functions.sh" 52 | 53 | assertEquals "did not correctly set \$truffleruby_arch" \ 54 | "amd64" \ 55 | "$truffleruby_arch" 56 | 57 | os_arch="$original_os_arch" 58 | } 59 | 60 | function test_truffleruby_arch_when_os_arch_is_aarch64() 61 | { 62 | local original_os_arch="$os_arch" 63 | os_arch="aarch64" 64 | 65 | source "$ruby_install_dir/functions.sh" 66 | source "$ruby_install_dir/truffleruby/functions.sh" 67 | 68 | assertEquals "did not correctly set \$truffleruby_arch" \ 69 | "aarch64" \ 70 | "$truffleruby_arch" 71 | 72 | os_arch="$original_os_arch" 73 | } 74 | 75 | function test_truffleruby_arch_when_os_arch_is_arm64() 76 | { 77 | local original_os_arch="$os_arch" 78 | os_arch="arm64" 79 | 80 | source "$ruby_install_dir/functions.sh" 81 | source "$ruby_install_dir/truffleruby/functions.sh" 82 | 83 | assertEquals "did not correctly set \$truffleruby_arch" \ 84 | "aarch64" \ 85 | "$truffleruby_arch" 86 | 87 | os_arch="$original_os_arch" 88 | } 89 | 90 | function test_truffleruby_artifact_id_when_ruby_version_is_23_0_0_and_os_platform_is_Linux_and_os_arch_is_x86_64() 91 | { 92 | local original_os_arch="$os_arch" 93 | local original_os_platform="$os_platform" 94 | os_arch="x86_64" 95 | os_platform="Linux" 96 | 97 | ruby_version="23.0.0" 98 | 99 | source "$ruby_install_dir/functions.sh" 100 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 101 | 102 | assertEquals "did not correctly set \$truffleruby_artifact_id" \ 103 | "FD4AB182EA4CEDFDE0531518000AF13E" \ 104 | "$truffleruby_artifact_id" 105 | 106 | os_arch="$original_os_arch" 107 | os_platform="$original_os_platform" 108 | } 109 | 110 | function test_truffleruby_artifact_id_when_ruby_version_is_23_0_0_and_os_platform_is_Linux_and_os_arch_is_aarch64() 111 | { 112 | local original_os_arch="$os_arch" 113 | local original_os_platform="$os_platform" 114 | os_arch="aarch64" 115 | os_platform="Linux" 116 | 117 | ruby_version="23.0.0" 118 | 119 | source "$ruby_install_dir/functions.sh" 120 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 121 | 122 | assertEquals "did not correctly set \$truffleruby_artifact_id" \ 123 | "FD40BA2367C226B6E0531518000AE71A" \ 124 | "$truffleruby_artifact_id" 125 | 126 | os_arch="$original_os_arch" 127 | os_platform="$original_os_platform" 128 | } 129 | 130 | function test_truffleruby_artifact_id_when_ruby_version_is_23_0_0_and_os_platform_is_Linux_and_os_arch_is_arm64() 131 | { 132 | local original_os_arch="$os_arch" 133 | local original_os_platform="$os_platform" 134 | os_arch="arm64" 135 | os_platform="Linux" 136 | 137 | ruby_version="23.0.0" 138 | 139 | source "$ruby_install_dir/functions.sh" 140 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 141 | 142 | assertEquals "did not correctly set \$truffleruby_artifact_id" \ 143 | "FD40BA2367C226B6E0531518000AE71A" \ 144 | "$truffleruby_artifact_id" 145 | 146 | os_arch="$original_os_arch" 147 | os_platform="$original_os_platform" 148 | } 149 | 150 | function test_truffleruby_artifact_id_when_ruby_version_is_23_0_0_and_os_platform_is_Darwin_and_os_arch_is_x86_64() 151 | { 152 | local original_os_arch="$os_arch" 153 | local original_os_platform="$os_platform" 154 | os_arch="x86_64" 155 | os_platform="Darwin" 156 | 157 | ruby_version="23.0.0" 158 | 159 | source "$ruby_install_dir/functions.sh" 160 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 161 | 162 | assertEquals "did not correctly set \$truffleruby_artifact_id" \ 163 | "FD4AB182EA51EDFDE0531518000AF13E" \ 164 | "$truffleruby_artifact_id" 165 | 166 | os_arch="$original_os_arch" 167 | os_platform="$original_os_platform" 168 | } 169 | 170 | function test_truffleruby_artifact_id_when_ruby_version_is_23_0_0_and_os_platform_is_Darwin_and_os_arch_is_aarch64() 171 | { 172 | local original_os_arch="$os_arch" 173 | local original_os_platform="$os_platform" 174 | os_arch="aarch64" 175 | os_platform="Darwin" 176 | 177 | ruby_version="23.0.0" 178 | 179 | source "$ruby_install_dir/functions.sh" 180 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 181 | 182 | assertEquals "did not correctly set \$truffleruby_artifact_id" \ 183 | "FD40BBF6750C366CE0531518000ABEAF" \ 184 | "$truffleruby_artifact_id" 185 | 186 | os_arch="$original_os_arch" 187 | os_platform="$original_os_platform" 188 | } 189 | 190 | function test_truffleruby_artifact_id_when_ruby_version_is_23_0_0_and_os_platform_is_Darwin_and_os_arch_is_arm64() 191 | { 192 | local original_os_arch="$os_arch" 193 | local original_os_platform="$os_platform" 194 | os_arch="arm64" 195 | os_platform="Darwin" 196 | 197 | ruby_version="23.0.0" 198 | 199 | source "$ruby_install_dir/functions.sh" 200 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 201 | 202 | assertEquals "did not correctly set \$truffleruby_artifact_id" \ 203 | "FD40BBF6750C366CE0531518000ABEAF" \ 204 | "$truffleruby_artifact_id" 205 | 206 | os_arch="$original_os_arch" 207 | os_platform="$original_os_platform" 208 | } 209 | 210 | function test_truffleruby_major() 211 | { 212 | assertEquals "did not correctly set \$truffleruby_major" \ 213 | "23" \ 214 | "$truffleruby_major" 215 | } 216 | 217 | function test_truffleruby_without_major() 218 | { 219 | assertEquals "did not correctly set \$truffleruby_without_major" \ 220 | "1.0" \ 221 | "$truffleruby_without_major" 222 | } 223 | 224 | function test_truffleruby_minor() 225 | { 226 | assertEquals "did not correctly set \$truffleruby_minor" \ 227 | "1" \ 228 | "$truffleruby_minor" 229 | } 230 | 231 | function test_ruby_archive_default_value() 232 | { 233 | assertEquals "did not preserve the \$ruby_archive value" \ 234 | "truffleruby-$ruby_version-$truffleruby_platform-$truffleruby_arch.tar.gz" \ 235 | "$ruby_archive" 236 | } 237 | 238 | function test_ruby_archive_when_its_already_set_and_when_ruby_version_is_23_0_0() 239 | { 240 | ruby_version="23.0.0" 241 | ruby_archive="truffleruby-custom-1.2.3.tar.bz2" 242 | 243 | source "$ruby_install_dir/functions.sh" 244 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 245 | 246 | assertEquals "did not correctly set \$ruby_archive" \ 247 | "truffleruby-custom-1.2.3.tar.bz2" \ 248 | "$ruby_archive" 249 | } 250 | 251 | function test_ruby_archive_when_its_already_set_and_when_ruby_version_is_greater_equal_to_23_1_0() 252 | { 253 | ruby_version="23.1.0" 254 | ruby_archive="truffleruby-custom-1.2.3.tar.bz2" 255 | 256 | source "$ruby_install_dir/functions.sh" 257 | source "$ruby_install_dir/truffleruby/functions.sh" 258 | 259 | assertEquals "did not correctly set \$ruby_archive" \ 260 | "truffleruby-custom-1.2.3.tar.bz2" \ 261 | "$ruby_archive" 262 | } 263 | 264 | function test_ruby_archive_when_its_already_set_and_when_ruby_version_is_less_than_23_0_0() 265 | { 266 | ruby_version="22.0.0" 267 | ruby_archive="truffleruby-custom-1.2.3.tar.bz2" 268 | 269 | source "$ruby_install_dir/functions.sh" 270 | source "$ruby_install_dir/truffleruby/functions.sh" 271 | 272 | assertEquals "did not correctly set \$ruby_archive" \ 273 | "truffleruby-custom-1.2.3.tar.bz2" \ 274 | "$ruby_archive" 275 | } 276 | 277 | function test_ruby_dir_name() 278 | { 279 | assertEquals "did not correctly set \$ruby_dir_name" \ 280 | "truffleruby-$ruby_version-$truffleruby_platform-$truffleruby_arch" \ 281 | "$ruby_dir_name" 282 | } 283 | 284 | function test_ruby_mirror_default_value_when_ruby_version_is_23_0_0() 285 | { 286 | ruby_version="23.0.0" 287 | unset ruby_mirror 288 | 289 | source "$ruby_install_dir/functions.sh" 290 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 291 | 292 | assertEquals "did not correctly set \$ruby_mirror" \ 293 | "https://gds.oracle.com/api/20220101/artifacts" \ 294 | "$ruby_mirror" 295 | } 296 | 297 | function test_ruby_mirror_default_value_when_ruby_version_is_greater_or_equal_to_23_1_0() 298 | { 299 | ruby_version="23.1.0" 300 | unset ruby_mirror 301 | 302 | source "$ruby_install_dir/functions.sh" 303 | source "$ruby_install_dir/truffleruby/functions.sh" 304 | 305 | assertEquals "did not correctly set \$ruby_mirror" \ 306 | "https://github.com/oracle/truffleruby/releases/download" \ 307 | "$ruby_mirror" 308 | } 309 | 310 | function test_ruby_mirror_default_value_when_ruby_version_is_less_than_23_0_0() 311 | { 312 | ruby_version="22.1.0" 313 | unset ruby_mirror 314 | 315 | source "$ruby_install_dir/functions.sh" 316 | source "$ruby_install_dir/truffleruby/functions.sh" 317 | 318 | assertEquals "did not correctly set \$ruby_mirror" \ 319 | "https://github.com/oracle/truffleruby/releases/download" \ 320 | "$ruby_mirror" 321 | } 322 | 323 | function test_ruby_mirror_when_its_already_set_and_when_ruby_version_is_23_0_0() 324 | { 325 | ruby_version="23.0.0" 326 | ruby_mirror="https://example.com/pub/truffleruby" 327 | 328 | source "$ruby_install_dir/functions.sh" 329 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 330 | 331 | assertEquals "did not preserve the \$ruby_mirror value" \ 332 | "https://example.com/pub/truffleruby" \ 333 | "$ruby_mirror" 334 | } 335 | 336 | function test_ruby_mirror_when_its_already_set_and_when_ruby_version_is_greater_equal_to_23_1_0() 337 | { 338 | ruby_version="23.1.0" 339 | ruby_mirror="https://example.com/pub/truffleruby" 340 | 341 | source "$ruby_install_dir/functions.sh" 342 | source "$ruby_install_dir/truffleruby/functions.sh" 343 | 344 | assertEquals "did not preserve the \$ruby_mirror value" \ 345 | "https://example.com/pub/truffleruby" \ 346 | "$ruby_mirror" 347 | } 348 | 349 | function test_ruby_mirror_when_its_already_set_and_when_ruby_version_is_less_than_23_0_0() 350 | { 351 | ruby_version="22.0.0" 352 | ruby_mirror="https://example.com/pub/truffleruby" 353 | 354 | source "$ruby_install_dir/functions.sh" 355 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 356 | 357 | assertEquals "did not preserve the \$ruby_mirror value" \ 358 | "https://example.com/pub/truffleruby" \ 359 | "$ruby_mirror" 360 | } 361 | 362 | function test_ruby_url_default_value_when_ruby_version_is_23_0_0() 363 | { 364 | ruby_version="23.0.0" 365 | unset ruby_mirror ruby_url 366 | 367 | source "$ruby_install_dir/functions.sh" 368 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 369 | 370 | assertEquals "did not correctly set \$ruby_url" \ 371 | "https://gds.oracle.com/api/20220101/artifacts/$truffleruby_artifact_id/content" \ 372 | "$ruby_url" 373 | } 374 | 375 | function test_ruby_url_default_value_when_ruby_version_is_greater_or_equal_to_23_1_0() 376 | { 377 | ruby_version="23.1.0" 378 | unset ruby_mirror ruby_url 379 | 380 | source "$ruby_install_dir/functions.sh" 381 | source "$ruby_install_dir/truffleruby/functions.sh" 382 | 383 | assertEquals "did not correctly set \$ruby_url" \ 384 | "https://github.com/oracle/truffleruby/releases/download/graal-$ruby_version/$ruby_archive" \ 385 | "$ruby_url" 386 | } 387 | 388 | function test_ruby_url_default_value_when_ruby_version_is_less_than_23_0_0() 389 | { 390 | ruby_version="22.1.0" 391 | unset ruby_mirror ruby_url 392 | 393 | source "$ruby_install_dir/functions.sh" 394 | source "$ruby_install_dir/truffleruby/functions.sh" 395 | 396 | assertEquals "did not correctly set \$ruby_url" \ 397 | "https://github.com/oracle/truffleruby/releases/download/vm-$ruby_version/$ruby_archive" \ 398 | "$ruby_url" 399 | } 400 | 401 | function test_ruby_url_when_its_already_set_and_ruby_version_is_23_0_0() 402 | { 403 | ruby_version="23.0.0" 404 | ruby_url="https://example.com/pub/truffleruby/truffleruby-1.2.3.tar.gz" 405 | 406 | source "$ruby_install_dir/functions.sh" 407 | source "$ruby_install_dir/truffleruby/functions.sh" >/dev/null 408 | 409 | assertEquals "did not preserve the \$ruby_url value" \ 410 | "https://example.com/pub/truffleruby/truffleruby-1.2.3.tar.gz" \ 411 | "$ruby_url" 412 | } 413 | 414 | function test_ruby_url_when_its_already_set_and_ruby_version_is_greater_equal_to_23_1_0() 415 | { 416 | ruby_version="23.1.0" 417 | ruby_url="https://example.com/pub/truffleruby/truffleruby-1.2.3.tar.gz" 418 | 419 | source "$ruby_install_dir/functions.sh" 420 | source "$ruby_install_dir/truffleruby/functions.sh" 421 | 422 | assertEquals "did not preserve the \$ruby_url value" \ 423 | "https://example.com/pub/truffleruby/truffleruby-1.2.3.tar.gz" \ 424 | "$ruby_url" 425 | } 426 | 427 | function test_ruby_url_when_its_already_set_and_ruby_version_is_less_than_23_0_0() 428 | { 429 | ruby_version="22.0.0" 430 | ruby_url="https://example.com/pub/truffleruby/truffleruby-1.2.3.tar.gz" 431 | 432 | source "$ruby_install_dir/functions.sh" 433 | source "$ruby_install_dir/truffleruby/functions.sh" 434 | 435 | assertEquals "did not preserve the \$ruby_url value" \ 436 | "https://example.com/pub/truffleruby/truffleruby-1.2.3.tar.gz" \ 437 | "$ruby_url" 438 | } 439 | 440 | function tearDown() 441 | { 442 | unset ruby ruby_version ruby_version_family ruby_archive ruby_dir_name \ 443 | ruby_mirror ruby_url 444 | } 445 | 446 | SHUNIT_PARENT=$0 . $SHUNIT2 447 | -------------------------------------------------------------------------------- /test/util-tests/absolute_path_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/util.sh 5 | 6 | function test_absolute_path_with_relative_path() 7 | { 8 | local path="foo/bar" 9 | local expected="${PWD}/${path}" 10 | 11 | assertEquals "did not return the correct absolute path" \ 12 | "$expected" "$(absolute_path "$path")" 13 | } 14 | 15 | function test_absolute_path_with_absolute_path() 16 | { 17 | local path="/foo/bar" 18 | 19 | assertEquals "did not return the the absolute path" \ 20 | "$path" "$(absolute_path "$path")" 21 | } 22 | 23 | SHUNIT_PARENT=$0 . $SHUNIT2 24 | -------------------------------------------------------------------------------- /test/util-tests/check_write_permissions_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/util.sh 5 | 6 | function test_check_write_permissions_with_non_existent_directory_within_a_writable_parent_directory() 7 | { 8 | local path="/tmp/foo/bar" 9 | 10 | assertTrue "did not return true" 'check_write_permissions "$path"' 11 | } 12 | 13 | function test_check_write_permissions_with_non_existent_directory_within_a_non_writable_parent_directory() 14 | { 15 | local path="/root/foo/bar" 16 | 17 | assertFalse "did not return false" 'check_write_permissions "$path"' 18 | } 19 | 20 | function test_check_write_permissions_with_an_existing_directory_that_is_writable() 21 | { 22 | local path="$PWD" 23 | 24 | assertTrue "did not return true" 'check_write_permissions "$path"' 25 | } 26 | 27 | function test_check_write_permissions_with_an_existing_directory_that_is_not_writable() 28 | { 29 | local path="/root" 30 | 31 | assertFalse "did not return true" 'check_write_permissions "$path"' 32 | } 33 | 34 | SHUNIT_PARENT=$0 . $SHUNIT2 35 | -------------------------------------------------------------------------------- /test/util-tests/download_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/util.sh 5 | 6 | test_dir="$test_fixtures_dir/download_test" 7 | test_url="https://raw.github.com/postmodern/ruby-install/master/README.md" 8 | test_dest="$test_dir/download.txt" 9 | 10 | function test_download() 11 | { 12 | download "$test_url" "$test_dest" 2>/dev/null 13 | 14 | assertFalse "did not remove the .part file" '[[ -f "$test_dest.part" ]]' 15 | assertTrue "did not download the file" '[[ -f "$test_dest" ]]' 16 | } 17 | 18 | function test_download_with_a_directory() 19 | { 20 | local dir="test/subdir" 21 | mkdir -p "$dir" 22 | 23 | download "$test_url" "$dir" 2>/dev/null 24 | 25 | assertTrue "did not download the file to the directory" \ 26 | '[[ -f "$dir/README.md" ]]' 27 | 28 | rm -r "$dir" 29 | } 30 | 31 | function test_download_using_wget() 32 | { 33 | command -v wget >/dev/null || return 0 34 | 35 | downloader="wget" download "$test_url" "$test_dest" 2>/dev/null 36 | 37 | assertTrue "did not download the file" '[[ -f "$test_dest" ]]' 38 | } 39 | 40 | function test_download_using_wget_when_stdout_is_not_a_tty() 41 | { 42 | command -v wget >/dev/null || return 0 43 | 44 | local output="$(downloader="wget" download "$test_url" "$test_dest")" 45 | 46 | assertEquals "did not silence wget output" "" "$output" 47 | } 48 | 49 | function test_download_using_curl() 50 | { 51 | command -v curl >/dev/null || return 0 52 | 53 | downloader="curl" download "$test_url" "$test_dest" 2>/dev/null 54 | 55 | assertTrue "did not download the file" '[[ -f "$test_dest" ]]' 56 | } 57 | 58 | function test_download_using_curl_when_stdout_is_not_a_tty() 59 | { 60 | command -v curl >/dev/null || return 0 61 | 62 | local output="$(downloader="curl" download "$test_url" "$test_dest")" 63 | 64 | assertEquals "did not silence curl output" "" "$output" 65 | } 66 | 67 | function tearDown() 68 | { 69 | rm -rf "$test_dir" 70 | } 71 | 72 | SHUNIT_PARENT=$0 . $SHUNIT2 73 | -------------------------------------------------------------------------------- /test/versions_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | . ./test/helper.sh 4 | . ./share/ruby-install/versions.sh 5 | 6 | test_dir="$test_fixtures_dir/versions_test" 7 | 8 | versions_file="$test_dir/versions.txt" 9 | stable_file="$test_dir/stable.txt" 10 | 11 | function oneTimeSetUp() 12 | { 13 | mkdir -p "$test_dir" 14 | 15 | local commit="08cb86b18210e58fb9f85c0b4403e0a83f64fbf3" 16 | local download_url="https://raw.githubusercontent.com/postmodern/ruby-versions/$commit" 17 | 18 | wget -q -O "$versions_file" "$download_url/ruby/versions.txt" 19 | wget -q -O "$stable_file" "$download_url/ruby/stable.txt" 20 | } 21 | 22 | function test_is_known_version() 23 | { 24 | local version="2.0.0-p576" 25 | 26 | is_known_version "$versions_file" "$version" 27 | 28 | assertEquals "did not find the version within the file" \ 29 | 0 $? 30 | } 31 | 32 | function test_is_known_version_with_invalid_file() 33 | { 34 | local version="2.0.0-p576" 35 | 36 | is_known_version "./test/foo/bar" "$version" 37 | 38 | assertEquals "did not return an error" 1 $? 39 | } 40 | 41 | function test_is_known_version_with_empty_version() 42 | { 43 | local version="" 44 | 45 | is_known_version "$versions_file" "$version" 46 | 47 | assertEquals "did not return an error" 1 $? 48 | } 49 | 50 | function test_is_known_version_with_invalid_version() 51 | { 52 | local version="1.2.3" 53 | 54 | is_known_version "$versions_file" "$version" 55 | 56 | assertEquals "did not return an error" 1 $? 57 | } 58 | 59 | function test_latest_version() 60 | { 61 | local version="2.0" 62 | local expected_version="2.0.0-p481" 63 | 64 | assertEquals "did not return the last matching version" \ 65 | "$expected_version" \ 66 | "$(latest_version "$stable_file" "$version")" 67 | } 68 | 69 | function test_latest_version_with_empty_string() 70 | { 71 | local expected_version="2.1.3" 72 | 73 | assertEquals "did not return the last version" \ 74 | "$expected_version" \ 75 | "$(latest_version "$stable_file" "")" 76 | } 77 | 78 | function test_latest_version_with_unknown_version() 79 | { 80 | local unknown_version="1.2.3" 81 | 82 | latest_version "$stable_file" "$unknown_version" 83 | 84 | assertEquals "did not return an error" 1 $? 85 | } 86 | 87 | function oneTimeTearDown() 88 | { 89 | rm -rf "$test_dir" 90 | } 91 | 92 | SHUNIT_PARENT=$0 . $SHUNIT2 93 | --------------------------------------------------------------------------------