Commit Graph

171 Commits

Author SHA1 Message Date
Xavier Claessens b7bcdb7839 wrap: sha256 digest is not case sensitive
Fixes: #8450.
2021-03-02 12:38:46 -05:00
Eli Schwartz 9d602e6531
do not require git installed in order to use wraps
It doesn't make sense to check for the presence of git every time we use
it, but short-circuit any attempt to use a wrap right from the get-go
because we are trying to be fancy with submodules.

If git is not installed, simply do not try to figure out whether the
wrap is a submodule that can potentially be checked out/updated for the
user. Just take it on faith that it isn't one.

Fixes #2623
2021-01-26 08:09:53 -05:00
Jussi Pakkanen efe7270429 Do not store config parser object in Wrap object. Closes: #7920. 2021-01-17 21:04:21 +00:00
Jussi Pakkanen ca30550e06 Handle uppercase dependency names in wraps. 2020-12-30 20:54:41 +00:00
Dylan Baker f6672c7a19 use real pathlib module
We added the _pathlib module to work around defeciencies in python 3.5's
implementation, since we now rely on 3.6 lets drop this
2020-11-20 15:08:40 -08:00
Dylan Baker 2bd309543f wrap: fix type annotations 2020-11-03 21:42:18 -05:00
Xavier Claessens 42cc9294e9 wrap: Fix git exception not catched by interpreter
This is a regression introduced in Meson 0.56.0, it was fatal
error when optional dependencies fails to download their fallback
subproject.
2020-11-03 21:28:32 +02:00
Jussi Pakkanen 64f8479097 In text, betterer grammer usings. 2020-10-19 00:04:14 +03:00
Xavier Claessens 3a01823786 wrap: Add 'redirect' type and use it when auto promote 2020-10-13 17:55:16 -04:00
Xavier Claessens a20d7ad67d wrap: Use sub-subproject packagefiles 2020-10-13 17:55:16 -04:00
Xavier Claessens 6333ee88c1 Merge wraps from subprojects into wraps from main project
wraps from subprojects are now merged into the list of wraps from main
project, so they can be used to download dependencies of dependencies
instead of having to promote wraps manually. If multiple projects
provides the same wrap file, the first one to be configured wins.

This also fix usage of sub-subproject that don't have wrap files. We can
now configure B when its source tree is at
`subprojects/A/subprojects/B/`. This has the implication that we cannot
assume that subproject "foo" is at `self.subproject_dir / 'foo'` any
more.
2020-10-13 17:55:16 -04:00
Daniel Mensinger 1dfaccfd91 pathlib: Fix resolve() by overriding it in Python 3.5 2020-10-04 10:45:48 +02:00
Xavier Claessens e0cd54a322 msubprojects: Stop trying to guess subproject type
It was done to include them in `meson subprojects foreach` without
--types argument, but it's better to special case missing --types and
include wraps that have type=None too. It was a bad idea because that
was messing them in `meson subprojects update`, now they are ignored by
that command.
2020-09-18 03:01:15 +00:00
Xavier Claessens 14c1a6983d msubprojects: Allow comma separated list of types 2020-09-10 11:39:30 -04:00
Xavier Claessens 276c3fcb5a Move verbose_git() and quiet_git() to mesonlib 2020-09-10 11:39:30 -04:00
Xavier Claessens 98d445a070 msubprojects: Support git subprojects with no wrap file
User could have cloned manually a subproject.
2020-09-10 11:39:30 -04:00
Daniel Mensinger e681235e5f
typing: fix code review 2020-09-08 20:15:58 +02:00
Daniel Mensinger 449dd8e72a
typing: fully annotate wrap 2020-09-08 20:15:56 +02:00
Xavier Claessens 2353d67c25 wrap: Raise MesonException when git command fails
This avoid printing long backtrace by default, the user already has the
output of the git command printed for debugging purpose since we don't
redirect stdout/stderr.
2020-07-14 20:49:47 +03:00
Xavier Claessens e1094df77e wrap: Add back filename member in PackageDefinition
It is still used by msubprojects.py and cause issues when updating
wrapdb.
2020-07-04 13:58:36 +03:00
Xavier Claessens 41aefd2145 wrap: Abort if multiple wraps provide the same dep or program 2020-07-01 09:51:57 -04:00
Xavier Claessens 13316f99fe wrap: Refactor to split wraps dictionary into 3 separate dicts
It makes the code cleaner to have 3 separate dictionaries for
packagename, dependency and programs.
2020-07-01 09:51:57 -04:00
Xavier Claessens fba796cf13 Fix typo: coma->comma 2020-07-01 09:51:57 -04:00
Xavier Claessens f08eed37cb find_program: Fallback if a wrap file provide the program name
We don't need the legacy variable name system as for dependency()
fallbacks because meson.override_find_program() is largely used already,
so we can just rely on it.
2020-07-01 09:51:57 -04:00
Xavier Claessens 71804e56eb wrap: Add special 'dependency_names' key in [provide] section
The value for that key must be a coma separated list of dependecy names
provided by that subproject, when no variable name is needed because the
subproject uses override_dependency().
2020-07-01 09:51:57 -04:00
Xavier Claessens 2a7f72885f wrap: Add 'provide' section 2020-07-01 09:51:44 -04:00
Xavier Claessens 4a371c97f4 wrap: Apply patch even in VCS cases 2020-06-30 19:42:43 +03:00
Eli Schwartz 33167d40a2 wrap: add user agent when downloading files
This lets servers know when they're being used by meson. It also avoids
issues where the Independent JPEG Group decided to ban the
"Python-urllib" default user agent.

