Skip to content

Commit

Permalink
Rename "rpm" command to "db"
Browse files Browse the repository at this point in the history
Eliminates some confusion between "rpm-ostree rpm" (or "atomic rpm")
commands versus actual "rpm" commands.

The "rpm" subcommand is retained as a hidden alias for the "db"
subcommand for backward-compatibility.  It is not listed in --help
output.

Fixes #22
  • Loading branch information
mbarnes committed Dec 2, 2014
1 parent b827a39 commit 8336e50
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 52 deletions.
4 changes: 2 additions & 2 deletions Makefile-rpm-ostree.am
Expand Up @@ -35,7 +35,7 @@ librpmostree_la_SOURCES = \
src/rpmostree-cleanup.h \
src/rpmostree-treepkgdiff.c \
src/rpmostree-treepkgdiff.h \
src/rpmostree-builtin-rpm.h \
src/rpmostree-builtin-db.h \
$(NULL)
if BUILDOPT_PATCHED_HAWKEY_AND_LIBSOLV
librpmostree_la_SOURCES += \
Expand All @@ -52,7 +52,7 @@ rpm_ostree_SOURCES = src/main.c \
src/rpmostree-builtin-rollback.c \
src/rpmostree-builtin-rebase.c \
src/rpmostree-builtin-status.c \
src/rpmostree-builtin-rpm.c \
src/rpmostree-builtin-db.c \
$(NULL)

if BUILDOPT_COMPOSE_TOOLING
Expand Down
6 changes: 5 additions & 1 deletion src/main.c
Expand Up @@ -40,7 +40,7 @@ static RpmOstreeCommand commands[] = {
{ "rebase", rpmostree_builtin_rebase },
{ "rollback", rpmostree_builtin_rollback },
{ "status", rpmostree_builtin_status },
{ "rpm", rpmostree_builtin_rpm },
{ "db", rpmostree_builtin_db },
{ NULL }
};

