diff options
author | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2021-07-13 08:07:42 -0400 |
---|---|---|
committer | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2021-07-13 08:07:59 -0400 |
commit | 99506f6bc429482d90111050a1f759a89f6fbc36 (patch) | |
tree | eafeb42fdac35e074fe6332735ea3947752eb1b4 /sci-calculators/units | |
parent | 5baf6aba1d353151946a870ac162e751c74df76e (diff) | |
download | gentoo-overlay-99506f6bc429482d90111050a1f759a89f6fbc36.tar.xz gentoo-overlay-99506f6bc429482d90111050a1f759a89f6fbc36.zip |
sci-calculators/units: add
Diffstat (limited to 'sci-calculators/units')
-rw-r--r-- | sci-calculators/units/Manifest | 1 | ||||
-rw-r--r-- | sci-calculators/units/files/units-2.17-network-sandbox.patch | 11 | ||||
-rw-r--r-- | sci-calculators/units/files/units-2.20-readerror.patch | 11 | ||||
-rw-r--r-- | sci-calculators/units/files/units_cur-urllib.patch | 60 | ||||
-rw-r--r-- | sci-calculators/units/metadata.xml | 8 | ||||
-rw-r--r-- | sci-calculators/units/units-2.21-r1.ebuild | 55 |
6 files changed, 146 insertions, 0 deletions
diff --git a/sci-calculators/units/Manifest b/sci-calculators/units/Manifest new file mode 100644 index 0000000..62a5de3 --- /dev/null +++ b/sci-calculators/units/Manifest @@ -0,0 +1 @@ +DIST units-2.21.tar.gz 1308533 BLAKE2B 0a02979eafa21af759128ec72b11e1f532640c9d0e88ae8f389a1beb52d5a400cbd6294042aa4c7d8786c06c8ac4106a77c302805b8c5e3bb84d4134805fd517 SHA512 34bacff606f12aa5b2e59170f6b2142277aa1121d79610a51b57f07f17ae2dbdfbbb0e60be34522f367679cc152408f77c1ebb551016224d23f81c21f4b3ba62 diff --git a/sci-calculators/units/files/units-2.17-network-sandbox.patch b/sci-calculators/units/files/units-2.17-network-sandbox.patch new file mode 100644 index 0000000..e457610 --- /dev/null +++ b/sci-calculators/units/files/units-2.17-network-sandbox.patch @@ -0,0 +1,11 @@ +--- a/Makefile.in ++++ b/Makefile.in +@@ -107,7 +107,7 @@ + -e "s@/usr/bin/python@$(PYTHON)@" \ + $(srcdir)/units_cur > units_cur_inst + +-install-support: definitions.units units_cur_inst currency-units-update ++install-support: definitions.units units_cur_inst + $(MKDIR_P) $(DESTDIR)@UDAT@ $(DESTDIR)$(bindir) $(DESTDIR)@CDAT@ + $(INSTALL_DATA) $(srcdir)/definitions.units $(DESTDIR)@UDAT@definitions.units + -rm -f $(DESTDIR)@UDAT@currency.units diff --git a/sci-calculators/units/files/units-2.20-readerror.patch b/sci-calculators/units/files/units-2.20-readerror.patch new file mode 100644 index 0000000..ccb12c6 --- /dev/null +++ b/sci-calculators/units/files/units-2.20-readerror.patch @@ -0,0 +1,11 @@ +--- a/units.c ++++ b/units.c +@@ -761,7 +761,7 @@ + } + + +-#define readerror (goterr=1) && errfile && fprintf ++#define readerror(...) do { goterr=1; if (errfile) fprintf(__VA_ARGS__); } while (0) + + #define VAGUE_ERR "%s: error in units file '%s' line %d\n", \ + progname, file, linenum diff --git a/sci-calculators/units/files/units_cur-urllib.patch b/sci-calculators/units/files/units_cur-urllib.patch new file mode 100644 index 0000000..e77ff96 --- /dev/null +++ b/sci-calculators/units/files/units_cur-urllib.patch @@ -0,0 +1,60 @@ +Only in a: currency.units +diff -ru a/units_cur b/units_cur +--- a/units_cur 2018-09-15 16:30:09.000000000 -0400 ++++ b/units_cur 2021-07-11 18:01:29.030260473 -0400 +@@ -28,8 +28,12 @@ + # + # + +-version = '5.0' ++version = '5.1' + ++# Version 5.1: ++# ++# Switch to urllib to avoid requests dependency. ++# + # Version 5.0: + # + # Rewrite to support multiple different data sources due to disappearance +@@ -54,8 +58,11 @@ + # Python 2 or Python 3. Thanks to Ray Hamel for some help with this update. + + # Normal imports +-import requests + import codecs ++import json ++import urllib.error ++import urllib.parse ++import urllib.request + from argparse import ArgumentParser + from collections import OrderedDict + from datetime import date +@@ -288,11 +295,12 @@ + currency[code][rate_index])) + + def getjson(address,args=None): ++ if args: ++ address = address + "?" + urllib.parse.urlencode(args) + try: +- res = requests.get(address,args) +- res.raise_for_status() +- return(res.json()) +- except requests.exceptions.RequestException as e: ++ res = urllib.request.urlopen(address) ++ return(json.load(res)) ++ except urllib.error.URLError as e: + stderr.write('Error connecting to currency server:\n{}.\n'.format(e)) + exit(1) + +@@ -323,9 +331,8 @@ + stderr.write('European bank uses euro for base currency. Specified base {} ignored.\n'.format(base)) + import xml.etree.ElementTree as ET + try: +- res=requests.get('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml') +- res.raise_for_status() +- data = ET.fromstring(res.content)[2][0] ++ res=urllib.request.urlopen('https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml') ++ data = ET.fromstring(res.read())[2][0] + except requests.exceptions.RequestException as e: + stderr.write('Error connecting to currency server:\n{}.\n'. + format(e)) diff --git a/sci-calculators/units/metadata.xml b/sci-calculators/units/metadata.xml new file mode 100644 index 0000000..fc2b905 --- /dev/null +++ b/sci-calculators/units/metadata.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> +<!-- maintainer-needed --> +<use> +<flag name="units-cur">Install the units_cur python script that updates currencies</flag> +</use> +</pkgmetadata> diff --git a/sci-calculators/units/units-2.21-r1.ebuild b/sci-calculators/units/units-2.21-r1.ebuild new file mode 100644 index 0000000..6c005df --- /dev/null +++ b/sci-calculators/units/units-2.21-r1.ebuild @@ -0,0 +1,55 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 + +PYTHON_COMPAT=( python3_{7,8,9,10} ) +inherit python-r1 + +DESCRIPTION="Unit conversion program" +HOMEPAGE="https://www.gnu.org/software/units/units.html" +SRC_URI="mirror://gnu/${PN}/${P}.tar.gz" + +LICENSE="FDL-1.3 GPL-3" +SLOT="0" +KEYWORDS="~alpha amd64 ~arm ~hppa ppc ppc64 ~sparc x86 ~amd64-linux ~x86-linux" +IUSE="+units-cur" +REQUIRED_USE="units-cur? ( ${PYTHON_REQUIRED_USE} )" + +RDEPEND=" + sys-libs/readline:= + units-cur? ( + ${PYTHON_DEPS} + ) +" +DEPEND="${RDEPEND}" + +PATCHES=( + "${FILESDIR}"/${PN}-2.17-network-sandbox.patch + "${FILESDIR}"/${PN}-2.20-readerror.patch + "${FILESDIR}"/units_cur-urllib.patch +) + +DOCS=( ChangeLog NEWS README ) + +src_configure() { + econf \ + --sharedstatedir="${EPREFIX}"/var/lib \ + ac_cv_path_PYTHON=no +} + +src_compile() { + emake ${PN} +} + +src_install() { + default + + if use units-cur; then + sed \ + -e "/^outfile/s|'.*'|'/usr/share/units/currency.units'|g" \ + -e 's|^#!|&/usr/bin/python|g' \ + units_cur_inst > units_cur || die + python_foreach_impl python_doscript units_cur + fi +} |