Permalink
Browse files

Initial work on lein-deb plugin

  • Loading branch information...
0 parents commit f23c4485c5a42bf731e96374d1b98606493c02a9 @travis committed Dec 16, 2010
Showing with 91 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +13 −0 README
  3. +6 −0 project.clj
  4. +30 −0 src/leiningen/deb.clj
  5. +38 −0 src/leiningen/tasks.clj
  6. 0 test/leiningen/test/deb.clj
@@ -0,0 +1,4 @@
+pom.xml
+*jar
+lib
+classes
13 README
@@ -0,0 +1,13 @@
+# lein-deb
+
+FIXME: write description
+
+## Usage
+
+FIXME: write
+
+## License
+
+Copyright (C) 2010 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
@@ -0,0 +1,6 @@
+(defproject lein-deb "1.0.0-SNAPSHOT"
+ :description "A leiningen plugin for building debs"
+ :dependencies [[org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]
+ [tvachon.ant-deb-task "1.0.0"]]
+ :eval-in-leiningen true)
@@ -0,0 +1,30 @@
+(ns leiningen.deb
+ (use leiningen.tasks)
+ (require [clojure.contrib.string :as s]))
+
+(defn deb
+ [project]
+ (let [[upstream debian] (s/split #"-" (:version project))
+ debian (if (= "SNAPSHOT" debian)
+ (str "~e" (System/currentTimeMillis))
+ "")
+ ]
+ (deb-task
+ (:description project)
+ (let [deb-spec (:deb project)]
+ (filter
+ (fn [[_ v]] (not (= nil v)))
+ (merge
+ deb-spec
+ {:package (:name project)
+ :homepage (:url project)
+
+ :version (version {:epoch (or (:epoch deb-spec) 0)
+ :upstream upstream
+ :debian debian})
+
+ :maintainer (maintainer (:maintainer deb-spec))
+ })))
+
+ (tarfileset {:dir "classes"
+ :prefix "/export/disk0"}))))
@@ -0,0 +1,38 @@
+(ns leiningen.tasks
+ (use lancet)
+ (require [clojure.contrib.string :as s]))
+
+(define-ant-type description com.googlecode.ant_deb_task.Deb$Description)
+(define-ant-type changelog com.googlecode.ant_deb_task.Deb$Changelog)
+(define-ant-type maintainer com.googlecode.ant_deb_task.Deb$Maintainer)
+(define-ant-type priority com.googlecode.ant_deb_task.Deb$Priority)
+(define-ant-type section com.googlecode.ant_deb_task.Deb$Section)
+(define-ant-type version com.googlecode.ant_deb_task.Deb$Version)
+(define-ant-type tarfileset org.apache.tools.ant.types.TarFileSet)
+
+(defmethod coerce [Integer/TYPE Integer] [_ i] (int i))
+(defmethod coerce [String com.googlecode.ant_deb_task.Deb$Version]
+ [_ v] (str v))
+(defmethod coerce [String com.googlecode.ant_deb_task.Deb$Maintainer]
+ [_ m] (str m))
+(defmethod coerce [com.googlecode.ant_deb_task.Deb$Section String]
+ [_ s] (section {:value s}))
+(defmethod coerce [com.googlecode.ant_deb_task.Deb$Priority String]
+ [_ s] (priority {:value s}))
+
+(defmethod coerce [com.googlecode.ant_deb_task.Deb$Description String]
+ [_ s] (doto (description {:synopsis (first (s/split-lines s))})
+ (.addText s)))
+
+(.addTaskDefinition ant-project "deb" com.googlecode.ant_deb_task.Deb)
+
+(defn deb-task
+ [description props & filesets]
+ (let [task (instantiate-task ant-project "deb" props)]
+ (doseq [fileset filesets]
+ (.add task fileset))
+ (.addDescription task (coerce com.googlecode.ant_deb_task.Deb$Description description))
+ (.execute task)
+ task) )
+
+
No changes.

0 comments on commit f23c448

Please sign in to comment.