Fixes https://github.com/mesonbuild/libjpeg/issues/9
2020-06-26 16:07:29 -04:00
Xavier Claessens e353b2e8d4 wrap: Add patch_directory support
Copy a tree instead of extracting an archive.

Closes: #7216
2020-06-21 23:39:12 +03:00
Daniel Mensinger ccdf7f6d34
wrap: Add support for local files via only `*_filename` 2020-04-25 11:43:42 +02:00
Xavier Claessens a6239d5100 wrap: Add fallback urls
It can happen that a server is temporaly down, tarballs often have
many mirrors available so we should be able to add at least one fallback
mirror in wrap files.
2020-04-13 13:29:33 +03:00
Xavier Claessens 5c8dbdcd38 wrap: Fix git clone with commit id in revision
Fixes: #6505.
2020-01-25 13:49:00 +05:30
Nirbheek Chauhan 712b2f08c7 Move git helper out into mesonlib for reuse
Reuse the git helper for `meson wrap` and `meson subprojects` so we
don't need to maintain the same git-colors-on-windows workarounds in
multiple places.
2020-01-22 17:29:38 -05:00
Nirbheek Chauhan 06dddf2ef0 wrap: Re-set the console mode after calling git
`git submodule update --recursive` calls git clone recursively, and on
Windows it will undo the console mode we set in mlog and cause ANSI
colors to stop working. We could set it again only when we call that,
but we will definitely miss other instances where this could happen
in the future and regress.
2020-01-22 17:29:38 -05:00
Nirbheek Chauhan e962147d8a wrap: Redirect stdin to DEVNULL when calling git
Without this git messes up the console and ANSI colors stop working on
Windows inside cmd.exe.

