2014-09-30 20:07:34 +02:00
|
|
|
#!/usr/bin/env hy
|
|
|
|
|
|
|
|
(import re)
|
|
|
|
(import pdb)
|
|
|
|
(import codecs)
|
|
|
|
|
|
|
|
(setv *maintainer-line*
|
|
|
|
" -- Alexander Artemenko <svetlyak.40wt@gmail.com> Thu, 30 Sep 2014 13:06:09 +0400")
|
|
|
|
|
2015-08-09 09:09:52 +02:00
|
|
|
(defn read-lines-from-file [filename]
|
2015-08-17 09:07:32 +02:00
|
|
|
(let [f (codecs.open filename "r" "utf-8")]
|
|
|
|
(fn [] (let [line (.readline f) ]
|
|
|
|
line))))
|
2014-09-30 20:07:34 +02:00
|
|
|
|
|
|
|
|
2015-08-09 09:09:52 +02:00
|
|
|
(defn get-version-number [line]
|
2015-08-17 09:07:32 +02:00
|
|
|
(let [match (re.search r"Changes from.*(\d+\.\d+\.\d+)$" line)]
|
|
|
|
(if match
|
|
|
|
(let [version (.group match (int 1))
|
|
|
|
numbered (list (map int (.split version ".")))
|
|
|
|
explicit-mapping {"0.9.12" "0.10.0"
|
|
|
|
"0.8.2" "0.9.0"}]
|
|
|
|
(assoc numbered 2 (+ (get numbered 2) 1))
|
|
|
|
(.get explicit-mapping
|
|
|
|
version
|
|
|
|
(.join "." (map str numbered)))))))
|
2014-09-30 20:07:34 +02:00
|
|
|
|
|
|
|
|
2015-08-09 09:09:52 +02:00
|
|
|
(defn read-version-content [reader]
|
2014-09-30 20:07:34 +02:00
|
|
|
(setv line (reader))
|
|
|
|
(setv content [])
|
|
|
|
(while (and line (not (get-version-number line)))
|
|
|
|
(.append content (.strip line))
|
|
|
|
(setv line (reader)))
|
|
|
|
[content line])
|
|
|
|
|
|
|
|
|
2015-08-09 09:09:52 +02:00
|
|
|
(defn read-versions-from-file [filename]
|
2015-08-17 09:07:32 +02:00
|
|
|
(let [reader (read-lines-from-file filename)]
|
|
|
|
(read-versions-rec (reader)
|
|
|
|
reader)))
|
2014-09-30 20:07:34 +02:00
|
|
|
|
2015-08-09 09:09:52 +02:00
|
|
|
(defn read-versions-rec [line reader]
|
2014-09-30 20:07:34 +02:00
|
|
|
(if line
|
2015-08-17 09:07:32 +02:00
|
|
|
(let [version (get-version-number line)
|
|
|
|
[content next-line] (read-version-content reader)]
|
2014-09-30 20:07:34 +02:00
|
|
|
|
|
|
|
(+ [{"from" version
|
|
|
|
"content" content}]
|
|
|
|
(read-versions-rec next-line reader)))
|
|
|
|
[]))
|
|
|
|
|
2015-08-09 09:09:52 +02:00
|
|
|
(defn format-deb-version [version]
|
2014-09-30 20:07:34 +02:00
|
|
|
(setv result [(.format "hy ({}) unstable; urgency=low"
|
|
|
|
(get version "from"))])
|
|
|
|
(for [line (get version "content")]
|
|
|
|
(.append result (+ " " line)))
|
|
|
|
(.append result *maintainer-line*)
|
|
|
|
(.append result "")
|
|
|
|
(.join "\n" result))
|
|
|
|
|
|
|
|
|
|
|
|
(defmain [&rest args]
|
2015-08-17 09:07:32 +02:00
|
|
|
(let [versions (read-versions-from-file "NEWS")]
|
2014-09-30 20:07:34 +02:00
|
|
|
(for [version versions]
|
2015-08-17 09:07:32 +02:00
|
|
|
(print (.encode (format-deb-version version) "utf-8")))))
|