X-Git-Url: https://njoseph.me/gitweb/babashka-scripts.git/blobdiff_plain/746d64040956017457d38f0bf59649e96d0ab449:/utils.clj..ec37ad05d576d79b3dc2d05b2bcae632a93e8c35:/scripts/debian.clj diff --git a/utils.clj b/scripts/debian.clj similarity index 66% rename from utils.clj rename to scripts/debian.clj index a19a9aa..6c07149 100644 --- a/utils.clj +++ b/scripts/debian.clj @@ -1,35 +1,11 @@ -(ns utils +(ns debian (:require [clojure.string :as str] [clojure.java.io :as io] [cheshire.core :as json] [org.httpkit.client :as http] [lib :refer [download-binary run-cmd]])) -(defn git-pull-rebase-branch - "Do git pull and rebase branch with master" - [] - (let [current-branch (str/trim (run-cmd ["git" "branch" "--show-current"]))] - (print (run-cmd ["git" "pull" "--rebase"])) - (when (not (contains? #{"master" "main"} current-branch)) - (run! print - (map run-cmd - '[["git" "checkout" "master"] ["git" "pull" "--rebase"] - ["git" "checkout" "-"] ["git" "rebase" "master"]]))))) - -(defn run-seq - "Run a sequence of shell commands on a sequence of arguments. - - Examples: - - 1. Play and delete each video from a folder - ls | bb -i '(run-seq [\"mpv\" \"rm\"] *input*)' - " - [commands arguments] - (doseq [argument arguments - command commands] - (println (run-cmd [command argument])))) - -(defn install-deb +(defn install-deb-from-url "Install a Debian package given a direct URL to the .deb file." [url] (println "Downloading deb package...") @@ -69,4 +45,4 @@ assets (get-assets api-url) deb-url (find-url-to-deb assets)] ;; Download and install Debian package - (install-deb deb-url)))) + (install-deb-from-url deb-url))))