scripts: Port some to new style, minor cleanup

Prep for further work.

Closes: #858
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-07-02 08:54:08 -04:00 committed by Atomic Bot
parent 2b547c2d0a
commit 1f33f42c7a

View File

@ -235,43 +235,37 @@ run_known_rpm_script (const KnownRpmScriptKind *rpmscript,
GCancellable *cancellable,
GError **error)
{
const char *desc = rpmscript->desc;
rpmTagVal tagval = rpmscript->tag;
rpmTagVal progtagval = rpmscript->progtag;
const char *script;
g_autofree char **args = NULL;
RpmOstreeScriptAction action;
struct rpmtd_s td;
if (!(headerIsEntry (hdr, tagval) || headerIsEntry (hdr, progtagval)))
return TRUE;
script = headerGetString (hdr, tagval);
const char *script = headerGetString (hdr, tagval);
if (!script)
return TRUE;
struct rpmtd_s td;
g_autofree char **args = NULL;
if (headerGet (hdr, progtagval, &td, (HEADERGET_ALLOC|HEADERGET_ARGV)))
args = td.data;
action = lookup_script_action (pkg, ignore_scripts, desc);
const char *desc = rpmscript->desc;
RpmOstreeScriptAction action = lookup_script_action (pkg, ignore_scripts, desc);
switch (action)
{
case RPMOSTREE_SCRIPT_ACTION_DEFAULT:
{
static const char lua[] = "<lua>";
if (args && args[0] && strcmp (args[0], lua) == 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Package '%s' has (currently) unsupported %s script in '%s'",
dnf_package_get_name (pkg), lua, desc);
return FALSE;
}
const char *argv0 = args && args[0] ? args[0] : "/bin/sh";
static const char lua_builtin[] = "<lua>";
if (g_strcmp0 (argv0, lua_builtin) == 0)
return glnx_throw (error, "Package '%s' has (currently) unsupported %s script in '%s'",
dnf_package_get_name (pkg), lua_builtin, desc);
if (!run_script_in_bwrap_container (rootfs_fd, dnf_package_get_name (pkg), desc, script,
cancellable, error))
{
g_prefix_error (error, "Running %s for %s: ", desc, dnf_package_get_name (pkg));
return FALSE;
}
return glnx_prefix_error (error, "Running %s for %s", desc, dnf_package_get_name (pkg));
break;
}
case RPMOSTREE_SCRIPT_ACTION_IGNORE: