Browse Source

install dust

raylu 10 months ago
parent
commit
4c391453c3
2 changed files with 30 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 29 0
      install_extras.py

+ 1 - 0
.gitignore

@@ -1,6 +1,7 @@
 /bk
 /buildifier
 /dua
+/dust
 /eza
 /git-whence
 /lazygit

+ 29 - 0
install_extras.py

@@ -16,6 +16,7 @@ def main():
 	bat()
 	delta()
 	dua()
+	dust()
 	eza()
 	git_whence()
 	lazygit()
@@ -90,6 +91,34 @@ def dua():
 	os.unlink(tarball_path)
 	dua_path.chmod(0o755)
 
+def dust():
+	if platform.system() == 'Darwin':
+		print('$ brew install dust')
+		subprocess.run(['brew', 'install', 'dust'], check=True)
+		return
+	else:
+		assert platform.system() == 'Linux'
+
+	dust_path = CURRENT_DIR / 'dust'
+	if dust_path.exists():
+		print('dust already downloaded')
+		return
+
+	client = httpx.Client()
+	latest = gh_latest_version(client, 'bootandy', 'dust')
+	version = latest['name']
+	dirname = f'dust-{version}-{platform.machine()}-unknown-linux-musl'
+	filename = dirname + '.tar.gz'
+	(asset,) = (asset for asset in latest['assets'] if asset['name'] == filename)
+	tarball_path = CURRENT_DIR / 'dust.tar.gz'
+	download(client, asset['browser_download_url'], tarball_path)
+	with tarfile.open(tarball_path) as tar:
+		with tar.extractfile(dirname + '/dust') as binary, dust_path.open('wb') as f: # pyright: ignore[reportOptionalContextManager]
+			shutil.copyfileobj(binary, f)
+	os.unlink(tarball_path)
+	dust_path.chmod(0o755)
+
+
 def eza():
 	if platform.system() == 'Darwin':
 		print('$ brew install eza')