-(= *file* (System/getProperty "babashka.file")
- (let [architecture "linux-static-amd64" ;; TODO support multiple architectures
- zip-file "babashka.zip"
- destination (expand-home "~/bin/bb")
- version (babashka-latest-version)]
- (check-latest version)
- (download-latest version architecture zip-file)
- (extract-file-from-zip zip-file "bb" destination)
- (fs/set-posix-file-permissions "/home/joseph/bin/bb" "rwxr-xr-x")
- (io/delete-file zip-file)))
+(defn update-babashka
+ []
+ (let [architecture "linux-amd64" ;; TODO support other architectures
+ tarball "babashka.tar.gz"
+ destination (expand-home "~/bin")
+ version (babashka-latest-version)]
+ (println (str "Latest version is " version))
+ (check-latest version)
+ (println "Updating...")
+ (download-latest version architecture tarball)
+ (run-cmd ["tar" "-xzf" tarball "--directory" destination])
+ (fs/set-posix-file-permissions (str destination "/bb") "rwxr-xr-x")
+ (io/delete-file tarball)
+ (println "Done!")))
+
+(when (= *file* (System/getProperty "babashka.file")) (update-babashka))