Commit Graph

67 Commits

Author SHA1 Message Date
Ryan Gonzalez 7e8c099387 Print message when using polkit 2018-05-18 17:12:24 +03:00
Ryan Gonzalez 60352521d1 Fix #3579: Wait for a permissions failure before trying to run pkexec 2018-05-18 17:12:24 +03:00
Ryan Gonzalez 559286a0da Support installation via polkit 2018-05-17 00:23:18 +03:00
Filipe Brandenburger 8651d55c6a Add new builtin option --install-umask
This option controls the permissions of installed files (except for
those specified explicitly using install_mode option, e.g. in
install_data rules.)

An install-umask of 022 will install all binaries, directories and
executable files with mode rwxr-xr-x, while all data and non-executable
files will be installed with mode rw-r--r--.

Setting install-umask to the string 'preserve' will disable this
feature, keeping the permissions of installed files same as the files in
the build tree (or source tree for install_data and install_subdir.)
Note that, in this case, the umask used when building and that used when
checking out the source tree will leak into the install tree.

Keep the default as 'preserve', to show that no behavior is changed and
all tests keep passing unchanged.

Tested: ./run_tests.py
2018-04-18 11:44:54 -07:00
Jussi Pakkanen 7c37ca15f3 🤦🤦🤦 2018-04-14 22:41:24 +03:00
Jussi Pakkanen aed11affd3 Update depfixer to fix rpaths also on OSX. 2018-04-08 19:48:31 +03:00
Fabrice Fontaine 2e128f71bb Fix FileNotFoundError when restorecon unavailable
Fixes:
 - http://autobuild.buildroot.net/results/d5dcdfdfab3503fdc387f99e68267972a38c417d

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2018-03-15 21:12:23 +02:00
Aleksey Filippov 3493a372e2 Use specific exception types instead of Exception 2018-03-12 02:39:27 +00:00
Aleksey Filippov e4faf396e6 Do not use bare except [flake8]
Use more specific exception types where appropriate.
This patch does not change bare except calls if exception is re-raised.
2018-03-11 23:36:04 +00:00
Aleksey Filippov 20c1cb7d02 Fix install_subdir() installation message
Print full destination path in 'Installing subdir ...' message,
including DESTDIR, consistent with other installation functions.
Use separate dst_dir and full_dst_dir variables to avoid mixing up
the order in the future and make code more readable.
Closes #3006.
2018-02-05 22:34:30 +02:00
Aleksey Filippov 8fe8161014 Refactor and simplify install_subdir()
- Pass exclude_files and exclude_directories relative to src_dir,
  same as specified by user and documented in public install_subdir().
- Make do_copydir() interface similar to do_copyfile():
  install src_dir contents to dst_dir.
- Remove src_prefix/src_dir code, it adds confusion and duplicates arguments.
  Use single src_dir parameter instead.
- Make callers specify that src_dir contents should be installed
  under dst_dir/basename(src_dir) if necessary.
- Use os.path.relpath() instead of string manipulations on paths.
- Add documentation to do_copydir(): specify types and add usage example.
2018-02-04 00:43:00 +02:00
Aleksey Filippov 2cf85ae16f Use os.path: basename() and dirname() instead of split()
According to Python documentation[1] dirname and basename
are defined as follows:
    os.path.dirname() = os.path.split()[0]
    os.path.basename() = os.path.split()[1]
For the purpose of better readability split() is replaced
by appropriate function if only one part of returned tuple
is used.

[1]: https://docs.python.org/3/library/os.path.html#os.path.split
2018-01-30 07:08:22 +11:00
Zbigniew Jędrzejewski-Szmek fadce7f9b4 Silence failed restorecon calls when $DESTDIR is set
This avoids hundres of warnings like:
Warning no default label for /var/tmp/instroot.hUbtYJ/path/to/some/binary

