app: Define a special exit code for no changes (77)

Used by upgrade and deploy to allow scripts to test for changes.
This commit is contained in:
Matthew Barnes 2015-11-02 16:54:00 -05:00
parent a555af0050
commit 1c01141e0c
4 changed files with 50 additions and 18 deletions

View File

@ -103,6 +103,12 @@ Boston, MA 02111-1307, USA.
any changes to take
effect.</para>
<para>
In addition to exit status 0 for success and 1 for error, this
command also uses exit status 77 to indicate that no upgrade is
available.
</para>
<para>
<command>--reboot</command> or <command>-r </command> to initiate a reboot after upgrade is prepared.
</para>
@ -162,6 +168,12 @@ Boston, MA 02111-1307, USA.
its SHA256 checksum, or by its "version" metadata value.
</para>
<para>
In addition to exit status 0 for success and 1 for error, this
command also uses exit status 77 to indicate that no deployment
change occurred.
</para>
<para>
<option>--reboot</option> or <option>-r</option> to initiate a
reboot after the downloaded tree is prepared.

View File

@ -145,12 +145,24 @@ rpmostree_builtin_deploy (int argc,
error))
goto out;
if (g_variant_n_children (result) == 0)
{
exit_status = RPM_OSTREE_EXIT_UNCHANGED;
goto out;
}
rpmostree_print_package_diffs (result);
}
else if (!opt_reboot && default_deployment != NULL)
else if (!opt_reboot)
{
const char *sysroot_path;
if (default_deployment == NULL)
{
exit_status = RPM_OSTREE_EXIT_UNCHANGED;
goto out;
}
sysroot_path = rpmostree_sysroot_get_path (sysroot_proxy);
if (!rpmostree_print_treepkg_diff_from_sysroot_path (sysroot_path,

View File

@ -141,19 +141,24 @@ rpmostree_builtin_upgrade (int argc,
error))
goto out;
rpmostree_print_package_diffs (result);
}
else
{
/* nothing changed */
if (default_deployment == NULL)
if (g_variant_n_children (result) == 0)
{
exit_status = RPM_OSTREE_EXIT_UNCHANGED;
goto out;
}
if (!opt_reboot)
rpmostree_print_package_diffs (result);
}
else if (!opt_reboot)
{
const char *sysroot_path;
if (default_deployment == NULL)
{
exit_status = RPM_OSTREE_EXIT_UNCHANGED;
goto out;
}
sysroot_path = rpmostree_sysroot_get_path (sysroot_proxy);
if (!rpmostree_print_treepkg_diff_from_sysroot_path (sysroot_path,
@ -163,7 +168,6 @@ rpmostree_builtin_upgrade (int argc,
g_print ("Run \"systemctl reboot\" to start a reboot\n");
}
}
exit_status = EXIT_SUCCESS;

View File

@ -25,6 +25,10 @@
G_BEGIN_DECLS
/* Exit code for no change after pulling commits.
* Use alongside EXIT_SUCCESS and EXIT_FAILURE. */
#define RPM_OSTREE_EXIT_UNCHANGED (77)
typedef enum {
RPM_OSTREE_BUILTIN_FLAG_NONE = 0,
RPM_OSTREE_BUILTIN_FLAG_LOCAL_CMD = 1 << 0