65 Commits

Author SHA1 Message Date
Kevin Abel
8fddd87472
Resource, CurlDownloadStrategy: Deduplicate the curl HEAD requests
Fixes #5357

* Eliminates getting a new strategy instance via Resource methods
* only call resolve_url_basename_time once and store the time result as
an instance variable for reuse
2018-12-16 13:56:58 -06:00
EricFromCanada
20167e5f1b Adjust comments to tidy API docs output. 2018-10-18 21:42:43 -04:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Markus Reiter
7c496f7a7e Explicitly pass specs to download strategy. 2018-08-02 10:33:14 +02:00
Markus Reiter
e367e7eea8 Explicitly pass url and mirrors to download strategy. 2018-08-02 10:09:35 +02:00
Markus Reiter
9ffc7dd465 Use Resource#downloader for BottleLoader. 2018-08-01 05:40:15 +02:00
Markus Reiter
3d27b2aa8d Explicitly pass version to download strategy. 2018-08-01 05:40:15 +02:00
Mike McQuaid
256dfc1af9 Move methods from FileUtils to Formula
These don't need to live on FileUtils and don't really make sense there
either.
2018-07-14 18:13:23 +01:00
Mike McQuaid
abf3043125 formula: move mktemp.
This should be an instance rather than a class method.
2018-07-14 15:41:16 +01:00
Mike McQuaid
0a76c9f02e mktemp: move to Formula and compat.
Move this method away from FileUtils as it doesn't need to be on that
class.
2018-07-13 14:42:49 +01:00
Markus Reiter
5e3bc85527 Remove unnecessary Pathname check. 2018-07-05 11:54:32 +02:00
Mike McQuaid
c101a82c5b
Revert "Fix SVN downloads of versioned formula by munging directory names" 2018-06-26 07:10:36 +01:00
Andrew Janke
b72c4e3248 Fix SVN downloads of versioned formula by munging directory names 2018-06-25 03:21:36 -04:00
ilovezfs
7c07ec5fc1 resource: allow patches to be applied 2018-01-22 01:10:14 -08:00
Markus Reiter
3b4ee58c49 Refactor using Forwardable and DelegateClass. 2017-06-28 09:25:31 +02:00
Misty De Meo
4e3d23ad14 Resource: set version to nil if version is null
Is this the right fix? This fixes version cascading from the parent.
2016-11-10 15:09:36 -08:00
Vlad Shablinsky
8a968a0b60
resource: detect HEAD versions 2016-07-16 20:39:13 +08:00
ilovezfs
21ca138edf Resource.unpack: install invisible files and dirs
Since patches sometimes change .gitignore and .travis.yml, it's
desirable to install them along with everything else if a resource needs
patching. Also, for resources that are git respositories, this allows
install to interact with git objects other than the commit specifically
checked out. More generally, this may help to avoid subtle issues by
preserving the fidelity of resources in cases where invisible dot files
play a functional role.

Closes #329.

Signed-off-by: ilovezfs <ilovezfs@icloud.com>
2016-06-07 12:16:43 -07:00
Andrew Janke
258a764f67 stage: fix block signature back-compatibility under Ruby 1.8.7
The new stage() signature introduced by #66 breaks back-compatibility
under Ruby 1.8.7. This fixes it by switching back to a one-argument
block signature and using a new class to wrap both the Resource and
Mktemp info for the staging context, in a signature-back-compatible
way.

Addresses homebrew/homebrew-core#529.

Closes #135.

Signed-off-by: Andrew Janke <andrew@apjanke.net>
2016-04-22 21:49:00 -04:00
Andrew Janke
acc9a7ca85 brew test, install, update-test: add --keep-tmp option
Also enables sandbox for --interactive and --debug use of install
and test, using automatic retention.

Closes #66.

Signed-off-by: Andrew Janke <andrew@apjanke.net>
2016-04-18 12:23:08 -04:00
ilovezfs
cc3d041c26 DSL method "apply" to specify patch files
The "apply" DSL method can be called from patch-do blocks to specify
the paths within an archive of the desired patch files, which will be
applied in the order in which they were supplied to the "apply" calls.
If "apply" isn't used, raise an error whenever the extracted directory
doesn't contain exactly one file.

The "apply" method can be called zero or more times within a patch-do
block with the following syntaxes supported:

    apply "single_apply"
    apply "multiple_apply_1", "multiple_apply_2"
    apply [array_of_apply]

If apply must be used, a single call using the second syntax above is
usually best practice. Each apply leaf should be the relative path to a
specific patch file in the extracted directory.

For example, if extracting this-v123-patches.tar.gz gives you

    this-123
    this-123/.DS_Store
    this-123/LICENSE.txt
    this-123/patches
    this-123/patches/A.diff
    this-123/patches/B.diff
    this-123/patches/C.diff
    this-123/README.txt

and you want to apply only B.diff and C.diff, then you need to use
"patches/B.diff" and "patches/C.diff" for the lowest-level apply leaves.

