Commit Graph

42 Commits

Author SHA1 Message Date
Colin Walters
a42c45f726 lib/core: Synthesize tmpdir for commit if no base provided
The `ex container` path was already doing this - lower the logic
into the core so I can use it for the jigdo path.  I think it's just
clearer as well even for the sysroot pkglayering path.

Closes: #1083
Approved by: jlebon
2017-11-08 02:12:52 +00:00
Colin Walters
170f74c282 lib/core: Add API to set devino cache
Rather than passing it to the assemble functions.

Prep for jigdo work.  I'm trying to move more logic
from the system upgrader path to the core, since some of
it is needed for jigdo and "unified core".

Closes: #1083
Approved by: jlebon
2017-11-08 02:12:52 +00:00
Colin Walters
2285f0f6db Inline assemble_commit() wrapper into ex-container, the only user
This is a cleanup I was going to do before, but had dropped. It's a general
followup to the `compose` rework; there's not much point to having a high level
wrapper, given that we generally need to do some postprocessing. Inline it into
the `ex container` code, which makes the core more "core".

Closes: #1074
Approved by: jlebon
2017-10-26 15:44:58 +00:00
Colin Walters
a9c8b1fae1 ex-container: Make /etc/shadow 0400 on import, not post-checkout
Switching to the `_CONSUME` flag revealed an "oh god how did I write that"
bug in the previous patch in https://github.com/projectatomic/rpm-ostree/pull/1046
AKA commit: 334f0b89be

The way that actually fixed the bug before was because we were using
hardlink checkouts, and we were operating outside an `rofiles-fuse`
context, we simply directly changed the on-disk object mode.

But with the `_CONSUME` flag we started deleting the files as we write,
meaning that stopped working.

I *initially* wrote a patch to do the same split "prepare/processing/commit"
flow that treecompose and package layering do, but that can't really fix this
bug - we need to do it on import.

So do the chmod on import and drop the postprocessing bits.

Closes: #1067
Approved by: jlebon
2017-10-18 17:07:54 +00:00
Colin Walters
d60cc0248a ex-container: Use shared helper for download+import+rootfs+commit
Prep for fixing a bug in the last (git) commit here for `/etc/shadow`.

Closes: #1067
Approved by: jlebon
2017-10-18 17:07:54 +00:00
Jonathan Lebon
c107a05b8e tree: pass NULL to glnx_fstatat_allow_noent when needed
Now that libglnx allows it, we can skip declaring a `struct stat` we
don't actually need just to check if a file exists.

Closes: #1066
Approved by: cgwalters
2017-10-17 20:48:13 +00:00
Jonathan Lebon
4d1b5b4636 libpriv/core: use cached repodata checksum for goal
An interesting behaviour arises from the new `--cache-only` option. We
would essentially consider two goals with the same exact pkglist as
different depending on whether a package came from a yum repo or our
pkgcache repo. This meant that `rpm-ostree upgrade` followed by
`rpm-ostree upgrade -C` was never detected as a no-op and always
resulted in a relayer.

This was due to the fact that the checksum libsolv calculated was based
on our chopped off pkgcache meta-RPMs. This of course won't match the
checksum from the repodata, which is of the whole RPM.

Thankfully, we already save the repodata checksum when unpacking RPMs.
This patch simply detects the case where we're trying to checksum a pkg
originating from the pkgcache, and reads in the saved repodata checksum
rather than the wrong libsolv-derived one.

Closes: #1049
Approved by: cgwalters
2017-10-16 17:49:51 +00:00
Colin Walters
334f0b89be ex-container: Make /usr/etc/{,g}shadow user-readable
For the `ex container` case, there's no security issues here; one shouldn't be
doing user management in these roots at all.

This is for work on exporting `ex container` roots to OCI as non-root. Without
this fix, libostree just tries to `openat()` the object for export to tar, and
fails.

See also https://github.com/projectatomic/rpm-ostree/issues/1045

Closes: #1046
Approved by: jlebon
2017-10-10 20:42:55 +00:00
Colin Walters
d4af84d428 Change ex-container to use BARE_USER_ONLY, update core creation API
Switch `ex container` to `OSTREE_REPO_MODE_BARE_USER_ONLY`; this is a good
match, for the same reasons as flatpak. We don't want suid binaries, we don't
want to chown anything, no SELinux labeling, etc.  There's no reason to write the
metadata to the `BARE_USER` xattrs.