Expand Down Expand Up @@ -144,6 +144,10 @@ main (int argc,

argc = out;

/* Keep the "rpm" command working for backward-compatibility. */
if (g_strcmp0 (command_name, "rpm") == 0)
command_name = "db";

command = commands;
while (command->name)
{
Expand Down
94 changes: 47 additions & 47 deletions src/rpmostree-builtin-rpm.c → src/rpmostree-builtin-db.c
Expand Up @@ -28,7 +28,7 @@
#include "rpmostree-builtins.h"
#include "rpmostree-treepkgdiff.h"
#include "rpmostree-util.h"
#include "rpmostree-builtin-rpm.h"
#include "rpmostree-builtin-db.h"

/* FIXME: */
#define OSTREE_GIO_FAST_QUERYINFO ("standard::name,standard::type,standard::size,standard::is-symlink,standard::symlink-target," \
Expand All @@ -44,35 +44,35 @@
#include <rpm/rpmts.h>
#include <rpm/rpmlog.h>

gboolean rpmostree_rpm_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean rpmostree_rpm_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean rpmostree_rpm_builtin_version (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean rpmostree_db_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean rpmostree_db_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean rpmostree_db_builtin_version (int argc, char **argv, GCancellable *cancellable, GError **error);

gboolean rpmostree_rpm_option_context_parse (GOptionContext *context,
const GOptionEntry *main_entries,
int *argc, char ***argv,
OstreeRepo **out_repo,
GFile **out_rpmdbdir,
gboolean *out_rpmdbdir_is_tmp,
GCancellable *cancellable, GError **error);
gboolean rpmostree_db_option_context_parse (GOptionContext *context,
const GOptionEntry *main_entries,
int *argc, char ***argv,
OstreeRepo **out_repo,
GFile **out_rpmdbdir,
gboolean *out_rpmdbdir_is_tmp,
GCancellable *cancellable, GError **error);

typedef struct {
const char *name;
gboolean (*fn) (int argc, char **argv, GCancellable *cancellable, GError **error);
} RpmOstreeRpmCommand;

static RpmOstreeRpmCommand rpm_subcommands[] = {
{ "diff", rpmostree_rpm_builtin_diff },
{ "list", rpmostree_rpm_builtin_list },
{ "version", rpmostree_rpm_builtin_version },
{ "diff", rpmostree_db_builtin_diff },
{ "list", rpmostree_db_builtin_list },
{ "version", rpmostree_db_builtin_version },
{ NULL, NULL }
};

static char *opt_format;
static char *opt_repo;
static char *opt_rpmdbdir;

static GOptionEntry global_rpm_entries[] = {
static GOptionEntry global_db_entries[] = {
{ "repo", 'r', 0, G_OPTION_ARG_STRING, &opt_repo, "Path to OSTree repository (defaults to /sysroot/ostree/repo)", "PATH" },
{ "rpmdbdir", 0, 0, G_OPTION_ARG_STRING, &opt_rpmdbdir, "Working directory for rpm", "WORKDIR" },
{ NULL }
Expand Down Expand Up @@ -1029,7 +1029,7 @@ _prnt_commit_line(const char *rev, struct RpmRevisionData *rpmrev)
}

static gboolean
_builtin_rpm_version(OstreeRepo *repo, GFile *rpmdbdir, GPtrArray *revs,
_builtin_db_version (OstreeRepo *repo, GFile *rpmdbdir, GPtrArray *revs,
GCancellable *cancellable,
GError **error)
{
Expand Down Expand Up @@ -1058,8 +1058,8 @@ _builtin_rpm_version(OstreeRepo *repo, GFile *rpmdbdir, GPtrArray *revs,
if (!(range_revs = ost_get_commit_hashes (repo, revdup, mrev, error)))
goto out;

if (!_builtin_rpm_version (repo, rpmdbdir, range_revs,
cancellable, error))
if (!_builtin_db_version (repo, rpmdbdir, range_revs,
cancellable, error))
goto out;

continue;
Expand All @@ -1084,7 +1084,7 @@ _builtin_rpm_version(OstreeRepo *repo, GFile *rpmdbdir, GPtrArray *revs,
}

static gboolean
_builtin_rpm_list(OstreeRepo *repo, GFile *rpmdbdir,
_builtin_db_list (OstreeRepo *repo, GFile *rpmdbdir,
GPtrArray *revs, const GPtrArray *patterns,
GCancellable *cancellable,
GError **error)
Expand Down Expand Up @@ -1113,8 +1113,8 @@ _builtin_rpm_list(OstreeRepo *repo, GFile *rpmdbdir,
if (!(range_revs = ost_get_commit_hashes (repo, revdup, mrev, error)))
goto out;

if (!_builtin_rpm_list (repo, rpmdbdir, range_revs, patterns,
cancellable, error))
if (!_builtin_db_list (repo, rpmdbdir, range_revs, patterns,
cancellable, error))
goto out;

continue;
Expand All @@ -1135,13 +1135,13 @@ _builtin_rpm_list(OstreeRepo *repo, GFile *rpmdbdir,
return ret;
}

static GOptionEntry rpm_diff_entries[] = {
static GOptionEntry db_diff_entries[] = {
{ "format", 'F', 0, G_OPTION_ARG_STRING, &opt_format, "Output format: \"diff\" or (default) \"block\"", "FORMAT" },
{ NULL }
};

gboolean
rpmostree_rpm_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error)
rpmostree_db_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error)
{
GOptionContext *context;
gs_unref_object OstreeRepo *repo = NULL;
Expand All @@ -1153,8 +1153,8 @@ rpmostree_rpm_builtin_diff (int argc, char **argv, GCancellable *cancellable, GE

context = g_option_context_new ("COMMIT COMMIT - Show package changes between two commits");

if (!rpmostree_rpm_option_context_parse (context, rpm_diff_entries, &argc, &argv, &repo,
&rpmdbdir, &rpmdbdir_is_tmp, cancellable, error))
if (!rpmostree_db_option_context_parse (context, db_diff_entries, &argc, &argv, &repo,
&rpmdbdir, &rpmdbdir_is_tmp, cancellable, error))
goto out;

if (argc != 3)
Expand Down Expand Up @@ -1223,12 +1223,12 @@ rpmostree_rpm_builtin_diff (int argc, char **argv, GCancellable *cancellable, GE
return success;
}

static GOptionEntry rpm_list_entries[] = {
static GOptionEntry db_list_entries[] = {
{ NULL }
};

gboolean
rpmostree_rpm_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
rpmostree_db_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error)
{
GOptionContext *context;
gs_unref_object OstreeRepo *repo = NULL;
Expand All @@ -1239,8 +1239,8 @@ rpmostree_rpm_builtin_list (int argc, char **argv, GCancellable *cancellable, GE

context = g_option_context_new ("[PREFIX-PKGNAME...] COMMIT... - List packages within commits");

if (!rpmostree_rpm_option_context_parse (context, rpm_list_entries, &argc, &argv, &repo,
&rpmdbdir, &rpmdbdir_is_tmp, cancellable, error))
if (!rpmostree_db_option_context_parse (context, db_list_entries, &argc, &argv, &repo,
&rpmdbdir, &rpmdbdir_is_tmp, cancellable, error))
goto out;

/* Put all the arguments in a GPtrArray (because it's easier to deal with
Expand Down Expand Up @@ -1278,7 +1278,7 @@ rpmostree_rpm_builtin_list (int argc, char **argv, GCancellable *cancellable, GE
while (!g_queue_is_empty (&queue))
g_ptr_array_add (revs, g_queue_pop_head (&queue));

if (!_builtin_rpm_list (repo, rpmdbdir, revs, patterns, cancellable, error))
if (!_builtin_db_list (repo, rpmdbdir, revs, patterns, cancellable, error))
goto out;
}

Expand All @@ -1293,12 +1293,12 @@ rpmostree_rpm_builtin_list (int argc, char **argv, GCancellable *cancellable, GE
return success;
}

static GOptionEntry rpm_version_entries[] = {
static GOptionEntry db_version_entries[] = {
{ NULL }
};

gboolean
rpmostree_rpm_builtin_version (int argc, char **argv, GCancellable *cancellable, GError **error)
rpmostree_db_builtin_version (int argc, char **argv, GCancellable *cancellable, GError **error)
{
GOptionContext *context;
gs_unref_object OstreeRepo *repo = NULL;
Expand All @@ -1309,13 +1309,13 @@ rpmostree_rpm_builtin_version (int argc, char **argv, GCancellable *cancellable,

context = g_option_context_new ("COMMIT... - Show rpmdb version of packages within the commits");

if (!rpmostree_rpm_option_context_parse (context, rpm_version_entries, &argc, &argv, &repo,
&rpmdbdir, &rpmdbdir_is_tmp, cancellable, error))
if (!rpmostree_db_option_context_parse (context, db_version_entries, &argc, &argv, &repo,
&rpmdbdir, &rpmdbdir_is_tmp, cancellable, error))
goto out;

revs = cmdline2ptrarray (argc - 1, argv + 1);

if (!_builtin_rpm_version (repo, rpmdbdir, revs, cancellable, error))
if (!_builtin_db_version (repo, rpmdbdir, revs, cancellable, error))
goto out;

success = TRUE;
Expand All @@ -1338,7 +1338,7 @@ rpm_option_context_new_with_commands (void)

context = g_option_context_new ("COMMAND");

summary = g_string_new ("Builtin \"rpm\" Commands:");
summary = g_string_new ("Builtin \"db\" Commands:");

while (command->name != NULL)
{
Expand All @@ -1354,13 +1354,13 @@ rpm_option_context_new_with_commands (void)
}

gboolean
rpmostree_rpm_option_context_parse (GOptionContext *context,
const GOptionEntry *main_entries,
int *argc, char ***argv,
OstreeRepo **out_repo,
GFile **out_rpmdbdir,
gboolean *out_rpmdbdir_is_tmp,
GCancellable *cancellable, GError **error)
rpmostree_db_option_context_parse (GOptionContext *context,
const GOptionEntry *main_entries,
int *argc, char ***argv,
OstreeRepo **out_repo,
GFile **out_rpmdbdir,
gboolean *out_rpmdbdir_is_tmp,
GCancellable *cancellable, GError **error)
{
gs_unref_object OstreeRepo *repo = NULL;
gs_unref_object GFile *rpmdbdir = NULL;
Expand All @@ -1370,7 +1370,7 @@ rpmostree_rpm_option_context_parse (GOptionContext *context,
/* Entries are listed in --help output in the order added. We add the
* main entries ourselves so that we can add the --repo entry first. */

g_option_context_add_main_entries (context, global_rpm_entries, NULL);
g_option_context_add_main_entries (context, global_db_entries, NULL);

if (!rpmostree_option_context_parse (context, main_entries, argc, argv, error))
goto out;
Expand Down Expand Up @@ -1429,7 +1429,7 @@ rpmostree_rpm_option_context_parse (GOptionContext *context,
}

gboolean
rpmostree_builtin_rpm (int argc, char **argv, GCancellable *cancellable, GError **error)
rpmostree_builtin_db (int argc, char **argv, GCancellable *cancellable, GError **error)
{
RpmOstreeRpmCommand *subcommand;
const char *subcommand_name = NULL;
Expand Down Expand Up @@ -1481,12 +1481,12 @@ rpmostree_builtin_rpm (int argc, char **argv, GCancellable *cancellable, GError
if (subcommand_name == NULL)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"No \"rpm\" subcommand specified");
"No \"db\" subcommand specified");
}
else
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Unknown \"rpm\" subcommand '%s'", subcommand_name);
"Unknown \"db\" subcommand '%s'", subcommand_name);
}
}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/rpmostree-builtin-upgrade.c
Expand Up @@ -27,7 +27,7 @@
#include "rpmostree-builtins.h"
#include "rpmostree-treepkgdiff.h"
#include "rpmostree-pull-progress.h"
#include "rpmostree-builtin-rpm.h"
#include "rpmostree-builtin-db.h"

#include "libgsystem.h"

Expand Down
2 changes: 1 addition & 1 deletion src/rpmostree-builtins.h
Expand Up @@ -36,7 +36,7 @@ BUILTINPROTO(upgrade);
BUILTINPROTO(rebase);
BUILTINPROTO(rollback);
BUILTINPROTO(status);
BUILTINPROTO(rpm);
BUILTINPROTO(db);

#undef BUILTINPROTO

Expand Down
33 changes: 33 additions & 0 deletions src/rpmostree-db-builtins.h
@@ -0,0 +1,33 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
*
* Copyright (C) 2014 Anne LoVerso <anne.loverso@students.olin.edu>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2 of the licence or (at
* your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*/

#pragma once

#include <ostree.h>

#include "rpmostree-builtins.h"

G_BEGIN_DECLS

gboolean rpmostree_db_builtin_diff (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean rpmostree_db_builtin_list (int argc, char **argv, GCancellable *cancellable, GError **error);
gboolean rpmostree_db_builtin_version (int argc, char **argv, GCancellable *cancellable, GError **error);

G_END_DECLS

0 comments on commit 8336e50

Please sign in to comment.