$DESTDIR is usually set to a temporary path, in which case the path is
unknown to selinux. For that case we could just skip the restorecon
calls.  But sometimes it is used with a path to container. In that
case, most of the time, selinux has no context for that path. But we
can't rule that out somebody added custom context rules for the
container. So let's still call restorecon, but silence the warning.
2017-11-19 18:26:46 +02:00
Elliott Sales de Andrade f91c4805b1 Pass restorecon file list through stdin.
This should avoid any issues with command-line argument limits.
2017-11-11 03:10:29 -05:00
Elliott Sales de Andrade 5f8b37d0e7 Coalesce restorecon calls into one.
Fixes #2596.
2017-11-09 19:45:28 -05:00
Jussi Pakkanen 876b2475dd Made man page gzip creation deterministic. Closes #2363. 2017-09-23 11:31:59 +03:00
Nirbheek Chauhan c63aa0372b install: Also ignore PermissionError for selinux
When the user does not have permissions to run `selinuxenabled`, a
PermissionError is raised instead of FileNotFoundError.

Closes https://github.com/mesonbuild/meson/issues/2257
2017-09-04 19:24:31 +03:00
Gabríel Arthúr Pétursson 24ff7da0d2 Remove leftover debug print statement in meson_install.py 2017-08-20 23:16:42 +03:00
Jussi Pakkanen 50fb7d37ab Make all functionality invokable via the main Meson binary,
which can be a Windows .exe file.
2017-08-18 12:08:20 +03:00
Elliott Sales de Andrade 5cb1d00537 Allow excluding files from `install_subdir`
The install_subdir command now accepts a new `exclude` keyword argument
that allows specified files to be excluded from the installed
subdirectory.
2017-08-06 03:58:35 -04:00
Peter Hutterer d436869a89 Remove directories created by ninja install
Introduce a DirMaker class that disassembles the path up to '/' and stores all
directories in a list. That list is in creation order and pre-existing
directories are ignored, i.e. creating the two paths
'/usr/share/foo/bar/baz' and '/usr/share/foo/bar/boo' is stored as
    [ '/usr/share/foo',
      '/usr/share/foo/bar',
      '/usr/share/foo/bar/baz',
      '/usr/share/foo/bar/boo' ]
This is on the assumption that /usr/share already existed.

After all files have been installed, the list of created directories is
appended in reverse order to the install log. The uninstall script then
triggers rmdir on all directories.

If a custom install script drops files into the directories, removing those
will fail. This matches the current expectation, see the existing warning
"Remember that files created by custom scripts have not been removed."

Unfortunately, this makes the behavior on uninstall inconsistent. Assuming a
non-existing prefix,
        ninja install && ninja uninstall
removes all traces of the install.
However,
        ninja install && ninja install && ninja uninstall
removes the files only, not the directories as they already existed.

This could be fixed by just unconditionally removing any (emtpy) directories
that we drop files into, at the risk of removing system directories if empty.
For example, one could imagine /etc/foo.conf.d/ to be removed in that case if
it is empty.

https://github.com/mesonbuild/meson/issues/2032
2017-08-01 11:40:28 +01:00
Peter Hutterer 36e58e8865 meson_install: rename 'data' to 'd' for consistency
All other functions call it 'd', let's do it here too
2017-08-01 11:40:28 +01:00
Peter Hutterer 1826872fd2 install: restore the SELinux context on install
Try to restore the context for SELinux. If we fail on running
'selinuxenabled', quietly ignore the error and continue. If we fail on the
actual restorecon call, we print a message but disable SELinux - chances are
high that if one restorecon fails, others will too and that's likely a system
setup issue.

Fixes #1967
2017-07-31 18:45:38 -04:00
Elliott Sales de Andrade ea636fcd51 Remove unused variables. 2017-05-17 04:41:54 -04:00
Peter Hutterer 6a4efe8a82 Drop terminating fullstop from "Installing blah to blah" messages
Grammatically, this full stop isn't needed and with file names it has a
potential to be confusing:
    Installing /foo/bar/filename.1 to /foo/bar/dirname.

The full stop caused me to do a double-take more than once, so let's drop it.
2017-04-19 16:11:37 +03:00
Jussi Pakkanen 761b28371a Merge pull request #1518 from centricular/mesonintrospect-evar
Export MESONINTROSPECT to postconf/install/run_command scripts
2017-04-08 21:25:25 +03:00
Jon Turney 320490cd00 Ignore install as non-existent user or group
'test cases/common/12 data' and 'test cases/common/66 install subdir' both
try to install something as 'root'.  This user doesn't exist on Cygwin.

Perhaps we should automatically convert this to some other user, but it's
not clear which. For real projects, it's possibly better for the meson.build
to explicitly handle this...

