aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bpkg/bpkg-options.cli7
-rw-r--r--bpkg/bpkg.cxx2
-rw-r--r--bpkg/buildfile2
-rw-r--r--bpkg/drop17
-rw-r--r--bpkg/drop-options.cli48
-rw-r--r--bpkg/drop.cxx52
6 files changed, 128 insertions, 0 deletions
diff --git a/bpkg/bpkg-options.cli b/bpkg/bpkg-options.cli
index 156bf99..176eafd 100644
--- a/bpkg/bpkg-options.cli
+++ b/bpkg/bpkg-options.cli
@@ -28,6 +28,13 @@ namespace bpkg
""
};
+ bool drop
+ {
+ "<pkg>...",
+ "Drop one or more packages.",
+ ""
+ };
+
bool pkg-verify
{
"<archive>",
diff --git a/bpkg/bpkg.cxx b/bpkg/bpkg.cxx
index 51c3b0a..61f7425 100644
--- a/bpkg/bpkg.cxx
+++ b/bpkg/bpkg.cxx
@@ -17,6 +17,7 @@
#include <bpkg/help>
#include <bpkg/build>
+#include <bpkg/drop>
#include <bpkg/pkg-verify>
#include <bpkg/pkg-status>
@@ -183,6 +184,7 @@ try
#define COMMAND(CMD) COMMAND_IMPL(, "", CMD)
COMMAND(build);
+ COMMAND(drop);
// pkg-* commands
//
diff --git a/bpkg/buildfile b/bpkg/buildfile
index 12bb391..e01dc92 100644
--- a/bpkg/buildfile
+++ b/bpkg/buildfile
@@ -16,6 +16,7 @@ exe{bpkg}: cxx{satisfaction fetch package package-odb manifest-utility \
cxx{help} cli.cxx{help-options} \
cli.cxx{configuration-options} \
cxx{build} cli.cxx{build-options} \
+ cxx{drop} cli.cxx{drop-options} \
cxx{pkg-command} \
cxx{pkg-verify} cli.cxx{pkg-verify-options} \
cxx{pkg-status} cli.cxx{pkg-status-options} \
@@ -55,6 +56,7 @@ cli.cxx{configuration-options}: cli.options += --exclude-base
#
#
cli.cxx{build-options}: cli{build-options}
+cli.cxx{drop-options}: cli{drop-options}
# pkg-*
#
diff --git a/bpkg/drop b/bpkg/drop
new file mode 100644
index 0000000..1687c82
--- /dev/null
+++ b/bpkg/drop
@@ -0,0 +1,17 @@
+// file : bpkg/drop -*- C++ -*-
+// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#ifndef BPKG_DROP
+#define BPKG_DROP
+
+#include <bpkg/types>
+#include <bpkg/drop-options>
+
+namespace bpkg
+{
+ void
+ drop (const drop_options&, cli::scanner& args);
+}
+
+#endif // BPKG_DROP
diff --git a/bpkg/drop-options.cli b/bpkg/drop-options.cli
new file mode 100644
index 0000000..301bc9a
--- /dev/null
+++ b/bpkg/drop-options.cli
@@ -0,0 +1,48 @@
+// file : bpkg/drop-options.cli
+// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+include <bpkg/configuration-options.cli>;
+
+/*
+"\section=1"
+"\name=bpkg-drop"
+
+"\h{SYNOPSIS}
+
+bpkg drop [<options>] <pkg>..."
+
+"\h{DESCRIPTION}
+
+The \cb{drop} command drops one or more packages from the configuration.
+If the packages being dropped still have dependents, then those will have
+to be drop as well and you will be prompted for a confirmation. Similarly,
+if the packages being dropped have prerequisites that are no longer needed,
+you will be offered to drop those as well.
+
+The \cb{drop} command also supports several \cb{--*-only} options that allow
+you to limit the amount of work that will be done.
+*/
+
+namespace bpkg
+{
+ class drop_options: configuration_options
+ {
+ bool --yes|-y
+ {
+ "Assume the answer to all prompts is \cb{yes}. Note that this option
+ does not apply to the dropping of dependents confirmation."
+ };
+
+ bool --disfigure-only|-d
+ {
+ "Disfigure all the packages but don't purge."
+ };
+
+ bool --print-only|-p
+ {
+ "Print to \cb{STDOUT} what would be done without actually doing
+ anything."
+ };
+ };
+}
diff --git a/bpkg/drop.cxx b/bpkg/drop.cxx
new file mode 100644
index 0000000..ac3919e
--- /dev/null
+++ b/bpkg/drop.cxx
@@ -0,0 +1,52 @@
+// file : bpkg/drop.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <bpkg/drop>
+
+#include <iostream> // cout
+
+#include <butl/utility> // reverse_iterate()
+
+#include <bpkg/types>
+#include <bpkg/package>
+#include <bpkg/package-odb>
+#include <bpkg/utility>
+#include <bpkg/database>
+#include <bpkg/diagnostics>
+#include <bpkg/satisfaction>
+#include <bpkg/manifest-utility>
+
+#include <bpkg/common-options>
+
+#include <bpkg/pkg-purge>
+#include <bpkg/pkg-disfigure>
+
+using namespace std;
+using namespace butl;
+
+namespace bpkg
+{
+ void
+ drop (const drop_options& o, cli::scanner& args)
+ {
+ tracer trace ("drop");
+
+ const dir_path& c (o.directory ());
+ level4 ([&]{trace << "configuration: " << c;});
+
+ if (!args.more ())
+ fail << "package name argument expected" <<
+ info << "run 'bpkg help drop' for more information";
+
+ database db (open (c, trace));
+
+ // Note that the session spans all our transactions. The idea here is
+ // that selected_package objects in the satisfied_packages list below
+ // will be cached in this session. When subsequent transactions modify
+ // any of these objects, they will modify the cached instance, which
+ // means our list will always "see" their updated state.
+ //
+ session s;
+ }
+}