The "unprivileged" context as used for `ex container` was a flag that was passed
down, but I think it's a lot easier if things just infer this state by looking
at whether the target repo is `bare-user-only`. Now we just have an
`rpmostree_context_new_tree()` API that handles both container and compose.

Closes: #1026
Approved by: jlebon
2017-10-02 16:13:52 +00:00
Colin Walters
d16d53ecae ex-container: Add --cache-only
Like the compose path; mostly doing this right now since I'm on a plane ✈.

Closes: #1026
Approved by: jlebon
2017-10-02 16:13:52 +00:00
Jonathan Lebon
2cf87ba897 tree: some more glnx_fstatat_allow_noent porting
Closes: #1022
Approved by: cgwalters
2017-09-28 21:15:10 +00:00
Colin Walters
3840fad28e tree-wide: Fully purge the rest of "noscripts" support
It was partially removed in 325ee354e9
from PR #873 - this removes all of the rest of the layers in
the daemon and core for this.

Note that while working on this I found it astoundingly confusing that
`rpmts_add_install()` and `add_install()` had separate orderings for `gboolean
noscripts, is_install`. That's fixed by having the latter lose the `noscripts`
flag entirely, but while we're here change `rpmts_add_install()` to use flags
for clarity.

Closes: #938
Approved by: jlebon
2017-08-23 16:31:27 +00:00
Colin Walters
0428275a3c tree-wide: Port to new libglnx tmpdir API
Lots of cleanups, and this also allows us to fully port to new style in several
places.

We can drop our own `rpmostree_mkdtemp()`.

Update submodule: libglnx

Closes: #928
Approved by: jlebon
2017-08-22 17:21:37 +00:00
Colin Walters
8bb604ce67 tree-wide: Port to ostree_repo_{open,create}_at()
A lot of code gets nicer.

Closes: #922
Approved by: jlebon
2017-08-17 15:28:14 +00:00
Jonathan Lebon
35d69c1577 container-builtins: squash a -Wmaybe-uninitialized
Closes: #920
Approved by: cgwalters
2017-08-16 15:48:49 +00:00
Jonathan Lebon
c59c11f789 container-builtins: initialize fds to -1
1. We weren't initializing all fds to -1, but 0 is a valid fd number.
2. We were checking for nonzero rather than explicitly for -1.

Coverity CID: 163691
Coverity CID: 163700
Coverity CID: 163714

Closes: #918
Approved by: cgwalters
2017-08-15 20:26:14 +00:00
Colin Walters
f41183e0e5 app/ex-container: Port to new style
Was just looking at this code as part of unified core work. It was an easy port.

Closes: #913
Approved by: jlebon
2017-08-10 13:39:08 +00:00
Colin Walters
b46fc35901 Add releasever opt, avoid opening up host's rpmdb in treecompose
Closes: https://github.com/projectatomic/rpm-ostree/issues/546

Previously, we'd open up the host's rpmdb for both `compose tree`
and `ex container`.  In the first case, because we require root, we'd
succeed.  For `ex container`, we'd spew an error.

Fixing this was trickier than I thought.  First because there was
*also* a libdnf bug here: https://github.com/rpm-software-management/libdnf/pull/307

Second, there's a compatibility hazard here for anyone using `.repo` files that
reference `$releasever`. This actually happened to me with `ex container` as I'd
just done a `ln -s /etc/yum.repos.d/fedora.repo rpmmd.repos.d`.  I fixed
that first by doing a `sed -i -e 's,$releasever,26,' rpmmd.repos.d/*.repo`.

As far as I can see today, none of Fedora Atomic or CentOS AH rely on this. But
in order to enhance compatibility, let's add a "releasever" option. This makes
it easier again to reuse stock `.repo` files if we wanted to do so.

(Also, I realized we can just use `/usr/share/empty` as *the* canonical immutable
 empty directory)

Closes: #875
Approved by: jlebon
2017-07-21 15:02:59 +00:00
Jonathan Lebon
c491114720 core: auto-call download_metadata()
In all cases, we always do download_metadata() followed by prepare().
Let's just make life easier for callers by inlining this in prepare(),
much like what libdnf does. The function is still public in case some
use case calls for making them separate.