'test cases/common/12 data' also tries to install something with GID 0.
There's no guarantee this group exists.
2017-04-06 22:48:02 +01:00
Jon Turney fd47ef3a27 Use '.exe' extension for executables for Cygwin
Use '.exe' extension for executables for Cygwin when building and installing
2017-04-06 22:47:15 +01:00
Nirbheek Chauhan 27f5f0a963 Export MESONINTROSPECT to postconf/install/run_command scripts
Points to the `mesonintrospect.py` script corresponding to the
currently-running version of Meson.

Includes a test for all three methods of running scripts/commands.

Closes https://github.com/mesonbuild/meson/issues/1385
2017-03-28 00:55:01 +05:30
Jussi Pakkanen 0c957b75c6 Install PDB files. Closes #1442. 2017-03-02 20:31:05 +02:00
Jussi Pakkanen b927468137 Use cross stripper when cross compiling and allow overriding native strip executable. Closes #1414. 2017-02-27 16:49:32 -05:00
Jussi Pakkanen 14e0529a03 Do not strip jar targets. Closes #1343. 2017-02-06 19:09:22 +01:00
Nirbheek Chauhan 7d6f628ed4 Support file perms for install_data and install_subdir
With the 'install_mode' kwarg, you can now specify the file and
directory permissions and the owner and the group to be used while
installing. You can pass either:

* A single string specifying just the permissions
* A list of strings with:
  - The first argument a string of permissions
  - The second argument a string specifying the owner or
    an int specifying the uid
  - The third argument a string specifying the group or
    an int specifying the gid

Specifying `false` as any of the arguments skips setting that one.

The format of the permissions kwarg is the same as the symbolic
notation used by ls -l with the first character that specifies 'd',
'-', 'c', etc for the file type omitted since that is always obvious
from the context.

Includes unit tests for the same. Sadly these only run on Linux right
now, but we want them to run on all platforms. We do set the mode in the
integration tests for all platforms but we don't check if they were
actually set correctly.
2017-01-24 00:20:51 +05:30
Igor Gnatenko 969dc7e995 style: fix E124 violations
E124: closing bracket does not match visual indentation

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Igor Gnatenko 2017d8578a style: fix E226 violations
E226: missing whitespace around arithmetic operator

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2017-01-01 12:02:05 -05:00
Jussi Pakkanen b55235dfbd Fix space before :. 2016-12-31 16:28:15 +02:00
Nirbheek Chauhan 0ac965cc10 Fix shared library symlink aliasing on install
Set the rules for the symlinking on the target itself, and then reuse
that information while generating aliases during the build, and then
pass it to the install script too.
2016-12-22 02:27:01 +05:30
Igor Gnatenko 8268eb4959 tree-wide: remove unused imports
./setup.py:17:1: F401 'os' imported but unused
import os
^
./setup.py:37:1: F401 'stat.ST_MODE' imported but unused
from stat import ST_MODE
^
./run_tests.py:17:1: F401 'os' imported but unused
import subprocess, sys, os
^
./run_tests.py:18:1: F401 'shutil' imported but unused
import shutil
^
./run_unittests.py:23:1: F401 'mesonbuild.dependencies.Qt5Dependency' imported but unused
from mesonbuild.dependencies import PkgConfigDependency, Qt5Dependency
^
./mesonbuild/build.py:15:1: F401 '.coredata' imported but unused
from . import coredata
^
./mesonbuild/interpreter.py:32:1: F401 'subprocess' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/interpreter.py:32:1: F401 're' imported but unused
import os, sys, subprocess, shutil, uuid, re
^
./mesonbuild/dependencies.py:23:1: F401 'subprocess' imported but unused
import os, stat, glob, subprocess, shutil
^
./mesonbuild/mesonlib.py:17:1: F401 'sys' imported but unused
import platform, subprocess, operator, os, shutil, re, sys
^
./mesonbuild/modules/qt5.py:15:1: F401 'subprocess' imported but unused
import os, subprocess
^
./mesonbuild/modules/pkgconfig.py:15:1: F401 '..coredata' imported but unused
from .. import coredata, build
^
./mesonbuild/scripts/scanbuild.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/meson_exe.py:20:1: F401 'subprocess' imported but unused
import subprocess
^
./mesonbuild/scripts/meson_exe.py:22:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/symbolextractor.py:23:1: F401 'subprocess' imported but unused
import os, sys, subprocess
^
./mesonbuild/scripts/symbolextractor.py:25:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/meson_install.py:19:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException, Popen_safe
^
./mesonbuild/scripts/yelphelper.py:15:1: F401 'sys' imported but unused
import sys, os
^
./mesonbuild/scripts/yelphelper.py:20:1: F401 '..mesonlib.MesonException' imported but unused
from ..mesonlib import MesonException
^
./mesonbuild/backend/vs2010backend.py:17:1: F401 're' imported but unused
import re
^
./test cases/vala/8 generated sources/src/copy_file.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/107 postconf/postconf.py:3:1: F401 'sys' imported but unused
import sys, os
^
./test cases/common/129 object only target/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^
./test cases/common/57 custom target chain/usetarget/subcomp.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/95 dep fallback/subprojects/boblib/genbob.py:3:1: F401 'os' imported but unused
import os
^
./test cases/common/98 gen extra/srcgen.py:4:1: F401 'os' imported but unused
import os
^
./test cases/common/113 generatorcustom/gen.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/113 generatorcustom/catter.py:3:1: F401 'os' imported but unused
import sys, os
^
./test cases/common/59 object generator/obj_generator.py:5:1: F401 'shutil' imported but unused
import sys, shutil, subprocess
^

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-19 18:19:35 +01:00
Jussi Pakkanen 7851daec7a Merge pull request #1216 from mesonbuild/ignatenko/shebangs
Remove shebangs on files inside module
2016-12-18 20:11:04 +02:00
Nirbheek Chauhan 6b8df9da84 custom_target: Make directory outputs installable
This is useful in many cases where the list of files cannot be known in
advance and is just dumped inside a directory. For example when
generating documentation with doxygen and other tools that we don't have
built-in support for.

