natives 0.5.1 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTE5NDQ2M2I2ZDc4YTVmY2QyZDdiN2U2NmExMTA0NTEyNmFjYjUzNQ==
4
+ MjdhYzVkMjU3YmYzMDRmNzIwMWMyOGVmNTZhYjM3ZGQ4ODdhNmQ5MA==
5
5
  data.tar.gz: !binary |-
6
- OTBiZDc0NTVmZDhhN2RkYWYyOTkxMWYxMmQ3NTFjNGE4MDQ2YTc4ZQ==
6
+ MmVhMGEzZjVkOGU2ODJmZTExOTU3ODlmZWI3MDhjZGFmZTUwZDAzMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDlkMDYyMjVkM2Y3Y2Y1NGM5ZjRhMTY5YWI4NDZjYWVjNDc3MzYxMzU4N2Zi
10
- ZmM0ZGJkZjQ5ZThkZDVkZWZhZGQ2MDhmZDUyZmI4Mjc0YzJhMjZlMTZhNGFi
11
- YTFmNTE0MTJjNzYyZTgzZWJlODk5NTE2NmRkMjEyMjc0MTMwMmI=
9
+ ZmY3ZmJjMmYzYjU2OWMzNjhhMjE3NWU3MTU2Y2NmOTlmNDUzNmJhNWFlMGNj
10
+ Y2ZkNzU2NmIxOGE3MjgzMjhlYTg1OTkxMzhkY2I0ZDc4MzI1ZGJiYTgzNzkx
11
+ ZmU0YTZlMDE1NGJiNjljOWVmMzkwNDNhNWY4MDdlOWNhOGMxNTU=
12
12
  data.tar.gz: !binary |-
