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

Trim kerl list releases #465

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
_KERL_REL=git
;;
*)
_VERSION=$(./kerl list releases | grep "^${_VERSION}" | tail -1)
_VERSION=$(./kerl list releases all | grep "^${_VERSION}" | tail -1)
_KERL_REL=${_VERSION}
;;
esac
Expand Down
58 changes: 37 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,20 @@ List the available releases:
<!-- markdownlint-disable MD007 # line-length -->
```console
$ kerl list releases
24.0-rc1
...
24.3.4.13
25.0-rc1
...
25.3.2.3
26.0-rc1
...
26.0.2
Run '/usr/local/bin/kerl update releases' to update this list from erlang.org

17.5.6.10
18.3.4.11
19.3.6.13
20.3.8.26
21.3.8.24
22.3.4.26
23.3.4.19
24.3.4.13 *
25.3.2.6 *
26.1 *
Run './kerl update releases' to update this list
Run './kerl list releases all' to view all available releases
Note: * means "currently supported"
```
<!-- markdownlint-enable MD007 # line-length -->

Expand Down Expand Up @@ -258,20 +262,20 @@ setting `OTP_GITHUB_URL` to the URL of the fork. For example, to build `<orgname
```console
$ export KERL_BUILD_BACKEND=git
$ export OTP_GITHUB_URL='https://github.com/<orgname>/otp'
$ kerl update releases
$ KERL_INCLUDE_RELEASE_CANDIDATES=yes kerl update releases
The available releases are:
24.0-rc1
24.0-rc1.1-orgname
24.0-rc1 *
24.0-rc1.1-orgname *
...
24.3.4.13
24.3.4.13.1-orgname
25.0-rc1
24.3.4.13 *
24.3.4.13.1-orgname *
25.0-rc1 *
...
25.3.2.3
26.0-rc1
26.0-rc1.1-orgname
25.3.2.3 *
26.0-rc1 *
26.0-rc1.1-orgname *
...
26.0.2
26.0.2 *
```
<!-- markdownlint-enable MD007 # line-length -->

Expand Down Expand Up @@ -696,14 +700,26 @@ releases from erlang.org.
If it is set to `KERL_BUILD_BACKEND=git` this command fetches an up-to-date
list of Erlang/OTP tags from the official Erlang/OTP GitHub repository.

**Note**: the output of this function can be tweaked with `KERL_INCLUDE_RELEASE_CANDIDATES=yes` to
print release candidates.

### `list`

```console
$ kerl list <releases|builds|installations>
$ kerl list <releases|builds|installations> [all]
```

Lists the releases, builds or installations available.

When listing releases (without option `all`), the following applies:

- no release candidates are shown, unless you set environment variable
`KERL_INCLUDE_RELEASE_CANDIDATES` to `yes`
- no "very old" releases are shown (depends on the current `kerl` version)
- versions included in the support policy are flagged with `*`

**Note**: using `all` means all available releases are shown without filters.

### `delete`

```console
Expand Down
87 changes: 77 additions & 10 deletions kerl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ if [ -n "$KERL_DEBUG" ]; then
fi

KERL_VERSION='3.1.0'
OLDEST_OTP_LISTED='17'
OLDEST_OTP_SUPPORTED='24'

ERLANG_DOWNLOAD_URL='https://erlang.org/download'
KERL_CONFIG_STORAGE_FILENAME='.kerl_config'
Expand Down Expand Up @@ -132,6 +134,7 @@ KERL_BUILD_DIR=${KERL_BUILD_DIR:="${KERL_BASE_DIR:?}"/builds}
KERL_GIT_DIR=${KERL_GIT_DIR:="${KERL_BASE_DIR:?}"/gits}
KERL_GIT_BASE=https://raw.githubusercontent.com/kerl/kerl/master
KERL_COLORIZE=${KERL_COLORIZE:=$KERL_COLOR_AVAILABLE}
KERL_INCLUDE_RELEASE_CANDIDATES=${KERL_INCLUDE_RELEASE_CANDIDATES:=no}

if [ -n "$OTP_GITHUB_URL" ]; then
_OGU="$OTP_GITHUB_URL"
Expand Down Expand Up @@ -1922,9 +1925,57 @@ maybe_remove() {
}

list_print() {
if [ -f "$KERL_BASE_DIR/otp_$1" ]; then
if [ "$(\wc -l "$KERL_BASE_DIR/otp_$1")" != '0' ]; then
cat "$KERL_BASE_DIR/otp_$1"
list_type=$1 # releases | builds | installations
maybe_all=$2

list=$KERL_BASE_DIR/otp_${list_type}
if [ -f "$list" ]; then
if [ "$(\wc -l "$list")" != '0' ]; then
if [ "${list_type}" = releases ] && [ "$maybe_all" != all ]; then
awk -v oldest_listed="$OLDEST_OTP_LISTED" \
-v oldest_supported="$OLDEST_OTP_SUPPORTED" \
-v include_rc="$KERL_INCLUDE_RELEASE_CANDIDATES" '
function _print(vsn, is_this_supported) {
if (is_this_supported) {
suf=" *"
}
printf "%s%s\n", vsn, suf
}
{
this_version=$0
split(this_version, version_components, ".")
this_major=version_components[1]

if (last_major == "") {
last_major = oldest_supported - 1
}

is_this_r=/^R/
is_this_rc=/-rc/
is_rc_printable=(include_rc == "yes")
is_this_supported=(last_major >= oldest_supported)

if (!is_this_r) {
is_transition_to_rc=(is_last_not_rc && is_this_rc)
is_transition_from_rc=(!is_last_not_rc && !is_this_rc && is_rc_printable)
(is_transition_to_rc || is_transition_from_rc) \
&& _print(last_version, is_this_supported)

last_version=this_version
last_major=this_major
is_last_not_rc=!is_this_rc
}
}
END {
last_version=$0
is_supported=1
(!is_this_rc || is_rc_printable) \
&& _print(last_version, is_supported)
}' "$list"
else
cat "$KERL_BASE_DIR/otp_$1"
paulo-ferraz-oliveira marked this conversation as resolved.
Show resolved Hide resolved
fi

return 0
fi
fi
Expand Down Expand Up @@ -1962,7 +2013,7 @@ path_usage() {
}

list_usage() {
stderr "usage: $0 list <releases|builds|installations>"
stderr "usage: $0 list <releases|builds|installations> [all]"
}

delete_usage() {
Expand Down Expand Up @@ -2526,20 +2577,36 @@ upgrade)
fi
;;
list)
if [ $# -ne 2 ]; then
list_usage
exit 1
fi
case "$2" in
releases)
if [ $# -ne 2 ] && [ $# -ne 3 ]; then
list_usage
exit 1
fi
if [ $# -eq 3 ] && [ "$3" != 'all' ]; then
list_usage
exit 1
fi
check_releases
list_print "$2"
l=t stderr "Run '$0 update releases' to update this list from erlang.org"
list_print "$2" "$3"
l=t stderr "Run '$0 update releases' to update this list"
if [ $# -eq 2 ]; then
l=t stderr "Run '$0 list releases all' to view all available releases"
l=t stderr "Note: * means \"currently supported\""
fi
;;
builds)
if [ $# -ne 2 ]; then
list_usage
exit 1
fi
list_print "$2"
;;
installations)
if [ $# -ne 2 ]; then
list_usage
exit 1
fi
list_print "$2"
;;
*)
Expand Down