晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
| DIR:/opt/alt/ruby34/share/gems/gems/bundler-2.6.9/lib/bundler/ |
| Current File : //opt/alt/ruby34/share/gems/gems/bundler-2.6.9/lib/bundler/rubygems_gem_installer.rb |
# frozen_string_literal: true
require "rubygems/installer"
module Bundler
class RubyGemsGemInstaller < Gem::Installer
def check_executable_overwrite(filename)
# Bundler needs to install gems regardless of binstub overwriting
end
def install
pre_install_checks
run_pre_install_hooks
spec.loaded_from = spec_file
# Completely remove any previous gem files
strict_rm_rf gem_dir
strict_rm_rf spec.extension_dir
SharedHelpers.filesystem_access(gem_dir, :create) do
FileUtils.mkdir_p gem_dir, mode: 0o755
end
SharedHelpers.filesystem_access(gem_dir, :write) do
extract_files
end
build_extensions if spec.extensions.any?
write_build_info_file
run_post_build_hooks
SharedHelpers.filesystem_access(bin_dir, :write) do
generate_bin
end
generate_plugins
write_spec
SharedHelpers.filesystem_access("#{gem_home}/cache", :write) do
write_cache_file
end
say spec.post_install_message unless spec.post_install_message.nil?
run_post_install_hooks
spec
end
if Bundler.rubygems.provides?("< 3.5")
def pre_install_checks
super
rescue Gem::FilePermissionError
# Ignore permission checks in RubyGems. Instead, go on, and try to write
# for real. We properly handle permission errors when they happen.
nil
end
end
def ensure_writable_dir(dir)
super
rescue Gem::FilePermissionError
# Ignore permission checks in RubyGems. Instead, go on, and try to write
# for real. We properly handle permission errors when they happen.
nil
end
def generate_plugins
return unless Gem::Installer.instance_methods(false).include?(:generate_plugins)
latest = Gem::Specification.stubs_for(spec.name).first
return if latest && latest.version > spec.version
ensure_writable_dir @plugins_dir
if spec.plugins.empty?
remove_plugins_for(spec, @plugins_dir)
else
regenerate_plugins_for(spec, @plugins_dir)
end
end
if Bundler.rubygems.provides?("< 3.5.19")
def generate_bin_script(filename, bindir)
bin_script_path = File.join bindir, formatted_program_filename(filename)
Gem.open_file_with_lock(bin_script_path) do
require "fileutils"
FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
File.open(bin_script_path, "wb", 0o755) do |file|
file.write app_script_text(filename)
file.chmod(options[:prog_mode] || 0o755)
end
end
verbose bin_script_path
generate_windows_script filename, bindir
end
end
def build_extensions
extension_cache_path = options[:bundler_extension_cache_path]
extension_dir = spec.extension_dir
unless extension_cache_path && extension_dir
prepare_extension_build(extension_dir)
return super
end
build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
if build_complete && !options[:force]
SharedHelpers.filesystem_access(File.dirname(extension_dir)) do |p|
FileUtils.mkpath p
end
SharedHelpers.filesystem_access(extension_cache_path) do
FileUtils.cp_r extension_cache_path, extension_dir
end
else
prepare_extension_build(extension_dir)
super
SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
SharedHelpers.filesystem_access(extension_cache_path) do
FileUtils.cp_r extension_dir, extension_cache_path
end
end
end
def spec
if Bundler.rubygems.provides?("< 3.3.12") # RubyGems implementation rescues and re-raises errors before 3.3.12 and we don't want that
@package.spec
else
super
end
end
def gem_checksum
Checksum.from_gem_package(@package)
end
private
def prepare_extension_build(extension_dir)
SharedHelpers.filesystem_access(extension_dir, :create) do
FileUtils.mkdir_p extension_dir
end
end
def strict_rm_rf(dir)
return unless File.exist?(dir)
return if Dir.empty?(dir)
parent = File.dirname(dir)
parent_st = File.stat(parent)
if parent_st.world_writable? && !parent_st.sticky?
raise InsecureInstallPathError.new(spec.full_name, dir)
end
begin
FileUtils.remove_entry_secure(dir)
rescue StandardError => e
raise unless File.exist?(dir)
raise DirectoryRemovalError.new(e, "Could not delete previous installation of `#{dir}`")
end
end
end
end
|