lyp 0.2.2 → 0.2.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 +4 -4
- data/README.md +35 -19
- data/bin/install_release.sh +1 -1
- data/lib/lyp.rb +11 -29
- data/lib/lyp/base.rb +5 -0
- data/lib/lyp/cli.rb +2 -2
- data/lib/lyp/etc/lyp.ly +8 -2
- data/lib/lyp/lilypond.rb +56 -10
- data/lib/lyp/package.rb +12 -4
- data/lib/lyp/system.rb +31 -1
- data/lib/lyp/templates/deps_wrapper.rb +13 -7
- data/lib/lyp/version.rb +1 -1
- data/lib/lyp/windows.rb +110 -0
- data/lib/lyp/wrapper.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0526bbb1656a6c6908733533c3bba2328fe7ae6e
|
4
|
+
data.tar.gz: c3bb37df62281ff3dcb02d06dffa6fbb9ad0bd93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c276e9128136b033690feca8346fc5012ef6d2a8a4f3394eb59a67d75f141b8a0ac00ee9224c9386669bfa63395221fd6bb24b5e1466045101dbefb142508c29
|
7
|
+
data.tar.gz: 1e613e28b8b5c03e5fcf22dff77e51d82f90b03d227f570bf7e76ffd089e30ff843a0a2b72ebc7de7e1f9602a06197271da5f47ca09d246fabef7b22942e57d4
|
data/README.md
CHANGED
@@ -11,8 +11,11 @@ __No hassle Lilypond installation__: With lyp you can also install any version o
|
|
11
11
|
## Table of contents
|
12
12
|
|
13
13
|
- [Installation](#installation)
|
14
|
-
- [
|
15
|
-
- [
|
14
|
+
- [System requirements](#system-requirements)
|
15
|
+
- [Installing lyp as a Ruby gem](#installing-lyp-as-a-ruby-gem)
|
16
|
+
- [Installing lyp as a standalone release](#installing-lyp-as-a-standalone-release)
|
17
|
+
- [Uninstalling lyp](#uninstalling-lyp)
|
18
|
+
- [How lyp works](#how-lyp-works)
|
16
19
|
- [Working with packages](#working-with-packages)
|
17
20
|
- [What constitutes a package?](#what-constitutes-a-package)
|
18
21
|
- [Installing packages](#installing-packages)
|
@@ -36,20 +39,33 @@ __No hassle Lilypond installation__: With lyp you can also install any version o
|
|
36
39
|
|
37
40
|
## Installation
|
38
41
|
|
39
|
-
|
42
|
+
### System requirements
|
40
43
|
|
41
|
-
|
44
|
+
Lyp is tested to work on Linux, Mac OSX and Windows 7+.
|
42
45
|
|
43
|
-
|
46
|
+
**Note**: Windows users will currently need to install lyp as a Ruby gem, and will also need to have git installed in order to be able to install packages.
|
47
|
+
|
48
|
+
### Installing lyp as a Ruby gem
|
49
|
+
|
50
|
+
If you have a recent (>=1.9.3) version of Ruby on your machine, you can install lyp as a gem.
|
44
51
|
|
45
52
|
```bash
|
53
|
+
# Linux/OSX only
|
46
54
|
$ gem install lyp
|
47
55
|
$ lyp install self
|
48
56
|
```
|
49
57
|
|
50
58
|
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.
|
51
59
|
|
52
|
-
|
60
|
+
Windows users should install the lyp-win gem:
|
61
|
+
|
62
|
+
```bash
|
63
|
+
> gem install lyp-win
|
64
|
+
```
|
65
|
+
|
66
|
+
On Windows, there's no need to run the `lyp install self` command.
|
67
|
+
|
68
|
+
### Installing lyp as a standalone release
|
53
69
|
|
54
70
|
If you don't have Ruby on your machine you can install lyp as a stand alone package using the install script ([view source](https://git.io/getlyp)):
|
55
71
|
|
@@ -76,19 +92,7 @@ https://github.com/noteflakes/lyp/releases/download/v0.2.1/lyp-0.2.1-linux-x86_6
|
|
76
92
|
|
77
93
|
**Note**: using the standalone release of lyp requires having git on your machine.
|
78
94
|
|
79
|
-
###
|
80
|
-
|
81
|
-
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:
|
82
|
-
|
83
|
-
- Select the correct version of lilypond to use (see below).
|
84
|
-
- Scan the given lilypond file for any dependencies (specified using `\require`), and also recursively scan any include files for dependencies
|
85
|
-
- Resolve the dependency tree and calculate the correct versions to use for each required package.
|
86
|
-
- Create a wrapper lilypond file that loads the packages.
|
87
|
-
- Invoke the selected version of lilypond.
|
88
|
-
|
89
|
-
For more information on running lilypond see the section on [Running lilypond](#running-lilypond).
|
90
|
-
|
91
|
-
### Uninstalling
|
95
|
+
### Uninstalling lyp
|
92
96
|
|
93
97
|
In order to remove lyp from your system use the `uninstall self` command:
|
94
98
|
|
@@ -104,6 +108,18 @@ In order to completely remove all files in `~/.lyp` you can simply delete the di
|
|
104
108
|
$ rm -rf ~/.lyp
|
105
109
|
```
|
106
110
|
|
111
|
+
## How lyp works
|
112
|
+
|
113
|
+
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:
|
114
|
+
|
115
|
+
- Select the correct version of lilypond to use (see below).
|
116
|
+
- Scan the given lilypond file for any dependencies (specified using `\require`), and also recursively scan any include files for dependencies
|
117
|
+
- Resolve the dependency tree and calculate the correct versions to use for each required package.
|
118
|
+
- Create a wrapper lilypond file that loads the packages.
|
119
|
+
- Invoke the selected version of lilypond.
|
120
|
+
|
121
|
+
For more information on running lilypond see the section on [Running lilypond](#running-lilypond).
|
122
|
+
|
107
123
|
## Working with Packages
|
108
124
|
|
109
125
|
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.
|
data/bin/install_release.sh
CHANGED
data/lib/lyp.rb
CHANGED
@@ -1,33 +1,15 @@
|
|
1
|
-
|
2
|
-
$rugged_available = begin
|
3
|
-
gem 'rugged', '>=0.23.0'
|
4
|
-
require 'rugged'
|
5
|
-
rescue Exception
|
6
|
-
nil
|
7
|
-
end
|
1
|
+
def req(f); require File.expand_path("lyp/#{f}", File.dirname(__FILE__)); end
|
8
2
|
|
9
|
-
|
3
|
+
req 'base'
|
4
|
+
req 'system'
|
5
|
+
req 'settings'
|
10
6
|
|
11
|
-
|
12
|
-
raise "Lyp needs git in order to be able to install packages. Please install git and then try again."
|
13
|
-
end
|
7
|
+
Lyp::System.test_rugged_gem!
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
base
|
21
|
-
system
|
22
|
-
settings
|
23
|
-
|
24
|
-
template
|
25
|
-
resolver
|
26
|
-
wrapper
|
27
|
-
|
28
|
-
package
|
29
|
-
lilypond
|
30
|
-
}.each do |f|
|
31
|
-
require File.expand_path("lyp/#{f}", File.dirname(__FILE__))
|
32
|
-
end
|
9
|
+
req 'template'
|
10
|
+
req 'resolver'
|
11
|
+
req 'wrapper'
|
12
|
+
req 'package'
|
13
|
+
req 'lilypond'
|
33
14
|
|
15
|
+
req 'windows' if Lyp::WINDOWS
|
data/lib/lyp/base.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'fileutils'
|
2
2
|
|
3
3
|
module Lyp
|
4
|
+
WINDOWS = Gem.win_platform?
|
5
|
+
TMP_DIR = WINDOWS ? "#{Dir.home}/AppData/Local/Temp" : "/tmp"
|
6
|
+
TMP_ROOT = "#{TMP_DIR}/lyp"
|
7
|
+
FileUtils.mkdir_p(TMP_ROOT)
|
8
|
+
|
4
9
|
# A package specifier is of the form <package>@<version specifier>, where
|
5
10
|
# the version specifier can be simply a version number, or include an operator
|
6
11
|
# before the version number.
|
data/lib/lyp/cli.rb
CHANGED
@@ -228,7 +228,7 @@ class Lyp::CLI < Thor
|
|
228
228
|
if pattern == 'lilypond'
|
229
229
|
list = Lyp::Lilypond.list
|
230
230
|
if list.empty?
|
231
|
-
puts LILYPOND_NOT_FOUND_MSG
|
231
|
+
puts Lyp::LILYPOND_NOT_FOUND_MSG
|
232
232
|
else
|
233
233
|
puts LILYPOND_PREAMBLE
|
234
234
|
list.each {|info| puts format_lilypond_entry(info)}
|
@@ -267,7 +267,7 @@ class Lyp::CLI < Thor
|
|
267
267
|
if current
|
268
268
|
puts Lyp::Lilypond.current_lilypond
|
269
269
|
else
|
270
|
-
puts LILYPOND_NOT_FOUND_MSG
|
270
|
+
puts Lyp::LILYPOND_NOT_FOUND_MSG
|
271
271
|
end
|
272
272
|
else
|
273
273
|
Lyp::Package.which(args.first).each {|p| puts p}
|
data/lib/lyp/etc/lyp.ly
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
#(begin
|
2
|
+
(define lyp:path-separator "/")
|
3
|
+
;(define lyp:path-separator (list->string (list
|
4
|
+
; (if (eq? PLATFORM 'windows) #\\ #\/ ))))
|
5
|
+
|
6
|
+
(define (lyp:file-join . ls) (string-join ls lyp:path-separator))
|
7
|
+
|
2
8
|
; hash table mapping package refs to package names
|
3
9
|
(define lyp:package-refs (make-hash-table))
|
4
10
|
|
@@ -34,7 +40,7 @@
|
|
34
40
|
(base-path (if (null? package)
|
35
41
|
lyp:current-package-dir (lyp:name->dir package)))
|
36
42
|
)
|
37
|
-
(
|
43
|
+
(lyp:file-join base-path path)
|
38
44
|
))
|
39
45
|
|
40
46
|
; converts a package file reference to absolute path
|
@@ -70,7 +76,7 @@
|
|
70
76
|
(define (lyp:require ref) (let* (
|
71
77
|
(name (lyp:ref->name ref))
|
72
78
|
(package-dir (lyp:name->dir name))
|
73
|
-
(entry-point-path (
|
79
|
+
(entry-point-path (lyp:file-join package-dir "package.ly"))
|
74
80
|
(loaded? (hash-ref lyp:package-loaded? name))
|
75
81
|
(prev-package-dir lyp:current-package-dir)
|
76
82
|
)
|
data/lib/lyp/lilypond.rb
CHANGED
@@ -95,7 +95,7 @@ module Lyp::Lilypond
|
|
95
95
|
default = latest[:path]
|
96
96
|
set_default_lilypond(default)
|
97
97
|
else
|
98
|
-
raise LILYPOND_NOT_FOUND_MSG
|
98
|
+
raise Lyp::LILYPOND_NOT_FOUND_MSG
|
99
99
|
end
|
100
100
|
end
|
101
101
|
|
@@ -110,7 +110,7 @@ module Lyp::Lilypond
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def session_settings_filename
|
113
|
-
"/
|
113
|
+
"#{Lyp::TMP_ROOT}/session.#{Process.getsid}.yml"
|
114
114
|
end
|
115
115
|
|
116
116
|
CMP_VERSION = proc do |x, y|
|
@@ -261,11 +261,15 @@ module Lyp::Lilypond
|
|
261
261
|
STDERR.puts "Installing version #{version}" unless opts[:silent]
|
262
262
|
install_version(version, opts)
|
263
263
|
|
264
|
-
lilypond_path =
|
264
|
+
lilypond_path = lyp_lilypond_path(version)
|
265
265
|
set_current_lilypond(lilypond_path)
|
266
266
|
set_default_lilypond(lilypond_path) if opts[:default]
|
267
267
|
end
|
268
268
|
|
269
|
+
def lyp_lilypond_path(version)
|
270
|
+
"#{Lyp.lilyponds_dir}/#{version}/bin/lilypond"
|
271
|
+
end
|
272
|
+
|
269
273
|
def detect_version_from_specifier(version_specifier)
|
270
274
|
case version_specifier
|
271
275
|
when /^\d/
|
@@ -299,6 +303,8 @@ module Lyp::Lilypond
|
|
299
303
|
"linux-64"
|
300
304
|
when "ppc-linux"
|
301
305
|
"linux-ppc"
|
306
|
+
when "x64-mingw32"
|
307
|
+
"mingw"
|
302
308
|
end
|
303
309
|
end
|
304
310
|
|
@@ -315,7 +321,14 @@ module Lyp::Lilypond
|
|
315
321
|
end
|
316
322
|
|
317
323
|
def lilypond_install_url(platform, version, opts)
|
318
|
-
ext = platform
|
324
|
+
ext = case platform
|
325
|
+
when /darwin/
|
326
|
+
".tar.bz2"
|
327
|
+
when /linux/
|
328
|
+
".sh"
|
329
|
+
when /mingw/
|
330
|
+
".exe"
|
331
|
+
end
|
319
332
|
filename = "lilypond-#{version}-1.#{platform}"
|
320
333
|
|
321
334
|
"#{BASE_URL}/#{platform}/#{filename}#{ext}"
|
@@ -323,7 +336,7 @@ module Lyp::Lilypond
|
|
323
336
|
|
324
337
|
def temp_install_filename(url)
|
325
338
|
u = URI(url)
|
326
|
-
"
|
339
|
+
"#{Lyp::TMP_ROOT}/#{File.basename(u.path)}"
|
327
340
|
end
|
328
341
|
|
329
342
|
def download_lilypond(url, fn, opts)
|
@@ -352,7 +365,7 @@ module Lyp::Lilypond
|
|
352
365
|
end
|
353
366
|
|
354
367
|
def install_lilypond_files(fn, platform, version, opts)
|
355
|
-
tmp_target = "/
|
368
|
+
tmp_target = "#{Lyp::TMP_ROOT}/lilypond-#{version}"
|
356
369
|
FileUtils.mkdir_p(tmp_target)
|
357
370
|
|
358
371
|
case platform
|
@@ -360,6 +373,8 @@ module Lyp::Lilypond
|
|
360
373
|
install_lilypond_files_osx(fn, tmp_target, platform, version, opts)
|
361
374
|
when /linux/
|
362
375
|
install_lilypond_files_linux(fn, tmp_target, platform, version, opts)
|
376
|
+
when /mingw/
|
377
|
+
install_lilypond_files_windows(fn, tmp_target, platform, version, opts)
|
363
378
|
end
|
364
379
|
|
365
380
|
ensure
|
@@ -379,7 +394,7 @@ module Lyp::Lilypond
|
|
379
394
|
STDERR.puts "Extracting..." unless opts[:silent]
|
380
395
|
|
381
396
|
# create temp directory in which to extract .sh file
|
382
|
-
tmp_dir = "
|
397
|
+
tmp_dir = "#{Lyp::TMP_ROOT}/#{Time.now.to_f}"
|
383
398
|
FileUtils.mkdir_p(tmp_dir)
|
384
399
|
|
385
400
|
FileUtils.cd(tmp_dir) do
|
@@ -394,6 +409,27 @@ module Lyp::Lilypond
|
|
394
409
|
ensure
|
395
410
|
FileUtils.rm_rf(tmp_dir)
|
396
411
|
end
|
412
|
+
|
413
|
+
def install_lilypond_files_windows(fn, target, platform, version, opts)
|
414
|
+
STDERR.puts "Running NSIS Installer..." unless opts[:silent]
|
415
|
+
|
416
|
+
target_dir = File.join(Lyp.lilyponds_dir, version)
|
417
|
+
FileUtils.mkdir_p(target_dir)
|
418
|
+
|
419
|
+
# run installer
|
420
|
+
cmd = "#{fn} /S /D=#{target_dir.gsub('/', '\\')}"
|
421
|
+
`#{cmd}`
|
422
|
+
|
423
|
+
# wait for installer to finish
|
424
|
+
t1 = Time.now
|
425
|
+
while !File.file?("#{target_dir}/usr/bin/lilypond.exe")
|
426
|
+
sleep 0.5
|
427
|
+
raise "Windows installation failed" if Time.now - t1 >= 60
|
428
|
+
end
|
429
|
+
|
430
|
+
# Show lilypond versions
|
431
|
+
STDERR.puts `#{target_dir}/usr/bin/lilypond -v` unless opts[:silent] || opts[:no_version_test]
|
432
|
+
end
|
397
433
|
|
398
434
|
def copy_lilypond_files(base_path, version, opts)
|
399
435
|
target_dir = File.join(Lyp.lilyponds_dir, version)
|
@@ -419,14 +455,14 @@ module Lyp::Lilypond
|
|
419
455
|
def patch_font_scm(version)
|
420
456
|
return unless Lyp::FONT_PATCH_REQ =~ Gem::Version.new(version)
|
421
457
|
|
422
|
-
target_fn = File.join(
|
458
|
+
target_fn = File.join(lyp_lilypond_share_dir(version), 'lilypond/current/scm/font.scm')
|
423
459
|
FileUtils.cp(Lyp::FONT_PATCH_FILENAME, target_fn)
|
424
460
|
end
|
425
461
|
|
426
462
|
def copy_fonts_from_all_packages(version, opts)
|
427
463
|
return unless Lyp::FONT_COPY_REQ =~ Gem::Version.new(version)
|
428
464
|
|
429
|
-
ly_fonts_dir = File.join(
|
465
|
+
ly_fonts_dir = File.join(lyp_lilypond_share_dir(version), 'lilypond/current/fonts')
|
430
466
|
|
431
467
|
Dir["#{Lyp.packages_dir}/**/fonts"].each do |package_fonts_dir|
|
432
468
|
|
@@ -447,6 +483,10 @@ module Lyp::Lilypond
|
|
447
483
|
end
|
448
484
|
end
|
449
485
|
|
486
|
+
def lyp_lilypond_share_dir(version)
|
487
|
+
File.join(Lyp.lilyponds_dir, version, 'share')
|
488
|
+
end
|
489
|
+
|
450
490
|
def use(version, opts)
|
451
491
|
lilypond_list = list.reverse
|
452
492
|
|
@@ -503,11 +543,17 @@ module Lyp::Lilypond
|
|
503
543
|
puts "Uninstalling lilypond #{l[:version]}" unless opts[:silent]
|
504
544
|
set_current_lilypond(nil) if l[:current]
|
505
545
|
set_default_lilypond(nil) if l[:default]
|
506
|
-
|
546
|
+
uninstall_lilypond_version(l[:root_path])
|
507
547
|
end
|
508
548
|
end
|
509
549
|
|
550
|
+
def uninstall_lilypond_version(path)
|
551
|
+
FileUtils.rm_rf(path)
|
552
|
+
end
|
553
|
+
|
510
554
|
def exec(cmd, raise_on_failure = true)
|
555
|
+
$_out = ""
|
556
|
+
$_err = ""
|
511
557
|
success = nil
|
512
558
|
Open3.popen3(cmd) do |_in, _out, _err, wait_thr|
|
513
559
|
exit_value = wait_thr.value
|
data/lib/lyp/package.rb
CHANGED
@@ -115,14 +115,18 @@ module Lyp::Package
|
|
115
115
|
File.open(package_ly_path, 'w+') do |f|
|
116
116
|
f << LOCAL_PACKAGE_WRAPPER % [entry_point_dirname, entry_point_path]
|
117
117
|
end
|
118
|
+
|
119
|
+
prepare_local_package_fonts(local_path, package_path)
|
118
120
|
|
121
|
+
{version: version, path: package_path}
|
122
|
+
end
|
123
|
+
|
124
|
+
def prepare_local_package_fonts(local_path, package_path)
|
119
125
|
# create fonts directory symlink if needed
|
120
126
|
fonts_path = File.join(local_path, 'fonts')
|
121
127
|
if File.directory?(fonts_path)
|
122
128
|
FileUtils.ln_sf(fonts_path, File.join(package_path, 'fonts'))
|
123
129
|
end
|
124
|
-
|
125
|
-
{version: version, path: package_path}
|
126
130
|
end
|
127
131
|
|
128
132
|
def install_from_repository(package, version, opts)
|
@@ -243,7 +247,7 @@ module Lyp::Package
|
|
243
247
|
Lyp::Lilypond.list.each do |lilypond|
|
244
248
|
next unless req =~ Gem::Version.new(lilypond[:version])
|
245
249
|
|
246
|
-
ly_fonts_dir = File.join(lilypond[:root_path],
|
250
|
+
ly_fonts_dir = File.join(lilypond[:root_path], lilypond_fonts_path)
|
247
251
|
package_fonts_dir = File.join(package_path, 'fonts')
|
248
252
|
|
249
253
|
Dir["#{package_fonts_dir}/*.otf"].each do |fn|
|
@@ -263,6 +267,10 @@ module Lyp::Package
|
|
263
267
|
end
|
264
268
|
end
|
265
269
|
|
270
|
+
def lilypond_fonts_path
|
271
|
+
'share/lilypond/current/fonts'
|
272
|
+
end
|
273
|
+
|
266
274
|
def package_git_url(package, search_index = true)
|
267
275
|
case package
|
268
276
|
when /^(?:(?:[^\:]+)|http|https)\:/
|
@@ -305,7 +313,7 @@ module Lyp::Package
|
|
305
313
|
@lyp_index ||= YAML.load(open(LYP_INDEX_URL))
|
306
314
|
end
|
307
315
|
|
308
|
-
TEMP_REPO_ROOT_PATH = "/
|
316
|
+
TEMP_REPO_ROOT_PATH = "#{Lyp::TMP_ROOT}/repos"
|
309
317
|
|
310
318
|
def git_url_to_temp_path(url)
|
311
319
|
case url
|
data/lib/lyp/system.rb
CHANGED
@@ -2,6 +2,36 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
module Lyp::System
|
4
4
|
class << self
|
5
|
+
RUGGED_REQ = Gem::Requirement.new('>=0.23.0')
|
6
|
+
|
7
|
+
def test_rugged_gem!
|
8
|
+
return if find_rugged_gem || use_git_based_rugged_gem
|
9
|
+
|
10
|
+
STDERR.puts "Lyp needs git in order to be able to install packages. Please install git and then try again."
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_rugged_gem
|
15
|
+
found = Gem::Specification.find_all_by_name('rugged').find do |s|
|
16
|
+
RUGGED_REQ =~ s.version
|
17
|
+
end
|
18
|
+
|
19
|
+
require_rugged_gem if found
|
20
|
+
found
|
21
|
+
end
|
22
|
+
|
23
|
+
def require_rugged_gem
|
24
|
+
gem 'rugged', RUGGED_REQ.to_s
|
25
|
+
require 'rugged'
|
26
|
+
end
|
27
|
+
|
28
|
+
def use_git_based_rugged_gem
|
29
|
+
git_available = `git --version` rescue nil
|
30
|
+
return false unless git_available
|
31
|
+
|
32
|
+
require File.expand_path('git_based_rugged', File.dirname(__FILE__))
|
33
|
+
end
|
34
|
+
|
5
35
|
INSTALL_MSG = <<EOF
|
6
36
|
|
7
37
|
Warning! Lyp is not yet properly installed in your home directory.
|
@@ -17,7 +47,7 @@ EOF
|
|
17
47
|
|
18
48
|
def test_installed_status!
|
19
49
|
unless installed?
|
20
|
-
puts INSTALL_MSG
|
50
|
+
STDERR.puts INSTALL_MSG
|
21
51
|
end
|
22
52
|
end
|
23
53
|
|
@@ -12,6 +12,11 @@ require 'fileutils'
|
|
12
12
|
user_filename = File.expand_path(_[:user_file])
|
13
13
|
user_dirname = File.dirname(user_filename)
|
14
14
|
|
15
|
+
quote_path = lambda do |path|
|
16
|
+
path = path.gsub("\\", "/") if Lyp::WINDOWS
|
17
|
+
path.inspect
|
18
|
+
end
|
19
|
+
|
15
20
|
current_package_dir = _[:current_package_dir] || FileUtils.pwd
|
16
21
|
|
17
22
|
# The wrapper defines a few global variables:
|
@@ -29,19 +34,20 @@ current_package_dir = _[:current_package_dir] || FileUtils.pwd
|
|
29
34
|
\include "{{Lyp::LYP_LY_LIB_PATH}}"
|
30
35
|
|
31
36
|
#(begin
|
32
|
-
(define lyp:
|
33
|
-
(define lyp:input-
|
34
|
-
(define lyp:
|
37
|
+
(define lyp:cwd {{quote_path[FileUtils.pwd]}})
|
38
|
+
(define lyp:input-filename {{quote_path[user_filename]}})
|
39
|
+
(define lyp:input-dirname {{quote_path[user_dirname]}})
|
40
|
+
(define lyp:current-package-dir {{quote_path[current_package_dir]}})
|
35
41
|
`
|
36
42
|
|
37
|
-
_[:package_refs].each do |spec,
|
43
|
+
_[:package_refs].each do |spec, name|
|
38
44
|
`
|
39
|
-
(hash-set! lyp:package-refs "{{spec}}" "{{
|
45
|
+
(hash-set! lyp:package-refs "{{spec}}" "{{name}}")`
|
40
46
|
end
|
41
47
|
|
42
48
|
_[:package_dirs].each do |package, path|
|
43
49
|
`
|
44
|
-
(hash-set! lyp:package-dirs "{{package}}"
|
50
|
+
(hash-set! lyp:package-dirs "{{package}}" {{quote_path[path]}})`
|
45
51
|
end
|
46
52
|
|
47
53
|
|
@@ -49,5 +55,5 @@ end
|
|
49
55
|
)
|
50
56
|
|
51
57
|
#(ly:debug "package loader is ready")
|
52
|
-
\include
|
58
|
+
\include {{quote_path[user_filename]}}
|
53
59
|
`
|
data/lib/lyp/version.rb
CHANGED
data/lib/lyp/windows.rb
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
module Process
|
2
|
+
def self.getsid
|
3
|
+
if `tasklist` =~ /^ruby\.exe\s+#{Process.pid}\s+[^\s]+\s+([0-9]+)/
|
4
|
+
$1.to_i
|
5
|
+
else
|
6
|
+
0
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Lyp::Lilypond
|
12
|
+
class << self
|
13
|
+
def get_system_lilyponds_paths
|
14
|
+
[]
|
15
|
+
end
|
16
|
+
|
17
|
+
def lyp_lilypond_path(version)
|
18
|
+
"#{Lyp.lilyponds_dir}/#{version}/usr/bin/lilypond.exe"
|
19
|
+
end
|
20
|
+
|
21
|
+
def lyp_lilypond_share_dir(version)
|
22
|
+
File.join(Lyp.lilyponds_dir, version, 'usr/share')
|
23
|
+
end
|
24
|
+
|
25
|
+
def lyp_lilyponds
|
26
|
+
list = []
|
27
|
+
|
28
|
+
Dir["#{Lyp.lilyponds_dir}/*"].each do |path|
|
29
|
+
next unless File.directory?(path) && File.basename(path) =~ /^[\d\.]+$/
|
30
|
+
|
31
|
+
root_path = path
|
32
|
+
version = File.basename(path)
|
33
|
+
path = File.join(path, "usr/bin/lilypond.exe")
|
34
|
+
list << {
|
35
|
+
root_path: root_path,
|
36
|
+
path: path,
|
37
|
+
version: version
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
list
|
42
|
+
end
|
43
|
+
|
44
|
+
def download_lilypond(url, fn, opts)
|
45
|
+
STDERR.puts "Downloading #{url}" unless opts[:silent]
|
46
|
+
|
47
|
+
if opts[:silent]
|
48
|
+
`curl -s -o "#{fn}" "#{url}"`
|
49
|
+
else
|
50
|
+
`curl -o "#{fn}" "#{url}"`
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def uninstall_lilypond_version(path)
|
55
|
+
# run installer
|
56
|
+
uninstaller_path = File.join(path, 'uninstall.exe')
|
57
|
+
if File.file?(uninstaller_path)
|
58
|
+
cmd = "#{uninstaller_path} /S _?=#{path.gsub('/', '\\')}"
|
59
|
+
`#{cmd}`
|
60
|
+
|
61
|
+
# wait for installer to finish
|
62
|
+
t1 = Time.now
|
63
|
+
while !File.directory?("#{target_dir}/usr")
|
64
|
+
sleep 0.5
|
65
|
+
raise "Uninstallation failed" if Time.now - t1 >= 60
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
FileUtils.rm_rf(path)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
module Lyp::Package
|
75
|
+
class << self
|
76
|
+
|
77
|
+
def prepare_local_package_fonts(local_path, package_path)
|
78
|
+
# create fonts directory symlink if needed
|
79
|
+
fonts_path = File.join(local_path, 'fonts')
|
80
|
+
if File.directory?(fonts_path)
|
81
|
+
FileUtils.cp_r(fonts_path, File.join(package_path, 'fonts'))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def lilypond_fonts_path
|
86
|
+
'usr/share/lilypond/current/fonts'
|
87
|
+
end
|
88
|
+
|
89
|
+
def lyp_index
|
90
|
+
@lyp_index ||= YAML.load(`curl -s #{LYP_INDEX_URL}`)
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
module Lyp::System
|
97
|
+
class << self
|
98
|
+
def installed?
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
102
|
+
def install!
|
103
|
+
puts "\ninstall self curently not supported on Windows.\n\n"
|
104
|
+
end
|
105
|
+
|
106
|
+
def uninstall!
|
107
|
+
puts "\nuninstall self curently not supported on Windows.\n\n"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/lib/lyp/wrapper.rb
CHANGED
@@ -12,8 +12,8 @@ module Lyp
|
|
12
12
|
r[:current_package_dir] = opts[:current_package_dir]
|
13
13
|
|
14
14
|
if !r[:package_dirs].empty? || opts[:force_wrap]
|
15
|
-
FileUtils.mkdir_p(
|
16
|
-
fn = "/
|
15
|
+
FileUtils.mkdir_p("#{Lyp::TMP_ROOT}/wrappers")
|
16
|
+
fn = "#{Lyp::TMP_ROOT}/wrappers/#{File.basename(fn)}"
|
17
17
|
|
18
18
|
File.open(fn, 'w+') {|f| f << WRAPPER_TEMPLATE.render(r)}
|
19
19
|
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.2.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/lyp/template.rb
|
114
114
|
- lib/lyp/templates/deps_wrapper.rb
|
115
115
|
- lib/lyp/version.rb
|
116
|
+
- lib/lyp/windows.rb
|
116
117
|
- lib/lyp/wrapper.rb
|
117
118
|
homepage: http://github.com/noteflakes/lyp
|
118
119
|
licenses:
|