summaryrefslogtreecommitdiff
path: root/mesonbuild/mdist.py
AgeCommit message (Collapse)Author
2025-10-30mdist: fix failure to create tar files the user asked to createEli Schwartz
Python added a "feature" to assume tarfile extraction is meant solely for "data", i.e. it ignores many useful features of tar such as symlinks, ownership, or permission modes that are uncommon on Windows. Revert this entirely, as Meson is a "fully trusted" application. It can already execute arbitrary programs, tar files are not vulnerabilities. In theory "tar" mode exists and is not "data", but we are fully trusted so why split hairs? Fixes: https://github.com/mesonbuild/meson/issues/15142
2025-10-29environment: move tool detection functions to a new modulePaolo Bonzini
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-10-29coredata: move cmd_line.txt and command line handling to a new modulePaolo Bonzini
cmd_line.txt is not related to serialized data, in fact it's a fallback for when serialized data cannot be used and is also related to setting up argparse for command line parsing. Since there is no code in common with the rest of coredata, move it to a new module. Fixes: #15081 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-05-11mdist.py: Import gzip only when neededHenrik Lindström
This is already done for bz2 and lzma, but even gzip is not always available in a minimal Python installation. For example, this happens when building Python from source without having zlib available.
2025-03-10coredata: replace get_option with optstore.get_value_forDylan Baker
This is an old method, that is now just a wrapper around the OptionStore method, that doesn't add any value. It's also an option related method attached to the CoreData instead of the OptionStore, so useless and a layering violation.
2024-09-20mdist: correctly detect dirty hg repos with non-English locale, reduxEli Schwartz
https://www.gnu.org/software/gettext/manual/html_node/The-LANGUAGE-variable.html GNU Gettext defines a feature, whereby for translation purposes, if LC_ALL / LANG are *not* set to C, but rather define an active translation, the LANGUAGE variable can be used to specify fallback languages in a colon-separated list wherein the first option is the primary language and the rest are fallbacks. CPython, instead, checks the LANGUAGE variable first, and the first variable that has a non-null value is treated as the canonical language specification, splitted, and iterated over. LC_ALL=C is therefore totally ignored, which is a major problem, and the variables aren't checked for consistency, which is a less major problem. GNU libc documents the same behavior CPython does -- which is broken as it makes LC_ALL=C useless. POSIX issue 8 standardizes on option 3: do like GNU Gettext, except do not require the primary language in $LANGUAGE to be consistent with LANG / LC_ALL. Thus, we sanitize the environment even harder. What an absolute disaster. Even if this was fixed tomorrow we would need to maintain this hack until 2030. Bug: https://bugs.gentoo.org/936670
2024-09-17mdist: detect pathological git repo cases and show a slightly better errorEli Schwartz
When `meson dist` fails with the error: ``` Dist currently only works with Git or Mercurial repos ``` It is sometimes inaccurate, since a git repo may exist but be nonfunctional. Offer some better guidance in that case. Fixes: #10866
2024-08-23mdist: don't mutate meson_command, which is supposed to be immutableDylan Baker
2024-07-30mdist: correctly detect dirty hg repos with non-English localeEli Schwartz
The command we use to heuristically parse whether it is dirty by interpreting prose descriptions of the repository state, is vulnerable to changes in locale resulting in failing to match the English word that means it is clean. Unfortunately, I am no mercurial expert so I am unaware if mercurial supports scripting, like git does. Perhaps the technology simply does not exist. A quick attempt at searching for the answer turned nothing up. It appears that #4278 had good cause indeed for using this prose parsing command. So, we simply sanitize the environment due to lack of any better idea. Bug: https://bugs.gentoo.org/936670
2024-07-22mdist: don't fail on readonly source treesEli Schwartz
In commit c9aa4aff66ebbbcd3eed3da8fbc3af0e0a8b90a2 we added a refresh call to git to catch cases where checking for uncommitted changes would misfire. Unfortunately, that refresh performs a write operation, which in turn misfires on readonly media. We don't actually care about the return value of the refresh, since its purpose is solely to make the next command more accurate -- so ignore it. Fixes: c9aa4aff66ebbbcd3eed3da8fbc3af0e0a8b90a2 Fixes: #13461
2024-07-11Move OptionKey in the option source file.Jussi Pakkanen
2024-04-27mdist: gracefully handle stale Git indexBenjamin Gilbert
Running `touch` on a tracked file in Git, to update its timestamp, and then running `meson dist` would cause dist to fail: ERROR: Repository has uncommitted changes that will not be included in the dist tarball Use --allow-dirty to ignore the warning and proceed anyway Unlike `git status` and `git diff`, `git diff-index` doesn't refresh the index before comparing, so stat changes are assumed to imply content changes. Run `git update-index -q --refresh` first to refresh the index. Fixes: #12985
2024-04-15Add bztar support to meson distTristan Partin
Some projects, like Postgres, distribute code in this format.
2024-03-02Merge pull request #12804 from joukewitteveen/dist-rewriterJussi Pakkanen
Support `meson dist` when getting project versions from VCS
2024-02-23coredata: use a Protocol for shared options between setup configure and distDylan Baker
These are all passed around interchangably inside Meson, so use a shared protocol for them.
2024-02-12Add MESONREWRITE to `meson dist` scriptsJouke Witteveen
Fixes #688
2024-02-03mdist: Hoist leftover late importJouke Witteveen
From 23d3b98, the meson command is exposed through a function. Therefore, the caveat no longer applies.
2023-12-13Use SPDX-License-Identifier consistentlyDylan Baker
This replaces all of the Apache blurbs at the start of each file with an `# SPDX-License-Identifier: Apache-2.0` string. It also fixes existing uses to be consistent in capitalization, and to be placed above any copyright notices. This removes nearly 3000 lines of boilerplate from the project (only python files), which no developer cares to look at. SPDX is in common use, particularly in the Linux kernel, and is the recommended format for Meson's own `project(license: )` field
2023-11-01Add comments suggesting to keep shell completion scripts up-to-date near cmd ↵Luke Elliott
line argument code
2023-06-25fully type mdist.pyEli Schwartz
2023-06-25mdist: consolidate facts about the current dist using a dataclassEli Schwartz
And avoid passing variables around several functions just to finally get where they need to be. These function signatures were kind of ugly... Also the use of dataclasses makes a big chunk of this file now typed properly.
2023-06-25mdist: refactor lots of code into VCS-specific classesEli Schwartz
Most of the dist handling is either git-specific or hg-specific. Tangling it all together makes it much harder to analyze what is going on.
2023-03-29Make --vsenv a readonly builtin optionXavier Claessens
We need to remember its value when reconfiguring, but the Build object is not reused, only coredata is. This also makes CLI more consistent by allowing `-Dvsenv=true` syntax. Fixes: #11309
2023-03-20fix one more missing explicit "setup" subcommandEli Schwartz
2023-02-01treewide: add future annotations importEli Schwartz
2022-11-29pylint: enable useless-returnDylan Baker
2022-06-10flake8: remove no longer used importsEli Schwartz
2022-04-11mdist: use better approach to finding original configured optionsEli Schwartz
Instead of reading intro-buildoptions.json, a giant json file containing every option ever + its current value, use the private file that is internally used by msetup for e.g. --wipe to restore settings. This accurately tracks exactly the options specified on the command line, and avoids lengthy summary messages containing all the overridden defaults. It also avoids passing potentially incompatible options, such as explictly specifying -Dpython.install_env while also having a non-empty -Dpython.{x}libdir Fixes #10181
2022-02-10implement 'dist --allow-dirty' flagandy5995
closes #9824
2021-10-10Add --vsenv command line option and active VS only when neededXavier Claessens
2021-09-03mdist: use git archive with git repositories for correctnessEli Schwartz
Fixes various inconsistencies: - gitattributes is respected - export-subst - export-ignore - submodules with relative paths are not checked out relative to the local clone (which does not work anyway) - no need to manually remove gitfiles with inaccurate heuristics Fixes #2287 Fixes #3081 Fixes #8144
2021-08-31pylint: turn on superfluous parens warningDylan Baker
Which is really useful for catching parens used with keywords like assert. Don't use parens with assert, it's bad.
2021-07-07cleanup self.options.wdPaolo Bonzini
It is never None and always an absolute path
2021-07-07resolve symlinks passed to -CPaolo Bonzini
"meson setup" is resolving symlinks for the build directory in validate_core_dirs. For consistency with it, do the same when the build directory is passed via -C to devenv, dist, init, install and test. This ensures for example that the path to test dependencies is computed correctly in "meson test". Fixes: #8765
2021-07-04dist: only exclude actual git filesAndrea Pappacoda
Instead of excluding all files starting with .git, meson dist now only excludes files really used by git
2021-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger
2021-05-30Don't use `os.path.relpath` in dist commandNaveen M K
This is problematic when we meson is installed in the different root(say C:) while building from another root(say D:). This is how it is done in mesonpep517 and causes problems because of that.
2021-04-26Fix issue where multiple dist files were not being produced for comma ↵Tristan Partin
separated formats value
2021-03-18Allow add_dist_script() in subprojectsXavier Claessens
Fixes: #8440.
2021-03-04mass rewrite of string formatting to use f-strings everywhereEli Schwartz
performed by running "pyupgrade --py36-plus" and committing the results
2021-01-30Fix executable as script on WindowsXavier Claessens
On Windows this would fail because of missing DLL: ``` mylib = library(...) exe = executable(..., link_with: mylib) meson.add_install_script(exe) ``` The reason is on Windows we cannot rely on rpath to find libraries from build directory, they are searched in $PATH. We already have all that mechanism in place for custom_target() using ExecutableSerialisation class, so reuse it for install/dist/postconf scripts too. This has bonus side effect to also use exe_wrapper for those scripts. Fixes: #8187
2021-01-26dist: Use windows_proof_rmtree() instead of shutil.rmtree()Xavier Claessens
2021-01-26dist: Allow packaging subproject in same git repo as main projectXavier Claessens
2021-01-23split mesonlib into a packageDylan Baker
Currently mesonlib does some import tricks to figure out whether it needs to use windows or posix specific functions. This is a little hacky, but works fine. However, the way the typing stubs are implemented for the msvcrt and fnctl modules will cause mypy to fail on the other platform, since the functions are not implemented. To aleviate this (and for slightly cleaner design), I've split mesonlib into a pacakge with three modules. A universal module contains all of the platform agnositc code, a win32 module contains window specific code, a posix module contains the posix specific code, and a platform module contains no-op implementations. Then the package's __init__ file imports all of the universal functions and all of the functions from the approriate platform module, or the no-op versions as fallbacks. This makes mypy happy, and avoids `if`ing all over the code to switch between the platform specific code.
2020-12-22mdist: Print file path at the end of run() instead of in create_hash().Aman Verma
2020-12-22mdist: Ensure correct format for sha256sum.Aman Verma
We conform to the format described at <https://www.gnu.org/software/coreutils/manual/html_node/md5sum-invocation.html>. and compatible with busybox and Perl's shasum utility.
2020-11-20use real pathlib moduleDylan Baker
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-10-04pathlib: Fix resolve() by overriding it in Python 3.5Daniel Mensinger
2020-09-22mdist: actually constrain the choices of the --formats optionDylan Baker
Since we already have that list available.
2020-09-04environment: use ExternalProgram to find ninjaPaolo Bonzini
This allows the NINJA environment variable to support all the Windows special cases, especially allowing an absolute path without extension. Based on a patch by Yonggang Luo. Fixes: #7659 Suggested-by: Nirbheek Chauhan <nirbheek@centricular.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>