Closes: #805
Approved by: cgwalters
2017-05-30 15:17:07 +00:00
Jonathan Lebon
b804ae8ae3 core: absorb RpmOstreeInstall into RpmOstreeContext
There's not much use in having RpmOstreeInstall be separate now that
it's completely private. Let's just make it part of the main context
object rather than making callers allocate space for it and pass it to
the various context methods.

We also rename `prepare_install` to `prepare` since it will (soon) do
more than just installs (and sometimes only pure uninstalls).

Closes: #805
Approved by: cgwalters
2017-05-30 15:17:07 +00:00
Jonathan Lebon
c35622dada app: make use of new UpdateDeployment()
Add support for --install/--uninstall to upgrade/deploy/rebase by
calling out to UpdateDeployment(). Since it's not released yet, back out
the support for install-local-packages in the options variant for
PkgChange(), and make it instead use UpdateDeployment() as needed.

Closes: #711
Approved by: cgwalters
2017-03-31 14:58:38 +00:00
Jonathan Lebon
071aa93f03 app: convert many builtins to new return style
One interesting note here was that I couldn't use glnx_throw in as many
places as I wanted because EXIT_SUCCESS/EXIT_FAILURE are the exact
opposite of that semantic. It was still convenient to use though as a
short-form for g_set_error().

Closes: #704
Approved by: cgwalters
2017-03-23 21:49:50 +00:00
Colin Walters
12c34bb249 Move flags into command struct, pass down through builtins
This is prep work for https://github.com/projectatomic/rpm-ostree/issues/682

Closes: #683
Approved by: jlebon
2017-03-16 19:57:14 +00:00
Colin Walters
7095c313d8 [ASAN] tree-wide: Clean up leaks of option context
Not all of these were leaks, but let's be consistent and use
`g_autoptr()` for `GOptionContext` everywhere.

Closes: #533
Approved by: jlebon
2016-12-06 16:47:26 +00:00
Colin Walters
ae108e08a5 Add rpmostree.clientlayer metadata to derived commits
In the future we may add more commands that take as input commit
IDs.  However, we really want to distinguish between server and
client generated commits, as some of these operations won't
make sense for derived commits.

This changes the API to have callers say which type of commit
they're generating, which also fixes a FIXME, and helps get us
a bit closer to the "unified core".

Closes: #520
Approved by: jlebon
2016-11-15 17:11:11 +00:00
Colin Walters
c8e7c63ab2 Final removal of libgsystem dependency
Just like ostree.  Now we can consider it dead.

Closes: #511
Approved by: jlebon
2016-11-08 14:38:54 +00:00
Colin Walters
7ee4edf8e3 tree-wide: Remove more unused variables
Now that the other PRs are merged, kill of the rest of the unused
variables.

Closes: #504
Approved by: jlebon
2016-10-28 18:25:33 +00:00
Colin Walters
e18d43bad3 Port to new ostree_repo_checkout_at()
Squashes some deprecation warnings, and now with the latest master we
can stop setting `disable_fsync`.

Closes: #418
Approved by: giuseppe
2016-08-04 12:21:38 +00:00
Colin Walters
d153ecec9d Don't print transaction in middle of upgrade overlay output
...but still do print it for `compose tree` and `container`.  This
is more followup to #403, where I noticed we were printing
just the overlay transaction in the middle of `Overlaying...`.

Since we're now printing the package diff again at the end, let's just
rely on that rather than show the user over and over which packages
they requested.

Closes: #403

Closes: #404
Approved by: jlebon
2016-07-25 14:37:34 +00:00
Colin Walters
f35f5cf468 core: Initial implementation of %posttrans using bwrap+rofiles-fuse
In order to make many things work, we need to run scripts.  Short version:
For now, we:

 - Run `%posttrans`
 - Treat most `%post` as the same as `%posttrans`
 - Ignore `%preun` and such since we never uninstall

Most importantly though, we start to build up an "override" list
for script handling.  Currently it's just a blacklist of scripts
we don't need.

Significant work here would be needed to run Lua scripts, so far I've
been able to just skip them.

