natives 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +8 -8
  2. data/Gemfile +2 -3
  3. data/Gemfile.lock +12 -53
  4. data/README.md +126 -29
  5. data/Rakefile +4 -5
  6. data/VERSION +1 -1
  7. data/bin/natives +1 -0
  8. data/catalogs/rubygems.yaml +50 -0
  9. data/lib/natives/apps/detect.rb +21 -0
  10. data/lib/natives/apps/list.rb +39 -0
  11. data/lib/natives/apps.rb +2 -0
  12. data/lib/natives/catalog/loader.rb +30 -0
  13. data/lib/natives/catalog/merger.rb +26 -0
  14. data/lib/natives/catalog/selector.rb +79 -0
  15. data/lib/natives/catalog/validator.rb +18 -0
  16. data/lib/natives/catalog.rb +56 -0
  17. data/lib/natives/cli.rb +27 -42
  18. data/lib/natives/gemfile_viewer.rb +19 -16
  19. data/lib/natives/host_detection/package_provider.rb +83 -0
  20. data/lib/natives/host_detection/platform.rb +34 -0
  21. data/lib/natives/host_detection.rb +25 -0
  22. data/lib/natives.rb +1 -0
  23. data/spec/fixtures/dir_with_matching_files/invalid1.yml +9 -0
  24. data/spec/fixtures/dir_with_matching_files/not_matching.json +0 -0
  25. data/spec/fixtures/dir_with_matching_files/valid1.yaml +21 -0
  26. data/spec/fixtures/dir_with_matching_files/valid2.yml +9 -0
  27. data/spec/fixtures/dir_without_matching_file/not_matching.json +0 -0
  28. data/spec/natives/apps/detect_spec.rb +26 -0
  29. data/spec/natives/apps/list_spec.rb +58 -0
  30. data/spec/natives/catalog/loader_spec.rb +101 -0
  31. data/spec/natives/catalog/merger_spec.rb +60 -0
  32. data/spec/natives/catalog/selector_spec.rb +124 -0
  33. data/spec/natives/catalog/validator_spec.rb +44 -0
  34. data/spec/natives/catalog_spec.rb +133 -0
  35. data/spec/natives/gemfile_viewer_spec.rb +3 -3
  36. data/spec/natives/host_detection/package_provider_spec.rb +33 -0
  37. data/spec/natives/host_detection/platform_spec.rb +21 -0
  38. data/spec/natives/host_detection_spec.rb +45 -0
  39. data/spec/spec_helper.rb +17 -2
  40. metadata +44 -66
  41. data/chef/.kitchen.yml +0 -27
  42. data/chef/Berksfile +0 -4
  43. data/chef/Berksfile.lock +0 -10
  44. data/chef/cookbooks/natives/Berksfile +0 -3
  45. data/chef/cookbooks/natives/Gemfile +0 -5
  46. data/chef/cookbooks/natives/LICENSE +0 -3
  47. data/chef/cookbooks/natives/README.md +0 -13
  48. data/chef/cookbooks/natives/chefignore +0 -96
  49. data/chef/cookbooks/natives/libraries/natives_recipe_helper.rb +0 -37
  50. data/chef/cookbooks/natives/metadata.rb +0 -9
  51. data/chef/cookbooks/natives/recipes/default.rb +0 -31
  52. data/chef/solo.rb +0 -17
  53. data/chef/vendored-cookbooks/apt/CHANGELOG.md +0 -144
  54. data/chef/vendored-cookbooks/apt/README.md +0 -247
  55. data/chef/vendored-cookbooks/apt/attributes/default.rb +0 -27
  56. data/chef/vendored-cookbooks/apt/files/default/apt-proxy-v2.conf +0 -50
  57. data/chef/vendored-cookbooks/apt/libraries/helpers.rb +0 -47
  58. data/chef/vendored-cookbooks/apt/libraries/network.rb +0 -33
  59. data/chef/vendored-cookbooks/apt/metadata.json +0 -54
  60. data/chef/vendored-cookbooks/apt/metadata.rb +0 -34
  61. data/chef/vendored-cookbooks/apt/providers/preference.rb +0 -61
  62. data/chef/vendored-cookbooks/apt/providers/repository.rb +0 -141
  63. data/chef/vendored-cookbooks/apt/recipes/cacher-client.rb +0 -81
  64. data/chef/vendored-cookbooks/apt/recipes/cacher-ng.rb +0 -43
  65. data/chef/vendored-cookbooks/apt/recipes/default.rb +0 -83
  66. data/chef/vendored-cookbooks/apt/resources/preference.rb +0 -30
  67. data/chef/vendored-cookbooks/apt/resources/repository.rb +0 -41
  68. data/chef/vendored-cookbooks/apt/templates/debian-6.0/acng.conf.erb +0 -173
  69. data/chef/vendored-cookbooks/apt/templates/default/01proxy.erb +0 -5
  70. data/chef/vendored-cookbooks/apt/templates/default/acng.conf.erb +0 -275
  71. data/chef/vendored-cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +0 -269
  72. data/chef/vendored-cookbooks/homebrew/CHANGELOG.md +0 -36
  73. data/chef/vendored-cookbooks/homebrew/README.md +0 -110
  74. data/chef/vendored-cookbooks/homebrew/attributes/default.rb +0 -22
  75. data/chef/vendored-cookbooks/homebrew/libraries/homebrew_mixin.rb +0 -53
  76. data/chef/vendored-cookbooks/homebrew/libraries/homebrew_package.rb +0 -104
  77. data/chef/vendored-cookbooks/homebrew/metadata.json +0 -32
  78. data/chef/vendored-cookbooks/homebrew/metadata.rb +0 -10
  79. data/chef/vendored-cookbooks/homebrew/providers/tap.rb +0 -48
  80. data/chef/vendored-cookbooks/homebrew/recipes/default.rb +0 -46
  81. data/chef/vendored-cookbooks/homebrew/resources/tap.rb +0 -35
  82. data/lib/natives/app.rb +0 -71
  83. data/natives.gemspec +0 -125
  84. data/spec/natives/app_spec.rb +0 -153
