Commit Graph

201 Commits

Author SHA1 Message Date
Alexander Larsson
07fa8138a2 Merge pull request #194 from smcv/shell-injection
unrpm: prevent shell injection
2016-08-26 11:19:34 +02:00
Alexander Larsson
90d4f8d1b4 Don't fail if appstream-compose fails, instead warn.
This means we stop breaking existing builds e.g. when an older
appstream-compose in the runtime can't handle a new appdata field.
2016-08-25 11:34:10 +02:00
Mathieu Bridon
63cddfa80e builder: Handle submodules using with relative URLs
Some projects declare their Git submodules with URLs relative to their
own.

For example, gedit is hosted at git://git.gnome.org/gedit, and has its
libgd submodule declared with the ../libgd URL. We should treat the
latter as git://git.gnome.org/libgd.

This was in fact properly done in the past, but I broke it in commit
1171e1d202.

This fixes it again.
2016-08-24 21:06:00 +02:00
Alexander Larsson
b0a7f8052b builder: Add --sandbox support
This disables build-args support, which is nice when building things
on e.g. a shared build-machine, where we don't want the build to
be able to break out of the sandbox (by specifying e.g. --share=network).
2016-08-22 17:23:32 +02:00
Alexander Larsson
b03b21f416 Merge branch 'builder-git-submodules' of git://github.com/bochecha/flatpak into bochecha-builder-git-submodules 2016-08-22 16:08:39 +02:00
Alexander Larsson
6578d37984 Drop libgsystem dependency 2016-08-22 16:00:33 +02:00
Alexander Larsson
65f1cf993d Create and use flatpak_file_get_path_cached
This is simpler that the one in libgs, as well as lockless. Also, it
removes one more use of libgs.
2016-08-22 10:22:42 +02:00
Alexander Larsson
9c907c992d Replace gs_shutil_rm_rf with small helper wrapper over libglnx 2016-08-22 10:06:08 +02:00
Alexander Larsson
e0bd22bfe8 Add flatpak_mkdir_p helper and use it
This replaces all current callers of gs_file_ensure_directory with
equivalent code.

Actually, two instances were calling gs_file_ensure_directory with
FALSE, i.e. error out on EEXIST, but those cases seem fine with the
do-nothing-if-exists semantics.
2016-08-22 09:29:24 +02:00
Mathieu Bridon
1171e1d202 builder: Redo git submodules handling
flatpak-builder was mixing the path and the name of a submodule, which
would lead to download failures when they were different.

Fixes #216
2016-08-20 12:44:27 +02:00
Alexander Larsson
fb3bfae85b builder: Add --stop-at=module
Stop building at a specified module from the json file.
This is useful during development. For instance, you can do --stop-at=main-app
to build all the dependencies into the appdir, then you can do a build of an
already checked out git repo (possibly with changes).
2016-08-19 11:25:23 +02:00
Alexander Larsson
f622b014a7 builder: Handle symbolic icons in rename-icons 2016-08-19 11:05:18 +02:00
Alexander Larsson
0d115fb2e7 builder: Save a copy of the base manifest 2016-08-17 14:24:32 +02:00
Alexander Larsson
7431fff588 Fix up pyo stale file handling
We were not doing what the comments said we should, and we also
want to change what happens in the case of an old py file from
a previous layer (such as a base layer in a runtime) has a non-rewritten
.pyc file. In that case we want to assume its correct and fix it up.
2016-08-11 07:54:48 +02:00
Alexander Larsson
348b7f9ab4 builder: Add some printouts if we remove stale .pyc files
This makes it easier to figure out why it disappeared
2016-08-11 07:54:25 +02:00
Alexander Larsson
006d9a1927 Correctly handle .pyc mtimes for .py files changing multiple times
If a .py file changes multiple times we can end up in a situation
where there is an .py file with corresponding .pyc file that we
rewrote, so both are now mtime==1. Then a new version of the .py file
is added, but the corresponding .pyc file is not updated. This means
that the .pyc file is stale, and python would not normally use it.
However, we will later change the mtime on the .py file to 1, causing
the old .pyo file to look up-to-date even though its stale.

We fix this by detecting the case where the is a new mtime on a .py file
where the .pyc file doesn't match, and remove the stale .pyc file.
2016-08-10 16:24:11 +02:00
Matthew Leeds
25d88477c5 builder: Allow git sources to be specified as paths
Currently to use a local copy of a git repo you have to specify the url
as "file:///path/to/repo". This commit allows you to specify a path directly
as "/path/to/repo", which is faster and more space-efficient because
git-clone will hardlink the objects rather than copying them.
2016-07-29 16:01:30 -04:00
Matthias Clasen
75218c4a65 Fix license headers
We were referring to the nonexisting "version 2" of the
Lesser GPL. It should be "version 2.1".
2016-07-29 14:27:49 -04:00
Matthias Clasen
3a281d0782 Add locations to some error messages
When a file is not found, mention where we looked for it.
This provides useful context for understanding the error.
2016-07-29 14:16:31 -04:00
Matthias Clasen
91b7b0a419 Mention app dir in output
This can help making sense out of error messages when something
goes wrong.
2016-07-29 14:15:46 -04:00
Matthew Leeds
b051571de8 builder: Fix a few memory leaks
These changes fix some memory leaks that valgrind pointed out.
2016-07-28 16:03:42 -04:00
Matthew Leeds
fcd6da2fa3 builder: Print a message when running flatpak build-finish
This commit makes flatpak-builder print the flatpak build-finish command
it constructs before executing it in a subprocess, which matches the
behavior for flatpak build-init and flatpak build.
2016-07-18 14:29:41 -04:00
Simon McVittie
5b8fdb4998 unrpm: prevent shell injection
Substituting into a shell command-line without escaping is a bad idea.
If the argument is attacker-controlled, it's a security vulnerability;
if the argument is legitimate-user-controlled (as I think it is here)
it's merely wrong.