Closes: #338
Approved by: jlebon
2016-06-24 16:08:08 +00:00
Colin Walters
a86826eff4 Add --noscripts concept for pkg-add/delete
Right now, while one can `pkg-add strace`, there are a lot of
packages with `%post`.  Since some current developers want
to use package layering as it is today, let's add the concept.

Even after we have a whitelist of scripts and have cleaned up Fedora
to use them, we'll still have potential issues with 3rd party RPMs
etc. for a long time, so allow people this out to stumble forward for
those and potentially run them by hand if necessary.

Closes: #311
Approved by: jlebon
2016-06-15 01:11:01 +00:00
Jonathan Lebon
a25cdde25c core: major rework
This patch prepares RpmOstreeContext for supporting package layering. A
relabel operation is added as well to support relabeling imported
packages if the sepolicy of the rootfs we're overlaying onto is
different from during import.

Closes: #289
Approved by: cgwalters
2016-05-27 22:18:44 +00:00
Jonathan Lebon
2a036cf8b4 package-layering fixups
This patch fixes up errors in the parent commit which added pkg-add.
Some of them are due to the rebase on top of the unprivileged
infrastructure.

- fix compile errors (due to libhif changes after rebase)
- delete duplicate prototype for rpmostree_sysroot_upgrader_deploy
- include allow-older in flags type
- fix change_upgrader_refspec to use g_strdup() (this was causing the
  wrong old refspec to be registered)
- in builtin-status.c, check for NULL before joining the packages array
- sysroot-upgrader: fix gtype function names
- roc_context_prepare_for_root(): delete unused param
- assemble_commit(): delete unused param
- RpmOstreeSysrootUpgraderFlags: fix docs
- Fix sysroot property name and add reboot opt

Closes: #289
Approved by: cgwalters
2016-05-27 22:18:44 +00:00
Jonathan Lebon
224e4b31d8 RpmOstreeTreespec: allow missing ref element
There will be cases where we don't actually want to tag a ref on the
final assembled commit. This will be true for package layering.

Pull request: #240
Approved by: cgwalters
2016-03-21 19:57:06 +00:00
Jonathan Lebon
bf44928f40 RpmOstreeContext: remove unused params
Pull request: #240
Approved by: cgwalters
2016-03-21 19:57:06 +00:00
Colin Walters
397fdd8d33 Use a dummy install root for unprivileged composes
Sadly, libhif keeps trying to auto-create it.  It'll need patching
there, and possibly in librpm.
2016-02-22 14:27:46 -05:00
Colin Walters
961a036c5b Introduce "treespec" concept as GKeyFile
I debated config file formats a lot.  JSON is fairly awkward for
humans to write, and really painful to parse from C.  YAML is nice,
but also painful from C.

Both are fairly overpowered for what we really need.  Keyfiles
(desktop spec, `GKeyFile`) have a lot of limitations, but at least
it's used by systemd and `.desktop` files, and we already have a
parser.

We still parse the JSON treefiles, but internally convert them to
`GKeyFile` (which is in turn converted to `GVariant` for a canonical
form).
2016-02-22 14:27:46 -05:00
Colin Walters
20170cba4f libpriv: Make the OSTree repo implicit
It's the default for unprivileged composes if it exists.  This is an
incremental step towards always using the ostree repo.
2016-02-22 14:27:46 -05:00
Colin Walters
1eda3a022c Introduce RpmOstreeContext as an object
This helps unify some code more initially between the treecompose and
container bits.
2016-02-22 14:27:46 -05:00
Colin Walters
b3a7b4e218 Rename rpmostree-hif.[ch] -> core
This is really going to be the heart of rpm-ostree, so let's give it a
better name.
2016-02-22 14:27:46 -05:00
Colin Walters
f14d1a3536 build: Port to master libhif
This is a work-in-progress port against the libhif master + some
outstanding PRs.
2016-02-22 14:27:46 -05:00
Colin Walters
8de4f9be27 Add a container builtin
This is just a tech demo.  Example usage:

```
mkdir -p ~/.cache/rpmostree-containers
cd ~/.cache/rpmostree-containers
rpm-ostree container init
cp /etc/yum.repos.d/CentOS-Core.repo rpmmd.repos.d
rpm-ostree container assemble bash
rpm-ostree container assemble httpd
```
2016-02-22 14:27:45 -05:00