13
- Yjk2NmNkM2E5MmZjZjcyYTU0ODMzODRlYTM1YWQ2ZjBhMDhlMDdlMTQxNTJl
14
- OWU4ZGE5Y2I5ZWEzYmEzNDRkYzA1ZmM0ZTcxMThhOGFkZjQ3NjU5MTE0OWI3
15
- YjJmMWEzNTU1NmJiN2ExYTBjNmVhMzJkODYwZGM0NjEyODEwMzU=
13
+ NGM0Zjc0OTQzNTFhMzlhZDQ3YzVjZjEyNDMxNjY4ODAzMWQ4ZWE4YmRjMDIz
14
+ YWE5ZjNmMmQ0MzE5ZTJjNjIyMjkyYzE2NjkyMTIzOGZiYjc2MzEzZGFmNWQ2
15
+ OGZkNmNmYTg0OGJhZWNkYTUwNGRmOTYzNmU5Njc4ZTNjMzEzN2Y=
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - 1.9.2
data/README.md CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/natives.png)](http://badge.fury.io/rb/natives)
4
4
  [![Code Climate](https://codeclimate.com/github/teohm/natives.png)](https://codeclimate.com/github/teohm/natives)
5
+ [![Build Status](https://travis-ci.org/teohm/natives.png)](https://travis-ci.org/teohm/natives)
5
6
 
6
7
  List native packages required by ruby gems on your machine.
7
8
 
@@ -61,7 +62,7 @@ rubygems:
61
62
  mac_os_x/homebrew:
62
63
  - package1
63
64
  ubuntu/apt:
64
- - package2
65
+ - package2
65
66
 
66
67
  $ natives list my_gem # runs on mac os x
67
68
  package1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -0,0 +1 @@
1
+ /data
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+
3
+ TEST_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
+
5
+ rm -rf $TEST_HOME/data
6
+ echo " * Removed data/ directory."
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'psych'
4
+ require 'yaml'
5
+ require 'fileutils'
6
+
7
+ test_home = File.expand_path(File.dirname(__FILE__))
8
+ project_home = File.expand_path(File.join(test_home, '..'))
9
+
10
+ rubygems_catalog_file = File.join(
11
+ project_home, 'catalogs', 'rubygems.yaml')
12
+
13
+ catalog = YAML.load_file(rubygems_catalog_file)
14
+ gem_names = catalog["rubygems"].keys
15
+
16
+ puts gem_names
data/catalogs_test/run ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env bash
2
+
3
+ TEST_HOME="$( cd "$( dirname "$0" )" && pwd )"
4
+ PROJECT_HOME="$( cd $TEST_HOME/.. && pwd )"
5
+
6
+ $TEST_HOME/setup
7
+
8
+ NATIVES_CMD="$PROJECT_HOME/bin/natives list $($TEST_HOME/list_all)"
9
+ NATIVE_PACKAGES="$( $NATIVES_CMD )"
10
+ echo " * Native packages: $NATIVE_PACKAGES"
11
+
12
+ if [ -n "$NATIVE_PACKAGES" ]; then
13
+ echo " * Installing native packages.."
14
+ INSTALL_CMD="$TEST_HOME/vendored/pacapt -v -S"
15
+ $INSTALL_CMD $NATIVE_PACKAGES
16
+ fi
17
+
18
+ echo " * Installing gems.."
19
+ bundle install --gemfile $TEST_HOME/data/Gemfile --path bundle --verbose
20
+
21
+ EXIT_CODE=$?
22
+ echo " * Exit code: $EXIT_CODE"
23
+ echo ""
24
+
25
+ if [ $EXIT_CODE -eq 0 ]; then
26
+ echo "SUCCESS"
27
+ else
28
+ echo "FAILED"
29
+ fi
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'yaml'
4
+ require 'fileutils'
5
+
6
+ test_home = File.expand_path(File.dirname(__FILE__))
7
+ project_home = File.expand_path(File.join(test_home, '..'))
8
+ gemfile_path = File.join(test_home, 'data', 'Gemfile')
9
+
10
+ gem_names = `#{ File.join(test_home, 'list_all') }`.split("\n")
11
+
12
+ FileUtils.mkdir_p File.dirname(gemfile_path)
13
+ File.open(gemfile_path, 'w') do |f|
14
+ f.puts %{source "https://rubygems.org"}
15
+ gem_names.each do |gem_name|
16
+ f.puts %{gem "#{gem_name}"}
17
+ end
18
+ end
19
+
20
+ puts " * Generated gemfile at #{gemfile_path}"
@@ -0,0 +1,660 @@
1
+ #!/bin/bash
2
+
3
+ # Purpose: A wrapper for all Unix package managers
4
+ # Author : Anh K. Huynh
5
+ # License: Fair license (http://www.opensource.org/licenses/fair)
6
+ # Source : http://github.com/icy/pacapt/
7
+
8
+ # Copyright (C) 2010 - 2013 Anh K. Huynh
9
+ #
10
+ # Usage of the works is permitted provided that this instrument is
11
+ # retained with the works, so that any entity that uses the works is
12
+ # notified of this instrument.
13
+ #
14
+ # DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
15
+
16
+ _POPT="" # primary operation
17
+ _SOPT="" # secondary operation
18
+ _TOPT="" # options for operations
19
+ _PKG="" # packages and extra parameters for apt-get
20
+ _VERBOSE="" # verbose mode
21
+ _FORCE="" # force yes
22
+ _OSTYPE="" # type of package manager (Arch pacman, Debian apt, ...)
23
+
24
+ _error() {
25
+ echo >&2 ":: $*"
26
+ }
27
+
28
+ _help() {
29
+ cat <<\EOF
30
+ NAME
31
+
32
+ pacapt - An Arch's pacman-like package manager for some Unices.
33
+
34
+ DESCRIPTION
35
+
36
+ An Arch's pacman-like package manager for some Unices. Actually this Bash
37
+ script provides a wrapper for system's package manager.
38
+
39
+ Instead of remembering various options/tools on different OSs, you only
40
+ need a common way to manipulate packages. Not all options of the native
41
+ package manager are ported; the tool only provides a very basic interface
42
+ to search, install, remove packages, and/or update the system.
43
+
44
+ Arch's pacman is chosen, as pacman is quite smart when it divides all
45
+ packages-related operations into three major groups: Synchronize, Query
46
+ and Remove/Clean up. It has a clean man page, and it is the only tool
47
+ needed to manipulate official packages on system. (Debian, for example,
48
+ requires you to use apt-get, dpkg, and/or aptitude.)
49
+
50
+ The tool supports the following package managers:
51
+
52
+ pacman by Arch Linux, ArchBang, Manjaro, etc.
53
+ dpkg/apt-get by Debian, Ubuntu, etc.
54
+ homebrew by Mac OS X
55
+ macports by Mac OS X
56
+ yum/rpm by Redhat, CentOS, Fedora, etc.
57
+ portage by Gentoo
58
+ zypper by OpenSUSE
59
+
60
+ SYNTAX
61
+
62
+ $ pacapt <operation> <option(s)> <packages>
63
+
64
+ OPERATIONS
65
+
66
+ Query
67
+
68
+ -Q list all installed packages
69
+ -Qc <package> show package's changelog
70
+ -Qi <package> print package status
71
+ -Ql <package> list package's files
72
+ -Qm list installed packages that aren't available
73
+ in any installation source
74
+ -Qo <file> query package that provides <file>
75
+ -Qp <file> query a package file (don't use package database)
76
+
77
+ Synchronize
78
+
79
+ -S <package> install package(s)
80
+ -Ss <package> search for packages
81
+ -Su upgrade the system
82
+ -Sy update package database
83
+ -Suy update package database, then upgrade the system
84
+
85
+ Remove / Clean up
86
+
87
+ -R <packages> remove some packages
88
+ -Sc delete old downloaded packages
89
+ -Scc delete all downloaded packages
90
+ -Sccc clean variant files.
91
+ (debian) See more at http://dragula.org/blogs/646
92
+
93
+ OPTIONS
94
+
95
+ -f force yes
96
+ -v be verbose
97
+ -w download packages but don't install them
98
+
99
+ NOTES
100
+
101
+ To install a package from backports repository on Debian system:
102
+ $ pacapt -S foobar -t lenny-backports
103
+
104
+ Similarly, any further option which isn't recognized by getopts (1)
105
+ can be passed to system tool.
106
+
107
+ When being executed on Arch-based system, the tool simply invokes
108
+ the system tool '/usr/bin/pacman'.
109
+
110
+ THANKS
111
+
112
+ Special thanks to
113
+
114
+ Châu An, Nguyễn (told me about 'Pacman Rosetta' [1])
115
+ Karol Blazewicz (for comments about '-Sy')
116
+ James Pearson (for userful comments and patches.
117
+ See also http://github.com/xiongchiamiov/pacapt)
118
+ Alexander Dupuy (for userful comments and patches.
119
+ See also https://github.com/dupuy/pacapt)
120
+ Hà Dương, Nguyễn (for adding Gentoo support.
121
+ See also https://github.com/CMPITG/pacapt)
122
+
123
+ REFERENCES
124
+
125
+ 1. Pacman Rosetta, https://wiki.archlinux.org/index.php?title=Pacman_Rosetta
126
+ EOF
127
+ }
128
+
129
+ ###
130
+ ### Helpers
131
+ ###
132
+
133
+ _os_is() {
134
+ [[ "$_OSTYPE" = "$*" ]]
135
+ }
136
+
137
+ _exec_() {
138
+ local _type="$1"
139
+ shift
140
+ if _os_is $_type; then
141
+ [[ -z "$_VERBOSE" ]] || _error "Going to execute: $* $_VERBOSE $_FORCE"
142
+ eval "$* $_VERBOSE $_FORCE"
143
+ fi
144
+ }
145
+
146
+
147
+ # Detect package type from /etc/issue
148
+ _found_arch() {
149
+ local _ostype="$1"
150
+ shift
151
+ grep -qis "$*" /etc/issue && _OSTYPE="$_ostype"
152
+ }
153
+
154
+ # Detect package type
155
+ _OSTYPE_detect() {
156
+ _found_arch PACMAN "Arch Linux" && return
157
+ _found_arch DPKG "Debian GNU/Linux" && return
158
+ _found_arch DPKG "Ubuntu" && return
159
+ _found_arch YUM "CentOS" && return
160
+ _found_arch YUM "Red Hat" && return
161
+ _found_arch YUM "Fedora" && return
162
+ _found_arch ZYPPER "SUSE" && return
163
+
164
+ [[ -z "$_OSTYPE" ]] || return
165
+
166
+ # See also https://github.com/icy/pacapt/pull/22
167
+ # Please not that $OSTYPE (which is `linux-gnu` on Linux system)
168
+ # is not our $_OSTYPE. The choice is not very good because
169
+ # a typo can just break the logic of the program.
170
+ if [[ "$OSTYPE" != "darwin"* ]]; then
171
+ _error "Can't detect OS type from /etc/issue. Running fallback method."
172
+ fi
173
+ [[ -x "/usr/bin/pacman" ]] && _OSTYPE="PACMAN" && return
174
+ [[ -x "/usr/bin/apt-get" ]] && _OSTYPE="DPKG" && return
175
+ [[ -x "/usr/bin/yum" ]] && _OSTYPE="YUM" && return
176
+ [[ -x "/opt/local/bin/port" ]] && _OSTYPE="MACPORTS" && return
177
+ command -v brew >/dev/null && _OSTYPE="HOMEBREW" && return
178
+ [[ -x "/usr/bin/emerge" ]] && _OSTYPE="PORTAGE" && return
179
+ [[ -x "/usr/bin/zypper" ]] && _OSTYPE="ZYPPER" && return
180
+ if [[ -z "$_OSTYPE" ]]; then
181
+ _error "No supported package manager installed on system"
182
+ _error "(supported: apt, homebrew, pacman, portage, yum)"
183
+ exit 1
184
+ fi
185
+ }
186
+
187
+ ###
188
+ ### Main
189
+ ###
190
+
191
+ # Detect type of package manager.
192
+ _OSTYPE_detect
193
+
194
+ # If the system is Arch-like, pass all of the arguments to /usr/bin/pacman
195
+ # and return. This is done here to achieve a consistent help menu.
196
+ [[ "$_OSTYPE" == "PACMAN" ]] && exec /usr/bin/pacman "$@"
197
+
198
+ #
199
+ # Get options from command lines. FIXME: Support long options
200
+ #
201
+
202
+ # By default, with Gentoo, 'force' is always 'yes', so we change it to 'no'
203
+ [[ "$_OSTYPE" == "PORTAGE" ]] && _FORCE="-a"
204
+
205
+ while getopts "URQShfvlumyispqwco" opt 2>/dev/null; do
206
+ case "$opt" in
207
+ Q|S|R|U)
208
+ if [[ "$_POPT" != "" && "$_POPT" != "$opt" ]]; then
209
+ _error "Only one operation may be used at a time"
210
+ exit 1
211
+ fi
212
+ _POPT="$opt"
213
+ ;;
214
+
215
+ # FIXME: Please check pacman(8) to see if they are really 2nd operation
216
+ s|l|i|p|o|m)
217
+ if [[ "$_SOPT" == '' ]]; then
218
+ _SOPT="$opt"
219
+ else
220
+ _TOPT="$opt"
221
+ fi
222
+ ;;
223
+
224
+ # NOTE: -q is an output option, not an operator!
225
+ # Thanks to James Pearson for his catch :)
226
+ q)
227
+ _TOPT="$opt"
228
+ ;;
229
+
230
+ u)
231
+ if [[ "${_SOPT:0:1}" = "y" ]]; then
232
+ _SOPT="uy"
233
+ else
234
+ _SOPT="u"
235
+ fi
236
+ ;;
237
+
238
+ y)
239
+ if [[ "${_SOPT:0:1}" = "u" ]]; then
240
+ _SOPT="uy"
241
+ else
242
+ _SOPT="y"
243
+ fi
244
+ ;;
245
+
246
+ c)
247
+ if [[ "${_SOPT:0:2}" = "cc" ]]; then
248
+ _SOPT="ccc"
249
+ elif [[ "${_SOPT:0:1}" = "c" ]]; then
250
+ _SOPT="cc"
251
+ else
252
+ _SOPT="$opt"
253
+ fi
254
+ ;;
255
+
256
+ w)
257
+ case "$_OSTYPE" in
258
+ "DPKG") _TOPT="-d" ;;
259
+ "YUM")
260
+ _TOPT="--downloadonly"
261
+ if ! rpm -q yum-downloadonly > /dev/null; then
262
+ _error "The '-w' option requires the package 'yum-downloadonly'"
263
+ _error "Install this with 'yum install -y yum-downloadonly' or"
264
+ _error "$0 -S -f yum-downloadonly"
265
+ exit 1
266
+ fi
267
+ ;;
268
+ "MACPORTS") _TOPT="fetch" ;;
269
+ "PORTAGE") _TOPT="--fetchonly" ;;
270
+ "ZYPPER") _TOPT="--download-only" ;;
271
+ esac
272
+ ;;
273
+
274
+ f)
275
+ case "$_OSTYPE" in
276
+ "DPKG") _FORCE="-f --force-yes" ;;
277
+ "YUM") _FORCE="-y" ;;
278
+ "MACPORTS") _FORCE="-f" ;;
279
+ "PORTAGE") _FORCE="" ;;
280
+ *) _FORCE="-y" ;;
281
+ esac
282
+ ;;
283
+
284
+ v) _VERBOSE="-v" ;;
285
+
286
+ h) _help; exit 0 ;;
287
+
288
+ *) _error "Error: Invalid option"; exit 1 ;;
289
+ esac
290
+ done
291
+
292
+ # Remained options/packages/queries
293
+ shift $((OPTIND - 1))
294
+ _PKG="$*"
295
+
296
+ # pacman man page (examples) says: "pacman -Syu gpm = Update package list,
297
+ # upgrade all packages, and then install gpm if it wasn't already installed."
298
+ # Instead, just disallow specific packages, as (ex-)yum users likely expect to
299
+ # just update/upgrade one package (and its dependencies) and apt-get and pacman
300
+ # have no way to do this.
301
+ if [[ -n "$_PKG" ]]; then
302
+ case "$_POPT$_SOPT" in
303
+ "Su"|"Sy"|"Suy")
304
+ _error "The -Sy/u options refresh and/or upgrade all packages"
305
+ _error "To install packages as well, use separate commands to do so:"
306
+ _error "$0 -S$_SOPT"
307
+ _error "$0 -S $_PKG"
308
+ exit 1
309
+ esac
310
+ fi
311
+
312
+ # DEBUG
313
+ # echo "Primary options: $_POPT"
314
+ # echo "Secondary options: $_SOPT"
315
+ # echo "Options for operations: $_TOPT"
316
+ # echo "Extra params: $_PKG"
317
+ # echo "Verbose: $_VERBOSE"
318
+ # echo "Force: $_FORCE"
319
+
320
+ # Return if no option was specified
321
+ if [[ -z "$_POPT" ]]; then
322
+ _error "No operation specified (use -h for help)"
323
+ exit 1
324
+ fi
325
+
326
+ # Invoke the native package manager
327
+ case "$_POPT$_SOPT" in
328
+ ####################################################################
329
+ # QUERYING #
330
+ ####################################################################
331
+
332
+ "Qi")
333
+ _exec_ ZYPPER "zypper info $_PKG"
334
+ _exec_ DPKG "dpkg-query -s $_PKG"
335
+ _exec_ HOMEBREW "brew info $_PKG"
336
+ #_exec_ MACPORTS "port info $_PKG"
337
+ _os_is MACPORTS && _error "Function not implemented in macports"
338
+ _exec_ YUM "yum info $_PKG"
339
+ _FORCE="" \
340
+ _exec_ PORTAGE "emerge --info $_PKG"
341
+ ;;
342
+ "Ql")
343
+ _exec_ ZYPPER "echo 'Function is not available'; exit 1"
344
+ _exec_ DPKG "
345
+ if [[ -n \"$_PKG\" ]]; then
346
+ dpkg-query -L $_PKG
347
+ else
348
+ dpkg -l \
349
+ | grep -E ^[hi]i \
350
+ | awk '{print \$2}' \
351
+ | while read _pkg; do
352
+ if [[ \"$_TOPT\" = 'q' ]]; then
353
+ dpkg-query -L \$_pkg
354
+ else
355
+ dpkg-query -L \$_pkg \
356
+ | while read _line; do
357
+ echo \$_pkg \$_line
358
+ done
359
+ fi
360
+ done
361
+ fi
362
+ "
363
+ _exec_ HOMEBREW "brew list $_PKG"
364
+ _exec_ MACPORTS "port contents $_PKG"
365
+ _exec_ YUM "rpm -ql $_PKG"
366
+ _FORCE="" \
367
+ _exec_ PORTAGE "
368
+ if [[ -x /usr/bin/qlist ]]; then
369
+ qlist $_PKG
370
+ elif [[ -x /usr/bin/equery ]]; then
371
+ equery files $_PKG
372
+ else
373
+ _error 'You need to install portage-utils or gentoolkit to perform this operation.'
374
+ fi
375
+ "
376
+ ;;
377
+ "Qo")
378
+ _exec_ ZYPPER "echo 'Function is not available'; exit 1"
379
+
380
+ _exec_ DPKG "dpkg-query -S $_PKG"
381
+ _exec_ HOMEBREW "
382
+ cd \"\$(dirname -- \$(which $_PKG))\"
383
+ pkg=\"\$(pwd -P)/\$(basename -- $_PKG)\"
384
+ prefix=\"\$(brew --prefix)\"
385
+ cellar=\"\$(brew --cellar)\"
386
+ for package in \$cellar/*; do
387
+ files=(\${package}/*/\${pkg/#\$prefix\//})
388
+ if [[ -e \${files[\${#files[@]} - 1]} ]]; then
389
+ echo \"\${package/#\$cellar\//}\"
390
+ break
391
+ fi
392
+ done
393
+ "
394
+ _exec_ MACPORTS "port provides $_PKG"
395
+ _exec_ YUM "rpm -qf $_PKG"
396
+ _FORCE="" \
397
+ _exec_ PORTAGE "
398
+ if [[ -x /usr/bin/equery ]]; then
399
+ equery belongs $_PKG
400
+ else
401
+ _error 'You need to install gentoolkit to perform this operation'
402
+ fi
403
+ "
404
+ ;;
405
+ "Qp")
406
+ _exec_ ZYPPER "echo 'Function is not available'; exit 1"
407
+ _os_is HOMEBREW && _error "Function not implemented in homebrew"
408
+ _os_is MACPORTS && _error "Function not implemented in macports"
409
+ _os_is PORTAGE && _error "Function not supported as Gentoo has no definition of 'package file"
410
+
411
+ _exec_ DPKG "dpkg-deb -I $_PKG"
412
+ _exec_ YUM "rpm -qp $_PKG"
413
+ ;;
414
+ "Qc")
415
+ _exec_ ZYPPER "echo 'Function is not available'; exit 1"
416
+ _os_is DPKG && _error "Function not implemented in Debian system"
417
+
418
+ _exec_ HOMEBREW "brew log $_PKG"
419
+ _exec_ MACPORTS "port log $_PKG"
420
+ _exec_ YUM "rpm -q --changelog $_PKG"
421
+ _FORCE="" \
422
+ _exec_ PORTAGE "emerge -p --changelog $_PKG"
423
+ ;;
424
+ "Qu")
425
+ _exec_ ZYPPER "zypper list-updates"
426
+ _exec_ DPKG "apt-get upgrade --trivial-only $_PKG"
427
+ _exec_ HOMEBREW "brew outdated | grep $_PKG"
428
+ _exec_ MACPORTS "port outdated $_PKG"
429
+ _exec_ YUM "yum list updates $_PKG"
430
+ _exec_ PORTAGE "emerge -uvN $_PKG" # FIXME: not exactly
431
+ ;;
432
+ "Qm")
433
+ _exec_ ZYPPER "zypper search -si | grep 'System Packages'"
434
+ _os_is DPKG && _error "Function not implemented in Debian system"
435
+ _os_is HOMEBREW && _error "Function not implemented in homebrew"
436
+ _os_is MACPORTS && _error "Function not implemented in macports"
437
+ _os_is PORTAGE && _error "Function not supported in Gentoo"
438
+
439
+ _exec_ YUM "yum list extras $_PKG"
440
+ ;;
441
+
442
+ "Q")
443
+ _exec_ ZYPPER "zypper search -i"
444
+ if [[ "$_TOPT" = 'q' ]]; then
445
+ # FIXME: Should we redirect user to a similar operation?
446
+ _os_is HOMEBREW && _error "Function not implemented in homebrew"
447
+ _os_is MACPORTS && _error "Function not implemented in macports"
448
+ _os_is PORTAGE && _error "Function not supported as Gentoo has no definition of 'package file"
449
+ _os_is YUM && _error "Function not implemented in Yum"
450
+
451
+ _exec_ DPKG "dpkg -l | grep -E ^[hi]i | awk '{print \$2}'"
452
+ elif [[ "$_TOPT" = "" ]]; then
453
+ _exec_ DPKG "dpkg -l $_PKG | grep -E ^[hi]i"
454
+ _exec_ HOMEBREW "brew list | grep $_PKG"
455
+ _exec_ MACPORTS "port installed $_PKG"
456
+ _exec_ YUM "yum list installed $_PKG"
457
+
458
+ # FIXME: There are actually many ways to do this in Gentoo
459
+ _FORCE="" \
460
+ _exec_ PORTAGE "
461
+ if [[ -x /usr/bin/eix ]]; then
462
+ eix -I $_PKG
463
+ elif [[ -x /usr/bin/equery ]]; then
464
+ equery list '*' $_PKG
465
+ else
466
+ LS_COLORS=never ls -1 -d /var/db/pkg/*/*
467
+ fi
468
+ "
469
+ else
470
+ _error "Error: Invalid option"
471
+ exit 1
472
+ fi
473
+ ;;
474
+
475
+ ####################################################################
476
+ # REMOVING #
477
+ ####################################################################
478
+
479
+ "Rs")
480
+ if [[ "$_TOPT" = 's' ]]; then
481
+ _os_is DPKG && _error "Function not implemented in Debian system"
482
+ _os_is YUM && _error "Function not implemented in Yum"
483
+ _os_is PORTAGE && _error "Function not supported in Gentoo"
484
+
485
+ _exec_ ZYPPER "zypper remove $_PKG --clean-deps"
486
+ _exec_ HOMEBREW "
487
+ brew rm $_PKG
488
+ brew rm \$(join <(brew leaves) <(brew deps $_PKG))
489
+ "
490
+ _os_is MACPORTS && _error "Function not implemented in macports"
491
+ elif [[ "$_TOPT" = '' ]]; then
492
+ _exec_ ZYPPER "echo 'Function is not available'; exit 1"
493
+ _os_is HOMEBREW && _error "Function not implemented in homebrew"
494
+ _exec_ MACPORTS "port uninstall --follow-dependencies $_PKG"
495
+ _exec_ DPKG "apt-get autoremove $_PKG"
496
+ _exec_ YUM "yum erase $_PKG"
497
+ _exec_ PORTAGE "emerge --depclean world $_PKG"
498
+ else
499
+ _error "Error: Invalid option"
500
+ fi
501
+ ;;
502
+ "R")
503
+ _exec_ ZYPPER "zypper remove $_PKG"
504
+ _exec_ DPKG "apt-get remove $_PKG"
505
+ _exec_ HOMEBREW "brew remove $_PKG"
506
+ _exec_ MACPORTS "port uninstall $_PKG"
507
+ _exec_ YUM "yum erase $_PKG"
508
+ _exec_ PORTAGE "emerge --depclean $_PKG"
509
+ ;;
510
+
511
+ ####################################################################
512
+ # SYNCHRONIZING #
513
+ ####################################################################
514
+
515
+ "Si")
516
+ _exec_ ZYPPER "echo 'Function is not available'; exit 1"
517
+ _exec_ DPKG "dpkg-query -s $_PKG"
518
+ _exec_ HOMEBREW "brew info $_PKG"
519
+ _exec_ MACPORTS "port info $_PKG"
520
+ _exec_ YUM "yum info $_PKG"
521
+ _FORCE="" \
522
+ _exec_ PORTAGE "emerge --info $_PKG"
523
+ ;;
524
+ "Suy")
525
+ _exec_ ZYPPER "zypper dup"
526
+ _VERBOSE="" \
527
+ _exec_ DPKG "apt-get update; apt-get upgrade"
528
+ _exec_ HOMEBREW "brew update; brew upgrade"
529
+ _exec_ MACPORTS "port selfupdate; port upgrade outdated"
530
+ _exec_ YUM "yum update"
531
+ _exec_ PORTAGE "
532
+ if [[ -x /usr/bin/layman ]]; then
533
+ layman --sync-all \
534
+ && emerge --sync \
535
+ && emerge -auND world $_PKG
536
+ else
537
+ emerge --sync \
538
+ && emerge -uND world $_PKG
539
+ fi
540
+ "
541
+ ;;
542
+ "Su")
543
+ _exec_ ZYPPER "echo 'Function is not available'; exit 1"
544
+ _VERBOSE="" \
545
+ _exec_ DPKG "apt-get upgrade"
546
+ _exec_ HOMEBREW "brew upgrade"
547
+ _exec_ MACPORTS "port upgrade outdated"
548
+ _exec_ YUM "yum update"
549
+ _exec_ PORTAGE "emerge -uND world $_PKG"
550
+ ;;
551
+ "Sy")
552
+ _exec_ ZYPPER "zypper refresh"
553
+ _VERBOSE="" \
554
+ _exec_ DPKG "apt-get update"
555
+ _exec_ HOMEBREW "brew update"
556
+ _exec_ MACPORTS "port selfupdate" # or sync?
557
+ _exec_ YUM "yum check-update"
558
+ _FORCE="" \
559
+ _exec_ PORTAGE "
560
+ if [[ -x /usr/bin/layman ]]; then
561
+ layman --sync-all && emerge --sync
562
+ else
563
+ emerge --sync
564
+ fi
565
+ "
566
+ ;;
567
+ "Ss")
568
+ _exec_ ZYPPER "zypper search $_PKG"
569
+ _exec_ DPKG "apt-cache search $_PKG"
570
+ _exec_ HOMEBREW "brew search $_PKG"
571
+ _exec_ MACPORTS "port search $_PKG"
572
+ _exec_ YUM "yum -C search $_PKG"
573
+ _FORCE="" \
574
+ _exec_ PORTAGE "
575
+ if [[ -x /usr/bin/eix ]]; then
576
+ eix $_PKG
577
+ else
578
+ emerge --search $_PKG
579
+ fi
580
+ "
581
+ ;;
582
+ "Sc")
583
+ _exec_ ZYPPER "zypper clean"
584
+ _exec_ DPKG "apt-get clean"
585
+ _exec_ HOMEBREW "brew cleanup"
586
+ _exec_ MACPORTS "port clean --all inactive"
587
+ _exec_ YUM "yum clean expire-cache"
588
+ __FORCE="" \
589
+ _exec_ PORTAGE "
590
+ if [[ -x usr/bin/eclean-dist ]]; then
591
+ eclean-dist -d -t1m -s50 -f
592
+ else
593
+ _error 'You need install gentoolkit to perform this operation.'
594
+ fi
595
+ "
596
+ ;;
597
+ "Scc")
598
+ _exec_ ZYPPER "zypper clean"
599
+ _exec_ DPKG "apt-get autoclean"
600
+ _exec_ HOMEBREW "brew cleanup -s"
601
+ _exec_ MACPORTS "port clean --all installed"
602
+ _exec_ YUM "yum clean packages"
603
+ _FORCE="" \
604
+ _exec_ PORTAGE "
605
+ if [[ -x /usr/bin/eclean ]]; then
606
+ eclean -i distfiles
607
+ else
608
+ _error 'You need install gentoolkit to perform this operation.'
609
+ fi
610
+ "
611
+ ;;
612
+ "Sccc")
613
+ _exec_ ZYPPER "echo 'Function is not available'; exit 1"
614
+ _exec_ DPKG "rm -fv /var/cache/apt/*.bin
615
+ rm -fv /var/cache/apt/archives/*.*
616
+ rm -fv /var/lib/apt/lists/*.*
617
+ apt-get autoclean"
618
+ _exec_ HOMEBREW 'rm -rf $(brew --cache)'
619
+ _os_is MACPORTS && _error "Function not implemented in macports"
620
+ _exec_ YUM "yum clean all"
621
+ _FORCE="" \
622
+ _exec_ PORTAGE "rm -fv /usr/portage/distfiles/*.*"
623
+ ;;
624
+ "S")
625
+ [[ -z "$_PKG" ]] \
626
+ && { _error "You must specify a package"; exit 1; }
627
+
628
+ _exec_ ZYPPER "zypper install $_TOPT $_PKG"
629
+ _exec_ DPKG "apt-get install $_TOPT $_PKG"
630
+ _exec_ HOMEBREW "brew install $_TOPT $_PKG"
631
+ if [[ "$_TOPT" = fetch ]]
632
+ then
633
+ _exec_ MACPORTS "port patch $_PKG"
634
+ else
635
+ _exec_ MACPORTS "port install $_TOPT $_PKG"
636
+ fi
637
+ _exec_ YUM "yum install $_TOPT $_PKG"
638
+ _exec_ PORTAGE "emerge $_TOPT $_PKG"
639
+ ;;
640
+
641
+ ####################################################################
642
+ # UPGRADING #
643
+ ####################################################################
644
+
645
+ "U")
646
+ _exec_ ZYPPER "zypper install $_PKG"
647
+ _os_is HOMEBREW && _error "Function not implemented in homebrew"
648
+ _os_is MACPORTS && _error "Function not implemented in macports"
649
+ _os_is PORTAGE && _error "You need to implement a local overlay and do the installation as usual."
650
+
651
+ _exec_ DPKG "dpkg -i $_TOPT $_PKG"
652
+ _exec_ YUM "yum localinstall $_TOPT $_PKG"
653
+ ;;
654
+
655
+ # Default option
656
+ *)
657
+ _error "Error: Invalid option"
658
+ exit 1
659
+ ;;
660
+ esac
@@ -1,4 +1,5 @@
1
1
  require 'natives/catalog/merger'
2
+ require 'psych'
2
3
  require 'yaml'
3
4
 
4
5
  module Natives
data/natives.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: natives 0.5.1 ruby lib
5
+ # stub: natives 0.5.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "natives"
9
- s.version = "0.5.1"
9
+ s.version = "0.5.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.authors = ["Huiming Teo"]
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.files = [
22
22
  ".document",
23
23
  ".rspec",
24
+ ".travis.yml",
24
25
  "Gemfile",
25
26
  "Gemfile.lock",
26
27
  "LICENSE.txt",
@@ -29,6 +30,12 @@ Gem::Specification.new do |s|
29
30
  "VERSION",
30
31
  "bin/natives",
31
32
  "catalogs/rubygems.yaml",
33
+ "catalogs_test/.gitignore",
34
+ "catalogs_test/clean",
35
+ "catalogs_test/list_all",
36
+ "catalogs_test/run",
37
+ "catalogs_test/setup",
38
+ "catalogs_test/vendored/pacapt",
32
39
  "lib/natives.rb",
33
40
  "lib/natives/apps.rb",
34
41
  "lib/natives/apps/detect.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: natives
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Huiming Teo
@@ -147,6 +147,7 @@ extra_rdoc_files:
147
147
  files:
148
148
  - .document
149
149
  - .rspec
150
+ - .travis.yml
150
151
  - Gemfile
151
152
  - Gemfile.lock
152
153
  - LICENSE.txt
@@ -155,6 +156,12 @@ files:
155
156
  - VERSION
156
157
  - bin/natives
157
158
  - catalogs/rubygems.yaml
159
+ - catalogs_test/.gitignore
160
+ - catalogs_test/clean
161
+ - catalogs_test/list_all
162
+ - catalogs_test/run
163
+ - catalogs_test/setup
164
+ - catalogs_test/vendored/pacapt
158
165
  - lib/natives.rb
159
166
  - lib/natives/apps.rb
160
167
  - lib/natives/apps/detect.rb