From fbc0885061f2ce47b5a21b5d4a5d99640d6f0e21 Mon Sep 17 00:00:00 2001 From: Joseph Nuthalapati Date: Fri, 12 Feb 2021 19:53:12 +0530 Subject: [PATCH] Utility to install deb packages using gdebi Signed-off-by: Joseph Nuthalapati --- ebook-to-audio-book.clj | 9 +-------- install-deb.clj | 16 ++++++++++++++++ lib.clj | 9 ++++++++- 3 files changed, 25 insertions(+), 9 deletions(-) create mode 100755 install-deb.clj diff --git a/ebook-to-audio-book.clj b/ebook-to-audio-book.clj index c09b8d0..0d17855 100755 --- a/ebook-to-audio-book.clj +++ b/ebook-to-audio-book.clj @@ -13,13 +13,6 @@ ;; 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 index 0000000..63b91df --- /dev/null +++ b/install-deb.clj @@ -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 5f216d1..70fef53 100644 --- 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] -- 2.43.0