lyp 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb8bf3168ca0cd5ed9769de74ce9511da0d657c8
4
- data.tar.gz: d8275bb1f8533d3563b773671578c04efddc691f
3
+ metadata.gz: af573692d11d242223f7cacfd3c03aafd2013e75
4
+ data.tar.gz: ebd0f0f9b0f1da5c7561df7cbea69c41db9d4665
5
5
  SHA512:
6
- metadata.gz: 991521014a20626dd4f22b8d894cd2430f5a4cc4c611e37d8600dee473b5a498ec8d5f8b3be339b622d17a471a3d058faab97ac216a489199feb016ee07b05cf
7
- data.tar.gz: b6e1cd88cc53a4f6daf4776e12005095a03a5ca07db826ff95e0b5c16d040c60a8215d847dbed7be5d29c94a82fa5640ca7e399931139ebcdd302293fd9ac24c
6
+ metadata.gz: 9e0839bada15ee142ce3b4d8d5a9f827cdedc235bc53cfa0760be0af3129963e2ce8c691bcef7bffb77b65965981cdddb9566fa5c420d7a36e452ba9b697f1f3
7
+ data.tar.gz: 3795e21469164bb52b2e10a96f2d96641ae2b28e678b50cfeccd38153d1a65506ae7ea9c1f42229d006caaad1d9d9a3d285baa5496d9c29676da6b9ce17302e6
data/README.md CHANGED
@@ -20,24 +20,41 @@ __No hassle Lilypond installation__: With lyp you can also install any version o
20
20
  - [Version specifiers](#version-specifiers)
21
21
  - [Using packages](#using-packages)
22
22
  - [Developing packages](#developing-packages)
23
+ - [Including files from within packages](#including-files-from-within-packages)
23
24
  - [Installing and switching Lilypond versions](#installing-and-switching-lilypond-versions)
24
25
  - [Contributing](#contributing)
25
26
 
26
27
  ## Installation
27
28
 
28
- **Note**: lyp is tested to work on Linux and Mac OSX. Installing and using it on Windows might be problematic.
29
+ **Note**: lyp is tested to work on Linux and Mac OSX. Installing and using it on Windows would probably be problematic.
29
30
 
30
- In order to install lyp, you need to have a relatively recent version of Ruby on your machine. You can then install lyp as a Ruby gem, and run the `install self` command:
31
+ #### Installing lyp as a Ruby gem
32
+
33
+ If you have a recent (>=1.9.3) version of Ruby on your machine, you can install lyp as a gem:
31
34
 
32
35
  ```bash
33
36
  gem install lyp
34
37
  lyp install self
35
38
  ```
36
39
 
37
- (For those without Ruby on their machines, a self-contained version of lyp will be released in the near future.)
38
-
39
40
  The `lyp install self` command is needed in order to setup the `~/.lyp` working directory and add the lyp binaries directory to your `PATH` (see below), by adding a line of code to your shell profile file.
40
41
 
42
+ #### Installing lyp without Ruby
43
+
44
+ If you don't have Ruby on your machine you can install lyp as a stand alone package using the [install script](https://raw.githubusercontent.com/noteflakes/lyp/master/bin/install_release.sh):
45
+
46
+ ```bash
47
+ curl -sSL https://git.io/getlyp | bash
48
+ ```
49
+
50
+ or with Wget:
51
+
52
+ ```bash
53
+ wget -qO- https://git.io/getlyp | bash
54
+ ```
55
+
56
+ **Note**: installing the standalone release of lyp requires a having git installed.
57
+
41
58
  ### How lyp works
42
59
 
43
60
  Lyp sets up a working directory in `~/.lyp` where it keeps its binaries, installed packages, and installed versions of lilypond. Lyp provides a wrapper script for lilypond, which does the following:
@@ -186,6 +203,29 @@ This will create a `mypack@dev` package referencing your local files, which you
186
203
  \require "mypack@dev"
187
204
  ```
188
205
 
206
+ ### Including files from within packages
207
+
208
+ In order to facilitate writing complex packages, lyp defines a few lilypond commands and scheme variables and commands that allow using relative paths when including files from within packages.
209
+
210
+ The following variables are defined:
211
+
212
+ - `lyp-input-filename` - the absolute path for the user's file being compiled
213
+ - `lyp-input-dirname` - the absolute directory path for the user's file being compiled
214
+ - `lyp-cwd` - the current working directory
215
+ - `current-package-dir` - the absolute directory path for the current package
216
+
217
+ In addition, lyp provides the `\pinclude` command for including files residing in the current package using relative paths. The `\pinclude` commands loads a given file only once:
218
+
219
+ ```lilypond
220
+ \pinclude "inc/init.ily"
221
+ ```
222
+
223
+ And a `pload` scheme function for loading scheme files using relative paths without manipulating the `%load-path`:
224
+
225
+ ```lilypond
226
+ #(if (not (defined? 'mypack:init))(pload "scm/init.scm"))
227
+ ```
228
+
189
229
  ### Publishing packages
190
230
 
191
231
  In order for your package to be available to all users, you'll need to first push your code to a publically accessible git repository (for example on github). Users will then be able to install your package by using the git URL of the public repository.
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env bash
2
+
3
+ shopt -s extglob
4
+ set -o errtrace
5
+ set -o errexit
6
+
7
+ fail() { log "\nERROR: $*\n" ; exit 1 ; }
8
+
9
+ has() {
10
+ type "$1" > /dev/null 2>&1
11
+ }
12
+
13
+ download() {
14
+ if has "curl"; then
15
+ curl -L -o $*
16
+ elif has "wget"; then
17
+ wget -O $*
18
+ else
19
+ fail "Could not find curl or wget"
20
+ fi
21
+ }
22
+
23
+ WORKDIR="/tmp/lyp-release-installer"
24
+ LYP_VERSION="0.1.3"
25
+ URL_BASE="https://github.com/noteflakes/lyp/releases/download/v$LYP_VERSION"
26
+
27
+ PLATFORM=`uname -sp`
28
+ case $PLATFORM in
29
+ "Linux x86_64")
30
+ RELEASE_FILE="lyp-$LYP_VERSION-linux-x86_64"
31
+ ;;
32
+ "Linux x86")
33
+ RELEASE_FILE="lyp-$LYP_VERSION-linux-x86"
34
+ ;;
35
+ "Darwin i386")
36
+ RELEASE_FILE="lyp-$LYP_VERSION-osx"
37
+ ;;
38
+ *)
39
+ fail "Unspported platform $PLATFORM"
40
+ esac
41
+
42
+ RELEASE_URL="$URL_BASE/$RELEASE_FILE.tar.gz"
43
+ RELEASE_PATH="$WORKDIR/$RELEASE_FILE"
44
+
45
+ rm -rf $WORKDIR
46
+ mkdir $WORKDIR
47
+ echo "Downloading $RELEASE_URL"
48
+ download "$WORKDIR/release.tar.gz" $RELEASE_URL
49
+ echo "Extracting $WORKDIR/release.tar.gz"
50
+ tar -xzf "$WORKDIR/release.tar.gz" -C $WORKDIR
51
+
52
+ $RELEASE_PATH/bin/lyp install self
53
+
54
+ rm -rf $WORKDIR
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Figure out where this script is located.
5
+ SELFDIR="`dirname \"$0\"`"
6
+ ROOTDIR="`cd \"$SELFDIR/..\" && pwd`"
7
+
8
+ # Tell Bundler where the Gemfile and gems are.
9
+ export BUNDLE_GEMFILE="$ROOTDIR/lib/vendor/Gemfile"
10
+ unset BUNDLE_IGNORE_CONFIG
11
+
12
+ # Run the actual app using the bundled Ruby interpreter, with Bundler activated.
13
+ exec "$ROOTDIR/lib/ruby/bin/ruby" -rbundler/setup -rreadline -I$ROOTDIR/lib/app/lib "$ROOTDIR/lib/app/bin/lilypond" "$@"
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Figure out where this script is located.
5
+ SELFDIR="`dirname \"$0\"`"
6
+ ROOTDIR="`cd \"$SELFDIR/..\" && pwd`"
7
+
8
+ # Tell Bundler where the Gemfile and gems are.
9
+ export BUNDLE_GEMFILE="$ROOTDIR/lib/vendor/Gemfile"
10
+ unset BUNDLE_IGNORE_CONFIG
11
+
12
+ # Run the actual app using the bundled Ruby interpreter, with Bundler activated.
13
+ exec "$ROOTDIR/lib/ruby/bin/ruby" -rbundler/setup -rreadline -I$ROOTDIR/lib/app/lib "$ROOTDIR/lib/app/bin/lyp" "$@"
data/lib/lyp/base.rb CHANGED
@@ -11,6 +11,7 @@ module Lyp
11
11
 
12
12
  LYP_DIRECTORY = File.expand_path('~/.lyp')
13
13
  LYP_BIN_DIRECTORY = File.join(LYP_DIRECTORY, 'bin')
14
+ LYP_LIB_DIRECTORY = File.join(LYP_DIRECTORY, 'lib')
14
15
  DEFAULT_PACKAGE_DIRECTORY = File.join(LYP_DIRECTORY, 'packages')
15
16
  DEFAULT_LILYPONDS_DIRECTORY = File.join(LYP_DIRECTORY, 'lilyponds')
16
17
 
@@ -1,6 +1,12 @@
1
- # A quick-n-dirty rugged swap-in
2
-
3
- puts "git_based_rugged"
1
+ # A quick-n-dirty rugged swap-in. Since the rugged gem includes a native
2
+ # extension (libgit2), and since traveling-ruby does not yet include an updated
3
+ # version of it (the latest is 0.22.0b5 and we need >=0.23.0), we make a
4
+ # compromise, and make a traveling-ruby-based standalone release without
5
+ # rugged, but using plain git in order to install packages. So, users will have
6
+ # to have git installed on their machines.
7
+ #
8
+ # So here's an absolutely minimal replacement for rugged (just for the
9
+ # functionality we need) wrapping the git command.
4
10
 
5
11
  module Rugged
6
12
  class Repository
data/lib/lyp/lilypond.rb CHANGED
@@ -154,7 +154,7 @@ module Lyp::Lilypond
154
154
  list = `which -a lilypond`
155
155
  list = list.lines.map {|f| f.chomp}.reject do |l|
156
156
  dir = File.dirname(l)
157
- (dir == Lyp::LYP_BIN_DIRECTORY) || (dir == self_bin_dir)
157
+ (dir == Gem.bindir) || (dir == Lyp::LYP_BIN_DIRECTORY) || (dir == self_bin_dir)
158
158
  end
159
159
  end
160
160
 
@@ -432,8 +432,6 @@ module Lyp::Lilypond
432
432
  raise "Error executing cmd #{cmd}: #{$_err.read}"
433
433
  end
434
434
  end
435
-
436
- # raise unless system(cmd)
437
435
  end
438
436
  end
439
437
  end
data/lib/lyp/resolver.rb CHANGED
@@ -24,8 +24,9 @@ class Lyp::Resolver
24
24
  }
25
25
  end
26
26
 
27
- DEP_RE = /\\(require|include) "([^"]+)"/.freeze
27
+ DEP_RE = /\\(require|include|pinclude) "([^"]+)"/.freeze
28
28
  INCLUDE = "include".freeze
29
+ PINCLUDE = "pinclude".freeze
29
30
  REQUIRE = "require".freeze
30
31
 
31
32
  # Each "leaf" on the dependency tree is a hash of the following structure:
@@ -64,7 +65,7 @@ class Lyp::Resolver
64
65
  tree
65
66
  end
66
67
 
67
- # Scans a lilypond file for \require and \include statements. An included
68
+ # Scans a lilypond file for \require and \(p)include statements. An included
68
69
  # file is queued for processing. For required packages, search for suitable
69
70
  # versions of the package and add them to the tree.
70
71
  #
@@ -80,7 +81,7 @@ class Lyp::Resolver
80
81
  # Parse lilypond file for \include and \require
81
82
  ly_content.scan(DEP_RE) do |type, path|
82
83
  case type
83
- when INCLUDE
84
+ when INCLUDE, PINCLUDE
84
85
  qualified_path = File.expand_path(path, dir)
85
86
  queue_file_for_processing(qualified_path, tree, leaf)
86
87
  when REQUIRE
data/lib/lyp/system.rb CHANGED
@@ -34,7 +34,7 @@ EOF
34
34
  puts "\nInstalling lyp...\n\nAdding ~/.lyp/bin to $PATH..."
35
35
  profile_fn = setup_bin_path
36
36
  puts "Setting up binary scripts..."
37
- setup_bin_scripts
37
+ setup_files
38
38
 
39
39
  if installed?(no_path_check: true)
40
40
  puts "\nTo finish installation, open a new shell or run 'source ~/#{File.basename(profile_fn)}'.\n\n"
@@ -64,31 +64,48 @@ EOF
64
64
  fn
65
65
  end
66
66
 
67
- def setup_bin_scripts
67
+ def setup_files
68
68
  bin_dir = File.expand_path(File.dirname($0))
69
69
 
70
70
  if is_gem?(bin_dir)
71
- setup_gem_bin_scripts(bin_dir)
71
+ setup_gem_files(bin_dir)
72
72
  else
73
- setup_release_bin_scripts(bin_dir)
73
+ setup_release_files(bin_dir)
74
74
  end
75
75
  end
76
76
 
77
- RELEASE_BIN_PATH = "lib/app/bin/"
77
+ RELEASE_BIN_PATH = "lib/app/bin"
78
78
 
79
79
  def is_gem?(bin_dir)
80
- bin_dir !~ /#{RELEASE_BIN_PATH}[a-z]+$/
80
+ bin_dir !~ /#{RELEASE_BIN_PATH}$/
81
81
  end
82
82
 
83
- def setup_gem_bin_scripts(bin_dir)
83
+ def setup_gem_files(bin_dir)
84
+
85
+ FileUtils.rm_rf(Lyp::LYP_BIN_DIRECTORY)
84
86
  FileUtils.mkdir_p(Lyp::LYP_BIN_DIRECTORY)
87
+
85
88
  %w{lyp lilypond}.each do |fn|
86
89
  FileUtils.ln_sf("#{bin_dir}/#{fn}", "#{Lyp::LYP_BIN_DIRECTORY}/#{fn}")
87
90
  end
88
91
  end
89
92
 
90
- def setup_release_bin_scripts(bin_dir)
91
- # to be implemented
93
+ def setup_release_files(bin_dir)
94
+ FileUtils.rm_rf(Lyp::LYP_BIN_DIRECTORY)
95
+ FileUtils.mkdir_p(Lyp::LYP_BIN_DIRECTORY)
96
+
97
+ release_dir = File.expand_path(File.join(bin_dir, '../../../'))
98
+
99
+ puts "Copying Ruby runtime & gems..."
100
+ lib_dir = File.join(release_dir, 'lib')
101
+ FileUtils.rm_rf(Lyp::LYP_LIB_DIRECTORY)
102
+ FileUtils.cp_r(lib_dir, Lyp::LYP_LIB_DIRECTORY)
103
+
104
+ puts "Copying binary scripts..."
105
+ wrapper_bin_dir = File.join(release_dir, 'bin')
106
+ %w{lyp lilypond}.each do |f|
107
+ FileUtils.cp("#{wrapper_bin_dir}/#{f}", "#{Lyp::LYP_BIN_DIRECTORY}/#{f}")
108
+ end
92
109
  end
93
110
 
94
111
  def uninstall!
@@ -7,51 +7,106 @@
7
7
  # }
8
8
  # }
9
9
 
10
- # define mapping of requested packages to actual file names
11
- # package-refs is a hash table with an entry for each package reference made
12
- # using \require, either in user files or in package files (for transitive dependencies).
10
+ require 'fileutils'
11
+
12
+ user_filename = File.expand_path(_[:user_file])
13
+ user_dirname = File.dirname(user_filename)
14
+
15
+ # The wrapper defines a few global variables:
16
+ #
17
+ # lyp-input-filename - the absolute path to the input file name
18
+ # lyp-input-dirname - the absolute path to the input file directory name
19
+ # lyp-cwd - the current working directory
20
+ # lyp-current-package-dir - the directory for the package currently being loaded
21
+ # lyp-package-refs - a hash table mapping package refs to package entry
22
+ # point absolute paths
23
+ # lyp-package-loaded - a hash table for keeping track of loaded packages
24
+ # lyp-file-included - a hash table for keeping track of include files
13
25
 
14
26
  `
15
27
  #(begin
16
- (define package-refs (make-hash-table))`
28
+ (define lyp-input-filename "{{user_filename}}")
29
+ (define lyp-input-dirname "{{user_dirname}}")
30
+ (define lyp-cwd "{{FileUtils.pwd}}")
31
+ (define lyp-current-package-dir "")
32
+ (define lyp-package-refs (make-hash-table))`
17
33
 
18
34
  _[:package_paths].each do |spec, path|
19
35
  `
20
- (hash-set! package-refs "{{spec}}" "{{path}}")`
36
+ (hash-set! lyp-package-refs "{{spec}}" "{{path}}")`
21
37
  end
22
38
 
23
39
  # package-loaded is hash table used for tracking loaded packages, so each
24
40
  # package is loaded only once.
41
+
42
+ # package-loaded is hash table used for tracking loaded packages, so each
43
+ # package is loaded only once.
44
+
25
45
  `
26
- (define package-loaded (make-hash-table))
46
+ (define lyp-package-loaded (make-hash-table))
47
+ (define lyp-file-included (make-hash-table))
27
48
  )
28
49
  `
29
50
 
30
- # define the \require command
51
+ # define the \require command for loading packages
31
52
  `
32
53
  require = #(define-void-function (parser location package)(string?)
33
54
  (let*
34
55
  (
35
- (path (hash-ref package-refs package))
36
- (loaded? (hash-ref package-loaded path))
56
+ (path (hash-ref lyp-package-refs package))
57
+ (loaded? (hash-ref lyp-package-loaded path))
37
58
  (package-dir (dirname path))
59
+ (prev-package-dir lyp-current-package-dir)
38
60
  )
39
61
  (if (and path (not loaded?)) (begin
40
62
  (if (not (file-exists? path)) (
41
63
  (ly:error "Failed to load package ~a (file not found ~a)" package path)
42
64
  ))
43
- (ly:debug "Loaded package ~a at ~a" package package-dir)
44
- (hash-set! package-loaded path #t)
65
+ (ly:debug "Loading package ~a at ~a" package package-dir)
66
+ (set! lyp-current-package-dir package-dir)
67
+ (hash-set! lyp-package-loaded path #t)
45
68
  #{ \include #path #}
69
+ (set! lyp-current-package-dir prev-package-dir)
46
70
  ))
47
71
  )
48
72
  )
49
73
  `
50
74
 
51
- # load the user's file
75
+ # define the \pinclude command for including files inside the current package
76
+
77
+ `
78
+ pinclude = #(define-void-function (parser location path)(string?)
79
+ (let*
80
+ (
81
+ (full-path (format "~a/~a" lyp-current-package-dir path))
82
+ (loaded? (hash-ref lyp-file-included full-path))
83
+ )
84
+ (if (and full-path (not loaded?)) (begin
85
+ (if (not (file-exists? full-path)) (
86
+ (ly:error "File not found ~a" full-path)
87
+ ))
88
+ (hash-set! lyp-file-included full-path #t)
89
+ #{ \include #full-path #}
90
+ ))
91
+ )
92
+ )
93
+ `
52
94
 
95
+ # define the \pload scheme function, for loading scheme files inside the current
96
+ # package
97
+ `
98
+ #(define (pload path)
99
+ (let*
100
+ (
101
+ (full-path (format "~a/~a" lyp-current-package-dir path))
102
+ )
103
+ (load full-path)
104
+ )
105
+ )
106
+ `
107
+
108
+ # load the user's file
53
109
  `
54
110
  #(ly:debug "package loader is ready")
55
- #(ly:set-option 'relative-includes #t)
56
- \include "{{File.expand_path(_[:user_file])}}"
111
+ \include "{{user_filename}}"
57
112
  `
data/lib/lyp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Lyp
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lyp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-18 00:00:00.000000000 Z
11
+ date: 2016-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -128,9 +128,11 @@ extra_rdoc_files: []
128
128
  files:
129
129
  - LICENSE
130
130
  - README.md
131
- - bin/get.sh
131
+ - bin/install_release.sh
132
132
  - bin/lilypond
133
133
  - bin/lyp
134
+ - bin/release_wrapper_lilypond.sh
135
+ - bin/release_wrapper_lyp.sh
134
136
  - lib/lyp.rb
135
137
  - lib/lyp/base.rb
136
138
  - lib/lyp/cli.rb
@@ -164,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
164
166
  version: '0'
165
167
  requirements: []
166
168
  rubyforge_project:
167
- rubygems_version: 2.4.8
169
+ rubygems_version: 2.5.1
168
170
  signing_key:
169
171
  specification_version: 4
170
172
  summary: Lyp is a package manager for lilypond
data/bin/get.sh DELETED
@@ -1,886 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- shopt -s extglob
4
- set -o errtrace
5
- set -o errexit
6
-
7
- rvm_install_initialize()
8
- {
9
- DEFAULT_SOURCES=(github.com/rvm/rvm bitbucket.org/mpapis/rvm)
10
-
11
- BASH_MIN_VERSION="3.2.25"
12
- if
13
- [[ -n "${BASH_VERSION:-}" &&
14
- "$(\printf "%b" "${BASH_VERSION:-}\n${BASH_MIN_VERSION}\n" | LC_ALL=C \sort -t"." -k1,1n -k2,2n -k3,3n | \head -n1)" != "${BASH_MIN_VERSION}"
15
- ]]
16
- then
17
- echo "BASH ${BASH_MIN_VERSION} required (you have $BASH_VERSION)"
18
- exit 1
19
- fi
20
-
21
- export HOME PS4
22
- export rvm_trace_flag rvm_debug_flag rvm_user_install_flag rvm_ignore_rvmrc rvm_prefix rvm_path
23
-
24
- PS4="+ \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
25
- }
26
-
27
- log() { printf "%b\n" "$*"; }
28
- debug(){ [[ ${rvm_debug_flag:-0} -eq 0 ]] || printf "%b\n" "Running($#): $*"; }
29
- fail() { log "\nERROR: $*\n" ; exit 1 ; }
30
-
31
- rvm_install_commands_setup()
32
- {
33
- \which which >/dev/null 2>&1 || fail "Could not find 'which' command, make sure it's available first before continuing installation."
34
- if
35
- [[ -z "${rvm_tar_command:-}" ]] && builtin command -v gtar >/dev/null
36
- then
37
- rvm_tar_command=gtar
38
- elif
39
- ${rvm_tar_command:-tar} --help 2>&1 | GREP_OPTIONS="" \grep -- --strip-components >/dev/null
40
- then
41
- rvm_tar_command="${rvm_tar_command:-tar}"
42
- else
43
- case "$(uname)" in
44
- (OpenBSD)
45
- log "Trying to install GNU version of tar, might require sudo password"
46
- if (( UID ))
47
- then sudo pkg_add -z gtar-1
48
- else pkg_add -z gtar-1
49
- fi
50
- rvm_tar_command=gtar
51
- ;;
52
- (Darwin|FreeBSD|DragonFly) # it's not possible to autodetect on OSX, the help/man does not mention all flags
53
- rvm_tar_command=tar
54
- ;;
55
- (SunOS)
56
- case "$(uname -r)" in
57
- (5.10)
58
- log "Trying to install GNU version of tar, might require sudo password"
59
- if (( UID ))
60
- then
61
- if \which sudo >/dev/null 2>&1
62
- then sudo_10=sudo
63
- elif \which /opt/csw/bin/sudo >/dev/null 2>&1
64
- then sudo_10=/opt/csw/bin/sudo
65
- else fail "sudo is required but not found. You may install sudo from OpenCSW repository (http://opencsw.org/about)"
66
- fi
67
- pkginfo -q CSWpkgutil || $sudo_10 pkgadd -a $rvm_path/config/solaris/noask -d http://get.opencsw.org/now CSWpkgutil
68
- sudo /opt/csw/bin/pkgutil -iy CSWgtar -t http://mirror.opencsw.org/opencsw/unstable
69
- else
70
- pkginfo -q CSWpkgutil || pkgadd -a $rvm_path/config/solaris/noask -d http://get.opencsw.org/now CSWpkgutil
71
- /opt/csw/bin/pkgutil -iy CSWgtar -t http://mirror.opencsw.org/opencsw/unstable
72
- fi
73
- rvm_tar_command=/opt/csw/bin/gtar
74
- ;;
75
- (*)
76
- rvm_tar_command=tar
77
- ;;
78
- esac
79
- esac
80
- builtin command -v ${rvm_tar_command:-gtar} >/dev/null ||
81
- fail "Could not find GNU compatible version of 'tar' command, make sure it's available first before continuing installation."
82
- fi
83
- if
84
- [[ " ${rvm_tar_options:-} " != *" --no-same-owner "* ]] &&
85
- $rvm_tar_command --help 2>&1 | GREP_OPTIONS="" \grep -- --no-same-owner >/dev/null
86
- then
87
- rvm_tar_options="${rvm_tar_options:-}${rvm_tar_options:+ }--no-same-owner"
88
- fi
89
- }
90
-
91
- usage()
92
- {
93
- printf "%b" "
94
-
95
- Usage
96
-
97
- rvm-installer [options] [action]
98
-
99
- Options
100
-
101
- [[--]version] <version>
102
-
103
- The version or tag to install. Valid values are:
104
-
105
- latest - The latest tagged version.
106
- latest-minor - The latest minor version of the current major version.
107
- latest-<x> - The latest minor version of version x.
108
- latest-<x>.<y> - The latest patch version of version x.y.
109
- <x>.<y>.<z> - Major version x, minor version y and patch z.
110
-
111
- [--]branch <branch>
112
-
113
- The name of the branch from which RVM is installed. This option can be used
114
- with the following formats for <branch>:
115
-
116
- <account>/
117
-
118
- If account is wayneeseguin or mpapis, installs from one of the following:
119
-
120
- https://github.com/rvm/rvm/archive/master.tar.gz
121
- https://bitbucket.org/mpapis/rvm/get/master.tar.gz
122
-
123
- Otherwise, installs from:
124
-
125
- https://github.com/<account>/rvm/archive/master.tar.gz
126
-
127
- <account>/<branch>
128
-
129
- If account is wayneeseguin or mpapis, installs from one of the following:
130
-
131
- https://github.com/rvm/rvm/archive/<branch>.tar.gz
132
- https://bitbucket.org/mpapis/rvm/get/<branch>.tar.gz
133
-
134
- Otherwise, installs from:
135
-
136
- https://github.com/<account>/rvm/archive/<branch>.tar.gz
137
-
138
- [/]<branch>
139
-
140
- Installs the branch from one of the following:
141
-
142
- https://github.com/rvm/rvm/archive/<branch>.tar.gz
143
- https://bitbucket.org/mpapis/rvm/get/<branch>.tar.gz
144
-
145
- [--]source <source>
146
-
147
- Defines the repository from which RVM is retrieved and installed in the format:
148
-
149
- <domain>/<account>/<repo>
150
-
151
- Where:
152
-
153
- <domain> - Is bitbucket.org, github.com or a github enterprise site serving
154
- an RVM repository.
155
- <account> - Is the user account in which the RVM repository resides.
156
- <repo> - Is the name of the RVM repository.
157
-
158
- Note that when using the [--]source option, one should only use the [/]branch format
159
- with the [--]branch option. Failure to do so will result in undefined behavior.
160
-
161
- --trace
162
-
163
- Provides debug logging for the installation script.
164
- Actions
165
-
166
- master - Installs RVM from the master branch at rvm/rvm on github or mpapis/rvm
167
- on bitbucket.org.
168
- stable - Installs RVM from the stable branch a rvm/rvm on github or mpapis/rvm
169
- on bitbucket.org.
170
- help - Displays this output.
171
-
172
- "
173
- }
174
-
175
- ## duplication marker 32fosjfjsznkjneuera48jae
176
- __rvm_curl_output_control()
177
- {
178
- if
179
- (( ${rvm_quiet_curl_flag:-0} == 1 ))
180
- then
181
- __flags+=( "--silent" "--show-error" )
182
- elif
183
- [[ " $*" == *" -s"* || " $*" == *" --silent"* ]]
184
- then
185
- # make sure --show-error is used with --silent
186
- [[ " $*" == *" -S"* || " $*" == *" -sS"* || " $*" == *" --show-error"* ]] ||
187
- {
188
- __flags+=( "--show-error" )
189
- }
190
- fi
191
- }
192
-
193
- ## duplication marker 32fosjfjsznkjneuera48jae
194
- # -S is automatically added to -s
195
- __rvm_curl()
196
- (
197
- __rvm_which curl >/dev/null ||
198
- {
199
- rvm_error "RVM requires 'curl'. Install 'curl' first and try again."
200
- return 200
201
- }
202
-
203
- typeset -a __flags
204
- __flags=( --fail --location --max-redirs 10 )
205
-
206
- [[ "$*" == *"--max-time"* ]] ||
207
- [[ "$*" == *"--connect-timeout"* ]] ||
208
- __flags+=( --connect-timeout 30 --retry-delay 2 --retry 3 )
209
-
210
- if [[ -n "${rvm_proxy:-}" ]]
211
- then __flags+=( --proxy "${rvm_proxy:-}" )
212
- fi
213
-
214
- __rvm_curl_output_control
215
-
216
- unset curl
217
- __rvm_debug_command \curl "${__flags[@]}" "$@" || return $?
218
- )
219
-
220
- rvm_error() { printf "ERROR: %b\n" "$*"; }
221
- __rvm_which(){ which "$@" || return $?; true; }
222
- __rvm_debug_command()
223
- {
224
- debug "Running($#): $*"
225
- "$@" || return $?
226
- true
227
- }
228
- rvm_is_a_shell_function()
229
- {
230
- [[ -t 0 && -t 1 ]] || return $?
231
- return ${rvm_is_not_a_shell_function:-0}
232
- }
233
-
234
- # Searches the tags for the highest available version matching a given pattern.
235
- # fetch_version (github.com/rvm/rvm bitbucket.org/mpapis/rvm) 1.10. -> 1.10.3
236
- # fetch_version (github.com/rvm/rvm bitbucket.org/mpapis/rvm) 1.10. -> 1.10.3
237
- # fetch_version (github.com/rvm/rvm bitbucket.org/mpapis/rvm) 1. -> 1.11.0
238
- # fetch_version (github.com/rvm/rvm bitbucket.org/mpapis/rvm) "" -> 2.0.1
239
- fetch_version()
240
- {
241
- typeset _account _domain _pattern _repo _sources _values _version
242
- _sources=(${!1})
243
- _pattern=$2
244
- for _source in "${_sources[@]}"
245
- do
246
- IFS='/' read -r _domain _account _repo <<< "${_source}"
247
- _version="$(
248
- fetch_versions ${_domain} ${_account} ${_repo} |
249
- GREP_OPTIONS="" \grep "^${_pattern:-}" | tail -n 1
250
- )"
251
- if
252
- [[ -n ${_version} ]]
253
- then
254
- echo "${_version}"
255
- return 0
256
- fi
257
- done
258
- }
259
-
260
- # Returns a sorted list of all version tags from a repository
261
- fetch_versions()
262
- {
263
- typeset _account _domain _repo _url
264
- _domain=$1
265
- _account=$2
266
- _repo=$3
267
- case ${_domain} in
268
- (bitbucket.org)
269
- _url=https://${_domain}/api/1.0/repositories/${_account}/${_repo}/branches-tags
270
- ;;
271
- (github.com)
272
- _url=https://api.${_domain}/repos/${_account}/${_repo}/tags
273
- ;;
274
-
275
- (*)
276
- _url=https://${_domain}/api/v3/repos/${_account}/${_repo}/tags
277
- ;;
278
- esac
279
- __rvm_curl -s ${_url} |
280
- \awk -v RS=',' -v FS='"' '$2=="name"{print $4}' |
281
- sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n
282
- }
283
-
284
- install_release()
285
- {
286
- typeset _source _sources _url _version _verify_pgp
287
- _sources=(${!1})
288
- _version=$2
289
- debug "Downloading RVM version ${_version}"
290
- for _source in "${_sources[@]}"
291
- do
292
- case ${_source} in
293
- (bitbucket.org*)
294
- _url="https://${_source}/get/${_version}.tar.gz"
295
- _verify_pgp="https://${_source}/downloads/${_version}.tar.gz.asc"
296
- ;;
297
- (*)
298
- _url="https://${_source}/archive/${_version}.tar.gz"
299
- _verify_pgp="https://${_source}/releases/download/${_version}/${_version}.tar.gz.asc"
300
- ;;
301
- esac
302
- get_and_unpack "${_url}" "rvm-${_version}.tgz" "$_verify_pgp" && return
303
- done
304
- return $?
305
- }
306
-
307
- install_head()
308
- {
309
- typeset _branch _source _sources _url
310
- _sources=(${!1})
311
- _branch=$2
312
- debug "Selected RVM branch ${_branch}"
313
- for _source in "${_sources[@]}"
314
- do
315
- case ${_source} in
316
- (bitbucket.org*)
317
- _url=https://${_source}/get/${_branch}.tar.gz
318
- ;;
319
- (*)
320
- _url=https://${_source}/archive/${_branch}.tar.gz
321
- ;;
322
- esac
323
- get_and_unpack "${_url}" "rvm-${_branch//\//_}.tgz" && return
324
- done
325
- return $?
326
- }
327
-
328
- # duplication marker dfkjdjngdfjngjcszncv
329
- # Drop in cd which _doesn't_ respect cdpath
330
- __rvm_cd()
331
- {
332
- typeset old_cdpath ret
333
- ret=0
334
- old_cdpath="${CDPATH}"
335
- CDPATH="."
336
- chpwd_functions="" builtin cd "$@" || ret=$?
337
- CDPATH="${old_cdpath}"
338
- return $ret
339
- }
340
-
341
- get_package()
342
- {
343
- typeset _url _file
344
- _url="$1"
345
- _file="$2"
346
- log "Downloading ${_url}"
347
- __rvm_curl -sS ${_url} -o ${rvm_archives_path}/${_file} ||
348
- {
349
- _return=$?
350
- case $_return in
351
- # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn
352
- (60)
353
- log "
354
- Could not download '${_url}', you can read more about it here:
355
- https://rvm.io/support/fixing-broken-ssl-certificates/
356
- To continue in insecure mode run 'echo insecure >> ~/.curlrc'.
357
- "
358
- ;;
359
- # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn
360
- (77)
361
- log "
362
- It looks like you have old certificates, you can read more about it here:
363
- https://rvm.io/support/fixing-broken-ssl-certificates/
364
- "
365
- ;;
366
- # duplication marker lfdgzkngdkjvnfjknkjvcnbjkncvjxbn
367
- (141)
368
- log "
369
- Curl returned 141 - it is result of a segfault which means it's Curls fault.
370
- Try again and if it crashes more than a couple of times you either need to
371
- reinstall Curl or consult with your distribution manual and contact support.
372
- "
373
- ;;
374
- (*)
375
- log "
376
- Could not download '${_url}'.
377
- curl returned status '$_return'.
378
- "
379
- ;;
380
- esac
381
- return $_return
382
- }
383
- }
384
-
385
- # duplication marker flnglfdjkngjndkfjhsbdjgfghdsgfklgg
386
- rvm_install_gpg_setup()
387
- {
388
- export rvm_gpg_command
389
- {
390
- rvm_gpg_command="$( \which gpg2 2>/dev/null )" &&
391
- [[ ${rvm_gpg_command} != "/cygdrive/"* ]]
392
- } ||
393
- rvm_gpg_command="$( \which gpg 2>/dev/null )" ||
394
- rvm_gpg_command=""
395
- debug "Detected GPG program: '$rvm_gpg_command'"
396
- [[ -n "$rvm_gpg_command" ]] || return $?
397
- }
398
-
399
- # duplication marker rdjgndfnghdfnhgfdhbghdbfhgbfdhbn
400
- verify_package_pgp()
401
- {
402
- if
403
- "${rvm_gpg_command}" --verify "$2" "$1"
404
- then
405
- log "GPG verified '$1'"
406
- else
407
- typeset _ret=$?
408
- log "\
409
- Warning, RVM 1.26.0 introduces signed releases and \
410
- automated check of signatures when GPG software found.
411
- Assuming you trust Michal Papis import the mpapis public \
412
- key (downloading the signatures).
413
-
414
- GPG signature verification failed for '$1' - '$3'!
415
- try downloading the signatures:
416
-
417
- ${SUDO_USER:+sudo }${rvm_gpg_command##*/} --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
418
-
419
- or if it fails:
420
-
421
- command curl -sSL https://rvm.io/mpapis.asc | ${SUDO_USER:+sudo }${rvm_gpg_command##*/} --import -
422
-
423
- the key can be compared with:
424
-
425
- https://rvm.io/mpapis.asc
426
- https://keybase.io/mpapis
427
- "
428
- exit $_ret
429
- fi
430
- }
431
-
432
- verify_pgp()
433
- {
434
- [[ -n "${1:-}" ]] ||
435
- {
436
- debug "No PGP url given, skipping."
437
- return 0
438
- }
439
-
440
- get_package "$1" "$2.asc" ||
441
- {
442
- debug "PGP url given but does not exist: '$1'"
443
- return 0
444
- }
445
-
446
- rvm_install_gpg_setup ||
447
- {
448
- log "Found PGP signature at: '$1',
449
- but no GPG software exists to validate it, skipping."
450
- return 0
451
- }
452
-
453
- verify_package_pgp "${rvm_archives_path}/$2" "${rvm_archives_path}/$2.asc" "$1"
454
- }
455
-
456
- get_and_unpack()
457
- {
458
- typeset _url _file _patern _return _verify_pgp
459
- _url="$1"
460
- _file="$2"
461
- _verify_pgp="$3"
462
-
463
- get_package "$_url" "$_file" || return $?
464
- verify_pgp "$_verify_pgp" "$_file" || return $?
465
-
466
- [[ -d "${rvm_src_path}/rvm" ]] || \mkdir -p "${rvm_src_path}/rvm"
467
- __rvm_cd "${rvm_src_path}/rvm" ||
468
- {
469
- _return=$?
470
- log "Could not change directory '${rvm_src_path}/rvm'."
471
- return $_return
472
- }
473
-
474
- rm -rf ${rvm_src_path}/rvm/*
475
- __rvm_debug_command $rvm_tar_command xzf ${rvm_archives_path}/${_file} ${rvm_tar_options:-} --strip-components 1 ||
476
- {
477
- _return=$?
478
- log "Could not extract RVM sources."
479
- return $_return
480
- }
481
- }
482
-
483
- rvm_install_default_settings()
484
- {
485
- # Tracing, if asked for.
486
- if
487
- [[ "$*" == *--trace* ]] || (( ${rvm_trace_flag:-0} > 0 ))
488
- then
489
- set -o xtrace
490
- rvm_trace_flag=1
491
- fi
492
-
493
- # Variable initialization, remove trailing slashes if they exist on HOME
494
- true \
495
- ${rvm_trace_flag:=0} ${rvm_debug_flag:=0}\
496
- ${rvm_ignore_rvmrc:=0} HOME="${HOME%%+(\/)}"
497
-
498
- if
499
- (( rvm_ignore_rvmrc == 0 ))
500
- then
501
- for rvmrc in /etc/rvmrc "$HOME/.rvmrc"
502
- do
503
- if
504
- [[ -s "$rvmrc" ]]
505
- then
506
- if
507
- GREP_OPTIONS="" \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1
508
- then
509
- printf "%b" "
510
- Error: $rvmrc is for rvm settings only.
511
- rvm CLI may NOT be called from within $rvmrc.
512
- Skipping the loading of $rvmrc
513
- "
514
- exit 1
515
- else
516
- source "$rvmrc"
517
- fi
518
- fi
519
- done
520
- fi
521
-
522
- if
523
- [[ -z "${rvm_path:-}" ]]
524
- then
525
- if
526
- (( UID == 0 ))
527
- then
528
- rvm_user_install_flag=0
529
- rvm_prefix="/usr/local"
530
- rvm_path="${rvm_prefix}/rvm"
531
- else
532
- rvm_user_install_flag=1
533
- rvm_prefix="$HOME"
534
- rvm_path="${rvm_prefix}/.rvm"
535
- fi
536
- fi
537
- if [[ -z "${rvm_prefix}" ]]
538
- then rvm_prefix=$( dirname $rvm_path )
539
- fi
540
-
541
- # duplication marker kkdfkgnjfndgjkndfjkgnkfjdgn
542
- [[ -n "${rvm_user_install_flag:-}" ]] ||
543
- case "$rvm_path" in
544
- (/usr/local/rvm) rvm_user_install_flag=0 ;;
545
- ($HOME/*|/${USER// /_}*) rvm_user_install_flag=1 ;;
546
- (*) rvm_user_install_flag=0 ;;
547
- esac
548
- }
549
-
550
- rvm_install_parse_params()
551
- {
552
- install_rubies=()
553
- install_gems=()
554
- flags=( ./scripts/install )
555
- forwarded_flags=()
556
- while
557
- (( $# > 0 ))
558
- do
559
- token="$1"
560
- shift
561
- case "$token" in
562
-
563
- (--trace)
564
- set -o xtrace
565
- rvm_trace_flag=1
566
- flags=( -x "${flags[@]}" "$token" )
567
- forwarded_flags+=( "$token" )
568
- ;;
569
-
570
- (--debug|--quiet-curl)
571
- flags+=( "$token" )
572
- forwarded_flags+=( "$token" )
573
- token=${token#--}
574
- token=${token//-/_}
575
- export "rvm_${token}_flag"=1
576
- printf "%b" "Turning on ${token/_/ } mode.\n"
577
- ;;
578
-
579
- (--path)
580
- if [[ -n "${1:-}" ]]
581
- then
582
- rvm_path="$1"
583
- shift
584
- else
585
- fail "--path must be followed by a path."
586
- fi
587
- ;;
588
-
589
- (--branch|branch) # Install RVM from a given branch
590
- if [[ -n "${1:-}" ]]
591
- then
592
- case "$1" in
593
- (/*)
594
- branch=${1#/}
595
- ;;
596
- (*/)
597
- branch=master
598
- if [[ "${1%/}" -ne wayneeseguin ]] && [[ "${1%/}" -ne mpapis ]]
599
- then sources=(github.com/${1%/}/rvm)
600
- fi
601
- ;;
602
- (*/*)
603
- branch=${1#*/}
604
- if [[ "${1%%/*}" -ne wayneeseguin ]] && [[ "${1%%/*}" -ne mpapis ]]
605
- then sources=(github.com/${1%%/*}/rvm)
606
- fi
607
- ;;
608
- (*)
609
- branch="$1"
610
- ;;
611
- esac
612
- shift
613
- else
614
- fail "--branch must be followed by a branchname."
615
- fi
616
- ;;
617
-
618
- (--source|source)
619
- if [[ -n "${1:-}" ]]
620
- then
621
- if [[ "$1" = */*/* ]]
622
- then
623
- sources=($1)
624
- shift
625
- else
626
- fail "--source must be in the format <domain>/<account>/<repo>."
627
- fi
628
- else
629
- fail "--source must be followed by a source."
630
- fi
631
- ;;
632
-
633
- (--user-install|--ignore-dotfiles)
634
- token=${token#--}
635
- token=${token//-/_}
636
- export "rvm_${token}_flag"=1
637
- printf "%b" "Turning on ${token/_/ } mode.\n"
638
- ;;
639
-
640
- (--auto-dotfiles)
641
- flags+=( "$token" )
642
- export "rvm_auto_dotfiles_flag"=1
643
- printf "%b" "Turning on auto dotfiles mode.\n"
644
- ;;
645
-
646
- (--auto)
647
- export "rvm_auto_dotfiles_flag"=1
648
- printf "%b" "Warning, --auto is deprecated in favor of --auto-dotfiles.\n"
649
- ;;
650
-
651
- (--verify-downloads)
652
- if [[ -n "${1:-}" ]]
653
- then
654
- export rvm_verify_downloads_flag="$1"
655
- forwarded_flags+=( "$token" "$1" )
656
- shift
657
- else
658
- fail "--verify-downloads must be followed by level(0|1|2)."
659
- fi
660
- ;;
661
-
662
- (--autolibs=*)
663
- flags+=( "$token" )
664
- export rvm_autolibs_flag="${token#--autolibs=}"
665
- forwarded_flags+=( "$token" )
666
- ;;
667
-
668
- (--without-gems=*|--with-gems=*|--with-default-gems=*)
669
- flags+=( "$token" )
670
- value="${token#*=}"
671
- token="${token%%=*}"
672
- token="${token#--}"
673
- token="${token//-/_}"
674
- export "rvm_${token}"="${value}"
675
- printf "%b" "Installing RVM ${token/_/ }: ${value}.\n"
676
- ;;
677
-
678
- (--version|version)
679
- version="$1"
680
- shift
681
- ;;
682
-
683
- (head|master)
684
- version="head"
685
- branch="master"
686
- ;;
687
-
688
- (stable)
689
- version="latest"
690
- ;;
691
-
692
- (latest|latest-*|+([[:digit:]]).+([[:digit:]]).+([[:digit:]]))
693
- version="$token"
694
- ;;
695
-
696
- (--ruby)
697
- install_rubies+=( ruby )
698
- ;;
699
-
700
- (--ruby=*)
701
- token=${token#--ruby=}
702
- install_rubies+=( ${token//,/ } )
703
- ;;
704
-
705
- (--rails)
706
- install_gems+=( rails )
707
- ;;
708
-
709
- (--gems=*)
710
- token=${token#--gems=}
711
- install_gems+=( ${token//,/ } )
712
- ;;
713
-
714
- (--add-to-rvm-group)
715
- export rvm_add_users_to_rvm_group="$1"
716
- shift
717
- ;;
718
-
719
- (help|usage)
720
- usage
721
- exit 0
722
- ;;
723
-
724
- (*)
725
- usage
726
- exit 1
727
- ;;
728
-
729
- esac
730
- done
731
-
732
- if (( ${#install_gems[@]} > 0 && ${#install_rubies[@]} == 0 ))
733
- then install_rubies=( ruby )
734
- fi
735
-
736
- true "${version:=head}"
737
- true "${branch:=master}"
738
-
739
- if [[ -z "${sources[@]}" ]]
740
- then sources=("${DEFAULT_SOURCES[@]}")
741
- fi
742
-
743
- rvm_src_path="$rvm_path/src"
744
- rvm_archives_path="$rvm_path/archives"
745
- rvm_releases_url="https://rvm.io/releases"
746
- }
747
-
748
- rvm_install_validate_rvm_path()
749
- {
750
- case "$rvm_path" in
751
- (*[[:space:]]*)
752
- printf "%b" "
753
- It looks you are one of the happy *space* users(in home dir name),
754
- RVM is not yet fully ready for it, use this trick to fix it:
755
-
756
- sudo mkdir -p /${USER// /_}.rvm
757
- sudo chown -R \"$USER:\" /${USER// /_}.rvm
758
- echo \"export rvm_path=/${USER// /_}.rvm\" >> \"$HOME/.rvmrc\"
759
-
760
- and start installing again.
761
-
762
- "
763
- exit 2
764
- ;;
765
- (/usr/share/ruby-rvm)
766
- printf "%b" "
767
- It looks you are one of the happy Ubuntu users,
768
- RVM packaged by Ubuntu is old and broken,
769
- follow this link for details how to fix:
770
-
771
- http://stackoverflow.com/a/9056395/497756
772
-
773
- "
774
- [[ "${rvm_uses_broken_ubuntu_path:-no}" == "yes" ]] || exit 3
775
- ;;
776
- esac
777
-
778
- if [[ "$rvm_path" != "/"* ]]
779
- then fail "The rvm install path must be fully qualified. Tried $rvm_path"
780
- fi
781
- }
782
-
783
- rvm_install_select_and_get_version()
784
- {
785
- typeset _version_release
786
-
787
- for dir in "$rvm_src_path" "$rvm_archives_path"
788
- do
789
- [[ -d "$dir" ]] || mkdir -p "$dir"
790
- done
791
-
792
- _version_release="${version}"
793
- case "${version}" in
794
- (head)
795
- _version_release="${branch}"
796
- install_head sources[@] ${branch:-master} || exit $?
797
- ;;
798
-
799
- (latest)
800
- install_release sources[@] $(fetch_version sources[@]) || exit $?
801
- ;;
802
-
803
- (latest-minor)
804
- version="$(\cat "$rvm_path/VERSION")"
805
- install_release sources[@] $(fetch_version sources[@] ${version%.*}) || exit $?
806
- ;;
807
-
808
- (latest-*)
809
- install_release sources[@] $(fetch_version sources[@] ${version#latest-}) || exit $?
810
- ;;
811
-
812
- (+([[:digit:]]).+([[:digit:]]).+([[:digit:]])) # x.y.z
813
- install_release sources[@] ${version} || exit $?
814
- ;;
815
-
816
- (*)
817
- fail "Something went wrong, unrecognized version '$version'"
818
- ;;
819
- esac
820
- echo "${_version_release}" > "$rvm_path/RELEASE"
821
- }
822
-
823
- rvm_install_main()
824
- {
825
- [[ -f ./scripts/install ]] ||
826
- {
827
- log "'./scripts/install' can not be found for installation, something went wrong, it usally means your 'tar' is broken, please report it here: https://github.com/rvm/rvm/issues"
828
- return 127
829
- }
830
-
831
- # required flag - path to install
832
- flags+=( --path "$rvm_path" )
833
- \command bash "${flags[@]}"
834
- }
835
-
836
- rvm_install_ruby_and_gems()
837
- (
838
- if
839
- (( ${#install_rubies[@]} > 0 ))
840
- then
841
- source ${rvm_scripts_path:-${rvm_path}/scripts}/rvm
842
- source ${rvm_scripts_path:-${rvm_path}/scripts}/version
843
- __rvm_version
844
-
845
- for _ruby in ${install_rubies[@]}
846
- do command rvm "${forwarded_flags[@]}" install ${_ruby} -j 2
847
- done
848
- # set the first one as default, skip rest
849
- for _ruby in ${install_rubies[@]}
850
- do
851
- rvm "${forwarded_flags[@]}" alias create default ${_ruby}
852
- break
853
- done
854
-
855
- for _gem in ${install_gems[@]}
856
- do rvm "${forwarded_flags[@]}" all do gem install ${_gem}
857
- done
858
-
859
- printf "%b" "
860
- * To start using RVM you need to run \`source $rvm_path/scripts/rvm\`
861
- in all your open shell windows, in rare cases you need to reopen all shell windows.
862
- "
863
-
864
- if
865
- [[ "${install_gems[*]}" == *"rails"* ]]
866
- then
867
- printf "%b" "
868
- * To start using rails you need to run \`rails new <project_dir>\`.
869
- "
870
- fi
871
- fi
872
- )
873
-
874
- rvm_install()
875
- {
876
- rvm_install_initialize
877
- rvm_install_commands_setup
878
- rvm_install_default_settings
879
- rvm_install_parse_params "$@"
880
- rvm_install_validate_rvm_path
881
- rvm_install_select_and_get_version
882
- rvm_install_main
883
- rvm_install_ruby_and_gems
884
- }
885
-
886
- rvm_install "$@"