lyp-win 0.2.2

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.
@@ -0,0 +1,51 @@
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
+ has() { type "$1" > /dev/null 2>&1 }
9
+
10
+ download() {
11
+ if has "curl"; then
12
+ curl -L -o $*
13
+ elif has "wget"; then
14
+ wget -O $*
15
+ else
16
+ fail "Could not find curl or wget"
17
+ fi
18
+ }
19
+
20
+ WORKDIR="/tmp/lyp-release-installer"
21
+ LYP_VERSION="0.2.2"
22
+ URL_BASE="https://github.com/noteflakes/lyp/releases/download/v$LYP_VERSION"
23
+
24
+ PLATFORM=`uname -sp`
25
+ case $PLATFORM in
26
+ "Linux x86_64")
27
+ RELEASE_FILE="lyp-$LYP_VERSION-linux-x86_64"
28
+ ;;
29
+ "Linux x86")
30
+ RELEASE_FILE="lyp-$LYP_VERSION-linux-x86"
31
+ ;;
32
+ "Darwin i386")
33
+ RELEASE_FILE="lyp-$LYP_VERSION-osx"
34
+ ;;
35
+ *)
36
+ fail "Unspported platform $PLATFORM"
37
+ esac
38
+
39
+ RELEASE_URL="$URL_BASE/$RELEASE_FILE.tar.gz"
40
+ RELEASE_PATH="$WORKDIR/$RELEASE_FILE"
41
+
42
+ rm -rf $WORKDIR
43
+ mkdir $WORKDIR
44
+ echo "Downloading $RELEASE_URL"
45
+ download "$WORKDIR/release.tar.gz" $RELEASE_URL
46
+ echo "Extracting $WORKDIR/release.tar.gz"
47
+ tar -xzf "$WORKDIR/release.tar.gz" -C $WORKDIR
48
+
49
+ $RELEASE_PATH/bin/lyp install self
50
+
51
+ rm -rf $WORKDIR
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'lyp/version'
4
+ require 'lyp'
5
+
6
+ def process_argv
7
+ options = {}
8
+ argv = ARGV.dup # copy for iterating
9
+ argv_clean = []
10
+ while arg = argv.shift
11
+ case arg
12
+ when '-r', '--raw'
13
+ options[:raw] = true
14
+ when '-E', '--env'
15
+ unless ENV['LILYPOND_VERSION']
16
+ STDERR.puts "$LILYPOND_VERSION not set"
17
+ exit 1
18
+ end
19
+ options[:use_version] = ENV['LILYPOND_VERSION']
20
+ when '-u', '--use'
21
+ options[:use_version] = argv.shift
22
+ when /^(?:\-u|\-\-use\=)"?([^\s]+)"?/
23
+ options[:use_version] = $1
24
+ when '-n', '--install'
25
+ options[:install] = true
26
+ else
27
+ argv_clean << arg
28
+ end
29
+ end
30
+
31
+ [options, argv_clean]
32
+ end
33
+ $options, $argv = process_argv
34
+
35
+ def get_lilypond_path
36
+ if $options[:use_version]
37
+ if $options[:install]
38
+ Lyp::Lilypond.install_if_missing($options[:use_version])
39
+ end
40
+ Lyp::Lilypond.force_version!($options[:use_version])
41
+ end
42
+ Lyp::Lilypond.check_lilypond!
43
+ Lyp::Lilypond.current_lilypond.tap do |path|
44
+ unless path && File.file?(path)
45
+ STDERR.puts "No version of lilypond found. To install lilypond run 'lyp install lilypond'."
46
+ exit 1
47
+ end
48
+ end
49
+ rescue => e
50
+ STDERR.puts e.message
51
+ exit 1
52
+ end
53
+ $lilypond_path = get_lilypond_path
54
+
55
+ if $options[:raw]
56
+ exec("#{$lilypond_path} #{$argv[1..-1].join(' ')}")
57
+ end
58
+
59
+ OVERRIDING_LILYPOND_SWITCHES = %w{
60
+ -w --warranty
61
+ -v --version
62
+ scheme-sandbox
63
+ }
64
+ LILYPOND_HELP_SWITCHES = %w{
65
+ -h --help
66
+ }
67
+ LYP_LY_HELP = <<EOF
68
+ Lyp-provided options:
69
+ -r, --raw run raw lilypond (no pre-processing)
70
+ -E, --env use version specified in $LILYPOND_VERSION
71
+ -u, --use=VERSION use the given version of lilypond
72
+ -n, --install install the given version if not found
73
+ EOF
74
+
75
+ case $argv.first
76
+ when nil, *OVERRIDING_LILYPOND_SWITCHES
77
+ STDERR.puts "Lyp version #{Lyp::VERSION}"
78
+ exec("#{$lilypond_path} #{$argv.join(' ')}")
79
+
80
+ when *LILYPOND_HELP_SWITCHES
81
+ STDERR.puts "Lyp version #{Lyp::VERSION}"
82
+ puts `#{$lilypond_path} #{$argv.join(' ')}`
83
+ puts LYP_LY_HELP
84
+ else
85
+ begin
86
+ Lyp::Lilypond.compile($argv, $options)
87
+ end
88
+ end
data/bin/lyp ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "lyp"
4
+ require "lyp/cli"
5
+
@@ -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" "$@"
@@ -0,0 +1,42 @@
1
+ $WINDOWS = Gem.win_platform?
2
+
3
+ # test for existence of
4
+ $rugged_available = begin
5
+ gem 'rugged', '>=0.23.0'
6
+ require 'rugged'
7
+ rescue Exception
8
+ nil
9
+ end
10
+
11
+ $git_available = `git --version` rescue nil
12
+
13
+ unless $rugged_available || $git_available
14
+ raise "Lyp needs git in order to be able to install packages. Please install git and then try again."
15
+ end
16
+
17
+ unless $rugged_available
18
+ require 'lyp/git_based_rugged'
19
+ end
20
+
21
+ require 'tmpdir'
22
+ require 'fileutils'
23
+ $TMP_DIR = $WINDOWS ? "#{Dir.home}/AppData/Local/Temp" : "/tmp"
24
+ $TMP_ROOT = "#{$TMP_DIR}/lyp"
25
+ FileUtils.mkdir_p($TMP_ROOT)
26
+
27
+ %w{
28
+ base
29
+ system
30
+ settings
31
+
32
+ template
33
+ resolver
34
+ wrapper
35
+
36
+ package
37
+ lilypond
38
+ }.each do |f|
39
+ require File.expand_path("lyp/#{f}", File.dirname(__FILE__))
40
+ end
41
+
42
+ require File.expand_path("lyp/windows", File.dirname(__FILE__)) if $WINDOWS
@@ -0,0 +1,51 @@
1
+ require 'fileutils'
2
+
3
+ module Lyp
4
+ # A package specifier is of the form <package>@<version specifier>, where
5
+ # the version specifier can be simply a version number, or include an operator
6
+ # before the version number.
7
+ #
8
+ # Accepted operators: >=, ~>
9
+ PACKAGE_RE = /^([^@\>~]+)(?:@)?((?:\>=|~\>)?.+)?/
10
+ LILYPOND_RE = /^lilypond(?:@?((?:\>=|~\>)?.+))?/
11
+
12
+ LYP_DIRECTORY = File.expand_path('~/.lyp')
13
+ LYP_BIN_DIRECTORY = File.join(LYP_DIRECTORY, 'bin')
14
+ LYP_LIB_DIRECTORY = File.join(LYP_DIRECTORY, 'lib')
15
+ DEFAULT_PACKAGE_DIRECTORY = File.join(LYP_DIRECTORY, 'packages')
16
+ DEFAULT_LILYPONDS_DIRECTORY = File.join(LYP_DIRECTORY, 'lilyponds')
17
+
18
+ # Fonts are installed on lilypond >= 2.18.2
19
+ FONT_COPY_REQ = Gem::Requirement.new('>=2.18.2')
20
+ FONT_PATCH_REQ = Gem::Requirement.new('>=2.18.2', '<2.19.12')
21
+
22
+ # Font patch filename (required for 2.18.2 <= lilypond < 2.19.12)
23
+ FONT_PATCH_FILENAME = File.expand_path('etc/font.scm', File.dirname(__FILE__))
24
+
25
+ # etc/lyp.ly contains lyp:* procedure definitions for loading packages and
26
+ # other support code.
27
+ LYP_LY_LIB_PATH = File.expand_path('etc/lyp.ly', File.dirname(__FILE__))
28
+
29
+ LILYPOND_NOT_FOUND_MSG = "No version of lilypond found.\nTo install lilypond run 'lyp install lilypond'"
30
+
31
+ SETTINGS_FILENAME = 'settings.yml'
32
+
33
+ def self.packages_dir
34
+ ensure_dir(DEFAULT_PACKAGE_DIRECTORY)
35
+ end
36
+
37
+ def self.lilyponds_dir
38
+ ensure_dir(DEFAULT_LILYPONDS_DIRECTORY)
39
+ end
40
+
41
+ def self.settings_file
42
+ ensure_dir(LYP_DIRECTORY)
43
+ File.join(LYP_DIRECTORY, SETTINGS_FILENAME)
44
+ end
45
+
46
+ def self.ensure_dir(dir)
47
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
48
+ dir
49
+ end
50
+ end
51
+
@@ -0,0 +1,314 @@
1
+ require 'thor'
2
+ require 'lyp/version'
3
+
4
+ def lilypond_prefix(info)
5
+ if info[:current] && info[:default]
6
+ "=* "
7
+ elsif info[:current]
8
+ "=> "
9
+ elsif info[:default]
10
+ " * "
11
+ else
12
+ " "
13
+ end
14
+ end
15
+
16
+ def lilypond_postfix(info)
17
+ if info[:system]
18
+ " (system)"
19
+ else
20
+ ""
21
+ end
22
+ end
23
+
24
+ def format_lilypond_entry(info)
25
+ "#{lilypond_prefix(info)}#{info[:version]}#{lilypond_postfix(info)}"
26
+ end
27
+
28
+ LILYPOND_PREAMBLE = <<EOF
29
+
30
+ Lilypond versions:
31
+
32
+ EOF
33
+
34
+ LILYPOND_LEGEND = <<EOF
35
+
36
+ # => - current
37
+ # =* - current && default
38
+ # * - default
39
+
40
+ EOF
41
+
42
+ $cmd_options = {}
43
+
44
+ class Lyp::CLI < Thor
45
+ package_name "lyp"
46
+ map "-v" => :version
47
+ check_unknown_options! :except => :compile
48
+ class_option :verbose, aliases: '-V', :type => :boolean
49
+
50
+ desc "version", "show Lyp version"
51
+ def version
52
+ $stderr.puts "Lyp #{Lyp::VERSION}"
53
+ end
54
+
55
+ desc "search [PATTERN|lilypond]", "List available packages matching PATTERN or versions of lilypond"
56
+ def search(pattern = '')
57
+ $cmd_options = options
58
+
59
+ pattern =~ Lyp::PACKAGE_RE
60
+ package, version = $1, $2
61
+
62
+ if package == 'lilypond'
63
+ search_lilypond(version)
64
+ else
65
+ search_package(pattern)
66
+ end
67
+ end
68
+
69
+ no_commands do
70
+ def search_lilypond(version)
71
+ versions = Lyp::Lilypond.search(version)
72
+
73
+ if versions.empty?
74
+ puts "\nNo available versions of lilypond@#{version} found\n\n"
75
+ else
76
+ puts "\nAvailable versions of lilypond@#{version}:\n\n"
77
+ versions.each do |v|
78
+ prefix = v[:installed] ? " * " : " "
79
+ puts "#{prefix}#{v[:version]}"
80
+ end
81
+ puts "\n * Currently installed\n\n"
82
+ end
83
+ end
84
+
85
+ def search_package(pattern)
86
+ packages = Lyp::Package.list_lyp_index(pattern)
87
+ if packages.empty?
88
+ puts "\nNo matching package found in lyp-index\n\n"
89
+ else
90
+ puts "\nAvailable packages on lyp-index:\n\n"
91
+ packages.each do |p|
92
+ puts " #{p[:name]}"
93
+ end
94
+ puts "\n\n"
95
+ end
96
+ end
97
+ end
98
+
99
+ desc "compile [<option>...] <FILE>", "Invokes lilypond with given file"
100
+ method_option :install, aliases: '-n', type: :boolean, desc: 'Install the requested version of lilypond if not present'
101
+ method_option :env, aliases: '-E', type: :boolean, desc: 'Use version set by LILYPOND_VERSION environment variable'
102
+ method_option :use, aliases: '-u', type: :string, desc: 'Use specified version'
103
+ def compile(*args)
104
+ $cmd_options = options
105
+
106
+ if options[:env]
107
+ unless ENV['LILYPOND_VERSION']
108
+ STDERR.puts "$LILYPOND_VERSION not set"
109
+ exit 1
110
+ end
111
+ options[:use] = ENV['LILYPOND_VERSION']
112
+ end
113
+
114
+ if options[:use]
115
+ if options[:install]
116
+ Lyp::Lilypond.install_if_missing(options[:use], no_version_test: true)
117
+ end
118
+ Lyp::Lilypond.force_version!(options[:use])
119
+ end
120
+
121
+ # check lilypond default / current settings
122
+ Lyp::Lilypond.check_lilypond!
123
+
124
+ $stderr.puts "Lyp #{Lyp::VERSION}"
125
+ Lyp::System.test_installed_status!
126
+ Lyp::Lilypond.compile(args)
127
+ end
128
+
129
+ desc "test [<option>...] [.|PATTERN]", "Runs package tests on installed packages or local directory"
130
+ method_option :install, aliases: '-n', type: :boolean, desc: 'Install the requested version of lilypond if not present'
131
+ method_option :env, aliases: '-E', type: :boolean, desc: 'Use version set by LILYPOND_VERSION environment variable'
132
+ method_option :use, aliases: '-u', type: :string, desc: 'Use specified version'
133
+ def test(*args)
134
+ $cmd_options = options
135
+
136
+ if options[:env]
137
+ unless ENV['LILYPOND_VERSION']
138
+ STDERR.puts "$LILYPOND_VERSION not set"
139
+ exit 1
140
+ end
141
+ options[:use] = ENV['LILYPOND_VERSION']
142
+ end
143
+
144
+ if options[:use]
145
+ if options[:install]
146
+ Lyp::Lilypond.install_if_missing(options[:use], no_version_test: true)
147
+ end
148
+ Lyp::Lilypond.force_version!(options[:use])
149
+ end
150
+
151
+ # check lilypond default / current settings
152
+ Lyp::Lilypond.check_lilypond!
153
+
154
+ $stderr.puts "Lyp #{Lyp::VERSION}"
155
+ case args
156
+ when ['.']
157
+ Lyp::Package.run_local_tests('.')
158
+ else
159
+ Lyp::Package.run_package_tests(args)
160
+ end
161
+ end
162
+
163
+ desc "install <PACKAGE|lilypond|self>...", "Install a package or a version of lilypond. When 'install self' is invoked, lyp installs itself in ~/.lyp."
164
+ method_option :default, aliases: '-d', type: :boolean, desc: 'Set default lilypond version'
165
+ method_option :test, aliases: '-t', type: :boolean, desc: 'Run package tests after installation'
166
+ def install(*args)
167
+ $cmd_options = options
168
+
169
+ raise "No package specified" if args.empty?
170
+
171
+ args.each do |package|
172
+ case package
173
+ when 'self'
174
+ Lyp::System.install!
175
+ when Lyp::LILYPOND_RE
176
+ Lyp::System.test_installed_status!
177
+ Lyp::Lilypond.install($1, options)
178
+ else
179
+ Lyp::System.test_installed_status!
180
+ Lyp::Package.install(package, options)
181
+ end
182
+ end
183
+ end
184
+
185
+ desc "uninstall <PACKAGE|lilypond|self>...", "Uninstall a package or a version of lilypond. When 'uninstall self' is invoked, lyp uninstalls itself from ~/.lyp."
186
+ method_option :all, aliases: '-a', type: :boolean, desc: 'Uninstall all versions'
187
+ def uninstall(*args)
188
+ $cmd_options = options
189
+
190
+ Lyp::System.test_installed_status!
191
+
192
+ raise "No package specified" if args.empty?
193
+ args.each do |package|
194
+ case package
195
+ when 'self'
196
+ Lyp::System.uninstall!
197
+ when Lyp::LILYPOND_RE
198
+ Lyp::System.test_installed_status!
199
+ Lyp::Lilypond.uninstall($1, options)
200
+ else
201
+ Lyp::System.test_installed_status!
202
+ Lyp::Package.uninstall(package, options)
203
+ end
204
+ end
205
+ end
206
+
207
+ desc "use [lilypond@]<VERSION>", "Switch version of lilypond"
208
+ method_option :default, aliases: '-d', type: :boolean, desc: 'Set default lilypond version'
209
+ def use(version)
210
+ $cmd_options = options
211
+
212
+ Lyp::System.test_installed_status!
213
+
214
+ if version =~ Lyp::LILYPOND_RE
215
+ version = $1
216
+ end
217
+
218
+ lilypond = Lyp::Lilypond.use(version, options)
219
+ puts "Using version #{lilypond[:version]}"
220
+ end
221
+
222
+ desc "list [PATTERN|lilypond]", "List installed packages matching PATTERN or versions of lilypond"
223
+ def list(pattern = nil)
224
+ $cmd_options = options
225
+
226
+ Lyp::System.test_installed_status!
227
+
228
+ if pattern == 'lilypond'
229
+ list = Lyp::Lilypond.list
230
+ if list.empty?
231
+ puts Lyp::LILYPOND_NOT_FOUND_MSG
232
+ else
233
+ puts LILYPOND_PREAMBLE
234
+ list.each {|info| puts format_lilypond_entry(info)}
235
+ puts LILYPOND_LEGEND
236
+ end
237
+ else
238
+ list = Lyp::Package.list(args.first)
239
+ if list.empty?
240
+ if args.first
241
+ return puts "\nNo installed packages found matching '#{args.first}'\n\n"
242
+ else
243
+ return puts "\nNo packages are currently installed\n\n"
244
+ end
245
+ end
246
+
247
+ by_package = list.inject({}) do |m, p|
248
+ p =~ Lyp::PACKAGE_RE; (m[$1] ||= []) << $2; m
249
+ end
250
+
251
+ puts "\nInstalled packages:\n\n"
252
+ by_package.keys.sort.each do |p|
253
+ puts " #{p} => (#{by_package[p].sort.join(', ')})"
254
+ end
255
+ puts "\n\n"
256
+ end
257
+ end
258
+
259
+ desc "which [PATTERN|lilypond]", "List locations of installed packages matching PATTERN or versions of lilypond"
260
+ def which(pattern = nil)
261
+ $cmd_options = options
262
+
263
+ Lyp::System.test_installed_status!
264
+
265
+ if pattern == 'lilypond'
266
+ current = Lyp::Lilypond.current_lilypond
267
+ if current
268
+ puts Lyp::Lilypond.current_lilypond
269
+ else
270
+ puts Lyp::LILYPOND_NOT_FOUND_MSG
271
+ end
272
+ else
273
+ Lyp::Package.which(args.first).each {|p| puts p}
274
+ end
275
+ end
276
+
277
+ desc "deps FILE", "Lists dependencies found in user's files"
278
+ def deps(fn)
279
+ $cmd_options = options
280
+
281
+ resolver = Lyp::Resolver.new(fn)
282
+ tree = resolver.get_dependency_tree(ignore_missing: true)
283
+ tree[:dependencies].each do |package, leaf|
284
+ versions = leaf[:versions].keys.map {|k| k =~ Lyp::PACKAGE_RE; $2 }.sort
285
+ if versions.empty?
286
+ puts " #{leaf[:clause]} => (no local version found)"
287
+ else
288
+ puts " #{leaf[:clause]} => #{versions.join(', ')}"
289
+ end
290
+ end
291
+ end
292
+
293
+ desc "resolve FILE", "Resolves and installs missing dependencies found in user's files"
294
+ method_option :all, aliases: '-a', type: :boolean, desc: 'Install all found dependencies'
295
+ def resolve(fn)
296
+ $cmd_options = options
297
+
298
+ resolver = Lyp::Resolver.new(fn)
299
+ tree = resolver.get_dependency_tree(ignore_missing: true)
300
+ tree[:dependencies].each do |package, leaf|
301
+ if options[:all] || leaf[:versions].empty?
302
+ Lyp::Package.install(leaf[:clause])
303
+ end
304
+ end
305
+ end
306
+ end
307
+
308
+ begin
309
+ Lyp::CLI.start(ARGV)
310
+ rescue => e
311
+ puts e.message
312
+ puts e.backtrace.join("\n") if $cmd_options[:verbose]
313
+ exit(1)
314
+ end