lyp 0.0.5 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8b10bc684d3755cd63fde5175e4769e7ee8d1ae
4
- data.tar.gz: dc4c7568047ba01915131cba0125e717f6c9f107
3
+ metadata.gz: eb8bf3168ca0cd5ed9769de74ce9511da0d657c8
4
+ data.tar.gz: d8275bb1f8533d3563b773671578c04efddc691f
5
5
  SHA512:
6
- metadata.gz: 1f3845fec6418ec6221659d9f04a8e5d6919fd77fe714ee0d91a02f3664cc66ffc1c3e1189c1d8f903ad96bbeffce7e28e361c7ca098d780e76c2afbb80b80ca
7
- data.tar.gz: 97ecbadebd13b96c51861c160c62b7e14f2546882d2cad65d9578c9488f2bed997abfb7678b8b43f8c04ee6bf5a4ddbb5f37b03b1c18a07d3947b1c8c8e72e91
6
+ metadata.gz: 991521014a20626dd4f22b8d894cd2430f5a4cc4c611e37d8600dee473b5a498ec8d5f8b3be339b622d17a471a3d058faab97ac216a489199feb016ee07b05cf
7
+ data.tar.gz: b6e1cd88cc53a4f6daf4776e12005095a03a5ca07db826ff95e0b5c16d040c60a8215d847dbed7be5d29c94a82fa5640ca7e399931139ebcdd302293fd9ac24c
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Sharon Rosner
3
+ Copyright (c) 2015-2016 Sharon Rosner
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -2,66 +2,197 @@
2
2
 
3
3
  # lyp - a package manager for lilypond
4
4
 
5
- lyp is a tool to install and manage packages for lilypond, and install versions of lilypond.
5
+ Use lyp to install and manage packages for lilypond, and install and manage multiple versions of lilypond on your machine.
6
6
 
7
- lyp lets you install lilypond packages that act as code libraries and can be used to enhance your lilypond files with additional functionality. Packages can depend on other packages. Lyp resolves the direct and transitive package dependencies, and selects the correct version to use for each package.
7
+ __Code reuse__: lyp lets you install packages that act as lilypond code libraries and can be used to enhance your lilypond files with additional functionality. Packages can depend on other packages. Lyp resolves both direct and transitive package dependencies, and automatically selects the correct version to use for each package.
8
8
 
9
- With lyp you can also install any version of lilypond on your machine with a single command, without having to visit the lilypond website, clicking a link and then copying files around. In addition, lyp lets you install multiple versions of lilypond and easily switch between them.
9
+ __No hassle Lilypond installation__: With lyp you can also install any version of lilypond on your machine with a single command, without having to visit the lilypond website, clicking a link and then copying files around. In addition, lyp lets you switch between multiple versions of lilypond and always keep your machine up to date with the latest version.
10
10
 
