-
Notifications
You must be signed in to change notification settings - Fork 7
/
acs
executable file
·85 lines (73 loc) · 3.84 KB
/
acs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env ruby
require 'rubygems'
require 'epitools'
lesspipe(:wrap=>true) do |less|
IO.popen("apt-cache show #{ARGV * ' '}", "rb") do |apt|
separator = ("#"*50).light_cyan
chunks = apt.read.split("\n\n")#.map {|chunk| chunk.lines.split_after(/^\S+:/) }
packages = chunks.map{|chunk| chunk.scan(/^([^\s:]+): ([^\n]+(?:\n [^\n]+)*)/m)}.map{|chunk| Hash[chunk]}
for info in packages
## title and version
ver = info["Version"].scan(/^([\d\.]+)(.*)$/).first
less.puts
less.puts "<8># <14>#{info["Package"]} <15>#{ver.first}<7>#{ver.last} <3>(#{info["Priority"]}) <8>#################################################".colorize
less.puts " <11>size: <15>#{info["Installed-Size"].to_i.commatize}<7>k <8>(<7>#{(info["Size"].to_i / 1024).commatize}k compressed<8>)".colorize
## description
desc = info[ info.keys.find{|k| k[/^Description/]} ] # find first key that starts with Description
desc = desc.split("\n")
less.puts
less.puts " <15>#{desc.first}".colorize
desc[1..-1].each { |line| less.puts " #{line}" }
less.puts
## dependencies
if deps = info["Depends"]
# example: Depends: libc6 (>= 2.7), libsensors4 (>= 1:3.0.0), debconf (>= 0.5) | debconf-2.0, ucf (>= 2.003), lsb-base (>= 3.0-6), bzip2
deps = deps.split(", ")
deps = deps.map do |unsplit|
unsplit.split(" | ").map do |dep|
if dep =~ /([^\s,]+)(?: \(([^\)]+)\))?/
name, ver = $1, $2
result = "<7>#{name}"
result += "<8>(<9>#{ver}<8>)" if ver
end
result
end.compact.join(" <8>| ").colorize
end
if deps.any?
less.puts " <11>depends:".colorize
table = Term::Table.new(deps, :strip_color=>true, :indent=>4)
less.puts table.by_columns
end
less.puts
end
end
end
end
=begin
Package: firefox
Priority: optional
Section: web
Installed-Size: 29968
Maintainer: Ubuntu Mozilla Team <[email protected]>
Architecture: i386
Version: 3.6.18+build2+nobinonly-0ubuntu0.10.10.2
Provides: iceweasel, www-browser
Depends: fontconfig, psmisc, lsb-release, debianutils (>= 1.16), libasound2 (>> 1.0.22), libatk1.0-0 (>= 1.29.3), libc6 (>= 2.11), libcairo2 (>= 1.2.4), libdbus-1-3 (>= 1.0.2), libdbus-glib-1-2 (>= 0.78), libfontconfig1 (>= 2.8.0), libfreetype6 (>= 2.3.5), libgcc1 (>= 1:4.1.1), libgdk-pixbuf2.0-0 (>= 2.21.6), libglib2.0-0 (>= 2.24.0), libgtk2.0-0 (>= 2.18.0), libnspr4-0d (>= 4.8.6-0ubuntu1~), libnss3-1d (>= 3.12.6), libpango1.0-0 (>= 1.14.0), libpng12-0 (>= 1.2.13-4), libstartup-notification0 (>= 0.10), libstdc++6 (>= 4.1.1), libx11-6, libxext6, libxrender1, libxt6, zlib1g (>= 1:1.1.4), firefox-branding | abrowser-branding
Depends: libc6 (>= 2.7), libsensors4 (>= 1:3.0.0), debconf (>= 0.5) | debconf-2.0, ucf (>= 2.003), lsb-base (>= 3.0-6), bzip2
Recommends: ubufox
Suggests: firefox-gnome-support (= 3.6.18+build2+nobinonly-0ubuntu0.10.10.2), firefox-kde-support, ttf-lyx, libthai0
Filename: pool/main/f/firefox/firefox_3.6.18+build2+nobinonly-0ubuntu0.10.10.2_i386.deb
Size: 11381258
MD5sum: 77d3eef51d61241acd802496cccaf5df
SHA1: ee37c42846363c17b2cc276e9f7bd2ba742a857a
SHA256: b51c15a9fc888d2f0a87ca1d5f10a45a04a7d47150748c45337aa22cada6e597
Description: safe and easy web browser from Mozilla
Firefox delivers safe, easy web browsing. A familiar user interface,
enhanced security features including protection from online identity theft,
and integrated search let you get the most out of the web.
Xul-Appid: {ec8030f7-c20a-464f-9b0e-13a3a9e97384}
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 18m
Task: ubuntu-desktop, ubuntu-uec-live, edubuntu-desktop, edubuntu-uec-live, xubuntu-desktop, mythbuntu-backend-master, mythbuntu-backend-slave, mythbuntu-desktop, mythbuntu-frontend, ubuntu-netbook
=end