]> njoseph.me Git - babashka-scripts.git/commitdiff
Utility to install deb packages using gdebi
authorJoseph Nuthalapati <njoseph@riseup.net>
Fri, 12 Feb 2021 14:23:12 +0000 (19:53 +0530)
committerJoseph Nuthalapati <njoseph@riseup.net>
Fri, 12 Feb 2021 14:26:36 +0000 (19:56 +0530)
Signed-off-by: Joseph Nuthalapati <njoseph@riseup.net>
ebook-to-audio-book.clj
install-deb.clj [new file with mode: 0755]
lib.clj

index c09b8d00aaf3bad531407d4e25d5d41649a9b4ae..0d178554e600bd2af2949d036641937f31a782b5 100755 (executable)
 
 ;; TODO Use festival-tts or say depending on OS
 
-(defn run-cmd
-  [command]
-  (->> command
-       p/process
-       :out
-       slurp))
-
 (let [book-file (first *command-line-args*)
       title (first (split book-file #"\."))
       txtz-file (str title ".txtz")
@@ -34,5 +27,5 @@
   (println "Creating mp3 file...")
   (run-cmd ["ffmpeg" "-i" aiff-file mp3-file])
   (println "Cleaning up...")
-  (run! #(io/delete-file %) [txtz-file txt-file aiff-file])
+  (run! io/delete-file [txtz-file txt-file aiff-file])
   (println (str "Done! Check out " mp3-file)))
diff --git a/install-deb.clj b/install-deb.clj
new file mode 100755 (executable)
index 0000000..63b91df
--- /dev/null
@@ -0,0 +1,16 @@
+#! /usr/bin/env bb
+
+; Install a deb package from URL
+
+(require '[babashka.process :as p]
+         '[clojure.java.io :as io])
+
+(when (= *file* (System/getProperty "babashka.file"))
+  (let [url (first *command-line-args*)]
+    (println "Downloading deb package...")
+    (download-binary url "package.deb")
+    (println "Installing...")
+    (run-cmd ["sudo" "gdebi" "--non-interactive" "package.deb"])
+    (println "Cleaning up..")
+    (io/delete-file "package.deb")
+    (println "Done.")))
diff --git a/lib.clj b/lib.clj
index 5f216d1980996346936bd57f3017363af3a46c8a..70fef53590648bb52015649d4ad872c4bc326737 100644 (file)
--- a/lib.clj
+++ b/lib.clj
@@ -2,7 +2,14 @@
 
 (import '[java.nio.file Files FileSystems CopyOption StandardCopyOption])
 
-(require '[org.httpkit.client :as http])
+(require '[babashka.process :as p] '[org.httpkit.client :as http])
+
+(defn run-cmd
+  [command]
+  (->> command
+       p/process
+       :out
+       slurp))
 
 (defn extract-file-from-zip
   [zip-file-name source destination]