Browse files

Add "clean" command.

Warn about how you need to work in order to build multiple projects in one shared git repo.
  • Loading branch information...
1 parent c3ac8aa commit 189f9fb00e4d2e482f983609ffb71962fdf2d0bd @gregs1104 committed Jan 15, 2011
Showing with 44 additions and 3 deletions.
  1. +1 −1 COPYRIGHT
  2. +25 −1 README
  3. +18 −1 peg
@@ -1,4 +1,4 @@
-Copyright (c) 2009, Gregory Smith
+Copyright (c) 2009-2011, Gregory Smith
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@@ -119,6 +119,10 @@ build steps, you can remove the symlink and manually copy the master repo.
TODO: Provide an example of that
+If you intend to work on multiple projects using a single git repo, make
+sure you note the "Serious problems" section below for caveats about
+common issues there.
Sample tgz session
@@ -357,6 +361,26 @@ should be aware of.
Serious problems
+So far these are serious only in the sense that you are likely to run into
+them and the problems they cause are annoying. But the workarounds to avoid
+each are pretty simple.
+* If you are running against a project, then create a new one, it's quite
+ easy to get into a state where environment variables and other information
+ set by the old project continue to linger around. If you're using a git
+ repo for the code, this is particularly likely to happen because
+ switching projects only switches branches in the single shared checkout
+ of the repo. That doesn't remove the parts of the source code build
+ configuration that refer to the old project: the ``configure`` stage
+ saves where the binaries are going to be stored at for example.
+ The suggested workflow when using git is therefore::
+ peg clean
+ peg init newproject
+ [start a new terminal session to clear all environment variables]
+ peg build
+ . peg switch
* peg has a notion that you might set PGDATA directly, rather than want that
particular directory structure to be in the same PGWORK area everything
else is at. And when you source peg into your environment to use
@@ -366,7 +390,7 @@ Serious problems
one you're switching to will believe that's a manually set PGDATA it
should use. So everything else will switch to the new project,
except the database directory, which is confusing. This problem
- will eventually be addressed in the code, too work around
+ will eventually be addressed in the code. To work around
it for now, before doing "peg switch" you should erase PGDATA (and PGLOG,
which suffers from the same issue)::
19 peg
@@ -42,6 +42,7 @@ echo switch: Switch to an existing built binary set and cluster
echo start: Start a cluster
echo stop: Stop a cluster
echo "rm: Remove all data from a project (but not the repo)"
+echo "clean: Clean up the source code tree ('make maintainer-clean')"
# Set $1 to $2 only if it's empty
@@ -293,6 +294,18 @@ function rm_if_exists {
+function clean_project {
+ if [ -d "$PGSRC/$PGPROJECT" ] ; then
+ echo Cleaning out source code tree at $PGSRC/$PGPROJECT
+ make maintainer-clean
+ popd
+ echo maintainer-clean of source directory $PGSRC/$PRPROJECT finished
+ else
+ echo Not cleaning up $PGSRC/$PGPROJECT because it does not exist
+ fi
function remove_project {
# This might be more than the user wants, but if we just removed a project
# and this is a git repo, odds are decent the repo directory is filled with
@@ -303,7 +316,7 @@ function remove_project {
pushd $GITBASE
make maintainer-clean
- echo distclean of repo directory $GITBASE finished
+ echo maintainer-clean of repo directory $GITBASE finished
# The tricky part here is that we want to cleanup things like PGDATA only
@@ -603,6 +616,10 @@ elif [ "$COMMAND" = "rm" ] ; then
wrap require_project
wrap remove_project
+elif [ "$COMMAND" = "clean" ] ; then
+ wrap require_project
+ wrap clean_project
error 5 "Command not recognized: $COMMAND"

0 comments on commit 189f9fb

Please sign in to comment.