Scoop 套件管理

Scoop 一個跨平台的軟體管理工具,用於安裝各式各樣的環境,類似於 Ubuntu 的 apt-get。

Scoop 一個跨平台的軟體管理工具,用於安裝各式各樣的環境,類似於 Ubuntu 的 apt-get。

相似的軟體有 :

Scoop 專注於在 Command-line 的使用,可以直接安裝軟體與版本管控不需要一直到網頁下載。


Installation

Requirement

  • PowerShell 3
  • 允許 PowerShell 可執行本地腳本

Powershell 中運行

$psversiontable.psversion.major # should be >= 3
set-executionpolicy remotesigned -scope currentuser

Install Scoop

確認上方無誤後,在 powershell 中打入安裝指令。

iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

如果想要安裝到指定目錄(如 : D: \Applications\Scoop)

[environment]::setEnvironmentVariable('SCOOP','D:\Applications\Scoop','User')
$env:SCOOP='D:\Applications\Scoop'
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')

Scoop Command

常用的指令如下

命令說明
scoop help查看有哪些指令可用
scoop install {app name}安裝指定 app
scoop search {app name}搜尋資料庫確認是否有此 app 或觀察目前版本
scoop update新 scoop ,後方可加上 app 名稱,表示更新 app。 如果使用 * 則是安裝的全部都更新
scoop cleanup {app name}刪掉目前沒用或較舊的 app 版本
scoop uninstall {app name}刪掉已安裝指定的 app
scoop uninstall scoop刪除 scoop

More Scoop

  • Apps
    • Scoop 使用名稱 “App” 表示一個應用程式或是需要被安裝的程式。一個 “App”應該是一個獨立的單元,也就是說一個”App”可能包含一個或是多個可執行的腳本。
  • Buckets
    • 一個 Bucket 像是一個容器,裡面有包含很多個可安裝的 “App”。準確來說是一個 github 的 repository,其中包含用來描述安裝 App 的 JSON 語法,
  • App Manifest
    • 用來描述如何去安裝一個程式的 JSON 格式的檔案。

Scoop 有一個主要的 Bucket,當你使用 scoop install {app} 會先搜尋主要的 bucket,當然還可以搜尋外部的 Bucket,更甚至你可以自己做自己的 bucket。查詢目前系統中的 Buckets:

scoop bucket known

註冊外部(別人建置的) Buckets 到本地端

// 主要格式為
scoop bucket add {name-of-bucket} {location-of-git-repo}

// 舉例如下 Buckets name {extras} {git-repo}
scoop bucket add extras https://github.com/lukesampson/scoop-extras.git

自建 Buckets

創建新的 Git-repo,將 app 加入到 Git-repo 中

git clone https://github.com/<your-username>/my-bucket
cd my-bucket
'{ 	version: "1.0", 
	url: "https://gist.github.com/lukesampson/6446238/raw/hello.ps1", 		
	bin: "hello.ps1" 
}' > hello.json
git add .
git commit -m "add hello app"
git push

設定你的 scoop 去連結你自己新建立的 bucket :

scoop bucket add my-bucket https://github.com/<your-username>/my-bucket

測試

scoop bucket list # -> 應該要看到自己的 bucket
scoop search hello # -> 應該要看到 hello 被放在 "my-bucket bucket:" 下面
scoop install hello
hello
hello # -> 應該要看到 'hello,<windows-username>!'

App Manifests

Example:

{
	"version" : "1.0",
	"url" : "https://github.com/lukesampon/cowsay-psh/archive/master.zip"
	"extract_dir" : " cowsay-psh-master",
	"bin" : "cowsay.ps1"
}

當我們使用指令“scoop install “的時候,

  1. 下載 url 中的 zip 檔案
  2. 提取出 “cowsay-psh-master“資料夾目錄
  3. 使 powershell 的腳本 .ps1 檔案可以在路徑中執行

Required Properties

  • version
    • 這個腳本準備要安裝的 APP 版本
  • url
    • 下載的網址。如果超過一個以上,則可以利用 JSON 的陣列格式。可以使用 HTTP, HTTPS, FTP

如果要改變下載後的檔案名稱,可以加入 URL 片段 (從 “#“後面開始)

這個範例表示,下載 program.exe 檔案,但是儲存成 dl.7z。這個技術常常被用來傳遞有著不好副作用的可執行安裝檔,像是註冊表改變、放置在安裝目錄之外的文件、管理員提升提示。

"http://example.org/program.exe" -> "http://example.org/program.exe#/dl.7z" // 從 #/ 後面開始

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *