bin/version curl, jq → ruby

This commit is contained in:
Nebel 2021-09-05 15:41:38 +09:00
parent 8f4dc4b208
commit 267de7185d
2 changed files with 12 additions and 9 deletions

View file

@ -49,7 +49,7 @@ bin/img-gen
- Docker - Docker
- Docker Compose - Docker Compose
- qemu-user-static - qemu-user-static
- awk, bash, curl, fallocate, grep, gzip, gzip, jq, losetup, mkfs.fat, parted, ruby, ssh-keygen, tar, xargs - awk, bash, curl, fallocate, grep, gzip, gzip, losetup, mkfs.fat, parted, ruby, ssh-keygen, tar, xargs
### WiFi の設定 ### WiFi の設定

View file

@ -1,10 +1,13 @@
#!/bin/sh #!/usr/bin/env ruby
# 最新のバージョンを取得 # 最新のバージョンを取得
# Usage: bin/version # Usage: bin/version
# Required: curl grep jq ruby require "open-uri"
set -eu require "yaml"
base="http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf"
curl -s "${base}/latest-releases.yaml" \ base = "http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf"
| ruby -ryaml -rjson -e 'puts(YAML.load($<).to_json)' \ url = "#{base}/latest-releases.yaml"
| jq -r '.[] | select(.title == "Raspberry Pi").file' \ io = URI.open(url)
| grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' yaml = YAML.load(io)
version = yaml.dig(0, "version")
puts version