@@ -1,269 +0,0 @@
1
- # Letter case in directive names does not matter. Must be separated with colons.
2
- # Valid boolean values are a zero number for false, non-zero numbers for true.
3
-
4
- CacheDir: <%= node['apt']['cacher_dir'] %>
5
-
6
- # set empty to disable logging
7
- LogDir: /var/log/apt-cacher-ng
8
-
9
- # place to look for additional configuration and resource files if they are not
10
- # found in the configuration directory
11
- # SupportDir: /usr/lib/apt-cacher-ng
12
-
13
- # TCP (http) port
14
- # Set to 9999 to emulate apt-proxy
15
- Port:<%= node['apt']['cacher_port'] %>
16
-
17
- # Addresses or hostnames to listen on. Multiple addresses must be separated by
18
- # spaces. Each entry must be an exact local address which is associated with a
19
- # local interface. DNS resolution is performed using getaddrinfo(3) for all
20
- # available protocols (IPv4, IPv6, ...). Using a protocol specific format will
21
- # create binding(s) only on protocol specific socket(s) (e.g. 0.0.0.0 will listen
22
- # only to IPv4).
23
- #
24
- # Default: not set, will listen on all interfaces and protocols
25
- #
26
- # BindAddress: localhost 192.168.7.254 publicNameOnMainInterface
27
-
28
- # The specification of another proxy which shall be used for downloads.
29
- # Username and password are, and see manual for limitations.
30
- #
31
- #Proxy: http://www-proxy.example.net:80
32
- #proxy: username:proxypassword@proxy.example.net:3128
33
-
34
- # Repository remapping. See manual for details.
35
- # In this example, some backends files might be generated during package
36
- # installation using information collected on the system.
37
- Remap-debrep: file:deb_mirror*.gz /debian ; file:backends_debian # Debian Archives
38
- Remap-uburep: file:ubuntu_mirrors /ubuntu ; file:backends_ubuntu # Ubuntu Archives
39
- Remap-debvol: file:debvol_mirror*.gz /debian-volatile ; file:backends_debvol # Debian Volatile Archives
40
-
41
- # This is usually not needed for security.debian.org because it's always the
42
- # same DNS hostname. However, it might be enabled in order to use hooks,
43
- # ForceManaged mode or special flags in this context.
44
- # Remap-secdeb: security.debian.org
45
-
46
- # Virtual page accessible in a web browser to see statistics and status
47
- # information, i.e. under http://localhost:3142/acng-report.html
48
- ReportPage: acng-report.html
49
-
50
- # Socket file for accessing through local UNIX socket instead of TCP/IP. Can be
51
- # used with inetd bridge or cron client.
52
- # SocketPath:/var/run/apt-cacher-ng/socket
53
-
54
- # Forces log file to be written to disk after every line when set to 1. Default
55
- # is 0, buffers are flushed when the client disconnects.
56
- #
57
- # (technically, alias to the Debug option, see its documentation for details)
58
- #
59
- # UnbufferLogs: 0
60
-
61
- # Set to 0 to store only type, time and transfer sizes.
62
- # 1 -> client IP and relative local path are logged too
63
- # VerboseLog: 1
64
-
65
- # Don't detach from the console
66
- # ForeGround: 0
67
-
68
- # Store the pid of the daemon process therein
69
- # PidFile: /var/run/apt-cacher-ng/pid
70
-
71
- # Forbid outgoing connections, work around them or respond with 503 error
72
- # offlinemode:0
73
-
74
- # Forbid all downloads that don't run through preconfigured backends (.where)
75
- #ForceManaged: 0
76
-
77
- # Days before considering an unreferenced file expired (to be deleted).
78
- # Warning: if the value is set too low and particular index files are not
79
- # available for some days (mirror downtime) there is a risk of deletion of
80
- # still useful package files.
81
- ExTreshold: 4
82
-
83
- # Stop expiration when a critical problem appeared. Currently only failed
84
- # refresh of an index file is considered as critical.
85
- #
86
- # WARNING: don't touch this option or set to zero.
87
- # Anything else is DANGEROUS and may cause data loss.
88
- #
89
- # ExAbortOnProblems: 1
90
-
91
- # Replace some Windows/DOS-FS incompatible chars when storing
92
- # StupidFs: 0
93
-
94
- # Experimental feature for apt-listbugs: pass-through SOAP requests and
95
- # responses to/from bugs.debian.org. If not set, default is true if
96
- # ForceManaged is enabled and false otherwise.
97
- # ForwardBtsSoap: 1
98
-
99
- # The daemon has a small cache for DNS data, to speed up resolution. The
100
- # expiration time of the DNS entries can be configured in seconds.
101
- # DnsCacheSeconds: 3600
102
-
103
- # Don't touch the following values without good consideration!
104
- #
105
- # Max. count of connection threads kept ready (for faster response in the
106
- # future). Should be a sane value between 0 and average number of connections,
107
- # and depend on the amount of spare RAM.
108
- # MaxStandbyConThreads: 8
109
- #
110
- # Hard limit of active thread count for incoming connections, i.e. operation
111
- # is refused when this value is reached (below zero = unlimited).
112
- # MaxConThreads: -1
113
- #
114
- # Pigeonholing files with regular expressions (static/volatile). Can be
115
- # overriden here but not should not be done permanently because future update
116
- # of default settings would not be applied later.
117
- # VfilePattern = (^|.*?/)(Index|Packages(\.gz|\.bz2|\.lzma|\.xz)?|InRelease|Release|Release\.gpg|Sources(\.gz|\.bz2|\.lzma|\.xz)?|release|index\.db-.*\.gz|Contents-[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|pkglist[^/]*\.bz2|rclist[^/]*\.bz2|/meta-release[^/]*|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|((setup|setup-legacy)(\.ini|\.bz2|\.hint)(\.sig)?)|mirrors\.lst|repo(index|md)\.xml(\.asc|\.key)?|directory\.yast|products|content(\.asc|\.key)?|media|filelists\.xml\.gz|filelists\.sqlite\.bz2|repomd\.xml|packages\.[a-zA-Z][a-zA-Z]\.gz|info\.txt|license\.tar\.gz|license\.zip|.*\.db(\.tar\.gz)?|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|metalink\?repo|.*prestodelta\.xml\.gz)$|/dists/.*/installer-[^/]+/[^0-9][^/]+/images/.*
118
- # PfilePattern = .*(\.d?deb|\.rpm|\.dsc|\.tar(\.gz|\.bz2|\.lzma|\.xz)(\.gpg)?|\.diff(\.gz|\.bz2|\.lzma|\.xz)|\.jigdo|\.template|changelog|copyright|\.udeb|\.debdelta|\.diff/.*\.gz|(Devel)?ReleaseAnnouncement(\?.*)?|[a-f0-9]+-(susedata|updateinfo|primary|deltainfo).xml.gz|fonts/(final/)?[a-z]+32.exe(\?download.*)?|/dists/.*/installer-[^/]+/[0-9][^/]+/images/.*)$
119
- # Whitelist for expiration, file types not to be removed even when being
120
- # unreferenced. Default: many parts from VfilePattern where no parent index
121
- # exists or might be unknown.
122
- # WfilePattern = (^|.*?/)(Release|InRelease|Release\.gpg|(Packages|Sources)(\.gz|\.bz2|\.lzma|\.xz)?|Translation[^/]*(\.gz|\.bz2|\.lzma|\.xz)?|MD5SUMS|SHA1SUMS|.*\.xml|.*\.db\.tar\.gz|.*\.files\.tar\.gz|.*\.abs\.tar\.gz|[a-z]+32.exe)$|/dists/.*/installer-.*/images/.*
123
-
124
- # Higher modes only working with the debug version
125
- # Warning, writes a lot into apt-cacher.err logfile
126
- # Value overwrites UnbufferLogs setting (aliased)
127
- # Debug:3
128
-
129
- # Usually, general purpose proxies like Squid expose the IP address of the
130
- # client user to the remote server using the X-Forwarded-For HTTP header. This
131
- # behaviour can be optionally turned on with the Expose-Origin option.
132
- # ExposeOrigin: 0
133
-
134
- # When logging the originating IP address, trust the information supplied by
135
- # the client in the X-Forwarded-For header.
136
- # LogSubmittedOrigin: 0
137
-
138
- # The version string reported to the peer, to be displayed as HTTP client (and
139
- # version) in the logs of the mirror.
140
- # WARNING: some archives use this header to detect/guess capabilities of the
141
- # client (i.e. redirection support) and change the behaviour accordingly, while
142
- # ACNG might not support the expected features. Expect side effects.
143
- #
144
- # UserAgent: Yet Another HTTP Client/1.2.3p4
145
-
146
- # In some cases the Import and Expiration tasks might create fresh volatile
147
- # data for internal use by reconstructing them using patch files. This
148
- # by-product might be recompressed with bzip2 and with some luck the resulting
149
- # file becomes identical to the *.bz2 file on the server, usable for APT
150
- # clients trying to fetch the full .bz2 compressed version. Injection of the
151
- # generated files into the cache has however a disadvantage on underpowered
152
- # servers: bzip2 compression can create high load on the server system and the
153
- # visible download of the busy .bz2 files also becomes slower.
154
- #
155
- # RecompBz2: 0
156
-
157
- # Network timeout for outgoing connections.
158
- # NetworkTimeout: 60
159
-
160
- # Sometimes it makes sense to not store the data in cache and just return the
161
- # package data to client as it comes in. DontCache parameters can enable this
162
- # behaviour for certain URL types. The tokens are extended regular expressions
163
- # that URLs are matched against.
164
- #
165
- # DontCacheRequested is applied to the URL as it comes in from the client.
166
- # Example: exclude packages built with kernel-package for x86
167
- # DontCacheRequested: linux-.*_10\...\.Custo._i386
168
- # Example usecase: exclude popular private IP ranges from caching
169
- # DontCacheRequested: 192.168.0 ^10\..* 172.30
170
- #
171
- # DontCacheResolved is applied to URLs after mapping to the target server. If
172
- # multiple backend servers are specified then it's only matched against the
173
- # download link for the FIRST possible source (due to implementation limits).
174
- # Example usecase: all Ubuntu stuff comes from a local mirror (specified as
175
- # backend), don't cache it again:
176
- # DontCacheResolved: ubuntumirror.local.net
177
- #
178
- # DontCache directive sets (overrides) both, DontCacheResolved and
179
- # DontCacheRequested. Provided for convenience, see those directives for
180
- # details.
181
- #
182
- # Default permission set of freshly created files and directories, as octal
183
- # numbers (see chmod(1) for details).
184
- # Can by limited by the umask value (see umask(2) for details) if it's set in
185
- # the environment of the starting shell, e.g. in apt-cacher-ng init script or
186
- # in its configuration file.
187
- # DirPerms: 00755
188
- # FilePerms: 00664
189
- #
190
- #
191
- # It's possible to use use apt-cacher-ng as a regular web server with limited
192
- # feature set, i.e.
193
- # including directory browsing and download of any file;
194
- # excluding sorting, mime types/encodings, CGI execution, index page
195
- # redirection and other funny things.
196
- # To get this behavior, mappings between virtual directories and real
197
- # directories on the server must be defined with the LocalDirs directive.
198
- # Virtual and real dirs are separated by spaces, multiple pairs are separated
199
- # by semi-colons. Real directories must be absolute paths.
200
- # NOTE: Since the names of that key directories share the same namespace as
201
- # repository names (see Remap-...) it's administrators job to avoid such
202
- # collisions on them (unless created deliberately).
203
- #
204
- # LocalDirs: woo /data/debarchive/woody ; hamm /data/debarchive/hamm
205
-
206
- # Precache a set of files referenced by specified index files. This can be used
207
- # to create a partial mirror usable for offline work. There are certain limits
208
- # and restrictions on the path specification, see manual for details. A list of
209
- # (maybe) relevant index files could be retrieved via
210
- # "apt-get --print-uris update" on a client machine.
211
- #
212
- # PrecacheFor: debrep/dists/unstable/*/source/Sources* debrep/dists/unstable/*/binary-amd64/Packages*
213
-
214
- # Arbitrary set of data to append to request headers sent over the wire. Should
215
- # be a well formated HTTP headers part including newlines (DOS style) which
216
- # can be entered as escape sequences (\r\n).
217
- # RequestAppendix: X-Tracking-Choice: do-not-track\r\n
218
-
219
- # Specifies the IP protocol families to use for remote connections. Order does
220
- # matter, first specified are considered first. Possible combinations:
221
- # v6 v4
222
- # v4 v6
223
- # v6
224
- # v4
225
- # (empty or not set: use system default)
226
- #
227
- # ConnectProto: v6 v4
228
-
229
- # Regular expiration algorithm finds package files which are no longer listed
230
- # in any index file and removes them of them after a safety period.
231
- # This option allows to keep more versions of a package in the cache after
232
- # safety period is over.
233
- # KeepExtraVersions: 1
234
-
235
- # Optionally uses TCP access control provided by libwrap, see hosts_access(5)
236
- # for details. Daemon name is apt-cacher-ng. Default if not set: decided on
237
- # startup by looking for explicit mentioning of apt-cacher-ng in
238
- # /etc/hosts.allow or /etc/hosts.deny files.
239
- # UseWrap: 0
240
-
241
- # If many machines from the same local network attempt to update index files
242
- # (apt-get update) at nearly the same time, the known state of these index file
243
- # is temporarily frozen and multiple requests receive the cached response
244
- # without contacting the server. This parameter (in seconds) specifies the
245
- # length of this period before the files are considered outdated.
246
- # Setting it too low transfers more data and increases remote server load,
247
- # setting it too high (more than a couple of minutes) increases the risk of
248
- # delivering inconsistent responses to the clients.
249
- # FreshIndexMaxAge: 27
250
-
251
- # Usually the users are not allowed to specify custom TCP ports of remote
252
- # mirrors in the requests, only the default HTTP port can be used (instead,
253
- # proxy administrator can create Remap- rules with custom ports). This
254
- # restriction can be disabled by specifying a list of allowed ports or 0 for
255
- # any port.
256
- #
257
- # AllowUserPorts: 80
258
-
259
- # Normally the HTTP redirection responses are forwarded to the original caller
260
- # (i.e. APT) which starts a new download attempt from the new URL. This
261
- # solution is ok for client configurations with proxy mode but doesn't work
262
- # well with configurations using URL prefixes. To work around this the server
263
- # can restart its own download with another URL. However, this might be used to
264
- # circumvent download source policies by malicious users.
265
- # The RedirMax option specifies how many such redirects the server should
266
- # follow per request, 0 disables the internal redirection. If not set,
267
- # default value is 0 if ForceManaged is used and 5 otherwise.
268
- #
269
- # RedirMax: 5
@@ -1,36 +0,0 @@
1
- homebrew Cookbook CHANGELOG
2
- ===========================
3
- This file is used to list changes made in each version of the homebrew cookbook.
4
-
5
-
6
- v1.5.0
7
- ------
8
- ### Bug
9
- - **[COOK-3589](https://tickets.opscode.com/browse/COOK-3589)** - Add homebrew as the default package manager on OS X Server
10
-
11
- v1.4.0
12
- ------
13
- ### Bug
14
- - **[COOK-3283](https://tickets.opscode.com/browse/COOK-3283)** - Support running homebrew cookbook as root user, with sudo, or a non-privileged user
15
-
16
- v1.3.2
17
- ------
18
- - [COOK-1793] - use homebrew "go" script to install homebrew
19
- - [COOK-1821] - Discovered version using Homebrew Formula factory fails check that verifies that version is a String
20
- - [COOK-1843] - Homebrew README.md contains non-ASCII characters, triggering same issue as COOK-522
21
-
22
- v1.3.0
23
- ------
24
- - [COOK-1425] - use new json output format for formula
25
- - [COOK-1578] - Use shell_out! instead of popen4
26
-
27
- v1.2.0
28
- ------
29
- Opscode has taken maintenance of this cookbook as the original author has other commitments. This is the initial release with Opscode as maintainer.
30
-
31
- Changes in this release:
32
-
33
- - [pull/2] - support for option passing to brew
34
- - [pull/3] - add brew upgrade and control return value from command
35
- - [pull/9] - added LWRP for "brew tap"
36
- - README is now markdown, not rdoc.
@@ -1,110 +0,0 @@
1
- Homebrew Cookbook
2
- =================
3
- This cookbook installs [Homebrew](http://mxcl.github.com/homebrew/) and replaces MacPorts as the *default package provider* for the package resource on OS X systems.
4
-
5
- This cookbook is now maintained by Opscode. The original author, maintainer and copyright holder is Graeme Mathieson. The cookbook remains licensed under the Apache License version 2.
6
-
7
- [Original blog post by Graeme](http://woss.name/2011/01/23/converging-your-home-directory-with-chef/)
8
-
9
-
10
- Requirements
11
- ------------
12
- ### Prerequisites
13
-
14
- In order for this recipe to work, your userid must own `/usr/local`. This is outside the scope of the cookbook because it's anticipated that you'll run the cookbook as your own user, not root and you'd have to be root to take ownership of the directory. Easiest way to get started:
15
-
16
- ```bash
17
- sudo chown -R `whoami`:staff /usr/local
18
- ```
19
-
20
- Bear in mind that this will take ownership of the entire folder and its contents, so if you've already got stuff in there (eg MySQL owned by a `mysql` user) you'll need to be a touch more careful. This is a recommendation from Homebrew.
21
-
22
- ### Platform
23
-
24
- - Mac OS X (10.6+)
25
-
26
- The only platform supported by Homebrew itself at the time of this writing is Mac OS X. It should work fine on Server edition as well, and on platforms that Homebrew supports in the future.
27
-
28
-
29
- Attributes
30
- ----------
31
- - `node['homebrew']['owner']` - The user that will own the Homebrew installation and packages. Setting this will override the default behavior which is to use the non-privileged user that has invoked the Chef run (or the `SUDO_USER` if invoked with sudo). The default is `nil`.
32
-
33
-
34
- Resources and Providers
35
- -----------------------
36
- ### package / homebrew\_package
37
-
38
- This cookbook provides a package provider called `homebrew_package` which will install/remove packages using Homebrew. This becomes the default provider for `package` if your platform is Mac OS X.
39
-
40
- As this extends the built-in package resource/provider in Chef, it has all the resource attributes and actions available to the package resource. However, a couple notes:
41
-
42
- - Homebrew itself doesn't have a notion of "upgrade" per se. The "upgrade" action will simply perform an install, and if the Homebrew Formula for the package is newer, it will upgrade.
43
- - Likewise, Homebrew doesn't have a purge, but the "purge" action will act like "remove".
44
-
45
- #### Examples
46
-
47
- ```ruby
48
- package 'mysql' do
49
- action :install
50
- end
51
-
52
- homebrew_package 'mysql'
53
-
54
- package 'mysql' do
55
- provider Chef::Provider::Package::Homebrew
56
- end
57
- ```
58
-
59
- ### homebrew\_tap
60
-
61
- LWRP for `brew tap`, a Homebrew command used to add additional formula repositories. From the `brew` man page:
62
-
63
- ```text
64
- tap [tap]
65
- Tap a new formula repository from GitHub, or list existing taps.
66
-
67
- tap is of the form user/repo, e.g. brew tap homebrew/dupes.
68
- ```
69
-
70
- Default action is `:tap` which enables the repository. Use `:untap` to disable a tapped repository.
71
-
72
- #### Examples
73
-
74
- ```ruby
75
- homebrew_tap 'homebrew/dupes'
76
-
77
- homebrew_tap 'homebrew/dupes' do
78
- action :untap
79
- end
80
- ```
81
-
82
-
83
- Usage
84
- -----
85
- We strongly recommend that you put "recipe[homebrew]" in your node's run list, to ensure that it is available on the system and that Homebrew itself gets installed. Putting an explicit dependency in the metadata will cause the cookbook to be downloaded and the library loaded, thus resulting in changing the package provider on Mac OS X, so if you have systems you want to use the default (Mac Ports), they would be changed to Homebrew.
86
-
87
- The default itself ensures that Homebrew is installed and up to date.
88
-
89
-
90
- License and Authors
91
- -------------------
92
- - Author:: Graeme Mathieson (<mathie@woss.name>)
93
- - Author:: Joshua Timberman (<joshua@opscode.com>)
94
-
95
- ```text
96
- Copyright:: 2011, Graeme Mathieson
97
- Copyright:: 2012, Opscode, Inc <legal@opscode.com>
98
-
99
- Licensed under the Apache License, Version 2.0 (the "License"); you may
100
- not use this file except in compliance with the License. You may obtain
101
- a copy of the License at
102
-
103
- http://www.apache.org/licenses/LICENSE-2.0
104
-
105
- Unless required by applicable law or agreed to in writing, software
106
- distributed under the License is distributed on an "AS IS" BASIS,
107
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
108
- See the License for the specific language governing permissions and
109
- limitations under the License.
110
- ```
@@ -1,22 +0,0 @@
1
- #
2
- # Author:: Joshua Timberman (<jtimberman@opscode.com>)
3
- # Author:: Graeme Mathieson (<mathie@woss.name>)
4
- # Cookbook Name:: homebrew
5
- # Attributes:: default
6
- #
7
- # Copyright 2011-2013, Opscode, Inc.
8
- #
9
- # Licensed under the Apache License, Version 2.0 (the "License");
10
- # you may not use this file except in compliance with the License.
11
- # You may obtain a copy of the License at
12
- #
13
- # http://www.apache.org/licenses/LICENSE-2.0
14
- #
15
- # Unless required by applicable law or agreed to in writing, software
16
- # distributed under the License is distributed on an "AS IS" BASIS,
17
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
-
22
- default['homebrew']['owner'] = nil
@@ -1,53 +0,0 @@
1
- #
2
- # Author:: Joshua Timberman (<jtimberman@opscode.com>)
3
- # Author:: Graeme Mathieson (<mathie@woss.name>)
4
- # Cookbook Name:: homebrew
5
- # Libraries:: homebrew_mixin
6
- #
7
- # Copyright 2011-2013, Opscode, Inc.
8
- #
9
- # Licensed under the Apache License, Version 2.0 (the "License");
10
- # you may not use this file except in compliance with the License.
11
- # You may obtain a copy of the License at
12
- #
13
- # http://www.apache.org/licenses/LICENSE-2.0
14
- #
15
- # Unless required by applicable law or agreed to in writing, software
16
- # distributed under the License is distributed on an "AS IS" BASIS,
17
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
-
22
- module Homebrew
23
- module Mixin
24
-
25
- def homebrew_owner
26
- @homebrew_owner ||= calculate_owner
27
- end
28
-
29
- private
30
-
31
- def calculate_owner
32
- owner = homebrew_owner_attr || sudo_user || current_user
33
- if owner == "root"
34
- raise Chef::Exceptions::User,
35
- "Homebrew owner is 'root' which is not supported. " +
36
- "To set an explicit owner, please set node['homebrew']['owner']."
37
- end
38
- owner
39
- end
40
-
41
- def homebrew_owner_attr
42
- node['homebrew']['owner']
43
- end
44
-
45
- def sudo_user
46
- ENV['SUDO_USER']
47
- end
48
-
49
- def current_user
50
- ENV['USER']
51
- end
52
- end
53
- end
@@ -1,104 +0,0 @@
1
- #
2
- # Author:: Joshua Timberman (<jtimberman@opscode.com>)
3
- # Author:: Graeme Mathieson (<mathie@woss.name>)
4
- # Cookbook Name:: homebrew
5
- # Libraries:: homebrew_package
6
- #
7
- # Copyright 2011-2013, Opscode, Inc.
8
- #
9
- # Licensed under the Apache License, Version 2.0 (the "License");
10
- # you may not use this file except in compliance with the License.
11
- # You may obtain a copy of the License at
12
- #
13
- # http://www.apache.org/licenses/LICENSE-2.0
14
- #
15
- # Unless required by applicable law or agreed to in writing, software
16
- # distributed under the License is distributed on an "AS IS" BASIS,
17
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
- # See the License for the specific language governing permissions and
19
- # limitations under the License.
20
- #
21
-
22
- require 'chef/provider/package'
23
- require 'chef/resource/package'
24
- require 'chef/platform'
25
- require 'chef/mixin/shell_out'
26
-
27
- class Chef
28
- class Provider
29
- class Package
30
- class Homebrew < Package
31
-
32
- include Chef::Mixin::ShellOut
33
- include ::Homebrew::Mixin
34
-
35
- def load_current_resource
36
- @current_resource = Chef::Resource::Package.new(@new_resource.name)
37
- @current_resource.package_name(@new_resource.package_name)
38
- @current_resource.version(current_installed_version)
39
-
40
- @current_resource
41
- end
42
-
43
- def install_package(name, version)
44
- brew('install', @new_resource.options, name)
45
- end
46
-
47
- def upgrade_package(name, version)
48
- brew('upgrade', name)
49
- end
50
-
51
- def remove_package(name, version)
52
- brew('uninstall', @new_resource.options, name)
53
- end
54
-
55
- # Homebrew doesn't really have a notion of purging, so just remove.
56
- def purge_package(name, version)
57
- @new_resource.options = ((@new_resource.options || "") << " --force").strip
58
- remove_package(name, version)
59
- end
60
-
61
- protected
62
- def brew(*args)
63
- get_response_from_command("brew #{args.join(' ')}")
64
- end
65
-
66
- def current_installed_version
67
- pkg = get_version_from_formula
68
- versions = pkg.to_hash['installed'].map {|v| v['version']}
69
- versions.join(" ") unless versions.empty?
70
- end
71
-
72
- def candidate_version
73
- pkg = get_version_from_formula
74
- pkg.stable.version.to_s || pkg.version.to_s
75
- end
76
-
77
- def get_version_from_command(command)
78
- version = get_response_from_command(command).chomp
79
- version.empty? ? nil : version
80
- end
81
-
82
- def get_version_from_formula
83
- brew_cmd = shell_out!("brew --prefix", :user => homebrew_owner)
84
- libpath = ::File.join(brew_cmd.stdout.chomp, "Library", "Homebrew")
85
- $:.unshift(libpath)
86
-
87
- require 'global'
88
- require 'cmd/info'
89
-
90
- Formula.factory new_resource.package_name
91
- end
92
-
93
- def get_response_from_command(command)
94
- Chef::Log.debug "Executing '#{command}' as #{homebrew_owner}"
95
- output = shell_out!(command, :user => homebrew_owner)
96
- output.stdout
97
- end
98
- end
99
- end
100
- end
101
- end
102
-
103
- Chef::Platform.set :platform => :mac_os_x_server, :resource => :package, :provider => Chef::Provider::Package::Homebrew
104
- Chef::Platform.set :platform => :mac_os_x, :resource => :package, :provider => Chef::Provider::Package::Homebrew
@@ -1,32 +0,0 @@
1
- {
2
- "name": "homebrew",
3
- "version": "1.5.0",
4
- "description": "Install Homebrew and use it as your package provider in Mac OS X",
5
- "long_description": "Homebrew Cookbook\n=================\nThis cookbook installs [Homebrew](http://mxcl.github.com/homebrew/) and replaces MacPorts as the *default package provider* for the package resource on OS X systems.\n\nThis cookbook is now maintained by Opscode. The original author, maintainer and copyright holder is Graeme Mathieson. The cookbook remains licensed under the Apache License version 2.\n\n[Original blog post by Graeme](http://woss.name/2011/01/23/converging-your-home-directory-with-chef/)\n\n\nRequirements\n------------\n### Prerequisites\n\nIn order for this recipe to work, your userid must own `/usr/local`. This is outside the scope of the cookbook because it's anticipated that you'll run the cookbook as your own user, not root and you'd have to be root to take ownership of the directory. Easiest way to get started:\n\n```bash\nsudo chown -R `whoami`:staff /usr/local\n```\n\nBear in mind that this will take ownership of the entire folder and its contents, so if you've already got stuff in there (eg MySQL owned by a `mysql` user) you'll need to be a touch more careful. This is a recommendation from Homebrew.\n\n### Platform\n\n- Mac OS X (10.6+)\n\nThe only platform supported by Homebrew itself at the time of this writing is Mac OS X. It should work fine on Server edition as well, and on platforms that Homebrew supports in the future.\n\n\nAttributes\n----------\n- `node['homebrew']['owner']` - The user that will own the Homebrew installation and packages. Setting this will override the default behavior which is to use the non-privileged user that has invoked the Chef run (or the `SUDO_USER` if invoked with sudo). The default is `nil`.\n\n\nResources and Providers\n-----------------------\n### package / homebrew\\_package\n\nThis cookbook provides a package provider called `homebrew_package` which will install/remove packages using Homebrew. This becomes the default provider for `package` if your platform is Mac OS X.\n\nAs this extends the built-in package resource/provider in Chef, it has all the resource attributes and actions available to the package resource. However, a couple notes:\n\n- Homebrew itself doesn't have a notion of \"upgrade\" per se. The \"upgrade\" action will simply perform an install, and if the Homebrew Formula for the package is newer, it will upgrade.\n- Likewise, Homebrew doesn't have a purge, but the \"purge\" action will act like \"remove\".\n\n#### Examples\n\n```ruby\npackage 'mysql' do\n action :install\nend\n\nhomebrew_package 'mysql'\n\npackage 'mysql' do\n provider Chef::Provider::Package::Homebrew\nend\n```\n\n### homebrew\\_tap\n\nLWRP for `brew tap`, a Homebrew command used to add additional formula repositories. From the `brew` man page:\n\n```text\ntap [tap]\n Tap a new formula repository from GitHub, or list existing taps.\n\n tap is of the form user/repo, e.g. brew tap homebrew/dupes.\n```\n\nDefault action is `:tap` which enables the repository. Use `:untap` to disable a tapped repository.\n\n#### Examples\n\n```ruby\nhomebrew_tap 'homebrew/dupes'\n\nhomebrew_tap 'homebrew/dupes' do\n action :untap\nend\n```\n\n\nUsage\n-----\nWe strongly recommend that you put \"recipe[homebrew]\" in your node's run list, to ensure that it is available on the system and that Homebrew itself gets installed. Putting an explicit dependency in the metadata will cause the cookbook to be downloaded and the library loaded, thus resulting in changing the package provider on Mac OS X, so if you have systems you want to use the default (Mac Ports), they would be changed to Homebrew.\n\nThe default itself ensures that Homebrew is installed and up to date.\n\n\nLicense and Authors\n-------------------\n- Author:: Graeme Mathieson (<mathie@woss.name>)\n- Author:: Joshua Timberman (<joshua@opscode.com>)\n\n```text\nCopyright:: 2011, Graeme Mathieson\nCopyright:: 2012, Opscode, Inc <legal@opscode.com>\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may\nnot use this file except in compliance with the License. You may obtain\na copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n",
6
- "maintainer": "Opscode, Inc.",
7
- "maintainer_email": "cookbooks@opscode.com",
8
- "license": "Apache 2.0",
9
- "platforms": {
10
- "mac_os_x": ">= 0.0.0",
11
- "mac_os_x_server": ">= 0.0.0"
12
- },
13
- "dependencies": {
14
- },
15
- "recommendations": {
16
- },
17
- "suggestions": {
18
- },
19
- "conflicting": {
20
- },
21
- "providing": {
22
- },
23
- "replacing": {
24
- },
25
- "attributes": {
26
- },
27
- "groupings": {
28
- },
29
- "recipes": {
30
- "homebrew": "Install Homebrew"
31
- }
32
- }
@@ -1,10 +0,0 @@
1
- name "homebrew"
2
- maintainer "Opscode, Inc."
3
- maintainer_email "cookbooks@opscode.com"
4
- license "Apache 2.0"
5
- description "Install Homebrew and use it as your package provider in Mac OS X"
6
- long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
7
- version "1.5.0"
8
- recipe "homebrew", "Install Homebrew"
9
- supports "mac_os_x"
10
- supports "mac_os_x_server"