remove vcs source from here and update README

It's cumbersome and prevent the project to be zip_safe. Move it to where
it's used (archlinuxcn/lilac) so that it can evolve with that project.
This commit is contained in:
lilydjwg 2020-08-30 18:22:58 +08:00
parent a2a239bdc6
commit 307c0db0f8
4 changed files with 90 additions and 192 deletions

View file

@ -57,7 +57,6 @@ Contents
* `Check Android SDK <#check-android-sdk>`_ * `Check Android SDK <#check-android-sdk>`_
* `Check Sparkle framework <#check-sparkle-framework>`_ * `Check Sparkle framework <#check-sparkle-framework>`_
* `Manually updating <#manually-updating>`_ * `Manually updating <#manually-updating>`_
* `Version Control System (VCS) (git, hg, svn, bzr) <#version-control-system-vcs-git-hg-svn-bzr>`_
* `Extending <#extending>`_ * `Extending <#extending>`_
* `Bugs <#bugs>`_ * `Bugs <#bugs>`_
@ -130,6 +129,7 @@ There are several backward-incompatible changes from the previous 1.x version.
4. Several options have been renamed. ``max_concurrent`` to ``max_concurrency``, and all option names have their ``-`` be replaced with ``_``. 4. Several options have been renamed. ``max_concurrent`` to ``max_concurrency``, and all option names have their ``-`` be replaced with ``_``.
5. All software configuration tables need a ``source`` option to specify which source is to be used rather than being figured out from option names in use. This enables additional source plugins to be discovered. 5. All software configuration tables need a ``source`` option to specify which source is to be used rather than being figured out from option names in use. This enables additional source plugins to be discovered.
6. The version record files have been changed to use JSON format (the old format will be converted on writing). 6. The version record files have been changed to use JSON format (the old format will be converted on writing).
7. The ``vcs`` source is removed. (It's available inside `lilac <https://github.com/archlinuxcn/lilac>`_ at the moment.)
Version Record Files Version Record Files
==================== ====================
@ -250,6 +250,10 @@ ignored
Search in a Webpage Search in a Webpage
------------------- -------------------
::
source = "regex"
Search through a specific webpage for the version string. This type of version finding has these fields: Search through a specific webpage for the version string. This type of version finding has these fields:
url url
@ -269,6 +273,10 @@ This source supports `list options`_.
Find with a Command Find with a Command
------------------- -------------------
::
source = "cmd"
Use a shell command line to get the version. The output is striped first, so trailing newlines do not bother. Use a shell command line to get the version. The output is striped first, so trailing newlines do not bother.
cmd cmd
@ -276,6 +284,10 @@ cmd
Check AUR Check AUR
--------- ---------
::
source = "aur"
Check `Arch User Repository <https://aur.archlinux.org/>`_ for updates. Check `Arch User Repository <https://aur.archlinux.org/>`_ for updates.
Per-item proxy setting doesn't work for this because several items will be Per-item proxy setting doesn't work for this because several items will be
batched into one request. batched into one request.
@ -291,6 +303,10 @@ use_last_modified
Check GitHub Check GitHub
------------ ------------
::
source = "github"
Check `GitHub <https://github.com/>`_ for updates. The version returned is in Check `GitHub <https://github.com/>`_ for updates. The version returned is in
date format ``%Y%m%d.%H%M%S``, e.g. ``20130701.012212``, unless ``use_latest_release`` date format ``%Y%m%d.%H%M%S``, e.g. ``20130701.012212``, unless ``use_latest_release``
or ``use_max_tag`` is used. See below. or ``use_max_tag`` is used. See below.
@ -345,6 +361,10 @@ This source supports `list options`_ when ``use_max_tag`` is set.
Check Gitea Check Gitea
------------- -------------
::
source = "gitea"
Check `Gitea <https://gitea.com/>`_ for updates. The version returned is in date format ``%Y%m%d``, e.g. ``20130701``, Check `Gitea <https://gitea.com/>`_ for updates. The version returned is in date format ``%Y%m%d``, e.g. ``20130701``,
unless ``use_max_tag`` is used. See below. unless ``use_max_tag`` is used. See below.
@ -373,6 +393,10 @@ This source supports `list options`_ when ``use_max_tag`` is set.
Check BitBucket Check BitBucket
--------------- ---------------
::
source = "bitbucket"
Check `BitBucket <https://bitbucket.org/>`_ for updates. The version returned Check `BitBucket <https://bitbucket.org/>`_ for updates. The version returned
is in date format ``%Y%m%d``, e.g. ``20130701``, unless ``use_max_tag`` is used. See below. is in date format ``%Y%m%d``, e.g. ``20130701``, unless ``use_max_tag`` is used. See below.
@ -394,6 +418,10 @@ This source supports `list options`_ when ``use_max_tag`` is set.
Check GitLab Check GitLab
------------- -------------
::
source = "gitlab"
Check `GitLab <https://gitlab.com/>`_ for updates. The version returned is in date format ``%Y%m%d``, e.g. ``20130701``, Check `GitLab <https://gitlab.com/>`_ for updates. The version returned is in date format ``%Y%m%d``, e.g. ``20130701``,
unless ``use_max_tag`` is used. See below. unless ``use_max_tag`` is used. See below.
@ -422,6 +450,10 @@ This source supports `list options`_ when ``use_max_tag`` is set.
Check PyPI Check PyPI
---------- ----------
::
source = "pypi"
Check `PyPI <https://pypi.python.org/>`_ for updates. Check `PyPI <https://pypi.python.org/>`_ for updates.
pypi pypi
@ -432,6 +464,10 @@ use_pre_release
Check RubyGems Check RubyGems
-------------- --------------
::
source = "gems"
Check `RubyGems <https://rubygems.org/>`_ for updates. Check `RubyGems <https://rubygems.org/>`_ for updates.
gems gems
@ -439,6 +475,10 @@ gems
Check NPM Registry Check NPM Registry
------------------ ------------------
::
source = "npm"
Check `NPM Registry <https://registry.npmjs.org/>`_ for updates. Check `NPM Registry <https://registry.npmjs.org/>`_ for updates.
npm npm
@ -446,6 +486,10 @@ npm
Check Hackage Check Hackage
------------- -------------
::
source = "hackage"
Check `Hackage <https://hackage.haskell.org/>`_ for updates. Check `Hackage <https://hackage.haskell.org/>`_ for updates.
hackage hackage
@ -453,6 +497,10 @@ hackage
Check CPAN Check CPAN
-------------- --------------
::
source = "cpan"
Check `MetaCPAN <https://metacpan.org/>`_ for updates. Check `MetaCPAN <https://metacpan.org/>`_ for updates.
cpan cpan
@ -460,6 +508,10 @@ cpan
Check Packagist Check Packagist
--------------- ---------------
::
source = "packagist"
Check `Packagist <https://packagist.org/>`_ for updates. Check `Packagist <https://packagist.org/>`_ for updates.
packagist packagist
@ -467,6 +519,10 @@ packagist
Check Local Pacman Database Check Local Pacman Database
--------------------------- ---------------------------
::
source = "pacman"
This is used when you run ``nvchecker`` on an Arch Linux system and the program always keeps up with a package in your configured repositories for `Pacman`_. This is used when you run ``nvchecker`` on an Arch Linux system and the program always keeps up with a package in your configured repositories for `Pacman`_.
pacman pacman
@ -477,6 +533,10 @@ strip_release
Check Arch Linux official packages Check Arch Linux official packages
---------------------------------- ----------------------------------
::
source = "archpkg"
This enables you to track the update of `Arch Linux official packages <https://www.archlinux.org/packages/>`_, without needing of pacman and an updated local Pacman databases. This enables you to track the update of `Arch Linux official packages <https://www.archlinux.org/packages/>`_, without needing of pacman and an updated local Pacman databases.
archpkg archpkg
@ -490,6 +550,10 @@ provided
Check Debian Linux official packages Check Debian Linux official packages
------------------------------------ ------------------------------------
::
source = "debianpkg"
This enables you to track the update of `Debian Linux official packages <https://packages.debian.org>`_, without needing of apt and an updated local APT database. This enables you to track the update of `Debian Linux official packages <https://packages.debian.org>`_, without needing of apt and an updated local APT database.
debianpkg debianpkg
@ -503,6 +567,10 @@ strip_release
Check Ubuntu Linux official packages Check Ubuntu Linux official packages
------------------------------------ ------------------------------------
::
source = "ubuntupkg"
This enables you to track the update of `Ubuntu Linux official packages <https://packages.ubuntu.com/>`_, without needing of apt and an updated local APT database. This enables you to track the update of `Ubuntu Linux official packages <https://packages.ubuntu.com/>`_, without needing of apt and an updated local APT database.
ubuntupkg ubuntupkg
@ -516,6 +584,10 @@ strip_release
Check Repology Check Repology
-------------- --------------
::
source = "repology"
This enables you to track updates from `Repology <https://repology.org/>`_ (repology.org). This enables you to track updates from `Repology <https://repology.org/>`_ (repology.org).
repology repology
@ -526,6 +598,10 @@ repo
Check Anitya Check Anitya
------------ ------------
::
source = "anitya"
This enables you to track updates from `Anitya <https://release-monitoring.org/>`_ (release-monitoring.org). This enables you to track updates from `Anitya <https://release-monitoring.org/>`_ (release-monitoring.org).
anitya anitya
@ -533,6 +609,10 @@ anitya
Check Android SDK Check Android SDK
----------------- -----------------
::
source = "android_sdk"
This enables you to track updates of Android SDK packages listed in ``sdkmanager --list``. This enables you to track updates of Android SDK packages listed in ``sdkmanager --list``.
android_sdk android_sdk
@ -543,6 +623,10 @@ repo
Check Sparkle framework Check Sparkle framework
----------------------- -----------------------
::
source = "sparkle"
This enables you to track updates of macOS applications which using `Sparkle framework <https://sparkle-project.org/>`_. This enables you to track updates of macOS applications which using `Sparkle framework <https://sparkle-project.org/>`_.
sparkle sparkle
@ -550,24 +634,15 @@ sparkle
Manually updating Manually updating
----------------- -----------------
::
source = "manual"
This enables you to manually specify the version (maybe because you want to approve each release before it gets to the script). This enables you to manually specify the version (maybe because you want to approve each release before it gets to the script).
manual manual
The version string. The version string.
Version Control System (VCS) (git, hg, svn, bzr)
------------------------------------------------
Check a VCS repo for new commits. The version returned is currently not related to the version of the software and will increase whenever the referred VCS branch changes. This is mainly for Arch Linux.
vcs
The url of the remote VCS repo, using the same syntax with a VCS url in PKGBUILD (`Pacman`_'s build script). The first VCS url found in the source array of the PKGBUILD will be used if this is left blank. (Note: for a blank ``vcs`` setting to work correctly, the PKGBUILD has to be in a directory with the name of the software under the path where nvchecker is run. Also, all the commands, if any, needed when sourcing the PKGBUILD need to be installed).
use_max_tag
Set this to ``true`` to check for the max tag. Currently only supported for ``git``.
This option returns the biggest tag sorted by ``pkg_resources.parse_version``.
This source supports `list options`_ when ``use_max_tag`` is set.
Extending Extending
--------- ---------
It's possible to extend the supported sources by writing plugins. See It's possible to extend the supported sources by writing plugins. See

View file

@ -1,62 +0,0 @@
# MIT licensed
# Copyright (c) 2013-2020 lilydjwg <lilydjwg@gmail.com>, et al.
import asyncio
import os.path as _path
from nvchecker.api import GetVersionError
_self_path = _path.dirname(_path.abspath(__file__))
_cmd_prefix = ['/bin/bash', _path.join(_self_path, 'vcs.sh')]
PROT_VER = 1
def _parse_oldver(oldver):
if oldver is None:
return PROT_VER, 0, ''
try:
prot_ver, count, ver = oldver.split('.', maxsplit=2)
prot_ver = int(prot_ver)
count = int(count)
except Exception:
return PROT_VER, 0, ''
if prot_ver != PROT_VER:
return PROT_VER, 0, ver
return PROT_VER, count, ver
async def get_version(name, conf, *, cache, **kwargs):
vcs = conf.get('vcs', '')
use_max_tag = conf.get('use_max_tag', False)
oldver = conf.get('oldver')
cmd = _cmd_prefix + [name, vcs]
if use_max_tag:
cmd += ["get_tags"]
output = await cache.get(tuple(cmd), run_cmd)
if use_max_tag:
return [tag for tag in output.split("\n")]
else:
oldvers = _parse_oldver(oldver)
if output == oldvers[2]:
return oldver
else:
return "%d.%d.%s" % (oldvers[0], oldvers[1] + 1, output)
async def run_cmd(cmd):
p = await asyncio.create_subprocess_exec(
*cmd,
stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE,
)
output, error = await asyncio.wait_for(p.communicate(), 20)
output = output.strip().decode('latin1')
error = error.strip().decode('latin1')
if p.returncode != 0:
raise GetVersionError(
'command exited with error', output=output,
returncode=p.returncode, error=error)
else:
return output

View file

@ -1,115 +0,0 @@
#!/bin/bash
exec 3>&1
exec >&2
dir=$1
vcs=$2
get_tags=$3
parse_vcs_url() {
local _url=$1
local _out_var=$2
# remove folder::
[[ $_url =~ ^[^/:]*::(.*)$ ]] && _url=${BASH_REMATCH[1]}
[[ $_url =~ ^(bzr|git|hg|svn)([+:])(.*) ]] || return 1
local _proto=${BASH_REMATCH[1]}
[[ ${BASH_REMATCH[2]} = + ]] && _url=${BASH_REMATCH[3]}
local _real_url=${_url%\#*}
local _frag=''
[[ $_real_url = $_url ]] || _frag=${_url##*\#}
eval "${_out_var}"'=("${_proto}" "${_real_url}" "${_frag}")'
}
get_vcs() {
local _vcs=$1
local _out_var=$2
if [[ -z $_vcs ]]; then
_vcs=$(. "${dir}"/PKGBUILD &> /dev/null
for src in "${source[@]}"; do
parse_vcs_url "$src" _ && {
echo "$src"
exit 0
}
done
exit 1) || return 1
fi
parse_vcs_url "$_vcs" "$_out_var"
}
git_get_version() {
local _url=$1
local _frag=$2
local _ref=''
if [[ -z $_frag ]]; then
_ref=HEAD
elif [[ $_frag =~ ^commit=(.*)$ ]]; then
echo "${BASH_REMATCH[1]}"
return 0
elif [[ $_frag =~ ^branch=(.*)$ ]]; then
_ref=refs/heads/${BASH_REMATCH[1]}
elif [[ $_frag =~ ^tag=(.*)$ ]]; then
_ref=refs/tags/${BASH_REMATCH[1]}
else
return 1
fi
local _res=$(git ls-remote "$_url" "$_ref")
[[ $_res =~ ^([a-fA-F0-9]*)[[:blank:]] ]] || return 1
echo "${BASH_REMATCH[1]}"
}
hg_get_version() {
local _url=$1
local _frag=$2
local _ref
if [[ -z $_frag ]]; then
_ref=default
elif [[ $_frag =~ ^(revision|tag|branch)=(.*)$ ]]; then
_ref=${BASH_REMATCH[2]}
else
return 1
fi
hg identify "${_url}#${_ref}"
}
svn_get_version() {
local _url=$1
local _frag=$2
local _extra_arg=()
if [[ -z $_frag ]]; then
true
elif [[ $_frag =~ ^(revision)=(.*)$ ]]; then
_extra_arg=(-r "${BASH_REMATCH[2]}")
else
return 1
fi
# Get rid of locale
env -i PATH="${PATH}" svn info "${_extra_arg[@]}" "${_url}" | \
sed -n 's/^Revision:[[:blank:]]*\([0-9]*\)/\1/p'
}
bzr_get_version() {
local _url=$1
local _frag=$2
local _extra_arg=()
if [[ -z $_frag ]]; then
true
elif [[ $_frag =~ ^(revision)=(.*)$ ]]; then
_extra_arg=(-r "${BASH_REMATCH[2]}")
else
return 1
fi
bzr revno -q "${_extra_arg[@]}" "${_url}"
}
git_get_tags() {
local _url=$1
git ls-remote "$_url" | grep -oP '(?<=refs/tags/)[^^]*$'
}
get_vcs "${vcs}" components || exit 1
if [[ "x$get_tags" == "xget_tags" ]]; then
eval "${components[0]}_get_tags"' ${components[@]:1}' >&3
else
eval "${components[0]}_get_version"' ${components[@]:1}' >&3
fi

View file

@ -18,7 +18,7 @@ setup(
long_description = open('README.rst', encoding='utf-8').read(), long_description = open('README.rst', encoding='utf-8').read(),
long_description_content_type = 'text/x-rst', long_description_content_type = 'text/x-rst',
platforms = 'any', platforms = 'any',
zip_safe = False, zip_safe = True,
packages = find_namespace_packages(exclude=['tests', 'build*']), packages = find_namespace_packages(exclude=['tests', 'build*']),
install_requires = ['setuptools', 'toml', 'structlog', 'tornado>=6', 'pycurl'], install_requires = ['setuptools', 'toml', 'structlog', 'tornado>=6', 'pycurl'],