Skip to content

Commit

Permalink
add ansicon as a package
Browse files Browse the repository at this point in the history
  • Loading branch information
vertiginous committed Jan 26, 2011
1 parent cab6c4a commit 7f33fa3
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/pik/commands/command.rb
Expand Up @@ -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
Expand Down
40 changes: 37 additions & 3 deletions lib/pik/commands/package_command.rb
Expand Up @@ -14,6 +14,8 @@ def execute
sevenzip
when "sqlite"
sqlite
when 'ansicon'
ansicon
else
help
end
Expand Down Expand Up @@ -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'))
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
10 changes: 6 additions & 4 deletions lib/pik/installer.rb
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/pik/packages.rb
Expand Up @@ -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
Expand Down

0 comments on commit 7f33fa3

Please sign in to comment.