Commit Graph

121 Commits

Author SHA1 Message Date
Eli Schwartz 108bd996ee
add install_emptydir function
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-08 14:35:00 -04:00
Eli Schwartz 800c3462f0
condense lines 2021-10-04 17:01:03 -04:00
Eli Schwartz d06cc042eb
f-strings 2021-10-04 16:29:32 -04:00
Xavier Claessens 8c5aa031b5 Add install tags
Fixes: #7007.
2021-08-17 15:19:18 -04:00
Stéphane Cerveau 51cbb15335 minstall: restore_selinux_contexts: fix env test
To avoid extra env test, test destdir presence
upper in restore_selinux_contexts
2021-08-06 15:03:29 -04:00
Stéphane Cerveau 2c3a68bc30 install: apply ldconfig at the end of the install
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-06 15:03:29 -04:00
Stéphane Cerveau 7e8d5207a7 install: update restore_selinux to use popen_safe
Use Popen_safe to simplify the code.
2021-08-06 15:03:29 -04:00
Xavier Claessens 9da99e7a59 destdir: Allow relative to build directory
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-08-04 09:43:41 -04:00
Paolo Bonzini b44a51d0fd resolve symlinks passed to -C
"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-07 18:00:37 +02:00
Daniel Mensinger 3e396b3782
fix: Always explicitly set encoding for text files (fixes #8263) 2021-06-29 11:28:08 +02:00
Dylan Baker 132420a059 minstall: make intentions clearer
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.
2021-06-22 09:13:41 -07:00
Dylan Baker 86da131129 mesonlib: Fix FileMode type annotations 2021-06-22 09:12:54 -07:00
Dylan Baker 5d3a60ae65 minstall: fix type annotation for add_arguments
This takes an `argparse.ArgumentParser` instance, not a namespace
2021-06-22 09:12:54 -07:00
Eli Schwartz 0ad870f3dc
minstall: always track meson-created directories
If a custom_target output is a directory, we install it as a directory,
not as a file. And, we try to track subdirectories which are created so
uninstalling works. But one directory creation did not go through
DirMaker, in the case where the output directory does not have any
further subdirectories.

Consolidate on makedirs, since I don't see much point in using os.mkdir
right here.
2021-03-18 20:30:13 -04:00
Peter Kjellerstedt 6226ac26ef minstall: Correctly set uid/gid of installed files
In commit caab4d3d, the uid and gid arguments passed to os.chown() by
set_chown() were accidentally swapped, causing files to end up with
incorrect owner/group if the owner and group are not the same.

Also update the documentation to better indicate which argument to
install_mode is which.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
2021-03-06 13:29:29 +02:00
Eli Schwartz 6a0fabc647
mass rewrite of string formatting to use f-strings everywhere
performed by running "pyupgrade --py36-plus" and committing the results
2021-03-04 17:16:11 -05:00
Xavier Claessens 2fabd4c7dc minstall: Add --skip-subprojects option
By default all subprojects are installed. If --skip-subprojects is given
with no value only the main project is installed. If --skip-subprojects
is given with a value, it should be a coma separated list of subprojects
to skip and all others will be installed.

Fixes: #2550.
2021-02-22 23:03:55 +02:00
Xℹ Ruoyao 3ed30cea6e Fix destdir detection for installation via polkit
In 0.57.0 installation via polkit won't work anymore. `destdir` is
defaulted to an empty string ('') instead of None.  But polkit
installation code incorrectly tests `destdir is None`.
2021-02-16 08:39:29 -05:00
Xavier Claessens 95c0790711 minstall: Add --dry-run option
Closes: #1281
2021-02-04 16:24:38 +00:00
Xavier Claessens 6c6b5d77d6 add_install_script: add skip_if_destdir kwarg
It is common, at least in GNOME projects, to have scripts that must be
run only in the final destination, to update system icon cache, etc.
Skipping them from Meson ensures we can properly log that they have not
been run instead of relying on such scripts to to it (they don't
always).
2021-01-30 21:28:21 +00:00
Xavier Claessens c491d48b9d minstall: Add --destdir command line option 2021-01-30 21:28:21 +00:00
Xavier Claessens 0626465ea8 Fix executable as script on Windows
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-30 09:51:06 +00:00
Dylan Baker caab4d3d92 minstall: Fix signature of monkeypatched os.chown
this also clears up the last of the mypy problems in minstall, yay!
2021-01-13 13:32:48 -08:00
Dylan Baker c49ad7ca48 minstall: Pass destdir and fullprefix instead of adding them to instance
Same idea as the last patch, just different data
2021-01-13 13:32:48 -08:00
Dylan Baker 2a30f0bd35 minstall: Pass DirMaker separately instead of adding to instance
Add a new attribute to an object outside of the initializer of
construtor is considered an antipattern for good reason, it's gross,
it's confusing, and it often leads to AttributeErrors down some paths.
Let's not do that.
2021-01-13 13:32:48 -08:00
Dylan Baker efe4547d80 minstall: Add type annotations
This adds annotations and fixes a couple of issues (passing Set[bytes]
where List[byte] is expected), however, there's some very gross addition
of attributes to types going on that I haven't fixed yet, and mypy is
very grump about.
2021-01-13 13:32:48 -08:00
Dylan Baker 59328aba29 build: Add some type annotations 2021-01-13 13:32:48 -08:00
Dylan Baker 6180992d49 minstall: fix imports
This uses PEP8 style, one per from `import mod`, but with commas from
`from mod import a, b`. Also run sort, for niceness.
2021-01-13 13:31:29 -08:00
wereii 3a7baef7ea Fix missed imports in #7902 2020-12-28 15:25:22 +00:00
Paolo Bonzini 79e2c52a15 mtest: only build what is needed for the tests
It is a usual workflow to fix something and retest to see if it is fixed using a
particular test.  When tests start to become numerous, it becomes time consuming
for "meson test" to relink all of them (and in fact rebuild the whole project)
where the user has already specified the tests they want to run, as well as
the tests' dependencies.

Teach meson to be smart and only build what is needed for the test (or suite)
that were specified.

Fixes: #7473
Related: #7830
2020-12-14 10:53:36 +01:00
Thomas Weißschuh 6b328ef7c4 install: don't elevate when using destdir
Previously the destdir was ignored completely when using elevated
privileges to install files as pkexec stripped the DESTDIR environment
variable.
As the destdir is not supposed to require any special privileges
anyways, just re-raise the error.
2020-12-10 00:26:28 +02:00
Dylan Baker b034f8cf61 pylint: Turn on warnings for incorrect number of args
This catches some very real errors.

The one in scalapack is pretty silly actually, it's failing to figure
out that the exploded list is at least two arguments. However, the code
is actually clearer by not using a list and exploding it, so I've done
that and pylint is happy too.
2020-09-22 17:57:03 -07:00
Nirbheek Chauhan 9fb839687b minstall: Add version field to install data
And check the install data in the same way that mtest checks
serialisation data.

Fixes https://github.com/mesonbuild/meson/issues/2354
2020-09-10 12:38:05 +00:00
Nirbheek Chauhan eca4c6fcaf minstall: Print a big FAILED when a script fails
We don't run any further scripts when this happens, so we need to
print a big error. The exit code was already correct.

Fixes https://github.com/mesonbuild/meson/issues/7627
2020-09-08 15:27:34 +00:00
Eli Schwartz 86b47250c6 simplify shutil usage by invoking copy2 where appropriate
It's equivalent to copyfile + copystat with the same arguments.
2020-08-20 23:47:54 +03:00
Dan Kegel d7235c5905 Let .pc files specify rpath.
Fixes #4027
2020-05-16 20:25:58 +00:00
Michael Kuhn 6952f9f6c9 Do not call restorecon if there are no files to install
Fixes #6452
2020-03-29 20:52:43 +03:00
Michael Brockus 98ddd52ced
Cherry-picking - (rm python2 % add python3 .format) (#6725) 2020-03-03 21:45:43 +02:00
Nirbheek Chauhan 53265e3bc2 minstall: Add a new option --quiet
This is a significant speed-up on Windows because terminals are
slow to print things out.

Speed-up in gst-build on Windows:

```
meson install:
before: 5.1 seconds
after:  4.0 seconds
```
2020-02-17 23:58:20 +05:30
Nirbheek Chauhan 1300485832 minstall: Optimize when to call makedirs()
In `--only-changed` mode, we were spending half our time inside
`makedirs()`, which is a waste in the case when only a few files have
changed.

Speed-up on Windows with gst-build:

```
meson install --only-changed
before: 1.6 seconds
after:  0.9 seconds
```
2020-02-17 23:58:20 +05:30
Nirbheek Chauhan bb7c0a163f minstall: Error out when trying to copy file to dir
Not sure why this wasn't already an error. It's a bad situation to be
in, and we should not ignore it.
2020-02-17 23:58:20 +05:30
Nirbheek Chauhan 21c4b7e400 minstall: Fix check for when something was installed
If we preserve the existing file, we did not install anything. In that
case, the output now looks like:

```
ninja: Entering directory `.'
ninja: no work to do.
Nothing to install.
Preserved 1732 unchanged files, see meson-logs\install-log.txt for the full list
```

This also avoids an `isfile` lookup, which shaves off a few seconds in
gst-build install.
2020-02-17 23:58:20 +05:30
Nirbheek Chauhan fa036a2127 minstall: Add new hidden argument --profile-self
Same purpose as `meson setup`.
2020-02-17 23:58:20 +05:30
Nirbheek Chauhan 36a0797e1c minstall: Make --only-changed less verbose
When `--only-changed` is passed, we only want to know about files that
were newly-installed. Everything else is noise. The full list can
always be found in `install-log.txt` anyway. Sample output:

```
ninja: Entering directory `.'
ninja: no work to do.
Preserved 667 unchanged files, see meson-logs\install-log.txt for the full list
```
2020-02-11 06:16:56 -05:00
Daniel Mensinger e4a0ee205d lgtm: Fix redundant code 2019-12-05 00:22:10 +02:00
Orlando Wingbrant 9ee9a1e1b2 Fix for issue #4499, multiple entries per file in install-log.txt 2019-10-23 22:37:45 +03:00
Jakub Adam 1bf1782476 Fix *.pdb files missing in meson introspect --installed output
On Windows, make sure the introspect command lists all Program database
(PDB) files containing debugging information that Meson will install.
2019-10-09 15:50:20 +02:00
Andrew Conrad 714908e5d9 Catch NotADirectoryError to fix selinux error
Fixes #4798
2019-09-27 13:09:52 -07:00
Jussi Pakkanen 51a601c2ee Log the used strip command. [skip ci] 2019-09-03 23:02:50 +03:00
Jussi Pakkanen f41bdae368 Add basic Webassembly support via Emscripten. 2019-08-05 19:31:32 +03:00
Daniel Mensinger e75211d321
Fix builtin variable names 2019-04-29 12:17:40 +02:00
Daniel Mensinger bf98ffca9e
Fix blind exceptions 2019-04-29 12:16:06 +02:00
Michael Hirsch, Ph.D da34bea893 pep8 py37 2019-01-29 22:06:11 +02:00
Nicolas Schneider 735e138382 fix meson configure exception when install_umask is not an int 2019-01-06 22:35:04 +02:00
Nicolas Schneider 211a60dc99 print 'Nothing to install.' if nothing was installed
Fixes #882.
2019-01-01 22:37:44 +02:00
Xavier Claessens 4178267bfe minstall: Do not delete dst files when installing a directory
do_copyfile() already takes the decision to delete or preserve them.

Also do not append a confusing '.' in log messages that finish by a file
path.
2018-11-20 22:51:31 +02:00
Jon Turney 93f7b83bf5 Fix flake8 'imported but unused' reports
$ flake8 | grep F401
./mesonbuild/minstall.py:15:1: F401 'gzip' imported but unused
./mesonbuild/backend/backends.py:26:1: F401 '..compilers.get_macos_dylib_install_name' imported but unused
./mesonbuild/backend/backends.py:29:1: F401 'functools.lru_cache' imported but unused
./mesonbuild/scripts/dist.py:27:1: F401 'mesonbuild.dependencies.ExternalProgram' imported but unused
2018-10-24 19:11:46 +03:00
Michał Górny e8232c7825 Remove implicit compression of man pages
Remove the code responsible for implicitly compressing manpages as .gz
files.  It has been established that manpage compression is a distro
packager's task, with existing distros already having their own
implementations of compression.

Fixes #4330
2018-10-20 13:16:28 +03:00
Xavier Claessens 37067a53c4 Use a single ArgumentParser for all subcommands
This has the adventage that "meson --help" shows a list of all commands,
making them discoverable. This also reduce the manual parsing of
arguments to the strict minimum needed for backward compatibility.
2018-10-04 09:40:21 -04:00
Jussi Pakkanen f34f0717e0 Revert symlink copy behaviour. Closes #4069. 2018-08-23 21:53:38 -07:00
Marco Trevisan (Treviño) abf65c92af minstall: use follow_symlinks to check executable
This could happen when setting an default install mode but with broken
symlinks.

Fixes #3914
2018-08-17 16:41:09 +02:00
Marco Trevisan (Treviño) 5de2a7910a minstall: never follow symlinks when setting ownership
Since we're supposed to call this for each installed path, we only should go
through what we've installed and not what this point to, as it might be
outside our scope or not existent.

To do this, since shutil.chown doesn't expose the follow_symlink that os.chown
has, we can temporarily replace os.chown with a lambda that acutually passes
all the values as we want them, and then restore it to the built-in functions.
Not the nicest way, but fixes the issue without having to reimplement what
shutil does.

Fixes #3914
2018-08-17 16:41:09 +02:00
Marco Trevisan (Treviño) 2d010727ed minstall: never try to set chmod on symlinks
It's only supported by few platforms when the linked file exists, while it
would cause an error otherwise.

In any case just implement this via an helper set_chmod function that will
handle the case where follow_symlinks is not supported by the platform
and will just not set any mod for the link itself (as it would otherwise
apply to the linked file).

Fixes #3914
2018-08-17 16:41:09 +02:00
Nirbheek Chauhan d03cf04598 install_subdir: Also copy dangling symlinks
Fixes https://github.com/mesonbuild/meson/issues/3914
2018-08-15 04:57:23 -07:00
Jussi Pakkanen 15fb284395 Fix install when run with meson.exe. Closes #3988. 2018-08-09 09:08:33 -07:00
Nirbheek Chauhan c69030c123 Don't require an import library for shared modules
Shared modules may be resource-only DLLs, or might automatically
self-initialize using C constructors or WinMain at DLL load time.

When an import library is not found for a shared module, just print
a message about it instead of erroring out.

Fixes #3965
2018-08-09 18:39:19 +03:00
Xi Ruoyao 8893d03703 Fix pkexec command for installation via polkit 2018-07-04 15:21:42 +00:00
Jussi Pakkanen 10b094c980 Make it work with current master. 2018-06-20 20:38:26 +03:00
Jussi Pakkanen e60bf5d833 Add option to only install changed files. 2018-06-18 22:12:13 +03:00
Jussi Pakkanen 6a21e19515 Refactored installer to use a class to eradicate global variables. 2018-06-18 22:12:13 +03:00
Jussi Pakkanen 6cf79f86ee Made install a top level Meson command. 2018-06-18 22:02:56 +03:00