aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/minstall.py
AgeCommit message (Collapse)AuthorFilesLines
2023-09-13install_{data,headers,subdir}: implement follow_symlinksArsen Arsenović1-13/+18
This permits users who rely on following symlinks to stay on the old default of following them.
2023-08-24minstall: move the "Installing foo to bar" message upPeter Hutterer1-6/+8
Move this message up before we attempt to change anything in the file system (in this case creating the directory structure). If an error occurs it will thus occur immediately after the message, allowing us to debug what failed to install.
2023-07-19fix implicit_reexport issues and enforce them going forwardEli Schwartz1-4/+4
This detects cases where module A imports a function from B, and C imports that same function from A instead of B. It's not part of the API contract of A, and causes innocent refactoring to break things.
2023-06-27Archive shared library in AIX (#11850)Aditya Kamath1-1/+8
* Archive shared library in AIX This code change to ensure we archive shared libraries in AIX. The things we do are: Archive shared library Install archived shared library Build all must build the archived shared library blibpath must have the archived shared library dependency. * Archive shared library in AIX. Made changes as per the review comments given in the first PR request. They are:- Use self.environment.machines[t.for_machine].is_aix() Remove trial spaces Use of val instead of internal Changed comments wherever requested * Space after octothorpe * Fixed failed test case causing build break during install section * Moved AIX specific code to AIXDynamicLinker from backend * Fix indentation, trailing spaces, add type annotations and Linux/macOS build break * Remove some more trailing space issues * Fixed the wrong return type in linkers
2023-05-02extend install scripts to allow specific directory variable exportsEli Schwartz1-3/+10
This is useful for internal scripts that want to know about something other than MESON_INSTALL_PREFIX and MESON_INSTALL_DESTDIR_PREFIX, which is very specific to the prefix.
2023-04-14minstall: work around broken environments with missing UIDsEli Schwartz1-2/+10
Running some container-like mechanisms such as chroot(1) from sudo, can result in a new isolated environment where the environment variables exist but no users exist. From there, a build is performed as root but installation fails when we try to look up the passwd database entry for the user outside of the chroot. Proper container mechanisms such as systemd-nspawn, and even improper ones like docker, sanitize this and ensure those stale environment variables don't exist anymore. But chroot is very low-level. Avoid crashing when this happens. Fixes #11662
2023-04-14minstall: do not drop privileges if msetup also ran under sudoEli Schwartz1-0/+4
A user might run `sudo somewrapper` to build and install something with meson, and it is not actually possible to drop privileges and build, since the build directory is also owned by root. A common case of this is `sudo pip install` for projects using meson-python or other python build-backends that wrap around meson. Fixes #11665
2023-04-14minstall: Fix install_subdir() excludes with path separators on WinDaniele Nicolodi1-0/+2
The paths in meson.build use / as path separator, however, the paths constructed during the directory structure walk use native path separators, thus the path never compare equal to the excluded ones. Normalize the exclusion paths before the comparison.
2023-04-11fix various spelling issuesJosh Soref1-2/+2
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-03-29Make --vsenv a readonly builtin optionXavier Claessens1-2/+4
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-20backends: add a new "none" backendEli Schwartz1-6/+8
It can only be used for projects that don't have any rules at all, i.e. they are purely using Meson to: - configure files - run (script?) tests - install files that exist by the end of the setup stage This can be useful e.g. for Meson itself, a pure python project.
2023-03-09utils: fix annotation of pickle_loadDylan Baker1-3/+1
It's actually Generic, and we should use Generic annotations to get the correct result. This means that we don't have to assert or cast the return type, because mypy just knowns
2023-02-27minstall: Replace non-breakable space with plain space in commentDaniele Nicolodi1-1/+1
2023-02-20minstall: add a timeout when waiting for user input for elevationEli Schwartz1-2/+13
Do not allow hanging forever. It's fine to use selectors here, which are unix-only, because we require Unix + a system that has e.g. sudo installed, anyway.
2023-02-20minstall: check 5 times for an answer to the elevation promptEli Schwartz1-3/+6
The user might press enter by accident and miss the message.
2023-02-20minstall: drop privileges before running rebuild_allEli Schwartz1-2/+36
If the user runs `sudo meson install` this may run ninja to build everything that gets installed. This naturally happens as root also, by default, which is bad. Instead, detect root elevation tools and drop the uid/gid of the child ninja process back to the original invoking user before doing anything.
2023-02-20minstall: rework root elevation prompt for extensibility and behaviorEli Schwartz1-6/+16
There's a couple issues with the current approach: - pkexec is an unusual elevation method, the standard is sudo - it tries to elevate even in automated workflows - the user may not want to automatically rerun as root, that might be badly behaved Do some upfront checks instead, first to make sure it even makes sense to try becoming root, and then to ask the user "do you really want this". Also check for a couple common approaches to root elevation, including doas. Fixes #7345 Fixes #7809
2023-02-20minstall: when elevating to root, don't allow ninja to rerunEli Schwartz1-1/+1
We just finished running rebuild_all, and then actually running the install routine failed because of permission errors, so we magically reran as root. But we should *know* that all prerequisite targets are up to date already, we don't need to run it *again*. Nevertheless, when running meson install directly we could end up without --no-rebuild in the original argv. This meant that it wouldn't be in the re-executed argv either. Add it on just in case -- repeating it twice doesn't hurt anyway.
2023-02-14allow install script to run in dry-run modeCharles Brunet1-3/+5
2022-11-01minstall: make do_strip run with -Sx for macOS targetsL. E. Segovia1-2/+8
This commit also adds some extra symbol noise to lib.c, in order to aid detection of the debug information with nm. Fixes #10943
2022-09-07minstall: handle extra error for selinuxenabledRosen Penev1-1/+1
Microsoft's WSL2 uses a Plan 9 filesystem, which returns IOError when file is missing.
2022-08-18minstall: do not trample install_mode by rpath fixerEli Schwartz1-1/+2
install_mode can include the setuid bit, which has the special property (mentioned in the set_mode logic for minstall itself) of needing to come last, because it "will get wiped by chmod" (or at least chown). In fact, it's not just chown that wipes setuid, but other changes as well, such as the file contents. This is not an issue for install_data / custom_target, but for compiled outputs, we run depfixer to handle rpaths. This may or may not cause edits to the binary, depending on whether we have a build rpath to wipe, or an install rpath to add. (We also may run `strip`, but that external program already has its own mode restoration logic.) Fix this by switching the order of operations around, so that setting the permissions happens last. Fixes https://github.com/void-linux/void-packages/issues/38682
2022-06-16minstall: Add more safety checks when unpickling installdataXavier Claessens1-11/+4
When need to catch exceptions just like we do in coredata.load() to print proper error message instead of backtrace when user mix meson versions. This happens frequently when user has a newer version of meson installed in their HOME and then "sudo meson install" uses the system version of meson.
2022-06-10treewide: various cleanups to move imports for mypy into typechecking blocksEli Schwartz1-4/+6
Along the way, add __future__ annotations where lacking.
2022-03-24install_symlink: Handle $DESTDIR case for links with absolute pathMarco Trevisan (Treviño)1-2/+4
In case a link is pointing_to an absolute path and we are using $DESTDIR we fail in case the target is missing. This is incorrect because we may need to use an absolute path to an already installed file that is in $DESTDIR. So if an absolute target is not existing, check if we have such file in $DESTDIR before failing for real.
2022-03-09install: Add --strip optionXavier Claessens1-9/+14
2022-03-07Fix default install tag for shared lib symlinksXavier Claessens1-7/+3
Versioned shared libraries should have .so file in devel, .so.1 and .so.1.2.3 in runtime. Fixes: #9811
2022-02-28devenv: Source bash completion scriptsXavier Claessens1-10/+10
2022-02-16fix missing f-string preventing variable formattingEli Schwartz1-1/+1
Detected by flake8 which reported that `e` was an unused variable.
2022-02-09minstall: raise explicit errors, by using MesonExceptionEli Schwartz1-7/+7
RuntimeError is way too generic when we have an explicit class for "Meson reports to the user, something went wrong". Moreover we now tell people that generic exceptions are "Meson bugs and should be reported", so our failure to do the technically correct thing and report the right kind of exception means we get haunted by demons of confusion. Specifically, people complain to us that Meson told them "there is a bug in Meson" when their install fails due to meson.build or build environment issues.
2022-02-01minstall: stop running ldconfig for the userEli Schwartz1-43/+0
This was a nice idea in theory, but in practice it had various problems: - On the only platform where ldconfig is expected to be run, it is really slow, even when the user uses a non-default prefix and ldconfig doesn't even have permission to run, nor can do anything useful due to ld.so.conf state - On FreeBSD, it bricked the system: #9592 - On cross builds, it should not be used and broke installing, because ldconfig may not be runnable without binfmt + qemu: #9707 - it prints weird and confusing errors in the common "custom prefix" layout: #9241 Some of these problems can be or have been fixed. But it's a constant source of footguns and complaints and for something that was originally supposed to be just "it's the right thing to do anyway, so just do it automatically" it is entirely too risky. Ultimately I do not think there is justification for keeping this feature in since it doesn't actually make everyone happy. Better for users to decide whether they need this themselves. This is anyways the case for cmake and autotools and generally any other build system, so it should not be too intimidating... Fixes #9721
2022-01-16install: Setup VS env if we did that during setupNirbheek Chauhan1-1/+4
Otherwise we might not find a ninja that was picked up from the Visual Studio installation. ``` $ meson setup _build ... Activating VS 15.9.40 ... Found ninja-1.8.2 at "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja\ninja.EXE" $ meson compile -C _build Activating VS 15.9.40 ... $ meson install -C _build Can't find ninja, can't rebuild test. ``` Fixes https://github.com/mesonbuild/meson/issues/9774
2021-12-11install: Don't run ldconfig on cross buildsDylan Baker1-4/+5
Even if we install without a DESTDIR set, we should never update ldconfig when cross compiling. Fixes #9707
2021-12-01add install_symlink functionPablo Correa Gómez1-17/+45
Allows installing symlinks directly from meson, which can become useful in multiple scenarios. Current main use is to help moving forward #9557
2021-11-28fix BSD ldconfig handling (#9631)Eli Schwartz1-5/+13
For libraries installed to libdir, it's not expected to have rpath hooked up. But for non-default libdirs, the path might not get searched by default. `ldconfig -m <libdir>` is convenient here, as it will programmatically add a new directory to search for shared libraries, so the resulting installed programs work out of the box. Include the dragonfly BSD platform name, which doesn't match the 'bsd' catch-all pattern.
2021-11-25minstall: do not run ldconfig on the *BSDsEli Schwartz1-0/+4
They don't utilize a soname cache, so running ldconfig without arguments is basically pointless -- and at least some of them are buggy: running ldconfig with the verbose flag switches on "delete all directories from the hints file, and recreate it using 0 command-line positional arguments", which would soft-brick the system. Fixes #9592
2021-10-27fix various flake8 whitespace errorsEli Schwartz1-2/+2
2021-10-10Fix typos discovered by codespellChristian Clauss1-1/+1
2021-10-10minstall: Ignore ldconfig errors when we did not install librariesXavier Claessens1-9/+22
Fixes: #9241
2021-10-08add install_emptydir functionEli Schwartz1-2/+16
This replaces the absolute hack of using ``` install_subdir('nonexisting', install_dir: 'share') ``` which requires you to make sure you don't accidentally or deliberately have a completely different directory with the same name in your source tree that is full of files you don't want installed. It also avoids splitting the name in two and listing them in the wrong order. You can also set the install mode of each directory component by listing them one at a time in order, and in fact create nested structures at all. Fixes #1604 Properly fixes #2904
2021-10-04condense linesEli Schwartz1-10/+5
2021-10-04f-stringsEli Schwartz1-14/+12
2021-08-17Add install tagsXavier Claessens1-9/+15
Fixes: #7007.
2021-08-06minstall: restore_selinux_contexts: fix env testStéphane Cerveau1-6/+3
To avoid extra env test, test destdir presence upper in restore_selinux_contexts
2021-08-06install: apply ldconfig at the end of the installStéphane Cerveau1-1/+19
On linux system ldconfig needs to be called to update the ld.so.cache to be able to load libraries from /usr/local/lib/x86_64-linux-gnu on debian based distributions for example.
2021-08-06install: update restore_selinux to use popen_safeStéphane Cerveau1-7/+8
Use Popen_safe to simplify the code.
2021-08-04destdir: Allow relative to build directoryXavier Claessens1-5/+10
Meson already works like that, except in do_copydir() that requires absolute destdir. Better explicitly support that instead of leaving it undefined and unconsistent.
2021-07-07resolve symlinks passed to -CPaolo Bonzini1-2/+2
"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-06-29fix: Always explicitly set encoding for text files (fixes #8263)Daniel Mensinger1-1/+1
2021-06-22minstall: make intentions clearerDylan Baker1-2/+2
The existing code works, but it probably doesn't do what the author thought it would do. `(x or y or z) is not None` works by checking that each of those things are *truthy* in turn, and returning the first truthy value, which is compared against None. Using `all()` makes it very clear that what you want to do is make sure that each value is not None.