dif#!/usr/bin/env python3
import ftplib
import json
import re
import urllib.parse
import urllib.request
from distutils.version import LooseVersion
def read_chrome_version(os, channel,
instance = 'https://omahaproxy.appspot.com/all'):
url = '{}?os={}&channel={}'.format(instance, os, channel)
data = urllib.request.urlopen(url).read()
return data.split(b'\n')[1].split(b',')[2].decode()
def read_vim_version(
instance = 'ftp://ftp.vim.org/mirror/vim'):
url_parse_result = urllib.parse.urlparse(instance)
host = url_parse_result.netloc
root = url_parse_result.path
with ftplib.FTP(host) as ftp:
ftp.login()
# Find the latest major release
ftp.cwd('{}/unix'.format(root))
tars = ftp.nlst()
tar_iter = filter(
lambda x: re.match(r'vim-[0-9]+.[0-9]+\.tar\.[a-z]z2?', x), tars)
ver_iter = map(
lambda x: re.sub(r'vim-(.+)\.tar\.[a-z]z2?$', r'\1', x), tar_iter)
max_ver = '0'
for ver in ver_iter:
if LooseVersion(ver) > LooseVersion(max_ver):
max_ver = ver
# Find the latest patch release
ftp.cwd('{}/patches/{}'.format(root, max_ver))
patches = ftp.nlst()
patch_pattern = '{}.[0-9]+'.format(max_ver).replace('.', r'\.')
patch_iter = filter(lambda x: re.match(patch_pattern, x), patches)
max_patch = '0'
for patch in patch_iter:
if LooseVersion(patch) > LooseVersion(max_patch):
max_patch = patch
return max_patch
def read_rpm_spec_version(url):
spec = urllib.request.urlopen(url).read()
return spec.split(b'\nVersion:')[1].split()[0].decode()
def read_anitya_version(project_id,
instance = 'https://release-monitoring.org/api'):
url = '{}/project/{}'.format(instance, project_id)
data = urllib.request.urlopen(url).read()
data = json.loads(data.decode())
return data['version']
def read_copr_version(repo, package, chroot, raw = False,
instance = 'https://copr.fedorainfracloud.org/api'):
url = '{}/coprs/{}/monitor/'.format(instance, repo)
data = urllib.request.urlopen(url).read()
data = json.loads(data.decode())
for pkg in data['packages']:
if pkg['pkg_name'] == package:
pkg_version = pkg['results'][chroot]['pkg_version']
if raw:
return pkg_version
pkg_version = re.sub('\.centos', '', pkg_version)
pkg_version = re.sub('\.el[0-9]+$', '', pkg_version)
pkg_version = re.sub('\.fc[0-9]+$', '', pkg_version)
pkg_version = re.sub('-.*$', '', pkg_version)
pkg_version = re.sub('^.*:', '', pkg_version)
return pkg_version
def write_package_status(latest, packaged, name, verbose = False):
out_of_date = LooseVersion(packaged) < LooseVersion(latest)
if out_of_date:
print('Please update {} package!'.format(name))
if out_of_date or verbose:
print('>>> latest = {}, packaged = {}'.format(latest, packaged))
return out_of_date
='add'>++ dnl Make all variables we use known to autoconf.
+ AC_SUBST(USE_INCLUDED_LIBINTL)
+ AC_SUBST(CATALOGS)
+ AC_SUBST(CATOBJEXT)
+ AC_SUBST(DATADIRNAME)
+ AC_SUBST(GMOFILES)
+ AC_SUBST(INSTOBJEXT)
+ AC_SUBST(INTLDEPS)
+ AC_SUBST(INTLLIBS)
+ AC_SUBST(INTLOBJS)
+ AC_SUBST(POFILES)
+ AC_SUBST(POSUB)
+ ])
+
+AC_DEFUN(AM_GNOME_GETTEXT,
+ [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+ AC_REQUIRE([AC_PROG_CC])dnl
+ AC_REQUIRE([AC_PROG_RANLIB])dnl
+ AC_REQUIRE([AC_ISC_POSIX])dnl
+ AC_REQUIRE([AC_HEADER_STDC])dnl
+ AC_REQUIRE([AC_C_CONST])dnl
+ AC_REQUIRE([AC_C_INLINE])dnl
+ AC_REQUIRE([AC_TYPE_OFF_T])dnl
+ AC_REQUIRE([AC_TYPE_SIZE_T])dnl
+ AC_REQUIRE([AC_FUNC_ALLOCA])dnl
+ AC_REQUIRE([AC_FUNC_MMAP])dnl
+
+ AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
+unistd.h sys/param.h])
+ AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
+strdup __argz_count __argz_stringify __argz_next])
+
+ if test "${ac_cv_func_stpcpy+set}" != "set"; then
+ AC_CHECK_FUNCS(stpcpy)
+ fi
+ if test "${ac_cv_func_stpcpy}" = "yes"; then
+ AC_DEFINE(HAVE_STPCPY)
+ fi
+
+ AM_LC_MESSAGES
+ AM_GNOME_WITH_NLS
+
+ if test "x$CATOBJEXT" != "x"; then
+ if test "x$ALL_LINGUAS" = "x"; then
+ LINGUAS=
+ else
+ AC_MSG_CHECKING(for catalogs to be installed)
+ NEW_LINGUAS=
+ for lang in ${LINGUAS=$ALL_LINGUAS}; do
+ case "$ALL_LINGUAS" in
+ *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
+ esac
+ done
+ LINGUAS=$NEW_LINGUAS
+ AC_MSG_RESULT($LINGUAS)
+ fi
+
+ dnl Construct list of names of catalog files to be constructed.
+ if test -n "$LINGUAS"; then
+ for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
+ fi
+ fi
+
+ dnl The reference to <locale.h> in the installed <libintl.h> file
+ dnl must be resolved because we cannot expect the users of this
+ dnl to define HAVE_LOCALE_H.
+ if test $ac_cv_header_locale_h = yes; then
+ INCLUDE_LOCALE_H="#include <locale.h>"
+ else
+ INCLUDE_LOCALE_H="\
+/* The system does not provide the header <locale.h>. Take care yourself. */"
+ fi
+ AC_SUBST(INCLUDE_LOCALE_H)
+
+ dnl Determine which catalog format we have (if any is needed)
+ dnl For now we know about two different formats:
+ dnl Linux libc-5 and the normal X/Open format
+ test -d intl || mkdir intl
+ if test "$CATOBJEXT" = ".cat"; then
+ AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
+
+ dnl Transform the SED scripts while copying because some dumb SEDs
+ dnl cannot handle comments.
+ sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
+ fi
+ dnl po2tbl.sed is always needed.
+ sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
+ $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
+
+ dnl In the intl/Makefile.in we have a special dependency which makes
+ dnl only sense for gettext. We comment this out for non-gettext
+ dnl packages.
+ if test "$PACKAGE" = "gettext"; then
+ GT_NO="#NO#"
+ GT_YES=
+ else
+ GT_NO=
+ GT_YES="#YES#"
+ fi
+ AC_SUBST(GT_NO)
+ AC_SUBST(GT_YES)
+
+ dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
+ dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
+ dnl Try to locate is.
+ MKINSTALLDIRS=
+ if test -n "$ac_aux_dir"; then
+ MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
+ fi
+ if test -z "$MKINSTALLDIRS"; then
+ MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
+ fi
+ AC_SUBST(MKINSTALLDIRS)
+
+ dnl *** For now the libtool support in intl/Makefile is not for real.
+ l=
+ AC_SUBST(l)
+
+ dnl Generate list of files to be processed by xgettext which will
+ dnl be included in po/Makefile.
+ test -d po || mkdir po
+ if test "x$srcdir" != "x."; then
+ if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
+ posrcprefix="$srcdir/"
+ else
+ posrcprefix="../$srcdir/"
+ fi
+ else
+ posrcprefix="../"
+ fi
+ rm -f po/POTFILES
+ sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
+ < $srcdir/po/POTFILES.in > po/POTFILES
+ ])
+