initial commit
This commit is contained in:
commit
c640c6d050
|
@ -0,0 +1,20 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright 2020 "yafox"
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,7 @@
|
|||
vercmp-lix-os-formats
|
||||
=====================
|
||||
|
||||
format scripts for use with `vercmp` under lix os. custom formats for some
|
||||
packages and symlinks to the appropriate "default" variant whenever possible.
|
||||
also contains a format script for comparing commit hashes in `src`-managed git
|
||||
repositories.
|
|
@ -0,0 +1 @@
|
|||
default-with-underscores.sh
|
|
@ -0,0 +1 @@
|
|||
default-with-underscores.sh
|
|
@ -0,0 +1 @@
|
|||
default.sh
|
|
@ -0,0 +1 @@
|
|||
./default-with-underscores.sh
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
. "$VERCMPROOT/format/default.sh"
|
||||
|
||||
comparever_default_after_dash() {
|
||||
comparever_default "$(echo "$1" | cut -d- -f2)" "$(echo "$2" | cut -d- -f2)"
|
||||
}
|
||||
comparever() { comparever_default_after_dash $@; }
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
. "$VERCMPROOT/format/default.sh"
|
||||
|
||||
comparever_dotless_patch() {
|
||||
# a semver that sometimes uses letters as an additional patch field without
|
||||
# bothering to add a dot.
|
||||
comparever_default \
|
||||
"$(echo "$1" | sed 's/\([a-z]\+[0-9a-z]*\)$/.\1/')" \
|
||||
"$(echo "$2" | sed 's/\([a-z]\+[0-9a-z]*\)$/.\1/')"
|
||||
}
|
||||
comparever() { comparever_dotless_patch $@; }
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
|
||||
. "$VERCMPROOT/format/default.sh"
|
||||
|
||||
comparever_default_with_underscores() {
|
||||
comparever_default "$(echo "$1" | tr '_' '.')" "$(echo "$2" | tr '_' '.')"
|
||||
}
|
||||
comparever() { comparever_default_with_underscores $@; }
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
|
||||
. "$VERCMPROOT/format/default.sh"
|
||||
|
||||
comparever_gdb() {
|
||||
# a semver that eschews using a dash before prerelease versions.
|
||||
comparever_default "$(echo "$1" | sed 's/\([a-z]\+[0-9a-z]*\)$/-\1/i')" \
|
||||
"$(echo "$2" | sed 's/\([a-z]\+[0-9a-z]*\)$/-\1/i')"
|
||||
}
|
||||
comparever() { comparever_gdb $@; }
|
|
@ -0,0 +1,67 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
# accepts two semantic-ish versions and echoes a character representing the
|
||||
# relationship between the two.
|
||||
# "semantic-ish" means here "a superset of semantic versioning." all correctly
|
||||
# constructed semantic versions should compare in accordance with version 2.0 of
|
||||
# the semver.org spec. versions that do not conform to the spec may also
|
||||
# compare correctly. the primary difference is that there is no limitation on
|
||||
# the number of version fields.
|
||||
comparever() { comparever_default $@; }
|
||||
|
||||
# a split definition allows other formats to use this function to define their
|
||||
# own comparever functions if they wish.
|
||||
comparever_default() {
|
||||
v1="$1"
|
||||
v2="$2"
|
||||
|
||||
# strip any trailing meta tags
|
||||
v1="${v1%+*}"
|
||||
v2="${v2%+*}"
|
||||
|
||||
# equal?
|
||||
[ "$v1" != "$v2" ] || { echo "=" && return 0; }
|
||||
|
||||
# strip leading characters that match.
|
||||
while [ "$(echo "$v1" | cut -c1)" = "$(echo "$v2" | cut -c1)" ]; do
|
||||
v1="$(echo "$v1" | cut -c2-)"
|
||||
v2="$(echo "$v2" | cut -c2-)"
|
||||
done
|
||||
v1head="$(echo "$v1" | cut -c1)"
|
||||
v2head="$(echo "$v2" | cut -c1)"
|
||||
|
||||
# if the difference is a prerelease tag, the prerelease is lesser.
|
||||
case "$v1head" in -) echo '<' && return 0;; esac
|
||||
case "$v2head" in -) echo '>' && return 0;; esac
|
||||
|
||||
# otherwise, if one is a prefix of the other, the other is greater.
|
||||
[ -n "$v1" ] || { echo '<' && return 0; }
|
||||
[ -n "$v2" ] || { echo '>' && return 0; }
|
||||
|
||||
# otherwise, if one starts with a dot, the other is the greater.
|
||||
case "$v1head" in .) echo '<' && return 0;; esac
|
||||
case "$v2head" in .) echo '>' && return 0;; esac
|
||||
|
||||
# strip any remaining version fields
|
||||
v1="$(echo "$v1" | sed s/\\..*\$//)"
|
||||
v2="$(echo "$v2" | sed s/\\..*\$//)"
|
||||
|
||||
# if the version tails are numeric, compare numerically. (ignore prerelease
|
||||
# tags.) otherwise, compare lexically.
|
||||
if (echo "${v1%-*}${v2%-*}" | grep -q "^[0-9]\+\$"); then
|
||||
[ "$(echo "${v1%-*}")" -gt "$(echo "${v2%-*}")" ] \
|
||||
&& echo ">" \
|
||||
|| echo "<"
|
||||
|
||||
else
|
||||
# v1 and v2 contain only the differences. using 'cut' and tabs here to
|
||||
# perform a lexical sort on the differences and retrieve the original
|
||||
# string associated with the greater of the two remainders.
|
||||
greater=$(printf "%s\t%s\n%s\t%s" "$v1" "$1" "$v2" "$2" \
|
||||
| sort | tail -n1 | cut -f2)
|
||||
|
||||
[ "$greater" = "$1" ] && echo ">" || echo "<"
|
||||
fi
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
./default.sh
|
|
@ -0,0 +1 @@
|
|||
default-without-dashed-prerelease.sh
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
. "$VERCMPROOT/format/default.sh"
|
||||
|
||||
comparever_mksh() {
|
||||
# mksh's versioning scheme is "R<version><optional patch letter>"
|
||||
# e.g., R56a is the first patch release following R56.
|
||||
# this means 'sort' sorts mksh's versions correctly.
|
||||
[ "$1" != "$2" ] || { echo '=' && return 0; }
|
||||
|
||||
[ "$(printf "$1\\n$2" | sort)" = "$(printf "$1\\n$2")" ] \
|
||||
&& echo '<' \
|
||||
|| echo '>'
|
||||
}
|
||||
comparever() { comparever_mksh $@; }
|
|
@ -0,0 +1 @@
|
|||
./default-with-dotless-patch.sh
|
|
@ -0,0 +1 @@
|
|||
./default-after-dash.sh
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
comparever() { comparever_src_git_type "$@"; }
|
||||
|
||||
# accepts two git commit hashes belonging to a git repository managed by the
|
||||
# `src` utility. assumes both are on the same branch.
|
||||
comparever_src_git_type() {
|
||||
v1="$1"
|
||||
v2="$2"
|
||||
$SRCROOT="$(dirname $(which src))"
|
||||
|
||||
# equal?
|
||||
[ "$v1" != "$v2" ] || { echo "==" && return 0; }
|
||||
|
||||
cd $SRCROOT/pkg/$fmt/git
|
||||
|
||||
# assume git version >= 1.8.0
|
||||
git merge-base --is-ancestor $1 $2 \
|
||||
&& echo "<" \
|
||||
|| echo ">"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
./default-with-dotless-patch.sh
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
. "$VERCMPROOT/format/default.sh"
|
||||
|
||||
comparever_valgrind() {
|
||||
comparever_default "$(echo "$1" | sed 's/\.\(RC[0-9]\+\)$/-\1/i')" \
|
||||
"$(echo "$2" | sed 's/\.\(RC[0-9]\+\)$/-\1/i')"
|
||||
}
|
||||
comparever() { comparever_valgrind $@; }
|
Loading…
Reference in New Issue