From 7f33fa3ec5d714120cd42777f1535c28e9bc427a Mon Sep 17 00:00:00 2001 From: Gordon Thiesfeld Date: Wed, 26 Jan 2011 10:22:11 -0600 Subject: [PATCH] add ansicon as a package --- lib/pik/commands/command.rb | 6 ++--- lib/pik/commands/package_command.rb | 40 ++++++++++++++++++++++++++--- lib/pik/installer.rb | 10 +++++--- lib/pik/packages.rb | 3 ++- 4 files changed, 48 insertions(+), 11 deletions(-) diff --git a/lib/pik/commands/command.rb b/lib/pik/commands/command.rb index 565e3a3..a7de121 100644 --- a/lib/pik/commands/command.rb +++ b/lib/pik/commands/command.rb @@ -128,9 +128,9 @@ def delete_old_pik_script Pik.script_file.path.delete if Pik.script_file.path.exist? end - def sh(cmd) - puts cmd if debug - system(cmd) + def sh(*cmd) + Log.debug cmd.join(' ') if debug + system(*cmd) end def hl diff --git a/lib/pik/commands/package_command.rb b/lib/pik/commands/package_command.rb index f0a1fb1..16171de 100644 --- a/lib/pik/commands/package_command.rb +++ b/lib/pik/commands/package_command.rb @@ -14,6 +14,8 @@ def execute sevenzip when "sqlite" sqlite + when 'ansicon' + ansicon else help end @@ -46,6 +48,16 @@ def devkit end end + def ansicon + check_7zip + file = download(url('ansicon')) + extract(install_root, file, {:recurse => ansicon_arch, :extract => :flat}) + sh(install_root + "ansicon.exe", "-i") + msg = "Ansicon is installed for new shells. Run 'ansicon -p'\n" + msg << " to install it for this shell" + Log.info msg + end + def sqlite check_7zip file = download(url('sqlite')) @@ -54,6 +66,7 @@ def sqlite def sevenzip file = download(url('7zip')) + Log.info "Extracting: #{file.windows}\n to: #{install_root}" Zip.fake_unzip(file.to_s, /\.exe|\.dll$/, install_root.to_s) end @@ -64,9 +77,20 @@ def url(package) def command_options super sep =<<-SEP - sqlite: 'pik package sqlite install' - 7zip: 'pik package 7zip install' - devkit: 'pik package devkit install' # Installed to mingw versions only. + sqlite: 'pik package sqlite install' + 7zip: 'pik package 7zip install' + ansicon: 'pik package ansicon install' + devkit: 'pik package devkit install' # Installed to mingw versions only. + +In some cases, The package command assumes that pik is +installed on your path. If it is not, you'll want to use +the path parameter so pik can install files to a location +that is in your path. + + pik package install sqlite C:\\bin + +In the case of the devkit, it is STRONGLY recommended +that you don't install to a path with spaces. If you have an idea for another package, submit a feature request at https://github.com/vertiginous/pik/issues @@ -91,6 +115,16 @@ def mingw?(version) Pik::VersionParser.parse(version).platform =~ /mingw/ end + #determines x86 or x64 architecture + def ansicon_arch + key = "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" + if Reg.new.hklm(key, 'PROCESSOR_ARCHITECTURE') =~ /64/ + 'x64' + else + 'x86' + end + end + end end \ No newline at end of file diff --git a/lib/pik/installer.rb b/lib/pik/installer.rb index c851780..e235ad2 100644 --- a/lib/pik/installer.rb +++ b/lib/pik/installer.rb @@ -59,14 +59,16 @@ def mv_r(src, dest, options = {}) end end - def extract(target, file) + def extract(target, file, options={}) target.mkpath # based on filetypes, extract the files - Log.info "Extracting: #{file.windows}\n to: #{target}" #if verbose + Log.info "Extracting: #{file.windows}\n to: #{target}" case file.to_s when /(^.+\.zip$)/, /(^.+\.7z$)/, /(^.+\.exe$)/ - file = Pathname($1) - cmd = " \"#{seven_zip}\" x \"#{file.windows}\" -y -o\"#{target}\" > NUL" + file = Pathname($1) + recurse = "-r #{options[:recurse]}" if options[:recurse] + ext = options[:extract] == :flat ? 'e' : 'x' + cmd = "\"#{seven_zip}\" #{ext} \"#{file.windows}\" -y #{recurse} -o\"#{target}\" > NUL" Log.debug cmd system(cmd) else diff --git a/lib/pik/packages.rb b/lib/pik/packages.rb index 9b0f968..528c6c9 100644 --- a/lib/pik/packages.rb +++ b/lib/pik/packages.rb @@ -12,7 +12,8 @@ def [](key) PACKAGES = { "sqlite"=>{:url=>"http://www.sqlite.org/sqlite-dll-win32-x86-3070400.zip"}, "devkit"=>{:url=>"http://cdn.rubyinstaller.org/archives/devkits/DevKit-tdm-32-4.5.1-20101231-1457.7z"}, - "7zip"=>{:url=>"http://downloads.sourceforge.net/sevenzip/7za920.zip"} + "7zip"=>{:url=>"http://downloads.sourceforge.net/sevenzip/7za920.zip"}, + "ansicon"=>{:url=>"http://adoxa.110mb.com/ansicon/ansi132.zip"} } end