From 267de7185d9288c5a974e0f6171efa7ff346d220 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Sun, 5 Sep 2021 15:41:38 +0900 Subject: [PATCH] =?UTF-8?q?bin/version=20curl,=20jq=20=E2=86=92=20ruby?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- bin/version | 19 +++++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index cbba19c..98ff4e1 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ bin/img-gen - Docker - Docker Compose - 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 の設定 diff --git a/bin/version b/bin/version index 8ba5475..b7ba2e5 100755 --- a/bin/version +++ b/bin/version @@ -1,10 +1,13 @@ -#!/bin/sh +#!/usr/bin/env ruby # 最新のバージョンを取得 # Usage: bin/version -# Required: curl grep jq ruby -set -eu -base="http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf" -curl -s "${base}/latest-releases.yaml" \ - | ruby -ryaml -rjson -e 'puts(YAML.load($<).to_json)' \ - | jq -r '.[] | select(.title == "Raspberry Pi").file' \ - | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+' +require "open-uri" +require "yaml" + +base = "http://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/armhf" +url = "#{base}/latest-releases.yaml" +io = URI.open(url) +yaml = YAML.load(io) +version = yaml.dig(0, "version") + +puts version