Includes a test for the same.

Closes #893
2016-12-18 20:00:25 +02:00
Nirbheek Chauhan c693bd9bb4 Allow passing arguments to install scripts
Closes #1213
2016-12-18 18:30:47 +02:00
Igor Gnatenko 4fbaf295f6 remove shebangs from scripts
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/regen_checker.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_test.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_benchmark.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_exe.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/symbolextractor.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/commandrunner.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/gtkdochelper.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/meson_install.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/depfixer.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/dirchanger.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/delwithsuffix.py 644 /usr/bin/python3
meson.noarch: E: non-executable-script /usr/lib/python3.5/site-packages/mesonbuild/scripts/vcstagger.py 644 /usr/bin/python3

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
2016-12-18 16:55:34 +01:00
Nirbheek Chauhan 60716fcd6d Use universal_newlines=True for all Popen calls
Instead of adding it everywhere manually, create a wrapper called
mesonlib.Popen_safe and use that everywhere that we call an executable
and extract its output.

This will also allow us to tweak it to do more/different things if
needed for some locales and/or systems.

Closes #1079
2016-12-11 01:59:58 +02:00
Nirbheek Chauhan b9a7c0cf39 misc: Use relative imports everywhere
Using 'mesonbuild' as the module can cause it to use the
system-installed module and can also break if we rename the directory,
so avoid that by always using relative imports.
2016-12-07 00:24:17 +05:30
Jussi Pakkanen 1f4cce86ad Remove shebangs on files that are not runnable and add execute bits to those that are. 2016-10-07 21:10:33 +03:00
Jussi Pakkanen cdf0c4f1a9 Merge branch 'QuLogic-context-managers' 2016-09-01 23:12:06 +03:00
Elliott Sales de Andrade 38a2a636b5 Refactor DESTDIR determination into a single function. 2016-08-27 23:07:59 -04:00
Elliott Sales de Andrade 3a593d0aca Always obey DESTDIR even with absolute install_dir.
Passing an absolute path to `install_dir` would previously always
attempt to install there, instead of obeying DESTDIR, since os.path.join
will 'reset' on absolute paths.
2016-08-27 23:07:59 -04:00
Elliott Sales de Andrade 4c71695e41 Use context manager for file I/O.
There are a few cases where a context manager cannot be used, such as
the logger.
2016-08-27 18:29:55 -04:00
Jussi Pakkanen 64919b1c74 Merge pull request #417 from nirbheek/dll-paths
Fix filenames and paths used in DLL shared library generation
2016-07-13 22:18:50 +03:00