Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools, docs: Parse version.txt using shlex and bash #279

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion content/docs/latest/installing/cloud/azure.md
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ resource_group_location = "westeurope"
You can resolve the latest Flatcar Stable version with this shell command:

```
curl -sSfL https://stable.release.flatcar-linux.net/amd64-usr/current/version.txt | grep -m 1 FLATCAR_VERSION_ID= | cut -d = -f 2
(source <(curl -sSfL https://stable.release.flatcar-linux.net/amd64-usr/current/version.txt); echo "${FLATCAR_VERSION_ID}")
```

The machine name listed in the `machines` variable is used to retrieve the corresponding [Container Linux Config](../../provisioning/config-transpiler/configuration) template from the `cl/` subfolder.
Expand Down
4 changes: 2 additions & 2 deletions content/docs/latest/installing/cloud/digitalocean.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ read SSH_KEY_ID
If not done yet, [create a custom image](https://developers.digitalocean.com/documentation/v2/#create-a-custom-image) from the current Flatcar Container Linux Stable version:

```shell
VER=$(curl https://stable.release.flatcar-linux.net/amd64-usr/current/version.txt | grep -m 1 FLATCAR_VERSION_ID= | cut -d = -f 2)
VER=$(source <(curl https://stable.release.flatcar-linux.net/amd64-usr/current/version.txt); echo "${FLATCAR_VERSION_ID}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this should serve as reference for copy paste it would be good to have error reporting with set -euo pipefail still work. The <(CMD) usage swallows the error - maybe an explicit check for a non-empty string could be added before the echo.

curl --request POST "https://api.digitalocean.com/v2/images" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $TOKEN" \
Expand Down Expand Up @@ -339,7 +339,7 @@ flatcar_stable_version = "x.y.z"
You can resolve the latest Flatcar Stable version with this shell command:

```shell
curl -sSfL https://stable.release.flatcar-linux.net/amd64-usr/current/version.txt | grep -m 1 FLATCAR_VERSION_ID= | cut -d = -f 2
(source <(curl -sSfL https://stable.release.flatcar-linux.net/amd64-usr/current/version.txt); echo "${FLATCAR_VERSION_ID}")
```

The machine name listed in the `machines` variable is used to retrieve the corresponding [Butane Config](https://www.flatcar.org/docs/latest/provisioning/config-transpiler/configuration/).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ core@host ~ $ sudo systemctl reboot
If it fails due to SSL connection issues from outdated certificates, you can also download the update payload of the latest Stable release through plain HTTP and use the `flatcar-update` script instead:

```shell
$ VER=$(curl -fsSL --insecure --ssl-no-revoke http://stable.release.flatcar-linux.net/amd64-usr/current/version.txt | grep FLATCAR_VERSION= | cut -d = -f 2)
$ VER=$(source <(curl -fsSL --insecure --ssl-no-revoke http://stable.release.flatcar-linux.net/amd64-usr/current/version.txt); echo "${FLATCAR_VERSION}")
$ wget --no-check-certificate "http://update.release.flatcar-linux.net/amd64-usr/$VER/flatcar_production_update.gz"
$ wget --no-check-certificate http://raw.githubusercontent.com/flatcar/init/flatcar-master/bin/flatcar-update
$ less flatcar-update # Double check the content of the script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ In some cases such a file can pin an exact version of a specific package, which
Some packages like `coreos-modules` take a long time to build. Use:

```shell
./build_packages --getbinpkgver=$(gsutil cat gs://…/boards/amd64-usr/current-master/version.txt |& sed -n 's/^FLATCAR_VERSION=//p')
./build_packages --getbinpkgver=$(source <(gsutil cat gs://…/boards/amd64-usr/current-master/version.txt); echo "${FLATCAR_VERSION}")
```

to use packages from the another build store.
Expand Down
2 changes: 1 addition & 1 deletion content/docs/latest/setup/releases/switching-channels.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ $ # In case another channel is set as GROUP, first remove it so that in the futu
$ sudo sed -i "/GROUP=.*/d" /etc/flatcar/update.conf
$ # Set the channel you want to jump to:
$ CHANNEL=beta
$ VER=$(curl -fsSL "https://$CHANNEL.release.flatcar-linux.net/amd64-usr/current/version.txt" | grep FLATCAR_VERSION= | cut -d = -f 2)
$ VER=$(source <(curl -fsSL "https://$CHANNEL.release.flatcar-linux.net/amd64-usr/current/version.txt"); echo "${FLATCAR_VERSION}")
$ sudo flatcar-update --to-version "$VER"
```

Expand Down
4 changes: 2 additions & 2 deletions content/docs/latest/setup/releases/update-strategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ The `flatcar-update` tool automatically removes the `SERVER=disabled` line to ap

```shell
$ # For example, update to the latest Stable release:
$ VER=$(curl -fsSL https://stable.release.flatcar-linux.net/amd64-usr/current/version.txt | grep FLATCAR_VERSION= | cut -d = -f 2)
$ VER=$(source <(curl -fsSL https://stable.release.flatcar-linux.net/amd64-usr/current/version.txt); echo "${FLATCAR_VERSION}")
$ sudo flatcar-update --to-version $VER
```

Expand Down Expand Up @@ -236,7 +236,7 @@ On the non-airgapped machine (here for amd64, use `ARCH=arm64` for arm64):

```shell
ARCH=amd64
VER=$(curl -fsSL https://stable.release.flatcar-linux.net/${ARCH}-usr/current/version.txt | grep FLATCAR_VERSION= | cut -d = -f 2)
VER=$(source <(curl -fsSL "https://stable.release.flatcar-linux.net/${ARCH}-usr/current/version.txt"; echo "${FLATCAR_VERSION}")
echo "$VER"
# or if you know which version to update to, set it like VER=3033.2.1 (no channel info needed)
wget "https://update.release.flatcar-linux.net/${ARCH}-usr/${VER}/flatcar_production_update.gz"
Expand Down
13 changes: 9 additions & 4 deletions tools/fcl-fetch-version-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

import glob
import json
import re
import sys
import shlex
import urllib.request

import yaml
Expand All @@ -27,9 +27,14 @@ def latestVersion(channel = 'stable', board = 'amd64-usr'):
url = 'https://%s.release.flatcar-linux.net/%s/current/version.txt' % (channel, board)
try:
versionTxt = fetch(url)
match = re.findall('FLATCAR_VERSION=(.*)', versionTxt)
if len(match) > 0:
return match[0]
s = shlex.shlex(versionTxt, posix = True, punctuation_chars = '=')
s.whitespace_split = True
for item in s:
if item == 'FLATCAR_VERSION':
items = list(s)
if len(items) < 2 or items[0] != '=':
raise 'malformed version.txt'
return items[1]
except:
return 'unreleased'

Expand Down
Loading