23 Commits

Author SHA1 Message Date
Dave Borowitz
4a74548c22 Document gjf and add a script to standardize/streamline setup
google-java-format is not uniformly available in package management
systems across OSes. More importantly, we want to make sure that all
contributors are using a standardized version, to avoid unnecessary
changes due to slight differences between versions.

While we're in the dev documentation, link to the Google Java Style
Guide, and remove some wording that is clearly redundant with the style
guide.

Change-Id: Ib14dab2e692339f836083fad08a7a435a2f24470
2017-02-07 12:38:37 -05:00
David Ostrovsky
fdbfcad77d Remove Buck based build
Bug: Issue 5302
Change-Id: I6e860446ef30ff0ad1c7c49fc0e39d39d921820b
2017-01-23 12:44:58 +00:00
David Ostrovsky
0883d977cd download_file.py: Add --show-error option to curl invocation
Change-Id: I9e7708e6e425a0a3eeb4e22172746b3dc2b094a0
2016-11-15 14:48:53 +00:00
Han-Wen Nienhuys
28e7a6d3fe bazel: bower support
* npm_binary (download tarball packaged npm apps)

* bower_archive (download a zip file, to be put in WORKSPACE)

* bower_component (defining a bower library, with dependency )

* bower_component_bundle (zipping up libraries together)

* js_component (insert plain js file into bower component bundle)

* bower2bazel.py: run bower to find dependencies, generate a .bzl to
  define archives and define components

Tested:

 python tools/js/bower2bazel.py -w lib/js/bower_archives.bzl -b \
    lib/js/bower_components.bzl

 bazel build polygerrit-ui:components
 unzip -v bazel-bin/polygerrit-ui/components.zip > /tmp/baz

 buck build polygerrit-ui:polygerrit_components
 unzip -v buck-out/gen/polygerrit-ui/polygerrit_components/polygerrit_components.bower_components.zip > /tmp/buck

 diff /tmp/buck /tmp/baz

The diff corresponds to newer file versions pinned through bower2bazel.

Change-Id: I4f33914d4853bcf8afe78b4719d0e0e83b139031
2016-09-29 13:18:19 +02:00
Han-Wen Nienhuys
1fb651e04b Remove legacy cache from tools/download_file.py
Change-Id: I2c524fd78285d1a976ec808663fe49d06050d2bd
2016-09-22 11:17:01 +02:00
Dave Borowitz
868f76458a tools: Use common hash_file implementation
Change-Id: Idf0dce913e012bfc3bcf12d6cd19d322af69505b
2015-11-25 10:15:17 -05:00
Christian Aistleitner
6f6de0d32c Disentangle BUCK caches for internally built and downloaded artifacts
Downloaded artifacts went directly into

  ~/.gerritcodereview/buck-cache

while artifacts built by BUCK went into the directory's `cache`
subdirectory:

  ~/.gerritcodereview/buck-cache/cache

. When just walking the file hierarchy on the command line, this
`cache` sub-directory is hardly visible, due to all the downloaded
artifacts. To increase visibility, we change to

* ~/.gerritcodereview/buck-cache/downloaded-artifacts
  (for downloaded artifacts)
* ~/.gerritcodereview/buck-cache/locally-built-artifacts
  (for artifacts built by buck locally)

That way `~/.gerritcodereview/buck-cache` (instead of one directory
and 100s files) now only contains two directories.

Change-Id: I7327ff6c1736f9af8ea15450949dc6a4bc10b684
2015-07-07 12:59:51 +02:00
Björn Pedersen
c357cebdae tools: use python on path
Use the canonical syntax to specify the python executable to use.

Avoids a fatal error if /usr/bin/python is a too old version (< 2.7).

Change-Id: I3e8affb52be993d35c0dcf90774d962a59ef5635
2015-06-18 17:10:11 +02:00
Hugo Arès
91f3a7456f Allow to download dependencies from insecure connections
SSL connections done by Curl will be attempted to be made secure by
using the CA certificated bundle but when the connection can be
established but not secured, Curl will not fail.

Change-Id: Id2fb1e3b65aed3e3334b2db302d028181ebd1e81
2014-07-11 12:35:44 +00:00
David Pursehouse
15a9f53f00 Buck: Remove Python 2.6 compatibility workarounds
The check_output method is only available from Python 2.7, so a wrapper
method was introduced for compatibility with 2.6.

The ZipFile class does not include context manager support in Python
2.6, so the file download code was written to explicitly open and close
the zip files.

Since Buck itself now requires at least Python 2.7, these workarounds
are no longer necessary.  Remove them.

Also, tidy up a few minor PEP-8 coding style violations in the modified
files.

Change-Id: I9a1b25ddf7494e25ccadeaed0c1d85cd1ce2fd09
2014-06-23 11:09:58 +09:00
Urs Wolfer
a11276ae99 Fix buck build error because of not encoded argument
On Arch Linux using Python 2.7.6 with a recent clone of buck,
I got the following error:

  Traceback (most recent call last):
    File "gerrit/tools/download_file.py", line 100, in <module>
      cache_ent = cache_entry(args)
    File "gerrit/tools/download_file.py", line 80, in cache_entry
      h = sha1(args.u).hexdigest()
  TypeError: Unicode-objects must be encoded before hashing

Change-Id: I7a638b56a14cf579ba57f2a5c17df62cf3fbf266
2014-04-26 13:20:00 +02:00
David Ostrovsky
2536d06da0 Buck: Support plugin own Maven repositories
Currently only predefined Maven repositories are supported by Buck maven_jar.
Additional logic exists to redirect to a local repository mirror.

Current implementation relies on the repository name matching between repo
passed to maven_jar and redirect definition defined in local.properties that
is not under Git control.