We could escape the filename with g_shell_quote(), but it's more
straightforward to take advantage of the shell's argument processing.
The first positional parameter (if given) is $0, and the rest are $@.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-07-18 14:32:14 +01:00
Christophe Fergeau
2b609c6624 Add RPM archive support 2016-07-15 11:13:28 +02:00
Christophe Fergeau
543d81c2fe Factor some zip uncompression code in a helper func 2016-07-15 11:13:28 +02:00
Alexander Larsson
b5204c908d builder: Clear mtime to 1, not 0, to match what new ostree does 2016-07-01 14:25:22 +02:00
Alexander Larsson
eaeb132a5a builder: Set the new extension properties
Set autodelete=true on locale and debug extensions.
Set no-autodownload=true on debug extensions.
Thats what will happen anyway, but its nice to be explicit.

Also, remove subdirectories=true on the locale extensions, as
we're not using that anymore.
2016-06-30 16:55:32 +02:00
Alexander Larsson
9558d7d6ae builder: Strip "." from locale names too
For instance, "C.utf8" => "C" or "en.utf8" => "en".
Mostly this was already handled for e.g. "en_US.utf8" though...
2016-06-30 11:47:45 +02:00
Alexander Larsson
de8d8a36c2 Merge pull request #158 from hadess/wip/use-git-patch
Add "use-git" option for patch source types
2016-06-28 15:24:49 +02:00
Alexander Larsson
b00dbed3bd builder: Report errors to stderr, not stdout 2016-06-28 15:08:09 +02:00
Bastien Nocera
c646f386eb builder: Add "use-git" option for patch source type
Closes #6
2016-06-28 14:24:16 +02:00
Matthias Clasen
d3629b8e72 builder: Add support for a var runtime
flatpak build-init as a --var option - support this as a
"var" key in the json.
2016-06-23 10:01:40 +02:00
Alexander Larsson
bd485fbc01 builder: Report error details when failing to checkout cache. 2016-06-09 17:45:44 +02:00
Alexander Larsson
5eb671aac4 builder: Warn for duplicate module names 2016-06-09 12:43:31 +02:00
Matthias Clasen
99e4f83e33 Allow inclusions in the module list
When we see a string in the modules array, parse it as a json
file and use the resulting BuilderModule object.
2016-06-09 01:01:37 -04:00
Matthias Clasen
5225e7b1d0 manifest: Prepare expand_modules to report errors
Move the expand_modules call from the modules setter to
builder_manifest_start, where we have a chance to report
errors.
2016-06-09 00:29:02 -04:00
Matthias Clasen
e25e379a2a manifest: expand module list
Linearize the tree of modules and submodules when the modules
are set on the manifest, while filtering out disabled modules
at the same time.

Skip source-less modules when building; this makes it possible
to have modules that only contain submodules.

With this approach, we use the tree structure of modules for
serializing and deserializing to and from json, while using
a linear list of modules for building.
2016-06-08 23:56:38 -04:00
Matthias Clasen
2757c63fea Add a modules property to BuilderModule
This will let us load modules recursively.
2016-06-08 23:56:38 -04:00
Matthias Clasen
9a8eef8597 manifest: Skip source-less modules when building
Building such modules won't produce anything. And future
commits will make source-less modules useful to support.
2016-06-08 23:56:38 -04:00
Matthias Clasen
914b841481 module: Be a bit more robust
When we call builder_module_cleanup_collect on a module that
has no changes, we shouldn't crash.
2016-06-08 23:55:57 -04:00
Alexander Larsson
bd66da0dad builder: Add support for patching mtime in python bytecode headers
This makes them work at runtime (as the mtime will then be 0) and
makes builds more repeatable.
2016-06-08 13:28:27 +02:00
Alexander Larsson
959fec1cd3 Zero out mtime when commiting
This means we get the same behaviour as if we checked out of
the cache. Also, its the same as the final behaviour will be
when running in flatpak.
2016-06-08 13:14:09 +02:00
Alexander Larsson
4990dd5f86 builder: Manually zero mtime of cache checkout
This works around an ostree bug where this didn't happen in the
mismatched mode (regular checkout, user repo) we're using.
2016-06-08 11:11:24 +02:00
Matthias Clasen
6d1837ce4b Make an error message more helpful
When we see somebody trying to use a command with spaces, we
should be helpful and point out how to do what they want to do.
2016-06-03 09:22:21 -04:00
Alexander Larsson
d950ed338f Merge pull request #65 from matthiasclasen/builder-messages
Add another status message to flatpak-builder
2016-06-02 09:12:08 +02:00
Alexander Larsson
4805d49bdf Merge pull request #37 from matthiasclasen/command-check
flatpak-builder: Ensure after build that the binary listed in "command" is installed
2016-06-02 08:58:30 +02:00
matthiasclasen
5e2be3cb10 builder: Some consistency fixes for output (#64)
* builder: Some consistency fixes for output

Capitalize all error messages.
2016-06-02 08:50:58 +02:00
Matthias Clasen
7794a70f50 builder: Check that command exists after build
This keeps us from creating a non-working flatpak.
2016-06-01 23:31:57 -04:00
Matthias Clasen
c7594e5515 Add another status message to flatpak-builder
Add a message for the 'rewriting the desktop file' step.
This helps in providing context for error messages when something
goes wrong.
2016-06-01 16:21:25 -04:00
Alexander Larsson
c7c9505e90 Always initialize autofree variable 2016-05-27 09:19:45 +02:00