Browse Source

jq replaced by yq

master
pvincent 3 years ago
parent
commit
73e08222f2
  1. 4
      install.sh
  2. 2
      tools/debian_bash_upgrade
  3. 9
      tools/semver_git_tag

4
install.sh

@ -1,8 +1,6 @@
#!/bin/bash #!/bin/bash
CURDIR=$PWD CURDIR=$PWD
# shellcheck disable=SC1091
# REQUIRED_PKGS=(jq rsync file git)
REQUIRED_PKGS=(file git) REQUIRED_PKGS=(file git)
function usage() { function usage() {
@ -72,7 +70,7 @@ function install_containers() {
# install inside active LXC containers # install inside active LXC containers
if [[ -f '/snap/bin/lxc' ]]; then if [[ -f '/snap/bin/lxc' ]]; then
for container in $(/snap/bin/lxc list --format=json | /bin/jq -r '.[] | select(.state.status == "Running") | .name'); do
for container in $(/snap/bin/lxc list --format=json | yq '.[] | select(.state.status == "Running") | .name' -); do
install_one_container $container install_one_container $container
echo echo
done done

2
tools/debian_bash_upgrade

@ -14,7 +14,7 @@ else
# install inside active LXC containers # install inside active LXC containers
if [[ -f '/snap/bin/lxc' ]]; then if [[ -f '/snap/bin/lxc' ]]; then
echo "refreshing containers ..." echo "refreshing containers ..."
for container in `lxc list --format=json | jq -r '.[] | select(.state.status == "Running") | .name'`; do
for container in $(lxc list --format=json | yq '.[] | select(.state.status == "Running") | .name' -); do
container_release=$(lxc exec $container -- cat /opt/debian-bash/.semver_git_tag) container_release=$(lxc exec $container -- cat /opt/debian-bash/.semver_git_tag)
if [[ $container_release != $remote_release ]]; then if [[ $container_release != $remote_release ]]; then
echo "upgrade container <$container> from <$container_release> to <$remote_release>" echo "upgrade container <$container> from <$container_release> to <$remote_release>"

9
tools/semver_git_tag

@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
function usage() { function usage() {
echo 'usage: --major | -M | --minor | -m | --patch | -p' echo 'usage: --major | -M | --minor | -m | --patch | -p'
exit 1 exit 1
@ -34,8 +33,6 @@ function setCommand() {
############# main ############# main
# check git covered # check git covered
REPOSITORY=$(git config --get remote.origin.url) REPOSITORY=$(git config --get remote.origin.url)
if [[ "$?" -ne 0 ]]; then if [[ "$?" -ne 0 ]]; then
@ -131,13 +128,13 @@ GIT_ROOT_FOLDER=$(dirname $(git rev-parse --git-dir))
if [[ -f "${GIT_ROOT_FOLDER}/package.json" ]]; then if [[ -f "${GIT_ROOT_FOLDER}/package.json" ]]; then
echo "package.json detected, version replaced with new tag <${TAG}>" echo "package.json detected, version replaced with new tag <${TAG}>"
if ! command -v jq &>/dev/null; then
echo 'command <jq> not found, hint: `sudo apt install jq`'
if ! command -v yq &>/dev/null; then
echo 'command <yq> not found, hint: go and fetch latest release from https://github.com/mikefarah/yq'
exit 5 exit 5
fi fi
tmp=$(mktemp) tmp=$(mktemp)
jq '.version = $TAG' --arg TAG $TAG "${GIT_ROOT_FOLDER}/package.json" >"$tmp" && mv "$tmp" "${GIT_ROOT_FOLDER}/package.json"
yq ".version = $TAG" "${GIT_ROOT_FOLDER}/package.json" >"$tmp" && mv "$tmp" "${GIT_ROOT_FOLDER}/package.json"
fi fi

Loading…
Cancel
Save