aboutsummaryrefslogtreecommitdiff
path: root/bpkg/pkg-purge.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-17 14:05:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-17 14:05:22 +0200
commit7221a63204a0b2a89e1c72fcbf9f2a7de0a575a3 (patch)
treecfd02eebc09b6700441d252513f692d1a67ed34f /bpkg/pkg-purge.cxx
parent299c4e373d2c2642a8e4c3537eb0436c5a6b9c09 (diff)
Implement pkg-{configure, disfigure} commands
Diffstat (limited to 'bpkg/pkg-purge.cxx')
-rw-r--r--bpkg/pkg-purge.cxx41
1 files changed, 24 insertions, 17 deletions
diff --git a/bpkg/pkg-purge.cxx b/bpkg/pkg-purge.cxx
index 8831b6d..319ec61 100644
--- a/bpkg/pkg-purge.cxx
+++ b/bpkg/pkg-purge.cxx
@@ -78,11 +78,9 @@ namespace bpkg
// First clean up the package source directory.
//
- if (p->source_purge)
+ if (p->purge_src)
{
- dir_path d (*p->source);
- if (d.relative ())
- d = c / d;
+ dir_path d (p->src_root->absolute () ? *p->src_root : c / *p->src_root);
if (p->state != state::broken)
{
@@ -91,8 +89,8 @@ namespace bpkg
if (exists (d)) // Don't complain if someone did our job for us.
rm_r (d);
- p->source = optional<dir_path> ();
- p->source_purge = false;
+ p->src_root = optional<dir_path> ();
+ p->purge_src = false;
}
catch (const failed&)
{
@@ -100,9 +98,8 @@ namespace bpkg
db.update (p);
t.commit ();
- if (verb)
- text << "broke " << p->name << " " << p->version;
-
+ info << "package " << n << " is now broken; "
+ << "use 'pkg-purge --force' to remove";
throw;
}
}
@@ -117,13 +114,24 @@ namespace bpkg
}
}
+ // Also check the output directory of broken packages.
+ //
+ if (p->out_root)
+ {
+ assert (p->state == state::broken); // Can only be present if broken.
+
+ dir_path d (c / *p->out_root); // Always relative.
+
+ if (exists (d))
+ fail << "broken package " << n << " output directory still exists" <<
+ info << "remove " << d << " manually then re-run pkg-purge";
+ }
+
// Now the archive. Pretty much the same code as above but for a file.
//
- if (p->archive_purge && !o.keep ())
+ if (p->purge_archive && !o.keep ())
{
- path a (*p->archive);
- if (a.relative ())
- a = c / a;
+ path a (p->archive->absolute () ? *p->archive : c / *p->archive);
if (p->state != state::broken)
{
@@ -133,7 +141,7 @@ namespace bpkg
rm (a);
p->archive = optional<path> ();
- p->archive_purge = false;
+ p->purge_archive = false;
}
catch (const failed&)
{
@@ -141,9 +149,8 @@ namespace bpkg
db.update (p);
t.commit ();
- if (verb)
- text << "broke " << p->name << " " << p->version;
-
+ info << "package " << n << " is now broken; "
+ << "use 'pkg-purge --force' to remove";
throw;
}
}