11
- ## What is a lilypond package?
11
+ ## Table of contents
12
+
13
+ - [Installation](#installation)
14
+ - [How lyp works](#how-lyp-works)
15
+ - [Uninstalling](#uninstalling)
16
+ - [Lilypond packages](#lilypond-packages)
17
+ - [What constitutes a package?](#what-constitutes-a-package)
18
+ - [Installing packages](#installing-packages)
19
+ - [Package references](#package-references)
20
+ - [Version specifiers](#version-specifiers)
21
+ - [Using packages](#using-packages)
22
+ - [Developing packages](#developing-packages)
23
+ - [Installing and switching Lilypond versions](#installing-and-switching-lilypond-versions)
24
+ - [Contributing](#contributing)
25
+
26
+ ## Installation
27
+
28
+ **Note**: lyp is tested to work on Linux and Mac OSX. Installing and using it on Windows might be problematic.
29
+
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
+
32
+ ```bash
33
+ gem install lyp
34
+ lyp install self
35
+ ```
36
+
37
+ (For those without Ruby on their machines, a self-contained version of lyp will be released in the near future.)
38
+
39
+ 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
+ ### How lyp works
42
+
43
+ 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:
44
+
45
+ - Select the correct version of lilypond to use (see below).
46
+ - Scan the given lilypond file for any dependencies (specified using `\require`), and also recursively scan any include files for dependencies
47
+ - Resolve the dependency tree and calculate the correct versions to use for each required package.
48
+ - Create a wrapper lilypond file that loads the packages.
49
+ - Invoke the selected version of lilypond.
50
+
51
+ ### Uninstalling
52
+
53
+ In order to remove lyp from your system use the `uninstall self` command:
54
+
55
+ ```bash
56
+ lyp uninstall self
57
+ ```
58
+
59
+ This command will undo the changes made to your shell profile file, and remove any binaries from `~/.lyp/bin`.
60
+
61
+ In order to completely remove all files in `~/.lyp` you can simply delete the directory:
62
+
63
+ ```bash
64
+ rm -rf ~/.lyp
65
+ ```
66
+
67
+ ## Lilypond packages
12
68
 
13
69
  A package is a library of lilypond code, containing one or more lilypond files, that provide commonly-used functionality for users. A package can be a library of scheme code to extend lilypond, as in openlilylib; or a stylesheet which contains music fonts and additional lilypond code to change the look of the music: font, spacing, line widths, sizes, etc.
14
70
 
15
71
  The difference between merely copying and including a lilypond file in your music, and using a lilypond package is that you can easily share your music file with anyone and let them compile your music without having to download and copy additional code. lyp takes care of installing and resolving any dependencies in your lilypond files, so that you can compile your lilypond files anywhere without schlepping around a bunch of include files. Also, because packages are versioned, repeatable compilation using external code becomes trivial.
16
72
 
17
- ## How to add a package to your lilypond file?
73
+ ### What constitutes a package?
18
74
 
19
- Lilypond packages are simply git repositories. As such they can be identified by the repository's URL, or by the github repository path. To add a package dependency to your code, use the <code>\require</code> command:
75
+ In lyp, a package should contain at least a single lilypond file named `package.ly` in its root directory. A package could contain additional lilypond files referenced in the main package file (using relative includes). A package could also depend on other packages by using the `\require` command (see below).
20
76
 
21
- ```lilypond
22
- \require "lypco/lilyjazz" % repository is at: github.com/lypco/lilyjazz
23
- \require "github.com/lypco/poormans_henle"
77
+ Lilypond packages are expected to be published as git repositories. The packages is then versioned using git tags. A package can be referenced either using its git URL, a short name (if it's registered in the [lyp package index](https://github.com/noteflakes/lyp-index)), or alternatively as a local path (which is meant for package development more than anything else).
78
+
79
+ ### Installing packages
80
+
81
+ In order to install a package, use the `lyp install` command:
82
+
83
+ ```bash
84
+ lyp install dummy # install latest version of package dummy
85
+ lyp install github.com/ciconia/mypack@0.2.0 # install version 0.2.0
86
+ lyp install mypack>=0.1.0 # install version 0.1.0 or higher
87
+ lyp install mypack@dev:~/repo/mypack # install from local opath
24
88
  ```
25
89
 
26
- Versions can be specified either as specific versions, or as version specifiers which denote a range of versions:
90
+ To uninstall the package, use the `lyp uninstall` command:
27
91
 
28
- ```lilypond
29
- \require "lypco/lilyjazz@0.3.2"
92
+ ```bash
93
+ lyp uninstall dummy@0.1.0 # uninstall version 0.1.0
94
+ lyp uninstall -a dummy # uninstall all versions of dummy
95
+ ```
30
96
 
31
- % highest version higher than 0.3.2
32
- \require "lypco/lilyjazz@>=0.3.2"
97
+ To list currently installed packages use `lyp list` command:
33
98
 
34
- % highest version higher than 0.4.5 but lower than 0.5.0
35
- \require "lypco/lilyjazz@~>0.4.5"
99
+ ```bash
100
+ lyp list # list all installed packages
101
+ lyp list font # list all installed packages matching the pattern 'font'
36
102
  ```
37
103
 
38
- Once the dependencies are specified, packages can be installed either using the <install> command:
39
-
104
+ To list packages available on the lyp package index use the `lyp search` command:
105
+
106
+ ```bash
107
+ lyp search # list all packages in index
108
+ lyp search stylesheet # list available packages matching pattern 'stylesheet'
109
+ ```
110
+
111
+ ### Package references
112
+
113
+ A package is normally referenced by its git URL. Lyp lets you provide either fully- or partially qualified URLs. A package hosted on github can be also referenced by the user/repository pair. The following are all equivalent:
114
+
40
115
  ```bash
41
- lyp install "lypco/lilyjazz@0.3.2" % OR:
42
- lyp install "lypco/lilyjazz@>=0.3.2"
116
+ lyp install https://github.com/noteflakes/lyp-package-template.git
117
+ lyp install https://github.com/noteflakes/lyp-package-template
118
+ lyp install github.com/noteflakes/lyp-package-template
119
+ lyp install noteflakes/lyp-package-template
43
120
  ```
44
121
 
45
- ... or the <code>resolve</code> command, which scans the user's file for dependencies and then installs them:
122
+ In addition, lyp also provides an [index of publically available package](https://github.com/noteflakes/lyp-index), which maps a package name to its URL (see also below). Using the index, packages are referenced by their published name instead of by their git URL:
46
123
 
47
124
  ```bash
48
- lyp resolve maitre_sans_marteau.ly
125
+ lyp install dummy
49
126
  ```
50
127
 
51
- ## Installation
128
+ To get a list of all available packages on the index, use the `lyp search` command.
52
129
 
53
- If you have Ruby on your machine, you can simply install the lyp gem, and run the install self command:
130
+ ### Version specifiers
131
+
132
+ When installing packages defining package dependencies, it is advisable to specify the desired version to use. Using definitive versions lets you ensure that your third-party dependencies do not change unexpectedly and do not break your code.
133
+
134
+ Versions can either be specified as specific version numbers, as version constraints or as descriptive names.
135
+
136
+ Versions are specified using the ampersand character:
137
+
138
+ ```
139
+ package@0.1.0
140
+ package@stable
141
+ ```
142
+
143
+ Version constraints specify a range of versions to use. Lyp currently supports two types of constraints:
144
+
145
+ - Optimistic constraint: `package>=0.1.0`, which means any version equal to or higher than 0.1.0.
146
+ - Pessimistic constraint: `package~>0.1.0`, which means any version equal or higher than 0.1.0, and lower than 0.2.0. This type of constraint is useful for packages which follow the semantic versioning standard.
147
+
148
+ Version specifiers could be used when installing, listing and requiring packages, and also for specifying versions of lilypond (see below). For example:
54
149
 
55
150
  ```bash
56
- gem install lyp
57
- lyp install self
151
+ lyp install "dummy~>0.2.0"
58
152
  ```
59
153
 
60
- ## Installing packages with lyp
154
+ (__Note__: that when using version constraints you should put the package specifier in quotes)
61
155
 
156
+ ### Using packages
62
157
 
158
+ To include a package in your lilypond code, use ther `\require` command:
159
+
160
+ ```lilypond
161
+ \require "dummy"
162
+ \require "github.com/lulu/mypack>=0.4.0"
163
+ ```
164
+
165
+ It is important to note that once you use `\require` in your code, you will have to compile it using the lilypond wrapper provided by lyp. It will not pass compilation using plain lilypond.
166
+
167
+ ### Developing packages
168
+
169
+ To create a lilypond package:
170
+
171
+ - Create a git repository.
172
+ - Add a `package.ly` file, which is the main entry point for your package.
173
+ - Optionally add additional lilypond files or package dependencies.
174
+ - Test & debug your code (see below).
175
+ - Publish your package (see below).
176
+
177
+ To test your package code, you can install it from a local path. Suppose your package is at ~/repo/mypack:
178
+
179
+ ```bash
180
+ lyp install mypack@dev:~/repo/mypack
181
+ ```
63
182
 
64
- ## Installing and managing versions of lilypond
183
+ This will create a `mypack@dev` package referencing your local files, which you can then reference from a test file in your package using the `\require` command:
184
+
185
+ ```lilypond
186
+ \require "mypack@dev"
187
+ ```
188
+
189
+ ### Publishing packages
190
+
191
+ 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.
192
+
193
+ You can also add your package to the lyp [public package index](https://github.com/noteflakes/lyp-index), by cloning it, editing [index.yaml](https://github.com/noteflakes/lyp-index/blob/master/index.yaml), and creating a pull request.
194
+
195
+ ## Installing and switching Lilypond versions
65
196
 
66
197
  When installing lilypond, the specific version to download can be specified in different ways:
67
198
 
@@ -71,25 +202,48 @@ lyp install lilypond@stable % latest stable version
71
202
  lyp install lilypond@unstable % latest stable version
72
203
  lyp install lilypond@latest % latest version
73
204
  lyp install lilypond@2.18.1 % version 2.18.1
74
- lyp install lilypond@>=2.19.27 % highest version higher than 2.19.27
75
- lyp install lilypond@~>2.18.1 % highest 2.18 version higher than 2.18.1
205
+ lyp install "lilypond>=2.19.27" % highest version higher than 2.19.27
206
+ lyp install "lilypond~>2.18.1" % highest 2.18 version higher than 2.18.1
76
207
  ```
77
208
 
78
- To display all installed versions of lilypond, use the <code>list</code> command:
209
+ To display all installed versions of lilypond, use the `list` command:
79
210
 
80
211
  ```bash
81
212
  lyp list lilypond
82
213
  ```
83
214
 
84
- To switch between versions use the <code>use</code>. The same version specifiers could be used as for the <code>install</code> command:
215
+ This will also list any versions of lilypond found outside of the `~/.lyp` directory.
216
+
217
+ You can also list available versions of lilypond by using the `search` command:
218
+
219
+ ```bash
220
+ lyp search lilypond # display all available versions of lilypond
221
+ lyp search "lilypond>=2.19" # display all available versions higher than 2.19
222
+ lyp search "lilypond@stable" # display all available stable versions
223
+ ````
224
+
225
+ To switch between versions use the `lyp use`. The same version specifiers could be used as for the `lyp install` command:
85
226
 
86
227
  ```bash
87
228
  lyp use lilypond@2.18.2 % or without the 'lilypond' identifier:
88
229
  lyp use stable % use latest stable version
230
+ lyp use unstable % use latest unstable version
89
231
  ```
90
232
 
91
- To show all versions available for download, use the <code>search</code> command:
92
-
233
+ The setting of the current lilypond version to use will be maintained for the current shell session.
234
+
235
+ In order to switch the default version of lilypond to use, add the `--default` switch:
236
+
237
+ ```bash
238
+ lyp use --default 2.19.35
239
+ ```
240
+
241
+ ## Contributing
242
+
243
+ Lyp is written in Ruby, and its code is [available on github](https://github.com/noteflakes/lyp). To hack on it, siply clone the repository. To run the specs:
244
+
93
245
  ```bash
94
- lyp search lilypond
95
- ```
246
+ rspec
247
+ ```
248
+
249
+ Please feel free to submit issues and pull requests.
data/bin/get.sh ADDED
@@ -0,0 +1,886 @@
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 "$@"