This broke in https://github.com/mesonbuild/meson/pull/6139. Also add
the same to all git calls. Missed this when I opened
https://github.com/mesonbuild/meson/pull/6255
2020-01-22 17:29:38 -05:00
Nirbheek Chauhan f09056f903 wrap: Always use a wrapper for running git
We need this for the next commit.
2020-01-22 17:29:38 -05:00
Nirbheek Chauhan 7065cef62f wrap: Look for git only once at startup
No need to repeatedly call `shutil.which`.
2020-01-22 17:29:38 -05:00
Nirbheek Chauhan 2661b1bfb5 wrap: Use uppercase for global constants
This makes things much clearer and follows PEP8.
2020-01-22 17:29:38 -05:00
Xavier Claessens 711969c3b5 wrap: Fix support of file:// URLs
Fixes: #6445
2020-01-17 11:36:37 -05:00
Daniel Mensinger 09b53c534f types: import typing as T (fixes #6333) 2020-01-08 15:28:17 +01:00
Xavier Claessens 5031f4981d dist: Fix --include-subprojects when .wrap file has directory value 2019-12-10 22:19:00 +02:00
Michael Brockus 4b69aea85d Update Python2 syntax to Python3 syntax in Wrap 2019-12-06 15:23:26 +02:00
Michael Hirsch, Ph.D d9b8dce975
wrap: check whitelist subdomain
wrap: add imposter URL test

this test shows that meson wrap subsystem historically allows
imposter URLs like https://wrapdb.mesonwrap.com.evil/v1/foo.zip
while the new code does no.
2019-12-05 23:14:13 -05:00
Michael Hirsch, Ph.D dc19768175
wrap: raise WrapException instead of Python exception when program not available 2019-12-05 23:07:18 -05:00
Michael Hirsch, Ph.D ccefc00a59
use WrapDB domain whitelist, don't fallback to non-SSL when SSL available
In my opinion, we should not fall back to http:// from the SSL HSTS WrapDB URL,
**for systems that have Python SSL** as that is controverting the point
of HSTS + SSL.

For systems that do not have Python SSL, they continue to work with a
colored mlog.warning instead of only a stderr console print.

 attempt to stop masquerade URLS containing wrapdb.mesonbuild.com.evil.stuff.com
2019-12-05 23:07:16 -05:00
Michael Hirsch, Ph.D 298299d711
doc: py35 deprecation comments 2019-12-05 22:19:28 -05:00
Daniel Mensinger e21f5959a5 lgtm: Fix insecure SSL/TLS version by removing dead code 2019-12-05 11:08:12 -05:00
Daniel Mensinger ef19e1ff2d lgtm: fix Incomplete URL substring sanitization 2019-12-05 00:22:10 +02:00
Martin Hostettler bb03cf0dbc wrap: Resolver.get_git: Factor out --depth argument generation and make sure not to pass None as parameter
507cf47507cf47 broke the combination of clone-recursive without depth.
Because it passed depth (as None) to git.

To fix this the depth option is now generated once as a list when depth is set
and else set to an empty list and unpacked into the argument this when
needed. This reduces duplication and allows code to work the same for
both cases.
2019-11-28 13:01:33 +02:00
Michael Hirsch, Ph.D d080917561 wrap.py: catch connection error with WrapException
fixes #6130

wrap: more error verbosity
2019-11-07 22:14:59 +02:00
Michael Hirsch, Ph.D a47c1374b9 wrap.py: apply type annotation, modernize syntax
correct syntax issues, missing imports revealed by type annotation checking
2019-11-07 22:14:59 +02:00
Martin Hostettler 507cf47941 wrap: Rework `depth` support for git.
Don't manually emulate a partial `git clone` when `depth` option is not
used. This keeps `git describe` working as before and generally supports
workflows that depend on tags and branches to exist in a wrap downloaded
subproject.

This also fixes downloading via git not working at all on CentOS 7
(git version 1.8.3.1).

For the `depth` case use `git clone --branch=... --depth=...` when
possible and only fall back to manual emulation wraps that specify a
full commit id, because for some reason that does not work with the
clone based workflow.

Fixes: #5991 (Regression in wrap support with git)
2019-10-06 14:29:32 +03:00
Christoph Weiss 0008b326ff Add support for `depth` option in wrap-git
This allows cloning subprojects shallowly.  It works recursively for a
subproject's submodules in case `clone-recursive` is set to `true`.
2019-09-29 20:47:59 +03:00
Nirbheek Chauhan 9c2724bce5 Add optional progress bar when generating build.ninja 2019-07-20 17:02:15 +03:00
Daniel Mensinger e02c101575
cmake: moved subprojects into the CMake module 2019-06-06 18:27:05 +02:00
Daniel Mensinger a9a3b3ffe6
Added method kwarg to subproject 2019-06-06 18:22:26 +02:00
Daniel Mensinger 3581839f4c
Fix unused variables warnings 2019-04-29 12:22:50 +02:00
Daniel Mensinger bf98ffca9e
Fix blind exceptions 2019-04-29 12:16:06 +02:00
Andrei Alexeyev faf3581df6 Fix git wraps with submodules
* If clone-recursive is specified, populate submodules only after
    the specified revision/branch has been checked out. Fixes #4996

    * Update submodules recursively on `meson subprojects update`
2019-03-11 20:31:52 +02:00
Michael Hirsch, Ph.D da34bea893 pep8 py37 2019-01-29 22:06:11 +02:00
Xavier Claessens 60b58e056f Add 'meson subprojects update' command
This is inspired by gst-build's git-update script.
2018-12-02 08:37:32 -05:00
Elliott Sales de Andrade e58f186121 Fix subproject initialization without git installed. 2018-11-22 22:31:54 +02:00
Xavier Claessens be09acbf56 wrap: Check the directory key is a name and not a path
Closes #1413.
2018-10-27 16:36:01 +03:00
Xavier Claessens adb9fdef3a wrap: Fix crash with file based wraps
Add unit test to avoid regressions in the future.
2018-10-21 23:21:36 +03:00
Xavier Claessens 76ac4f5689 wrap: Make 'directory' key optional
wrap files can now omit the 'directory' key, in that case it will
default to the packagename.
2018-10-18 18:36:32 -04:00
Xavier Claessens d9ea7b16a8 wrap: Rename p to self.wrap 2018-10-18 18:29:35 -04:00
Xavier Claessens b26eb3d384 wrap: Disable interpolation 2018-10-18 18:25:05 -04:00
Xavier Claessens 3f98ad8eed wrap: Improve error handling and logging 2018-10-18 11:42:17 -04:00
Xavier Claessens 1889e33389 wrap: Remove dead code trying to update git/hg/svn repositories
If the directory exists we early return or raise exception in resolve()
method. It was already like that even before the recent refactoring of
the code.

It is safer like that anyway, we don't want a project reconfigure to
silently pull new code. Updating subprojects should be an explicit
action of the user. For example gst-build has a 'git-update' script that
does that. In the future we could add a 'meson subprojects update'
command.
2018-10-18 11:42:17 -04:00
Xavier Claessens d6fba7f01c wrap: Allow source and patch to be local files
It is sometimes important to be able to build projects offline, in that
case subproject tarballs and patches could be shipped directly within
the project's repository.
2018-10-17 21:56:49 -04:00
Xavier Claessens a3db9f6ae3 wrap: Some cleanups and fixes in resolver
- Use CongifParser instead of parsing ourself, this will give more
  flexibility in the future.

- Always read the .wrap file first, because if it contains the
  'directory' key we should use that value instead of packagename for
  the path where do download/lookup for the subproject.

- If we download the subproject (git/submodule/tarball/etc) we should
  still check it contains a meson.build file.
2018-10-17 21:56:49 -04:00
Andrei Alexeyev 67cc636e53 Add 'clone-recursive' option for git wraps
This causes Meson to clone the repo with the --recursive flag, pulling
all of the submodules automatically.
2018-09-16 14:57:56 +03:00
Nirbheek Chauhan e7b25018c4 wrap: Redirect git's stdin to DEVNULL
Otherwise, git fiddles with the cmd.exe console's color behaviour and
disables it, which causes it to stop interpreting ANSI color codes
outputted by meson for colored output.

Effectively, as soon as any subproject is initialized, cmd.exe goes
nice coloured output to ugly raw ANSI codes.
2018-09-03 21:12:09 +03:00
Andrei Antonov 8f7781f1d6 using urlopen() with explicit timeout 2018-08-27 00:55:45 +03:00
Mohammed Amer Khalidi 376cdd7054 Adding support to checkout from reviews in git/gerrit using commit ids. 2018-08-07 18:55:46 +03:00
Nirbheek Chauhan 0ec18a0531 wrap: Fix broken logic when initializing submodules
Also be more lenient when doing git checkout, and continue even if it
failed.

Closes https://github.com/mesonbuild/meson/issues/3088
2018-02-20 00:16:38 +02:00
Nirbheek Chauhan 15a1a317f4 wrap: Handle more submodule status cases
The '+' and 'U' cases should not happen normally because we don't run
any git commands if the subproject directory exists and contains
a meson build file. However, if the user accidentally messed up the
subproject checkout to a version that had no build files, we would
error out with an assertion.
2018-02-11 13:41:06 +02:00
Jussi Pakkanen 7d49d1d2d7 Merge pull request #2373 from leiflm/svn-wraps
introduce svn wrap support
2017-10-01 01:21:12 +03:00
Leif Middelschulte a90e47bd4f adds missing import of `Popen_safe` 2017-09-30 19:49:14 +02:00
Leif Middelschulte 078527a744 As per jpakkane's suggestion use `Popen_safe` instead of `subprocess.getoutput`
Jussi suggested to use `Popen_safe` from meson's library for portability reasons.
2017-09-30 19:45:24 +02:00
liugang c93bce7839 Don't download patch archive if already download
the behavior of download patch should
keep same as download package.
2017-09-29 21:43:28 +03:00
Leif Middelschulte 50376cca37 fixup 993a12c5: use right variable 2017-09-26 14:03:07 +02:00
Leif Middelschulte 993a12c543 avoid errornous type conversion. Compare strings instead 2017-09-26 14:01:29 +02:00
Leif Middelschulte fab15d433a fixes offline working (if desired revision is already present). 2017-09-26 13:56:58 +02:00
Leif Middelschulte aa28675ebc fixes initial checkout command independend of provided revision 2017-09-26 13:13:46 +02:00
Leif Middelschulte 667d5d2d9f introduce svn wrap support 2017-09-25 22:26:42 +02:00
liugang a93ac1a6a8 Improve download package
Using wrap mechanism in enterprise environment,
Some package is very large, example, sdk package from
BSP vendor.

so:
- open file in the output directory with a temporary name
- download a chunk, update hash calculation, write chunk to file
- when finished close file and check the hash
- if hash is incorrect, delete temp file and raise error
- if hash is correct, atomically rename temp file to final file

fix issue: #2358
2017-09-23 16:01:11 +08:00
liugang de259b6690 Fix unpack patch archive fail
fix shutil.unpack_archive() failure when the
destination files already exists and is read-only.

Example: all files in opensource package live555
is `-r--r--r--`, if some file in patch archive try to
patch original files of live555, shutil.unpack_archive
will raise `[Errno 13] Permission denied`
2017-09-23 15:59:43 +08:00
liugang 7060b15773 fix patch archive never download on some case
Fix issue #2359
2017-09-23 13:53:27 +08:00
Luke Shumaker 4dbbb4884c flake8: Clean up complained-about unused imports
This also adds a "# noqa: F401" comment on an unused "import lzma",
which we are using it in a try/except block that is being used to
check if the lzma module is importable; of course it is unused.

v2: This turned out to be a little tricky.

    mesonbuild/modules/__init__.py had the "unused" import:

        from ..interpreterbase import permittedKwargs, noKwargs

    However, that meant that the various modules could do things like:

        from . import noKwargs # "." is "mesonbuild.modules"

    Which breaks when you remove __init__.py's "unused" import.  I
    could have tagged that import with "# noqa: F401", but instead I
    chose to have each of the module import directly from
    "..interpreterbase" instead of ".".
2017-09-21 13:41:03 -04:00
Alistair Thomas a195b78c8d Whitespace tweaks to reduce Flake8 warnings 2017-05-29 19:32:47 +03:00
Goncalo Carvalho c9c3070f53 fix typo 2017-05-26 23:21:48 +03:00
Elliott Sales de Andrade 83d1c7f063 Rearrange trys to avoid possible undefined vars. 2017-05-17 05:37:02 -04:00
Elliott Sales de Andrade ea636fcd51 Remove unused variables. 2017-05-17 04:41:54 -04:00
Ernestas Kulik 8d720527b7 wrap: pass -C to git when resolving submodules
Using Meson from outside a git repo results in an error when trying to
resolve submodule subprojects. Running git from inside subproject root
should be enough to fix it.

Partially fixes #1679

Signed-off-by: Ernestas Kulik <ernestas.kulik@gmail.com>
2017-04-25 19:40:23 +03:00
Ernestas Kulik a13bde821f wrap: initialize submodules when updating
After an initial checkout, submodules aren’t initialized and thus trying
to update them fails.

Partially fixes #1679

Signed-off-by: Ernestas Kulik <ernestas.kulik@gmail.com>
2017-04-25 19:39:56 +03:00
Nirbheek Chauhan fa09b122b0 wrap: Also capture stderr while running quiet_git()
We want to return the stderr if the command failed.
2017-03-27 15:09:18 +05:30
Nirbheek Chauhan d5975cc683 wrap: Implement special wrap modes for use by packagers
Special wrap modes:
  nofallback: Don't download wraps for dependency() fallbacks
  nodownload: Don't download wraps for all subproject() calls

Subprojects are used for two purposes:
1. To download and build dependencies by using .wrap files if they
   are not provided by the system. This is usually expressed via
   dependency(..., fallback: ...).
2. To download and build 'copylibs' which are meant to be used by
   copying into your project. This is always done with an explicit
   subproject() call.

--wrap-mode=nofallback will never do (1)
--wrap-mode=nodownload will do neither (1) nor (2)

If you are building from a release tarball, you should be able to
safely use 'nodownload' since upstream is expected to ship all
required sources with the tarball.

If you are building from a git repository, you will want to use
'nofallback' so that any 'copylib' wraps will be download as
subprojects.

Note that these options do not affect subprojects that are git
submodules since those are only usable in git repositories, and you
almost always want to download them.
2017-03-25 06:57:30 +05:30
Nirbheek Chauhan a60d688973 wrap: Initialize subprojects that are git submodules
This will benefit projects such as GNOME Recipes that prefer using
submodules over wraps because it's easier to maintain since git is
aware of it, and because it integrates with their existing
workflow. Without this, these projects have to manually initialize
the submodules which is completely unnecessary.

Closes https://github.com/mesonbuild/meson/issues/1449
2017-03-25 06:47:04 +05:30
Nirbheek Chauhan fb809e79e5 wrap: Check that the package dir contains 'meson'build'
Also use a pathlib.Path object for the checks since it does I/O only
once and is much more efficient anyway. Path objects are available
since Python 3.4, so this is fine.
2017-03-25 03:47:55 +05:30