This change extends that by allowing to pass not only the repo name but the
complete URL to maven_jar. The augmented implementation checks if it is a
known Maven repository: if it is, then the behavious is unchanged, if not,
then the passed URL is used.

As result plugin's can use custom Maven repositories:

  GERRIT_FORGE = 'http://gerritforge.com/snapshot'

  maven_jar(
    name = 'gitblit',
    id = 'com.gitblit:gitblit:1.4.0',
    sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa',
    license = 'Apache2.0',
    repository = GERRIT_FORGE,
  )

Plugin owned Maven repositories can also be rewritten in local.properties.
To achieve that custom repository name must be passed to the maven_jar()
function, like known repositories, and the URL must be defined in
local.properties.

local.properties excerpt:

  download.GERRIT_FORGE = http://my.company.mirror/gerrit-forge

BUCK excerpt:

  GERRIT_FORGE = 'GERRIT_FORGE:'

  maven_jar(
    name = 'gitblit',
    id = 'com.gitblit:gitblit:1.4.0',
    sha1 = '1b130dbf5578ace37507430a4a523f6594bf34fa',
    license = 'Apache2.0',
    repository = GERRIT_FORGE,
  )

Python unit test can be executed with other Java unit tests:

  buck test tools:python_tests
Change-Id: Ib31d51f0884b1ca1a07b6492f861f404db115946
2013-11-18 01:12:09 +01:00
David Ostrovsky
6e0a3e5da8 Buck: extend the tool chain to support unsigning JARs
After switching to Eclipse Maven repository for pulling JGit lib, we
have the problem that according to Eclipse release train the JARs have
to be signed. That collids with our jgit patch for diff deserialization.

To rectify that, add `unsign` parameter to maven_jar() function.

Change-Id: Ib7bfa5d16f980a64b887d61a4b4ec325e6ffb0a1
2013-10-28 21:30:53 +01:00
David Pursehouse
71a869fefe Update jgit to 3.1.0.201310021548-r
Change-Id: Ib1526cd97353933dee1b76de33239cbcb31107b0
2013-10-23 20:09:48 +02:00
David Ostrovsky
56fe1f8dc3 BUCK: fix build against unpublished JARs
This change fixes the following problems:

* MAVEN_LOCAL definition must be prefixed with 'file://' for curl to work
* src_sha1 was unnecessary required to define source artifact
* update the documentation that sha1 must not be provided

Change-Id: I1cee6588897c928f01bac5cc9fb252251f4f8027
2013-08-16 16:26:59 +00:00
Shawn Pearce
e585fc0449 Define MAVEN_LOCAL for unpublished Maven JARs
Standardize the definition of MAVEN_LOCAL as ~/.m2/repository.
This makes it slightly easier to point to a custom build of a
dependency such as gwtorm or PrologCafe by installing the JAR to
the local Maven repository and updating the maven_jar() rule to
use repository = MAVEN_LOCAL instead of GERRIT.

Change-Id: I2e54d1039608c0195a992dbc12fe74bb513466c6
2013-08-14 15:40:35 -07:00
David Pursehouse
e277fc3f74 download_file: Catch exceptions raised from shutil.copyfile
shutil.copyfile can raise shutil.Error and IOError.  Catch these and
exit with error status after logging the error to the console.

Change-Id: I63b8caa371cc7034bbb3f19d0bd3fdd0446af2bf
2013-08-08 10:50:20 +09:00
David Pursehouse
8ea0650c8c download_file: Exit with error if extracting files from zip fails
If extracting files fails, it prints the error message but then
continues.

Make it exit with error status in this case.

Change-Id: I19fafda68a85b46300a1abaf6a86567cf1f712b0
2013-08-08 10:48:51 +09:00
Shawn Pearce
f98b3798a6 Support build where ~/ and $(pwd) are different filesystems
download_file caches original zips in ~/.gerritcodereview/buck-cache.
If this is a different filesystem than $(pwd)/buck-out a symlink
was used to connect the build file with the original archive. This
confuses Buck when creating the $SRCDIR for a genrule().

If a hardlink does not work, copy the file.

Change-Id: If66c59fb6aecc93b5a3e85cdd76ef880538875ff
2013-08-06 12:20:30 -07:00
Shawn Pearce
d500500b5e Update URLs for Google Cloud Storage
Per [1] the correct URL is <bucket>.storage.googleapis.com/<object>.
Update existing references to project resources to use this domain
name instead of the old name.

[1] https://developers.google.com/storage/docs/reference-uris

Change-Id: I3788cfb4504b3908d2b5eccbdf52beffc3d18387
2013-06-21 11:01:45 -07:00
Sasa Zivkov
4709fff0f3 Better error reporting when curl is not installed
If buck build was done on a system without curl installed
a misleading error message would be printed out:

  error creating directory /home/user/.gerritcodereview/buck-cache

However, the real error was that invocation of curl failed. Since
it was an OSError it was handled with the wrong except block.

Separate handling of the OSError for the folder creation and curl
invocation.

Change-Id: Ic7e7c2c2704ea4cbccff4689dffe17a436108395
2013-06-13 17:41:19 +02:00
Shawn Pearce
eb2eeec491 Delete corrupt cache entries from ~/.gerritcodereview/buck-cache
If the SHA-1 does not match the downloaded file content, delete the
file from the cache. This allows a user to fix whatever connectivity
problem led to the corruption and re-run buck build to download
the correct content.

Change-Id: I2f72fb2b187675ec9d5cda650d8982bc93a00189
2013-05-22 17:54:32 -07:00
Shawn Pearce
8713eb859e Rename download_jar to download_file
This is a generic downloader that can be used for other
dependencies, like ZIP files containing JS.

Change-Id: I643f81fc06d790cebaa0eb677fa232ba0c652053
2013-05-20 11:25:59 -07:00