   ;; This function should build up a map of variables that are allowed to
   ;; be interpolated into an upstream ezbake config file.  For now, the only one
   ;; we've had a need for is :user.
-  {:user (get-local-ezbake-var lein-project build-target :user (:name lein-project))})
+  {:user (get-local-ezbake-var lein-project :user (:name lein-project))})
 
 (defn interpolate-ezbake-config
   [ezbake-vars s]

    (rename-debian-init-file lein-project)
    (rename-debian-default-file lein-project)
    (generate-ezbake-config-file lein-project build-target config-files)
    (generate-project-data-yaml lein-project)
    (generate-manifest-file lein-project)
    (create-git-repo lein-project)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Main

(defn -main
  [& args]
  ;; TODO: these will be configurable and allow us to build other projects besides
  ;; just jvm-puppet, and choose between foss and pe templates
  (let [build-target "foss"
        project      "jvm-puppet"
        template-dir (fs/file template-dir-prefix build-target)
        project-file (.toString (fs/file "./configs" project (str project ".clj")))]
    (try
      (stage-all-the-things build-target project template-dir project-file)
      (finally
        ;; this is required in order to make the threads started by sh/sh terminate,
        ;; and thus allow the jvm to exit
        (shutdown-agents)))))

       })))

(defn stage-all-the-things
  [project project-file]
  (let [lein-project (project/read project-file)
        build-target (get-local-ezbake-var lein-project :build-type "foss")
        template-dir (fs/file template-dir-prefix build-target)
        ]
  (clean)
  (cp-template-files template-dir)
  (cp-shared-files)
  (let [config-files (cp-shared-config-files lein-project)
        config-files (cp-project-config-files project config-files)]
    (cp-doc-files lein-project)
    (cp-project-file project-file)
