From c640c6d05039d113d08c041d6ccfd8b299ff288a Mon Sep 17 00:00:00 2001 From: yafox Date: Tue, 24 Nov 2020 21:16:54 +0000 Subject: [PATCH] initial commit --- LICENSE | 20 +++++++++ README | 7 +++ at-spi2-atk.sh | 1 + at-spi2-core.sh | 1 + autoconf.sh | 1 + busybox.sh | 1 + curl.sh | 1 + dash.sh | 1 + default-after-dash.sh | 8 ++++ default-with-dotless-patch.sh | 12 +++++ default-with-underscores.sh | 8 ++++ default-without-dashed-prerelease.sh | 10 +++++ default.sh | 67 ++++++++++++++++++++++++++++ e2fsprogs.sh | 1 + elvis.sh | 1 + expat.sh | 1 + gdb.sh | 1 + glade.sh | 1 + gzip.sh | 1 + libarchive.sh | 1 + lynx.sh | 1 + mksh.sh | 15 +++++++ mle.sh | 1 + musl-cross-make.sh | 1 + pkgconf.sh | 1 + src-git-type.sh | 23 ++++++++++ tcl.sh | 1 + texinfo.sh | 1 + valgrind.sh | 9 ++++ xz.sh | 1 + 30 files changed, 199 insertions(+) create mode 100644 LICENSE create mode 100644 README create mode 120000 at-spi2-atk.sh create mode 120000 at-spi2-core.sh create mode 120000 autoconf.sh create mode 120000 busybox.sh create mode 120000 curl.sh create mode 120000 dash.sh create mode 100755 default-after-dash.sh create mode 100755 default-with-dotless-patch.sh create mode 100755 default-with-underscores.sh create mode 100755 default-without-dashed-prerelease.sh create mode 100755 default.sh create mode 120000 e2fsprogs.sh create mode 120000 elvis.sh create mode 120000 expat.sh create mode 120000 gdb.sh create mode 120000 glade.sh create mode 120000 gzip.sh create mode 120000 libarchive.sh create mode 120000 lynx.sh create mode 100755 mksh.sh create mode 120000 mle.sh create mode 120000 musl-cross-make.sh create mode 120000 pkgconf.sh create mode 100755 src-git-type.sh create mode 120000 tcl.sh create mode 120000 texinfo.sh create mode 100755 valgrind.sh create mode 120000 xz.sh diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..bd8c239 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/README b/README new file mode 100644 index 0000000..4bd52d1 --- /dev/null +++ b/README @@ -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. diff --git a/at-spi2-atk.sh b/at-spi2-atk.sh new file mode 120000 index 0000000..3226ce6 --- /dev/null +++ b/at-spi2-atk.sh @@ -0,0 +1 @@ +default-with-underscores.sh \ No newline at end of file diff --git a/at-spi2-core.sh b/at-spi2-core.sh new file mode 120000 index 0000000..3226ce6 --- /dev/null +++ b/at-spi2-core.sh @@ -0,0 +1 @@ +default-with-underscores.sh \ No newline at end of file diff --git a/autoconf.sh b/autoconf.sh new file mode 120000 index 0000000..520e88d --- /dev/null +++ b/autoconf.sh @@ -0,0 +1 @@ +default.sh \ No newline at end of file diff --git a/busybox.sh b/busybox.sh new file mode 120000 index 0000000..1b9fa15 --- /dev/null +++ b/busybox.sh @@ -0,0 +1 @@ +./default-with-underscores.sh \ No newline at end of file diff --git a/curl.sh b/curl.sh new file mode 120000 index 0000000..1b9fa15 --- /dev/null +++ b/curl.sh @@ -0,0 +1 @@ +./default-with-underscores.sh \ No newline at end of file diff --git a/dash.sh b/dash.sh new file mode 120000 index 0000000..7b7aae7 --- /dev/null +++ b/dash.sh @@ -0,0 +1 @@ +./default.sh \ No newline at end of file diff --git a/default-after-dash.sh b/default-after-dash.sh new file mode 100755 index 0000000..2e7874b --- /dev/null +++ b/default-after-dash.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 $@; } diff --git a/default-with-dotless-patch.sh b/default-with-dotless-patch.sh new file mode 100755 index 0000000..21b7833 --- /dev/null +++ b/default-with-dotless-patch.sh @@ -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 $@; } diff --git a/default-with-underscores.sh b/default-with-underscores.sh new file mode 100755 index 0000000..866ff2c --- /dev/null +++ b/default-with-underscores.sh @@ -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 $@; } diff --git a/default-without-dashed-prerelease.sh b/default-without-dashed-prerelease.sh new file mode 100755 index 0000000..df6cdb1 --- /dev/null +++ b/default-without-dashed-prerelease.sh @@ -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 $@; } diff --git a/default.sh b/default.sh new file mode 100755 index 0000000..fab0fd4 --- /dev/null +++ b/default.sh @@ -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 +} diff --git a/e2fsprogs.sh b/e2fsprogs.sh new file mode 120000 index 0000000..7b7aae7 --- /dev/null +++ b/e2fsprogs.sh @@ -0,0 +1 @@ +./default.sh \ No newline at end of file diff --git a/elvis.sh b/elvis.sh new file mode 120000 index 0000000..1b9fa15 --- /dev/null +++ b/elvis.sh @@ -0,0 +1 @@ +./default-with-underscores.sh \ No newline at end of file diff --git a/expat.sh b/expat.sh new file mode 120000 index 0000000..1b9fa15 --- /dev/null +++ b/expat.sh @@ -0,0 +1 @@ +./default-with-underscores.sh \ No newline at end of file diff --git a/gdb.sh b/gdb.sh new file mode 120000 index 0000000..c692289 --- /dev/null +++ b/gdb.sh @@ -0,0 +1 @@ +./default-without-dashed-prerelease.sh \ No newline at end of file diff --git a/glade.sh b/glade.sh new file mode 120000 index 0000000..3226ce6 --- /dev/null +++ b/glade.sh @@ -0,0 +1 @@ +default-with-underscores.sh \ No newline at end of file diff --git a/gzip.sh b/gzip.sh new file mode 120000 index 0000000..c692289 --- /dev/null +++ b/gzip.sh @@ -0,0 +1 @@ +./default-without-dashed-prerelease.sh \ No newline at end of file diff --git a/libarchive.sh b/libarchive.sh new file mode 120000 index 0000000..1ecc81d --- /dev/null +++ b/libarchive.sh @@ -0,0 +1 @@ +default-without-dashed-prerelease.sh \ No newline at end of file diff --git a/lynx.sh b/lynx.sh new file mode 120000 index 0000000..1ecc81d --- /dev/null +++ b/lynx.sh @@ -0,0 +1 @@ +default-without-dashed-prerelease.sh \ No newline at end of file diff --git a/mksh.sh b/mksh.sh new file mode 100755 index 0000000..94077da --- /dev/null +++ b/mksh.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. "$VERCMPROOT/format/default.sh" + +comparever_mksh() { + # mksh's versioning scheme is "R" + # 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 $@; } diff --git a/mle.sh b/mle.sh new file mode 120000 index 0000000..7b7aae7 --- /dev/null +++ b/mle.sh @@ -0,0 +1 @@ +./default.sh \ No newline at end of file diff --git a/musl-cross-make.sh b/musl-cross-make.sh new file mode 120000 index 0000000..ba2ec28 --- /dev/null +++ b/musl-cross-make.sh @@ -0,0 +1 @@ +./default-with-dotless-patch.sh \ No newline at end of file diff --git a/pkgconf.sh b/pkgconf.sh new file mode 120000 index 0000000..ed5bb8e --- /dev/null +++ b/pkgconf.sh @@ -0,0 +1 @@ +./default-after-dash.sh \ No newline at end of file diff --git a/src-git-type.sh b/src-git-type.sh new file mode 100755 index 0000000..d4ca322 --- /dev/null +++ b/src-git-type.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 ">" +} diff --git a/tcl.sh b/tcl.sh new file mode 120000 index 0000000..1ecc81d --- /dev/null +++ b/tcl.sh @@ -0,0 +1 @@ +default-without-dashed-prerelease.sh \ No newline at end of file diff --git a/texinfo.sh b/texinfo.sh new file mode 120000 index 0000000..ba2ec28 --- /dev/null +++ b/texinfo.sh @@ -0,0 +1 @@ +./default-with-dotless-patch.sh \ No newline at end of file diff --git a/valgrind.sh b/valgrind.sh new file mode 100755 index 0000000..3544f3c --- /dev/null +++ b/valgrind.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 $@; } diff --git a/xz.sh b/xz.sh new file mode 120000 index 0000000..c692289 --- /dev/null +++ b/xz.sh @@ -0,0 +1 @@ +./default-without-dashed-prerelease.sh \ No newline at end of file