sysroot: Reject attempts to pin the staged deployment

From https://github.com/projectatomic/rpm-ostree/pull/1434#discussion_r198936674

To support it we'd have to actually write it to disk, which...let's
not try that right now.

Closes: #1660
Approved by: jlebon
This commit is contained in:
Colin Walters 2018-06-28 15:18:27 -04:00 committed by Atomic Bot
parent bab3b2bd4c
commit 7ead3c1aa8
2 changed files with 9 additions and 1 deletions

View File

@ -1894,7 +1894,8 @@ ostree_sysroot_deployment_unlock (OstreeSysroot *self,
* for e.g. older versions of libostree unaware of pinning to GC the deployment. * for e.g. older versions of libostree unaware of pinning to GC the deployment.
* *
* This function does nothing and returns successfully if the deployment * This function does nothing and returns successfully if the deployment
* is already in the desired pinning state. * is already in the desired pinning state. It is an error to try to pin
* the staged deployment (as it's not in the bootloader entries).
* *
* Since: 2018.3 * Since: 2018.3
*/ */
@ -1908,6 +1909,9 @@ ostree_sysroot_deployment_set_pinned (OstreeSysroot *self,
if (is_pinned == current_pin) if (is_pinned == current_pin)
return TRUE; return TRUE;
if (ostree_deployment_is_staged (deployment))
return glnx_throw (error, "Cannot pin staged deployment");
g_autoptr(OstreeDeployment) deployment_clone = ostree_deployment_clone (deployment); g_autoptr(OstreeDeployment) deployment_clone = ostree_deployment_clone (deployment);
GKeyFile *origin_clone = ostree_deployment_get_origin (deployment_clone); GKeyFile *origin_clone = ostree_deployment_get_origin (deployment_clone);

View File

@ -21,6 +21,10 @@
done done
test -f deployment-ref-found test -f deployment-ref-found
rm deployment-ref-found rm deployment-ref-found
if ostree admin pin 0 2>err.txt; then
echo "Pinned staged deployment"; exit 1
fi
grep -qFe 'Cannot pin staged deployment' err.txt
environment: environment:
commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}" commit: "{{ rpmostree_status['deployments'][0]['checksum'] }}"
- include_tasks: ../tasks/reboot.yml - include_tasks: ../tasks/reboot.yml