libgems 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +5811 -0
- data/History.txt +887 -0
- data/LICENSE.txt +51 -0
- data/README.md +87 -0
- data/Rakefile +113 -0
- data/lib/gauntlet_libgems.rb +50 -0
- data/lib/libgems.rb +1246 -0
- data/lib/libgems/builder.rb +102 -0
- data/lib/libgems/command.rb +534 -0
- data/lib/libgems/command_manager.rb +182 -0
- data/lib/libgems/commands/build_command.rb +53 -0
- data/lib/libgems/commands/cert_command.rb +86 -0
- data/lib/libgems/commands/check_command.rb +80 -0
- data/lib/libgems/commands/cleanup_command.rb +106 -0
- data/lib/libgems/commands/contents_command.rb +98 -0
- data/lib/libgems/commands/dependency_command.rb +195 -0
- data/lib/libgems/commands/environment_command.rb +133 -0
- data/lib/libgems/commands/fetch_command.rb +67 -0
- data/lib/libgems/commands/generate_index_command.rb +133 -0
- data/lib/libgems/commands/help_command.rb +172 -0
- data/lib/libgems/commands/install_command.rb +178 -0
- data/lib/libgems/commands/list_command.rb +35 -0
- data/lib/libgems/commands/lock_command.rb +110 -0
- data/lib/libgems/commands/mirror_command.rb +111 -0
- data/lib/libgems/commands/outdated_command.rb +33 -0
- data/lib/libgems/commands/owner_command.rb +75 -0
- data/lib/libgems/commands/pristine_command.rb +93 -0
- data/lib/libgems/commands/push_command.rb +56 -0
- data/lib/libgems/commands/query_command.rb +280 -0
- data/lib/libgems/commands/rdoc_command.rb +91 -0
- data/lib/libgems/commands/search_command.rb +31 -0
- data/lib/libgems/commands/server_command.rb +86 -0
- data/lib/libgems/commands/sources_command.rb +157 -0
- data/lib/libgems/commands/specification_command.rb +125 -0
- data/lib/libgems/commands/stale_command.rb +27 -0
- data/lib/libgems/commands/uninstall_command.rb +83 -0
- data/lib/libgems/commands/unpack_command.rb +121 -0
- data/lib/libgems/commands/update_command.rb +160 -0
- data/lib/libgems/commands/which_command.rb +86 -0
- data/lib/libgems/config_file.rb +345 -0
- data/lib/libgems/custom_require.rb +44 -0
- data/lib/libgems/defaults.rb +101 -0
- data/lib/libgems/dependency.rb +227 -0
- data/lib/libgems/dependency_installer.rb +286 -0
- data/lib/libgems/dependency_list.rb +208 -0
- data/lib/libgems/doc_manager.rb +242 -0
- data/lib/libgems/errors.rb +35 -0
- data/lib/libgems/exceptions.rb +91 -0
- data/lib/libgems/ext.rb +18 -0
- data/lib/libgems/ext/builder.rb +56 -0
- data/lib/libgems/ext/configure_builder.rb +25 -0
- data/lib/libgems/ext/ext_conf_builder.rb +24 -0
- data/lib/libgems/ext/rake_builder.rb +39 -0
- data/lib/libgems/format.rb +81 -0
- data/lib/libgems/gem_openssl.rb +92 -0
- data/lib/libgems/gem_path_searcher.rb +100 -0
- data/lib/libgems/gem_runner.rb +79 -0
- data/lib/libgems/gemcutter_utilities.rb +49 -0
- data/lib/libgems/indexer.rb +720 -0
- data/lib/libgems/install_update_options.rb +125 -0
- data/lib/libgems/installer.rb +604 -0
- data/lib/libgems/local_remote_options.rb +135 -0
- data/lib/libgems/old_format.rb +153 -0
- data/lib/libgems/package.rb +97 -0
- data/lib/libgems/package/f_sync_dir.rb +23 -0
- data/lib/libgems/package/tar_header.rb +266 -0
- data/lib/libgems/package/tar_input.rb +222 -0
- data/lib/libgems/package/tar_output.rb +144 -0
- data/lib/libgems/package/tar_reader.rb +106 -0
- data/lib/libgems/package/tar_reader/entry.rb +141 -0
- data/lib/libgems/package/tar_writer.rb +241 -0
- data/lib/libgems/package_task.rb +126 -0
- data/lib/libgems/platform.rb +183 -0
- data/lib/libgems/remote_fetcher.rb +414 -0
- data/lib/libgems/require_paths_builder.rb +18 -0
- data/lib/libgems/requirement.rb +153 -0
- data/lib/libgems/security.rb +814 -0
- data/lib/libgems/server.rb +872 -0
- data/lib/libgems/source_index.rb +597 -0
- data/lib/libgems/source_info_cache.rb +395 -0
- data/lib/libgems/source_info_cache_entry.rb +56 -0
- data/lib/libgems/spec_fetcher.rb +337 -0
- data/lib/libgems/specification.rb +1487 -0
- data/lib/libgems/test_utilities.rb +147 -0
- data/lib/libgems/text.rb +65 -0
- data/lib/libgems/uninstaller.rb +278 -0
- data/lib/libgems/user_interaction.rb +527 -0
- data/lib/libgems/validator.rb +240 -0
- data/lib/libgems/version.rb +316 -0
- data/lib/libgems/version_option.rb +65 -0
- data/lib/rbconfig/datadir.rb +20 -0
- data/test/bogussources.rb +8 -0
- data/test/data/gem-private_key.pem +27 -0
- data/test/data/gem-public_cert.pem +20 -0
- data/test/fake_certlib/openssl.rb +7 -0
- data/test/foo/discover.rb +0 -0
- data/test/gem_installer_test_case.rb +97 -0
- data/test/gem_package_tar_test_case.rb +132 -0
- data/test/gemutilities.rb +605 -0
- data/test/insure_session.rb +43 -0
- data/test/mockgemui.rb +56 -0
- data/test/plugin/exception/libgems_plugin.rb +2 -0
- data/test/plugin/load/libgems_plugin.rb +1 -0
- data/test/plugin/standarderror/libgems_plugin.rb +2 -0
- data/test/private_key.pem +27 -0
- data/test/public_cert.pem +20 -0
- data/test/rubygems_plugin.rb +21 -0
- data/test/simple_gem.rb +66 -0
- data/test/test_config.rb +12 -0
- data/test/test_gem.rb +780 -0
- data/test/test_gem_builder.rb +27 -0
- data/test/test_gem_command.rb +178 -0
- data/test/test_gem_command_manager.rb +207 -0
- data/test/test_gem_commands_build_command.rb +74 -0
- data/test/test_gem_commands_cert_command.rb +124 -0
- data/test/test_gem_commands_check_command.rb +18 -0
- data/test/test_gem_commands_contents_command.rb +156 -0
- data/test/test_gem_commands_dependency_command.rb +216 -0
- data/test/test_gem_commands_environment_command.rb +144 -0
- data/test/test_gem_commands_fetch_command.rb +76 -0
- data/test/test_gem_commands_generate_index_command.rb +135 -0
- data/test/test_gem_commands_install_command.rb +315 -0
- data/test/test_gem_commands_list_command.rb +36 -0
- data/test/test_gem_commands_lock_command.rb +68 -0
- data/test/test_gem_commands_mirror_command.rb +60 -0
- data/test/test_gem_commands_outdated_command.rb +40 -0
- data/test/test_gem_commands_owner_command.rb +105 -0
- data/test/test_gem_commands_pristine_command.rb +108 -0
- data/test/test_gem_commands_push_command.rb +81 -0
- data/test/test_gem_commands_query_command.rb +426 -0
- data/test/test_gem_commands_server_command.rb +59 -0
- data/test/test_gem_commands_sources_command.rb +209 -0
- data/test/test_gem_commands_specification_command.rb +139 -0
- data/test/test_gem_commands_stale_command.rb +38 -0
- data/test/test_gem_commands_uninstall_command.rb +83 -0
- data/test/test_gem_commands_unpack_command.rb +199 -0
- data/test/test_gem_commands_update_command.rb +207 -0
- data/test/test_gem_commands_which_command.rb +66 -0
- data/test/test_gem_config_file.rb +287 -0
- data/test/test_gem_dependency.rb +149 -0
- data/test/test_gem_dependency_installer.rb +661 -0
- data/test/test_gem_dependency_list.rb +230 -0
- data/test/test_gem_doc_manager.rb +31 -0
- data/test/test_gem_ext_configure_builder.rb +84 -0
- data/test/test_gem_ext_ext_conf_builder.rb +173 -0
- data/test/test_gem_ext_rake_builder.rb +81 -0
- data/test/test_gem_format.rb +70 -0
- data/test/test_gem_gem_path_searcher.rb +78 -0
- data/test/test_gem_gem_runner.rb +45 -0
- data/test/test_gem_gemcutter_utilities.rb +103 -0
- data/test/test_gem_indexer.rb +673 -0
- data/test/test_gem_install_update_options.rb +68 -0
- data/test/test_gem_installer.rb +857 -0
- data/test/test_gem_local_remote_options.rb +97 -0
- data/test/test_gem_package_tar_header.rb +130 -0
- data/test/test_gem_package_tar_input.rb +112 -0
- data/test/test_gem_package_tar_output.rb +97 -0
- data/test/test_gem_package_tar_reader.rb +46 -0
- data/test/test_gem_package_tar_reader_entry.rb +109 -0
- data/test/test_gem_package_tar_writer.rb +144 -0
- data/test/test_gem_package_task.rb +59 -0
- data/test/test_gem_platform.rb +264 -0
- data/test/test_gem_remote_fetcher.rb +740 -0
- data/test/test_gem_requirement.rb +292 -0
- data/test/test_gem_server.rb +356 -0
- data/test/test_gem_silent_ui.rb +113 -0
- data/test/test_gem_source_index.rb +461 -0
- data/test/test_gem_spec_fetcher.rb +410 -0
- data/test/test_gem_specification.rb +1334 -0
- data/test/test_gem_stream_ui.rb +218 -0
- data/test/test_gem_text.rb +43 -0
- data/test/test_gem_uninstaller.rb +146 -0
- data/test/test_gem_validator.rb +63 -0
- data/test/test_gem_version.rb +181 -0
- data/test/test_gem_version_option.rb +89 -0
- data/test/test_kernel.rb +59 -0
- metadata +402 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#++
|
6
|
+
|
7
|
+
require 'libgems'
|
8
|
+
|
9
|
+
##
|
10
|
+
# Mixin methods for --version and --platform LibGems::Command options.
|
11
|
+
|
12
|
+
module LibGems::VersionOption
|
13
|
+
|
14
|
+
##
|
15
|
+
# Add the --platform option to the option parser.
|
16
|
+
|
17
|
+
def add_platform_option(task = command, *wrap)
|
18
|
+
OptionParser.accept LibGems::Platform do |value|
|
19
|
+
if value == LibGems::Platform::RUBY then
|
20
|
+
value
|
21
|
+
else
|
22
|
+
LibGems::Platform.new value
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
add_option('--platform PLATFORM', LibGems::Platform,
|
27
|
+
"Specify the platform of gem to #{task}", *wrap) do
|
28
|
+
|value, options|
|
29
|
+
unless options[:added_platform] then
|
30
|
+
LibGems.platforms = [LibGems::Platform::RUBY]
|
31
|
+
options[:added_platform] = true
|
32
|
+
end
|
33
|
+
|
34
|
+
LibGems.platforms << value unless LibGems.platforms.include? value
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Add the --prerelease option to the option parser.
|
40
|
+
|
41
|
+
def add_prerelease_option(*wrap)
|
42
|
+
add_option("--[no-]prerelease",
|
43
|
+
"Allow prerelease versions of a gem", *wrap) do |value, options|
|
44
|
+
options[:prerelease] = value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Add the --version option to the option parser.
|
50
|
+
|
51
|
+
def add_version_option(task = command, *wrap)
|
52
|
+
OptionParser.accept LibGems::Requirement do |value|
|
53
|
+
LibGems::Requirement.new value
|
54
|
+
end
|
55
|
+
|
56
|
+
add_option('-v', '--version VERSION', LibGems::Requirement,
|
57
|
+
"Specify version of gem to #{task}", *wrap) do
|
58
|
+
|value, options|
|
59
|
+
options[:version] = value
|
60
|
+
options[:prerelease] = true if value.prerelease?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#++
|
6
|
+
|
7
|
+
module RbConfig
|
8
|
+
|
9
|
+
##
|
10
|
+
# Return the path to the data directory associated with the given package
|
11
|
+
# name. Normally this is just
|
12
|
+
# "#{RbConfig::CONFIG['datadir']}/#{package_name}", but may be modified by
|
13
|
+
# packages like SlimGems to handle versioned data directories.
|
14
|
+
|
15
|
+
def self.datadir(package_name)
|
16
|
+
File.join(CONFIG['datadir'], package_name)
|
17
|
+
end unless RbConfig.respond_to?(:datadir)
|
18
|
+
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
-----BEGIN RSA PRIVATE KEY-----
|
2
|
+
MIIEpQIBAAKCAQEAz0tTOtsJuHDKAEXrQx0f6DUEzBEUTSLR1fk0iEHsY9rDCQxm
|
3
|
+
sw5Bf2UnVhdD03B4/XzIK+pat2CMQc37/vLIBuVgS7g/fzatGiM0m5rAHtycr0XU
|
4
|
+
8Ek6zjx4iSv70OLjybY+/utHCEc838awGDMCFR21jYxgATPVwqAIyasvwbKh/Vhw
|
5
|
+
uErFPqT9G8BKTHsaX+H+ADIRH001OmWkjB6EyjF05114kNMa0+2C7daV9hoBL3md
|
6
|
+
hCt6zOGcapl/9LkGxhcNEUB/So16V1ZQldg9macGyWktyNTSfctlF+f8okAmicG3
|
7
|
+
XIwaW8UTmjFCmvDs/h1R/uKpe2IOHz87n29d2QIDAQABAoIBAQCR6n/nyg+JmTtX
|
8
|
+
/d+hGns/RTLfQpZ7xarXZ9gmoeD4WSE42VXhbIOGXXnXDAFecKl6Jb/xycGZm4if
|
9
|
+
OZPM3rEWyZeDNWrc7WvkHiwF7GSYVMqmRg2iJqoSSla+mAtl+pBFiNfHMW6K0Tp0
|
10
|
+
erOyFRW+L2+A9/MMZaRun6AP9URkn0jz2kwmMFf+6szmzVn6fPFzZDRI+hEeaDmi
|
11
|
+
LBzSrfrddrIBX+xGEoBj6RmfnKBCSUVSSxOauYjd4mVjVYxvMH4SV1hXDUS5GPl5
|
12
|
+
MbCiBb7bpNIg/8ljMoRrQiqk0XwwS7MaCqPtMhUtpSmC/zSjAfmoN7AOc/Xh69cQ
|
13
|
+
OCMNZH9BAoGBAPBlsuuU6fg0gVTKDdR12jHx03uRRt8/nPxHnpJkZCIh9XKh1LtY
|
14
|
+
bkumi9HZpp3mzDiaGg/rwfCwNckKx8NLhICLgkric6ClrKftxTu6C8tBAb5YDi6u
|
15
|
+
74KYnV8lMY/unzBtIloPgM3uluS292POmrWZpKwhvHLD71MewzMor5HFAoGBANy/
|
16
|
+
mwsBs8i3Gzk8Twjq8effhPpE7kpxhC7bhwmjX3q41EjQWDT8M6xb1P9dRSsCIebi
|
17
|
+
kqP1yhl27dJpA8r5WqE/z89xhBvObAGRv41eXxOI0LaH2k5lJQrUeSC+51dy+BEB
|
18
|
+
T3GXD4C5ezZHQ8Wz/oL73uikrfhD+AqOZT2YbMEFAoGBAJvWEWpOGm3f+4bvhI+Z
|
19
|
+
5lxCG4oa3wqRvj58XvsfQRovUWGCLtlTtgwsZq8enLf3iaOXohV4Czzvva4Z4u1i
|
20
|
+
4v5BcbEBo1scixRBOn5BWKvl9C9j/a2dkX3jWQD4p2xaj69gz8f6DNFyPTb+tNhq
|
21
|
+
cjgO5YUASZ1MDrSfWIKteULRAoGAZkZv8x2KyofrmQ0UITGZerDYz4t4TA1kDMGx
|
22
|
+
QwnqhtVzpXjCJWpkFotFmDsCfPaz9mErR8PtKvcrIL1/AF+fWe5Sve3+I1P0PpXk
|
23
|
+
hf8fVdGhwbAXuRKrouTmagGI9b9Sp65PvHUcvasyJufFwqeuV8mScX87CzeSiHGI
|
24
|
+
/ozMdnECgYEAq4+losrhe0DEmiC9zVPvwRXjbSixDsSJxHfOcqIsZqhUgBiZ4TJD
|
25
|
+
SrkuukrMZib6BAD+PtCJS1TBbJyyvL3QecizhHSIh3ZnT0HnaRPatLEYmU65+3kE
|
26
|
+
kTqL4ik92bJnnWowy677sydl1lzBJDVa9ZlTs7BFSd8y/0DZaUxGg2I=
|
27
|
+
-----END RSA PRIVATE KEY-----
|
@@ -0,0 +1,20 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMREwDwYDVQQDDAhydWJ5
|
3
|
+
Z2VtczEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUxEzARBgoJkiaJk/IsZAEZFgNj
|
4
|
+
b20wHhcNMDcwODAyMDMyNTQyWhcNMDgwODAxMDMyNTQyWjBBMREwDwYDVQQDDAhy
|
5
|
+
dWJ5Z2VtczEXMBUGCgmSJomT8ixkARkWB2V4YW1wbGUxEzARBgoJkiaJk/IsZAEZ
|
6
|
+
FgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPS1M62wm4cMoA
|
7
|
+
RetDHR/oNQTMERRNItHV+TSIQexj2sMJDGazDkF/ZSdWF0PTcHj9fMgr6lq3YIxB
|
8
|
+
zfv+8sgG5WBLuD9/Nq0aIzSbmsAe3JyvRdTwSTrOPHiJK/vQ4uPJtj7+60cIRzzf
|
9
|
+
xrAYMwIVHbWNjGABM9XCoAjJqy/BsqH9WHC4SsU+pP0bwEpMexpf4f4AMhEfTTU6
|
10
|
+
ZaSMHoTKMXTnXXiQ0xrT7YLt1pX2GgEveZ2EK3rM4ZxqmX/0uQbGFw0RQH9KjXpX
|
11
|
+
VlCV2D2ZpwbJaS3I1NJ9y2UX5/yiQCaJwbdcjBpbxROaMUKa8Oz+HVH+4ql7Yg4f
|
12
|
+
Pzufb13ZAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
|
13
|
+
BBRYTAoj4cn8CWZMHFnHGQgoO5jyFTANBgkqhkiG9w0BAQUFAAOCAQEATRrJC05l
|
14
|
+
dOmx67Sy3bU+AVXkOr7B9nn2Myqo9uSIAncPoElN6aHr/Q8wOOjtok4r0JcHPe1e
|
15
|
+
eotDCZUE1Jkl13Tpv26rOfOOUHtGlyAIAtpsUGOraaJkSut4WKLr1/KckyAAEtgP
|
16
|
+
c13A0s0mEiWFRuYxIdEi54561pTT2qQBE/DUPGoYD5rUg9XYAlSovMMwG99Oca7L
|
17
|
+
cI6vCymr1bzzddExoywBNOy0fbBT62I3ICBGbH5yOVVKVmlxeo2Zp10FCj0kDrnq
|
18
|
+
OuMJSDr5I2XPYqoC+W4YSbwn55o2jGIUX1lOq2Hvj4tFgSxlnJZn0tUhBfR3gSOn
|
19
|
+
IFnrqu8PlZsLFw==
|
20
|
+
-----END CERTIFICATE-----
|
File without changes
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'libgems/installer'
|
3
|
+
|
4
|
+
class LibGems::Installer
|
5
|
+
attr_accessor :gem_dir
|
6
|
+
|
7
|
+
attr_writer :format
|
8
|
+
attr_writer :gem_home
|
9
|
+
attr_writer :env_shebang
|
10
|
+
attr_writer :ignore_dependencies
|
11
|
+
attr_writer :format_executable
|
12
|
+
attr_writer :security_policy
|
13
|
+
attr_writer :spec
|
14
|
+
attr_writer :wrappers
|
15
|
+
end
|
16
|
+
|
17
|
+
class LibGemsInstallerTestCase < RubyGemTestCase
|
18
|
+
|
19
|
+
def setup
|
20
|
+
super
|
21
|
+
|
22
|
+
@spec = quick_gem 'a'
|
23
|
+
@gem = File.join @tempdir, @spec.file_name
|
24
|
+
|
25
|
+
@installer = util_installer @spec, @gem, @gemhome
|
26
|
+
|
27
|
+
@user_spec = quick_gem 'b'
|
28
|
+
@user_gem = File.join @tempdir, @user_spec.file_name
|
29
|
+
|
30
|
+
@user_installer = util_installer @user_spec, @user_gem, LibGems.user_dir
|
31
|
+
@user_installer.gem_dir = File.join(LibGems.user_dir, 'gems',
|
32
|
+
@user_spec.full_name)
|
33
|
+
end
|
34
|
+
|
35
|
+
def util_gem_bindir(version = '2')
|
36
|
+
File.join util_gem_dir(version), "bin"
|
37
|
+
end
|
38
|
+
|
39
|
+
def util_gem_dir(version = '2')
|
40
|
+
File.join @gemhome, "gems", "a-#{version}" # HACK
|
41
|
+
end
|
42
|
+
|
43
|
+
def util_inst_bindir
|
44
|
+
File.join @gemhome, "bin"
|
45
|
+
end
|
46
|
+
|
47
|
+
def util_make_exec(version = '2', shebang = "#!/usr/bin/ruby")
|
48
|
+
@spec.executables = ["my_exec"]
|
49
|
+
|
50
|
+
FileUtils.mkdir_p util_gem_bindir(version)
|
51
|
+
exec_path = File.join util_gem_bindir(version), "my_exec"
|
52
|
+
File.open exec_path, 'w' do |f|
|
53
|
+
f.puts shebang
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def util_setup_gem(ui = @ui) # HACK fix use_ui to make this automatic
|
58
|
+
@spec.files = File.join('lib', 'code.rb')
|
59
|
+
@spec.executables << 'executable'
|
60
|
+
@spec.extensions << File.join('ext', 'a', 'mkrf_conf.rb')
|
61
|
+
|
62
|
+
Dir.chdir @tempdir do
|
63
|
+
FileUtils.mkdir_p 'bin'
|
64
|
+
FileUtils.mkdir_p 'lib'
|
65
|
+
FileUtils.mkdir_p File.join('ext', 'a')
|
66
|
+
File.open File.join('bin', 'executable'), 'w' do |f| f.puts '1' end
|
67
|
+
File.open File.join('lib', 'code.rb'), 'w' do |f| f.puts '1' end
|
68
|
+
File.open File.join('ext', 'a', 'mkrf_conf.rb'), 'w' do |f|
|
69
|
+
f << <<-EOF
|
70
|
+
File.open 'Rakefile', 'w' do |rf| rf.puts "task :default" end
|
71
|
+
EOF
|
72
|
+
end
|
73
|
+
|
74
|
+
use_ui ui do
|
75
|
+
FileUtils.rm @gem
|
76
|
+
LibGems::Builder.new(@spec).build
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
@installer = LibGems::Installer.new @gem
|
81
|
+
end
|
82
|
+
|
83
|
+
def util_installer(spec, gem_path, gem_home)
|
84
|
+
util_build_gem spec
|
85
|
+
FileUtils.mv File.join(@gemhome, 'cache', spec.file_name),
|
86
|
+
@tempdir
|
87
|
+
|
88
|
+
installer = LibGems::Installer.new gem_path
|
89
|
+
installer.gem_dir = util_gem_dir
|
90
|
+
installer.gem_home = gem_home
|
91
|
+
installer.spec = spec
|
92
|
+
|
93
|
+
installer
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
@@ -0,0 +1,132 @@
|
|
1
|
+
require File.expand_path('../gemutilities', __FILE__)
|
2
|
+
require 'libgems/package'
|
3
|
+
|
4
|
+
class TarTestCase < RubyGemTestCase
|
5
|
+
|
6
|
+
def ASCIIZ(str, length)
|
7
|
+
str + "\0" * (length - str.length)
|
8
|
+
end
|
9
|
+
|
10
|
+
def SP(s)
|
11
|
+
s + " "
|
12
|
+
end
|
13
|
+
|
14
|
+
def SP_Z(s)
|
15
|
+
s + " \0"
|
16
|
+
end
|
17
|
+
|
18
|
+
def Z(s)
|
19
|
+
s + "\0"
|
20
|
+
end
|
21
|
+
|
22
|
+
def assert_headers_equal(expected, actual)
|
23
|
+
expected = expected.to_s unless String === expected
|
24
|
+
actual = actual.to_s unless String === actual
|
25
|
+
|
26
|
+
fields = %w[
|
27
|
+
name 100
|
28
|
+
mode 8
|
29
|
+
uid 8
|
30
|
+
gid 8
|
31
|
+
size 12
|
32
|
+
mtime 12
|
33
|
+
checksum 8
|
34
|
+
typeflag 1
|
35
|
+
linkname 100
|
36
|
+
magic 6
|
37
|
+
version 2
|
38
|
+
uname 32
|
39
|
+
gname 32
|
40
|
+
devmajor 8
|
41
|
+
devminor 8
|
42
|
+
prefix 155
|
43
|
+
]
|
44
|
+
|
45
|
+
offset = 0
|
46
|
+
|
47
|
+
until fields.empty? do
|
48
|
+
name = fields.shift
|
49
|
+
length = fields.shift.to_i
|
50
|
+
|
51
|
+
if name == "checksum" then
|
52
|
+
chksum_off = offset
|
53
|
+
offset += length
|
54
|
+
next
|
55
|
+
end
|
56
|
+
|
57
|
+
assert_equal expected[offset, length], actual[offset, length],
|
58
|
+
"Field #{name} of the tar header differs."
|
59
|
+
|
60
|
+
offset += length
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_equal expected[chksum_off, 8], actual[chksum_off, 8]
|
64
|
+
end
|
65
|
+
|
66
|
+
def calc_checksum(header)
|
67
|
+
sum = header.unpack("C*").inject{|s,a| s + a}
|
68
|
+
SP(Z(to_oct(sum, 6)))
|
69
|
+
end
|
70
|
+
|
71
|
+
def header(type, fname, dname, length, mode, checksum = nil)
|
72
|
+
checksum ||= " " * 8
|
73
|
+
|
74
|
+
arr = [ # struct tarfile_entry_posix
|
75
|
+
ASCIIZ(fname, 100), # char name[100]; ASCII + (Z unless filled)
|
76
|
+
Z(to_oct(mode, 7)), # char mode[8]; 0 padded, octal null
|
77
|
+
Z(to_oct(0, 7)), # char uid[8]; ditto
|
78
|
+
Z(to_oct(0, 7)), # char gid[8]; ditto
|
79
|
+
Z(to_oct(length, 11)), # char size[12]; 0 padded, octal, null
|
80
|
+
Z(to_oct(0, 11)), # char mtime[12]; 0 padded, octal, null
|
81
|
+
checksum, # char checksum[8]; 0 padded, octal, null, space
|
82
|
+
type, # char typeflag[1]; file: "0" dir: "5"
|
83
|
+
"\0" * 100, # char linkname[100]; ASCII + (Z unless filled)
|
84
|
+
"ustar\0", # char magic[6]; "ustar\0"
|
85
|
+
"00", # char version[2]; "00"
|
86
|
+
ASCIIZ("wheel", 32), # char uname[32]; ASCIIZ
|
87
|
+
ASCIIZ("wheel", 32), # char gname[32]; ASCIIZ
|
88
|
+
Z(to_oct(0, 7)), # char devmajor[8]; 0 padded, octal, null
|
89
|
+
Z(to_oct(0, 7)), # char devminor[8]; 0 padded, octal, null
|
90
|
+
ASCIIZ(dname, 155) # char prefix[155]; ASCII + (Z unless filled)
|
91
|
+
]
|
92
|
+
|
93
|
+
format = "C100C8C8C8C12C12C8CC100C6C2C32C32C8C8C155"
|
94
|
+
h = if RUBY_VERSION >= "1.9" then
|
95
|
+
arr.join
|
96
|
+
else
|
97
|
+
arr = arr.join("").split(//).map{|x| x[0]}
|
98
|
+
arr.pack format
|
99
|
+
end
|
100
|
+
ret = h + "\0" * (512 - h.size)
|
101
|
+
assert_equal(512, ret.size)
|
102
|
+
ret
|
103
|
+
end
|
104
|
+
|
105
|
+
def tar_dir_header(name, prefix, mode)
|
106
|
+
h = header("5", name, prefix, 0, mode)
|
107
|
+
checksum = calc_checksum(h)
|
108
|
+
header("5", name, prefix, 0, mode, checksum)
|
109
|
+
end
|
110
|
+
|
111
|
+
def tar_file_header(fname, dname, mode, length)
|
112
|
+
h = header("0", fname, dname, length, mode)
|
113
|
+
checksum = calc_checksum(h)
|
114
|
+
header("0", fname, dname, length, mode, checksum)
|
115
|
+
end
|
116
|
+
|
117
|
+
def to_oct(n, pad_size)
|
118
|
+
"%0#{pad_size}o" % n
|
119
|
+
end
|
120
|
+
|
121
|
+
def util_entry(tar)
|
122
|
+
io = TempIO.new tar
|
123
|
+
header = LibGems::Package::TarHeader.from io
|
124
|
+
entry = LibGems::Package::TarReader::Entry.new header, io
|
125
|
+
end
|
126
|
+
|
127
|
+
def util_dir_entry
|
128
|
+
util_entry tar_dir_header("foo", "bar", 0)
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
@@ -0,0 +1,605 @@
|
|
1
|
+
at_exit { $SAFE = 1 }
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
4
|
+
|
5
|
+
if defined? LibGems::QuickLoader
|
6
|
+
LibGems::QuickLoader.load_full_rubygems_library
|
7
|
+
else
|
8
|
+
require 'libgems'
|
9
|
+
end
|
10
|
+
require 'fileutils'
|
11
|
+
require 'minitest/autorun'
|
12
|
+
require 'tmpdir'
|
13
|
+
require 'uri'
|
14
|
+
require 'libgems/package'
|
15
|
+
require 'libgems/test_utilities'
|
16
|
+
require 'pp'
|
17
|
+
require 'zlib'
|
18
|
+
LibGems.load_yaml
|
19
|
+
|
20
|
+
begin
|
21
|
+
gem 'rdoc'
|
22
|
+
rescue LibGems::LoadError
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'rdoc/rdoc'
|
26
|
+
|
27
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'mockgemui')
|
28
|
+
|
29
|
+
module LibGems
|
30
|
+
def self.searcher=(searcher)
|
31
|
+
@searcher = searcher
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.source_index=(si)
|
35
|
+
@@source_index = si
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.win_platform=(val)
|
39
|
+
@@win_platform = val
|
40
|
+
end
|
41
|
+
|
42
|
+
module DefaultUserInteraction
|
43
|
+
@ui = MockGemUi.new
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class RubyGemTestCase < MiniTest::Unit::TestCase
|
48
|
+
|
49
|
+
include LibGems::DefaultUserInteraction
|
50
|
+
|
51
|
+
undef_method :default_test if instance_methods.include? 'default_test' or
|
52
|
+
instance_methods.include? :default_test
|
53
|
+
|
54
|
+
def setup
|
55
|
+
super
|
56
|
+
|
57
|
+
@ui = MockGemUi.new
|
58
|
+
tmpdir = nil
|
59
|
+
Dir.chdir Dir.tmpdir do tmpdir = Dir.pwd end # HACK OSX /private/tmp
|
60
|
+
@tempdir = File.join tmpdir, "test_rubygems_#{$$}"
|
61
|
+
@tempdir.untaint
|
62
|
+
@gemhome = File.join @tempdir, "gemhome"
|
63
|
+
@gemcache = File.join(@gemhome, "source_cache")
|
64
|
+
@usrcache = File.join(@gemhome, ".gem", "user_cache")
|
65
|
+
@latest_usrcache = File.join(@gemhome, ".gem", "latest_user_cache")
|
66
|
+
@userhome = File.join @tempdir, 'userhome'
|
67
|
+
|
68
|
+
LibGems.ensure_gem_subdirectories @gemhome
|
69
|
+
|
70
|
+
@orig_ruby = if ruby = ENV['RUBY'] then
|
71
|
+
LibGems.class_eval { ruby, @ruby = @ruby, ruby }
|
72
|
+
ruby
|
73
|
+
end
|
74
|
+
|
75
|
+
LibGems.ensure_gem_subdirectories @gemhome
|
76
|
+
|
77
|
+
@orig_ENV_HOME = ENV['HOME']
|
78
|
+
ENV['HOME'] = @userhome
|
79
|
+
LibGems.instance_variable_set :@user_home, nil
|
80
|
+
|
81
|
+
FileUtils.mkdir_p @gemhome
|
82
|
+
FileUtils.mkdir_p @userhome
|
83
|
+
|
84
|
+
ENV['LIBGEMSCACHE'] = @usrcache
|
85
|
+
LibGems.use_paths(@gemhome)
|
86
|
+
LibGems.loaded_specs.clear
|
87
|
+
|
88
|
+
LibGems.configuration.verbose = true
|
89
|
+
LibGems.configuration.update_sources = true
|
90
|
+
|
91
|
+
@gem_repo = "http://gems.example.com/"
|
92
|
+
@uri = URI.parse @gem_repo
|
93
|
+
LibGems.sources.replace [@gem_repo]
|
94
|
+
|
95
|
+
LibGems::SpecFetcher.fetcher = nil
|
96
|
+
|
97
|
+
@orig_BASERUBY = LibGems::ConfigMap[:BASERUBY]
|
98
|
+
LibGems::ConfigMap[:BASERUBY] = LibGems::ConfigMap[:ruby_install_name]
|
99
|
+
|
100
|
+
@orig_arch = LibGems::ConfigMap[:arch]
|
101
|
+
|
102
|
+
if win_platform?
|
103
|
+
util_set_arch 'i386-mswin32'
|
104
|
+
else
|
105
|
+
util_set_arch 'i686-darwin8.10.1'
|
106
|
+
end
|
107
|
+
|
108
|
+
@marshal_version = "#{Marshal::MAJOR_VERSION}.#{Marshal::MINOR_VERSION}"
|
109
|
+
|
110
|
+
@private_key = File.expand_path File.join(File.dirname(__FILE__),
|
111
|
+
'private_key.pem')
|
112
|
+
@public_cert = File.expand_path File.join(File.dirname(__FILE__),
|
113
|
+
'public_cert.pem')
|
114
|
+
|
115
|
+
LibGems.post_install_hooks.clear
|
116
|
+
LibGems.post_uninstall_hooks.clear
|
117
|
+
LibGems.pre_install_hooks.clear
|
118
|
+
LibGems.pre_uninstall_hooks.clear
|
119
|
+
|
120
|
+
LibGems.post_install do |installer|
|
121
|
+
@post_install_hook_arg = installer
|
122
|
+
end
|
123
|
+
|
124
|
+
LibGems.post_uninstall do |uninstaller|
|
125
|
+
@post_uninstall_hook_arg = uninstaller
|
126
|
+
end
|
127
|
+
|
128
|
+
LibGems.pre_install do |installer|
|
129
|
+
@pre_install_hook_arg = installer
|
130
|
+
end
|
131
|
+
|
132
|
+
LibGems.pre_uninstall do |uninstaller|
|
133
|
+
@pre_uninstall_hook_arg = uninstaller
|
134
|
+
end
|
135
|
+
|
136
|
+
@orig_LOAD_PATH = $LOAD_PATH.dup
|
137
|
+
end
|
138
|
+
|
139
|
+
def teardown
|
140
|
+
$LOAD_PATH.replace @orig_LOAD_PATH
|
141
|
+
|
142
|
+
LibGems::ConfigMap[:BASERUBY] = @orig_BASERUBY
|
143
|
+
LibGems::ConfigMap[:arch] = @orig_arch
|
144
|
+
|
145
|
+
if defined? LibGems::RemoteFetcher then
|
146
|
+
LibGems::RemoteFetcher.fetcher = nil
|
147
|
+
end
|
148
|
+
|
149
|
+
FileUtils.rm_rf @tempdir
|
150
|
+
|
151
|
+
ENV.delete 'LIBGEMSCACHE'
|
152
|
+
ENV.delete 'LIBGEMS_HOME'
|
153
|
+
ENV.delete 'LIBGEMS_PATH'
|
154
|
+
|
155
|
+
LibGems.clear_paths
|
156
|
+
|
157
|
+
LibGems.class_eval { @ruby = ruby } if ruby = @orig_ruby
|
158
|
+
|
159
|
+
if @orig_ENV_HOME then
|
160
|
+
ENV['HOME'] = @orig_ENV_HOME
|
161
|
+
else
|
162
|
+
ENV.delete 'HOME'
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
def install_gem gem
|
167
|
+
require 'libgems/installer'
|
168
|
+
|
169
|
+
use_ui MockGemUi.new do
|
170
|
+
Dir.chdir @tempdir do
|
171
|
+
LibGems::Builder.new(gem).build
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
gem = File.join(@tempdir, gem.file_name).untaint
|
176
|
+
LibGems::Installer.new(gem, :wrappers => true).install
|
177
|
+
end
|
178
|
+
|
179
|
+
def uninstall_gem gem
|
180
|
+
require 'libgems/uninstaller'
|
181
|
+
|
182
|
+
uninstaller = LibGems::Uninstaller.new gem.name, :executables => true,
|
183
|
+
:user_install => true
|
184
|
+
uninstaller.uninstall
|
185
|
+
end
|
186
|
+
|
187
|
+
def mu_pp(obj)
|
188
|
+
s = ''
|
189
|
+
s = PP.pp obj, s
|
190
|
+
s = s.force_encoding(Encoding.default_external) if defined? Encoding
|
191
|
+
s.chomp
|
192
|
+
end
|
193
|
+
|
194
|
+
def prep_cache_files(lc)
|
195
|
+
@usr_si ||= LibGems::SourceIndex.new
|
196
|
+
@usr_sice ||= LibGems::SourceInfoCacheEntry.new @usr_si, 0
|
197
|
+
|
198
|
+
@sys_si ||= LibGems::SourceIndex.new
|
199
|
+
@sys_sice ||= LibGems::SourceInfoCacheEntry.new @sys_si, 0
|
200
|
+
|
201
|
+
latest_si = LibGems::SourceIndex.new
|
202
|
+
latest_si.add_specs(*@sys_si.latest_specs)
|
203
|
+
latest_sys_sice = LibGems::SourceInfoCacheEntry.new latest_si, 0
|
204
|
+
|
205
|
+
latest_si = LibGems::SourceIndex.new
|
206
|
+
latest_si.add_specs(*@usr_si.latest_specs)
|
207
|
+
latest_usr_sice = LibGems::SourceInfoCacheEntry.new latest_si, 0
|
208
|
+
|
209
|
+
[ [lc.system_cache_file, @sys_sice],
|
210
|
+
[lc.latest_system_cache_file, latest_sys_sice],
|
211
|
+
[lc.user_cache_file, @usr_sice],
|
212
|
+
[lc.latest_user_cache_file, latest_usr_sice],
|
213
|
+
].each do |filename, data|
|
214
|
+
FileUtils.mkdir_p File.dirname(filename).untaint
|
215
|
+
|
216
|
+
open filename.dup.untaint, 'wb' do |f|
|
217
|
+
f.write Marshal.dump({ @gem_repo => data })
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def read_cache(path)
|
223
|
+
open path.dup.untaint, 'rb' do |io|
|
224
|
+
Marshal.load io.read
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
def read_binary(path)
|
229
|
+
LibGems.read_binary path
|
230
|
+
end
|
231
|
+
|
232
|
+
def write_file(path)
|
233
|
+
path = File.join(@gemhome, path)
|
234
|
+
dir = File.dirname path
|
235
|
+
FileUtils.mkdir_p dir
|
236
|
+
|
237
|
+
open path, 'wb' do |io|
|
238
|
+
yield io if block_given?
|
239
|
+
end
|
240
|
+
|
241
|
+
path
|
242
|
+
end
|
243
|
+
|
244
|
+
def quick_gem(gemname, version='2')
|
245
|
+
require 'libgems/specification'
|
246
|
+
|
247
|
+
spec = LibGems::Specification.new do |s|
|
248
|
+
s.platform = LibGems::Platform::RUBY
|
249
|
+
s.name = gemname
|
250
|
+
s.version = version
|
251
|
+
s.author = 'A User'
|
252
|
+
s.email = 'example@example.com'
|
253
|
+
s.homepage = 'http://example.com'
|
254
|
+
s.has_rdoc = true
|
255
|
+
s.summary = "this is a summary"
|
256
|
+
s.description = "This is a test description"
|
257
|
+
|
258
|
+
yield(s) if block_given?
|
259
|
+
end
|
260
|
+
|
261
|
+
path = File.join "specifications", spec.spec_name
|
262
|
+
written_path = write_file path do |io|
|
263
|
+
io.write(spec.to_ruby)
|
264
|
+
end
|
265
|
+
|
266
|
+
spec.loaded_from = written_path
|
267
|
+
|
268
|
+
LibGems.source_index.add_spec spec
|
269
|
+
|
270
|
+
return spec
|
271
|
+
end
|
272
|
+
|
273
|
+
def util_build_gem(spec)
|
274
|
+
dir = File.join(@gemhome, 'gems', spec.full_name)
|
275
|
+
FileUtils.mkdir_p dir
|
276
|
+
|
277
|
+
Dir.chdir dir do
|
278
|
+
spec.files.each do |file|
|
279
|
+
next if File.exist? file
|
280
|
+
FileUtils.mkdir_p File.dirname(file)
|
281
|
+
File.open file, 'w' do |fp| fp.puts "# #{file}" end
|
282
|
+
end
|
283
|
+
|
284
|
+
use_ui MockGemUi.new do
|
285
|
+
LibGems::Builder.new(spec).build
|
286
|
+
end
|
287
|
+
|
288
|
+
FileUtils.mv spec.file_name,
|
289
|
+
File.join(@gemhome, 'cache', "#{spec.original_name}.gem")
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
def util_clear_gems
|
294
|
+
FileUtils.rm_r File.join(@gemhome, 'gems')
|
295
|
+
FileUtils.rm_r File.join(@gemhome, 'specifications')
|
296
|
+
LibGems.source_index.refresh!
|
297
|
+
end
|
298
|
+
|
299
|
+
def util_gem(name, version, deps = nil, &block)
|
300
|
+
if deps then # fuck you eric
|
301
|
+
block = proc do |s|
|
302
|
+
deps.each do |n, req|
|
303
|
+
s.add_dependency n, (req || '>= 0')
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
spec = quick_gem(name, version, &block)
|
309
|
+
|
310
|
+
util_build_gem spec
|
311
|
+
|
312
|
+
cache_file = File.join @tempdir, 'gems', "#{spec.original_name}.gem"
|
313
|
+
FileUtils.mv File.join(@gemhome, 'cache', "#{spec.original_name}.gem"),
|
314
|
+
cache_file
|
315
|
+
FileUtils.rm File.join(@gemhome, 'specifications', spec.spec_name)
|
316
|
+
|
317
|
+
spec.loaded_from = nil
|
318
|
+
spec.loaded = false
|
319
|
+
|
320
|
+
[spec, cache_file]
|
321
|
+
end
|
322
|
+
|
323
|
+
def util_gzip(data)
|
324
|
+
out = StringIO.new
|
325
|
+
|
326
|
+
Zlib::GzipWriter.wrap out do |io|
|
327
|
+
io.write data
|
328
|
+
end
|
329
|
+
|
330
|
+
out.string
|
331
|
+
end
|
332
|
+
|
333
|
+
def util_make_gems(prerelease = false)
|
334
|
+
@a1 = quick_gem 'a', '1' do |s|
|
335
|
+
s.files = %w[lib/code.rb]
|
336
|
+
s.require_paths = %w[lib]
|
337
|
+
s.date = LibGems::Specification::TODAY - 86400
|
338
|
+
s.homepage = 'http://a.example.com'
|
339
|
+
s.email = %w[example@example.com example2@example.com]
|
340
|
+
s.authors = %w[Example Example2]
|
341
|
+
s.description = <<-DESC
|
342
|
+
This line is really, really long. So long, in fact, that it is more than eighty characters long! The purpose of this line is for testing wrapping behavior because sometimes people don't wrap their text to eighty characters. Without the wrapping, the text might not look good in the RSS feed.
|
343
|
+
|
344
|
+
Also, a list:
|
345
|
+
* An entry that's actually kind of sort
|
346
|
+
* an entry that's really long, which will probably get wrapped funny. That's ok, somebody wasn't thinking straight when they made it more than eighty characters.
|
347
|
+
DESC
|
348
|
+
end
|
349
|
+
|
350
|
+
init = proc do |s|
|
351
|
+
s.files = %w[lib/code.rb]
|
352
|
+
s.require_paths = %w[lib]
|
353
|
+
end
|
354
|
+
|
355
|
+
@a2 = quick_gem('a', '2', &init)
|
356
|
+
@a3a = quick_gem('a', '3.a', &init)
|
357
|
+
@a_evil9 = quick_gem('a_evil', '9', &init)
|
358
|
+
@b2 = quick_gem('b', '2', &init)
|
359
|
+
@c1_2 = quick_gem('c', '1.2', &init)
|
360
|
+
@pl1 = quick_gem 'pl', '1' do |s| # l for legacy
|
361
|
+
s.files = %w[lib/code.rb]
|
362
|
+
s.require_paths = %w[lib]
|
363
|
+
s.platform = LibGems::Platform.new 'i386-linux'
|
364
|
+
s.instance_variable_set :@original_platform, 'i386-linux'
|
365
|
+
end
|
366
|
+
|
367
|
+
if prerelease
|
368
|
+
@a2_pre = quick_gem('a', '2.a', &init)
|
369
|
+
write_file File.join(*%W[gems #{@a2_pre.original_name} lib code.rb]) do
|
370
|
+
end
|
371
|
+
util_build_gem @a2_pre
|
372
|
+
end
|
373
|
+
|
374
|
+
write_file File.join(*%W[gems #{@a1.original_name} lib code.rb]) do end
|
375
|
+
write_file File.join(*%W[gems #{@a2.original_name} lib code.rb]) do end
|
376
|
+
write_file File.join(*%W[gems #{@a3a.original_name} lib code.rb]) do end
|
377
|
+
write_file File.join(*%W[gems #{@b2.original_name} lib code.rb]) do end
|
378
|
+
write_file File.join(*%W[gems #{@c1_2.original_name} lib code.rb]) do end
|
379
|
+
write_file File.join(*%W[gems #{@pl1.original_name} lib code.rb]) do end
|
380
|
+
|
381
|
+
[@a1, @a2, @a3a, @a_evil9, @b2, @c1_2, @pl1].each do |spec|
|
382
|
+
util_build_gem spec
|
383
|
+
end
|
384
|
+
|
385
|
+
FileUtils.rm_r File.join(@gemhome, 'gems', @pl1.original_name)
|
386
|
+
|
387
|
+
LibGems.source_index = nil
|
388
|
+
end
|
389
|
+
|
390
|
+
##
|
391
|
+
# Set the platform to +arch+
|
392
|
+
|
393
|
+
def util_set_arch(arch)
|
394
|
+
LibGems::ConfigMap[:arch] = arch
|
395
|
+
platform = LibGems::Platform.new arch
|
396
|
+
|
397
|
+
LibGems.instance_variable_set :@platforms, nil
|
398
|
+
LibGems::Platform.instance_variable_set :@local, nil
|
399
|
+
|
400
|
+
platform
|
401
|
+
end
|
402
|
+
|
403
|
+
def util_setup_fake_fetcher(prerelease = false)
|
404
|
+
require 'zlib'
|
405
|
+
require 'socket'
|
406
|
+
require 'libgems/remote_fetcher'
|
407
|
+
|
408
|
+
@fetcher = LibGems::FakeFetcher.new
|
409
|
+
|
410
|
+
util_make_gems(prerelease)
|
411
|
+
|
412
|
+
@all_gems = [@a1, @a2, @a3a, @a_evil9, @b2, @c1_2].sort
|
413
|
+
@all_gem_names = @all_gems.map { |gem| gem.full_name }
|
414
|
+
|
415
|
+
gem_names = [@a1.full_name, @a2.full_name, @a3a.full_name, @b2.full_name]
|
416
|
+
@gem_names = gem_names.sort.join("\n")
|
417
|
+
|
418
|
+
@source_index = LibGems::SourceIndex.new
|
419
|
+
@source_index.add_spec @a1
|
420
|
+
@source_index.add_spec @a2
|
421
|
+
@source_index.add_spec @a3a
|
422
|
+
@source_index.add_spec @a_evil9
|
423
|
+
@source_index.add_spec @c1_2
|
424
|
+
@source_index.add_spec @a2_pre if prerelease
|
425
|
+
|
426
|
+
LibGems::RemoteFetcher.fetcher = @fetcher
|
427
|
+
end
|
428
|
+
|
429
|
+
def util_setup_spec_fetcher(*specs)
|
430
|
+
specs = Hash[*specs.map { |spec| [spec.full_name, spec] }.flatten]
|
431
|
+
si = LibGems::SourceIndex.new specs
|
432
|
+
|
433
|
+
spec_fetcher = LibGems::SpecFetcher.fetcher
|
434
|
+
|
435
|
+
spec_fetcher.specs[@uri] = []
|
436
|
+
si.gems.sort_by { |_, spec| spec }.each do |_, spec|
|
437
|
+
spec_tuple = [spec.name, spec.version, spec.original_platform]
|
438
|
+
spec_fetcher.specs[@uri] << spec_tuple
|
439
|
+
end
|
440
|
+
|
441
|
+
spec_fetcher.latest_specs[@uri] = []
|
442
|
+
si.latest_specs.sort.each do |spec|
|
443
|
+
spec_tuple = [spec.name, spec.version, spec.original_platform]
|
444
|
+
spec_fetcher.latest_specs[@uri] << spec_tuple
|
445
|
+
end
|
446
|
+
|
447
|
+
spec_fetcher.prerelease_specs[@uri] = []
|
448
|
+
si.prerelease_specs.sort.each do |spec|
|
449
|
+
spec_tuple = [spec.name, spec.version, spec.original_platform]
|
450
|
+
spec_fetcher.prerelease_specs[@uri] << spec_tuple
|
451
|
+
end
|
452
|
+
|
453
|
+
(si.gems.merge si.prerelease_gems).sort_by { |_,spec| spec }.each do |_, spec|
|
454
|
+
path = "#{@gem_repo}quick/Marshal.#{LibGems.marshal_version}/#{spec.original_name}.gemspec.rz"
|
455
|
+
data = Marshal.dump spec
|
456
|
+
data_deflate = Zlib::Deflate.deflate data
|
457
|
+
@fetcher.data[path] = data_deflate
|
458
|
+
end
|
459
|
+
|
460
|
+
si
|
461
|
+
end
|
462
|
+
|
463
|
+
def util_zip(data)
|
464
|
+
Zlib::Deflate.deflate data
|
465
|
+
end
|
466
|
+
|
467
|
+
def self.win_platform?
|
468
|
+
LibGems.win_platform?
|
469
|
+
end
|
470
|
+
|
471
|
+
def win_platform?
|
472
|
+
LibGems.win_platform?
|
473
|
+
end
|
474
|
+
|
475
|
+
# Returns whether or not we're on a version of Ruby built with VC++ (or
|
476
|
+
# Borland) versus Cygwin, Mingw, etc.
|
477
|
+
#
|
478
|
+
def self.vc_windows?
|
479
|
+
RUBY_PLATFORM.match('mswin')
|
480
|
+
end
|
481
|
+
|
482
|
+
# Returns whether or not we're on a version of Ruby built with VC++ (or
|
483
|
+
# Borland) versus Cygwin, Mingw, etc.
|
484
|
+
#
|
485
|
+
def vc_windows?
|
486
|
+
RUBY_PLATFORM.match('mswin')
|
487
|
+
end
|
488
|
+
|
489
|
+
# Returns the make command for the current platform. For versions of Ruby
|
490
|
+
# built on MS Windows with VC++ or Borland it will return 'nmake'. On all
|
491
|
+
# other platforms, including Cygwin, it will return 'make'.
|
492
|
+
#
|
493
|
+
def self.make_command
|
494
|
+
vc_windows? ? 'nmake' : 'make'
|
495
|
+
end
|
496
|
+
|
497
|
+
# Returns the make command for the current platform. For versions of Ruby
|
498
|
+
# built on MS Windows with VC++ or Borland it will return 'nmake'. On all
|
499
|
+
# other platforms, including Cygwin, it will return 'make'.
|
500
|
+
#
|
501
|
+
def make_command
|
502
|
+
vc_windows? ? 'nmake' : 'make'
|
503
|
+
end
|
504
|
+
|
505
|
+
# Returns whether or not the nmake command could be found.
|
506
|
+
#
|
507
|
+
def nmake_found?
|
508
|
+
system('nmake /? 1>NUL 2>&1')
|
509
|
+
end
|
510
|
+
|
511
|
+
# NOTE Allow tests to use a random (but controlled) port number instead of
|
512
|
+
# a hardcoded one. This helps CI tools when running parallels builds on
|
513
|
+
# the same builder slave.
|
514
|
+
def self.process_based_port
|
515
|
+
@@process_based_port ||= 8000 + $$ % 1000
|
516
|
+
end
|
517
|
+
|
518
|
+
def process_based_port
|
519
|
+
self.class.process_based_port
|
520
|
+
end
|
521
|
+
|
522
|
+
def build_rake_in
|
523
|
+
gem_ruby = LibGems.ruby
|
524
|
+
ruby = @@ruby
|
525
|
+
LibGems.module_eval {@ruby = ruby}
|
526
|
+
env_rake = ENV["rake"]
|
527
|
+
ENV["rake"] = @@rake
|
528
|
+
yield @@rake
|
529
|
+
ensure
|
530
|
+
LibGems.module_eval {@ruby = gem_ruby}
|
531
|
+
if env_rake
|
532
|
+
ENV["rake"] = env_rake
|
533
|
+
else
|
534
|
+
ENV.delete("rake")
|
535
|
+
end
|
536
|
+
end
|
537
|
+
|
538
|
+
def self.rubybin
|
539
|
+
if ruby = ENV["RUBY"]
|
540
|
+
return ruby
|
541
|
+
end
|
542
|
+
ruby = "ruby"
|
543
|
+
rubyexe = ruby+".exe"
|
544
|
+
3.times do
|
545
|
+
if File.exist? ruby and File.executable? ruby and !File.directory? ruby
|
546
|
+
return File.expand_path(ruby)
|
547
|
+
end
|
548
|
+
if File.exist? rubyexe and File.executable? rubyexe
|
549
|
+
return File.expand_path(rubyexe)
|
550
|
+
end
|
551
|
+
ruby = File.join("..", ruby)
|
552
|
+
end
|
553
|
+
begin
|
554
|
+
require "rbconfig"
|
555
|
+
File.join(
|
556
|
+
RbConfig::CONFIG["bindir"],
|
557
|
+
RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]
|
558
|
+
)
|
559
|
+
rescue LoadError
|
560
|
+
"ruby"
|
561
|
+
end
|
562
|
+
end
|
563
|
+
|
564
|
+
@@ruby = rubybin
|
565
|
+
env_rake = ENV['rake']
|
566
|
+
ruby19_rake = File.expand_path("../../../bin/rake", __FILE__)
|
567
|
+
@@rake = if env_rake then
|
568
|
+
ENV["rake"]
|
569
|
+
elsif File.exist? ruby19_rake then
|
570
|
+
@@ruby + " " + ruby19_rake
|
571
|
+
else
|
572
|
+
'rake'
|
573
|
+
end
|
574
|
+
|
575
|
+
##
|
576
|
+
# Construct a new LibGems::Dependency.
|
577
|
+
|
578
|
+
def dep name, *requirements
|
579
|
+
LibGems::Dependency.new name, *requirements
|
580
|
+
end
|
581
|
+
|
582
|
+
##
|
583
|
+
# Construct a new LibGems::Requirement.
|
584
|
+
|
585
|
+
def req *requirements
|
586
|
+
return requirements.first if LibGems::Requirement === requirements.first
|
587
|
+
LibGems::Requirement.create requirements
|
588
|
+
end
|
589
|
+
|
590
|
+
##
|
591
|
+
# Construct a new LibGems::Specification.
|
592
|
+
|
593
|
+
def spec name, version, &block
|
594
|
+
LibGems::Specification.new name, v(version), &block
|
595
|
+
end
|
596
|
+
|
597
|
+
##
|
598
|
+
# Construct a new LibGems::Version.
|
599
|
+
|
600
|
+
def v string
|
601
|
+
LibGems::Version.create string
|
602
|
+
end
|
603
|
+
|
604
|
+
end
|
605
|
+
|