The code was provided by Xu Cheng. Any mistakes are mine.
2016-02-01 18:37:36 +00:00
Xu Cheng
6c8c56a689 build: store source modified time in tabfile 2016-01-15 16:26:04 +08:00
Xu Cheng
b121e5fd7b more core file style updated by rubocop 2015-08-06 17:23:56 +08:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Dominyk Tiller
12861686b8 checksums: switch to sha256 for bottles and new formulae
Closes Homebrew/homebrew#37164.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-03-05 14:45:39 +00:00
Jack Nagel
7a49c143e4 Use attr_accessor for checksum 2015-01-12 00:37:24 -05:00
Jack Nagel
0f01e9ff43 Remove the direct url writer from Resource 2015-01-08 14:18:41 -05:00
Jack Nagel
b459f953c4 Stop caching the downloader on the resource instance 2015-01-06 00:25:04 -05:00
Jack Nagel
62c0a391b4 Don't attempt to detect version if URL is not set 2014-12-31 10:38:04 -05:00
Jack Nagel
9a89878b75 Revert "Skip temporary directory when target directory is known"
This reverts commit 028ee18b851497f8aede55004bcdcc5c16f087cc.
2014-12-14 17:59:35 -05:00
Jack Nagel
5ca4dbfd25 Skip temporary directory when target directory is known 2014-12-14 13:32:55 -05:00
Jack Nagel
0ed43d607b Validate arguments in Resource#stage 2014-12-13 23:27:59 -05:00
Jack Nagel
d157301cdc Pass the downloader a proxy object instead of the resource
We need to limit the interface that is exposed to the downloader in
order to make future changes easier.

This will be important for work on new features, such as selecting
a mirror from the command line.

In the future, the existing Resource class will probably be split into
multiple classes.
2014-12-05 22:11:23 -05:00
Jack Nagel
68a5268aef Download strategies should return a Pathname from cached_location 2014-12-05 18:08:21 -05:00
Jack Nagel
3d96dad25c Pull cache creation out of begin block 2014-10-10 20:30:29 -05:00
Jack Nagel
b3ed5a367d Remove redundant comments 2014-10-10 20:30:29 -05:00
Misty De Meo
4743fc1662 Add Go language module, resources
This introduces a new GoResource category of resource. GoResources
have a specialized stage method which allows a resource to stage
itself into a gopath.

The new Go language module provides a one-liner to stage all
GoResources present in the formula.
2014-09-01 19:56:43 -07:00
Misty De Meo
aec47d8a19 resource: escape slashes from download_name
This is useful to be able to write go resources using their package
name as the resource name
2014-09-01 19:56:43 -07:00
Jack Nagel
771bc2978c Eagerly set the download strategy 2014-07-15 13:42:03 -05:00
Jack Nagel
f446e95852 Remove support for version "schemes", just pass version objects directly
I'm not sure why I thought reinventing object instantiation was a good
idea.
2014-05-27 21:41:43 -05:00
Jack Nagel
28fa5b0261 Remove some evals from formula DSL
The default arguments were removed from these methods long ago, so
nothing is standing in the way of using define_method here.
2014-05-27 21:03:47 -05:00
Jack Nagel
7af46a5ed0 Always use CurlDownloadStrategy for legacy patches
Fixes Homebrew/homebrew#27671.
2014-03-18 14:24:32 -05:00
Jack Nagel
bc6e4a1894 New patch implementation and DSL
This commit introduces a new patch implementation that supports
checksums and caching.

Patches are declared in blocks:

  patch do
    url ...
    sha1 ...
  end

A strip level of -p1 is assumed. It can be overridden using a symbol
argument:

  patch :p0 do
    url ...
    sha1 ...
  end

Patches can be declared in stable, devel, and head blocks. This form is
preferred over using conditionals.

  stable do
    # ...

    patch do
      url ...
      sha1 ...
    end
  end

Embedded (__END__) patches are declared like so:

  patch :DATA
  patch :p0, :DATA

Patches can also be embedded by passing a string. This makes it possible
to provide multiple embedded patches while making only some of them
conditional.

  patch :p0, "..."
2014-03-13 21:35:41 -05:00
Jack Nagel
9b8cff1484 Tweak DownloadError message to include wrapped exception 2014-02-18 15:08:03 -05:00
Jack Nagel
c9784c1857 Collapse begin..end into def..end and use else clause 2014-02-18 15:08:03 -05:00
Drew Rodman
d63ef14794 Add DownloadError to catch a broader range of resource download errors.
Adding a broader exception class allows for errors raised in Resource.fetch
to be caught in upgrade and prevent the process from being killed when
a download fails. This should resolve issue 18364.

Fixes Homebrew/homebrew#18364.
Closes Homebrew/homebrew#26618.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
2014-02-18 15:08:03 -05:00
Jack Nagel
ca0eff67fa Inline static exception text to remove a rescue 2014-02-18 13:27:35 -05:00
Mike McQuaid
a762f21e33 formula, resource: output when verifying checksum.
References Homebrew/homebrew#24566.
2013-12-08 21:37:40 +00:00
Mike McQuaid
8ba503ebb6 resource: convert unpack target to Pathname. 2013-11-27 13:29:24 +00:00
Mike McQuaid
1d0515c1d3 resource: only unpack to target if it exists. 2013-11-06 18:34:08 +00:00