Compare commits

...

No commits in common. "c8s" and "c10s" have entirely different histories.
c8s ... c10s

12 changed files with 162 additions and 229 deletions

1
.fmf/version Normal file
View File

@ -0,0 +1 @@
1

1
.gitignore vendored
View File

@ -1 +1,2 @@
/units-*.tar.gz
/units-*.tar.gz.sig

View File

@ -1,152 +0,0 @@
From 9d1129f41f193a47d6791f44f14abe9479999266 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 8 Aug 2018 17:42:17 +0200
Subject: [PATCH] units_cur: validate rate data from server
---
units_cur | 72 ++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 55 insertions(+), 17 deletions(-)
diff --git a/units_cur b/units_cur
index 00281d8..d625570 100755
--- a/units_cur
+++ b/units_cur
@@ -28,8 +28,12 @@ from __future__ import absolute_import, division, print_function
#
#
-version = '4.2'
+version = '4.3'
+# Version 4.3: 20 July 2018
+#
+# Validate rate data from server
+#
# Version 4.2: 18 April 2018
#
# Handle case of empty/malformed entry returned from the server
@@ -55,6 +59,10 @@ from sys import exit, stderr, stdout
outfile_name = 'currency.units'
+# valid metals
+
+validmetals = ['silver','gold','platinum']
+
# This exchange rate table lists the currency ISO 4217 codes, their
# long text names, and any fixed definitions. If the definition is
# empty then units_cur will query the server for a value.
@@ -271,11 +279,19 @@ ap.add_argument('-v','--verbose',
help='display details when fetching currency data',
)
+
+def validfloat(x):
+ try:
+ float(x)
+ return True
+ except ValueError:
+ return False
+
outfile_name = ap.parse_args().output_file
verbose = ap.parse_args().verbose
try:
- res = requests.get('http://finance.yahoo.com/webservice/v1/symbols'
+ res = requests.get('https://finance.yahoo.com/webservice/v1/symbols'
'/allcurrencies/quote?format=json')
res.raise_for_status()
webdata = res.json()['list']['resources']
@@ -299,10 +315,16 @@ for data in webdata:
stderr.write('Got unknown currency with code {}\n'.format(code))
else:
if not currency[code][rate_index]:
- currency[code][rate_index] = '1|{} US$'.format(rate)
+ if validfloat(rate):
+ currency[code][rate_index] = '1|{} US$'.format(rate)
+ else:
+ stderr.write('Got invalid rate "{}" for currency "{}"\n'.format(
+ rate, code))
elif verbose:
- stderr.write('Got value "{}" for currency "{}" but '
- 'it is already defined\n'.format(rate, code))
+ if currency[code][rate_index] != '1|{} US$'.format(rate):
+ stderr.write('Got value "{}" for currency "{}" but '
+ 'it is already defined as {}\n'.format(rate, code,
+ currency[code][rate_index]))
# Delete currencies where we have no rate data
@@ -313,17 +335,15 @@ for code in currency.keys():
del currency[code]
try:
- req = requests.get('http://services.packetizer.com/spotprices/?f=json')
+ req = requests.get('https://services.packetizer.com/spotprices/?f=json')
req.raise_for_status()
metals = req.json()
except requests.exceptions.RequestException as e:
stderr.write('Error connecting to spotprices server:\n{}\n'.format(e))
exit(1)
-del metals['date']
-
try:
- req = requests.get('http://services.packetizer.com/btc/?f=json')
+ req = requests.get('https://services.packetizer.com/btc/?f=json')
req.raise_for_status()
bitcoin = req.json()
except requests.exceptions.RequestException as e:
@@ -344,13 +364,31 @@ ratestr = '\n'.join(
'{:{}}{}'.format(name, maxlen, rate) for (name, rate) in zip(cnames, crates)
)
-ozzystr = '\n'.join('{:19}{} US$/troyounce'.format(
- metal + 'price',
- price,
- ) for metal, price in metals.items())
-
-bitcoinstr = '{:{}}{} US$ # From services.packetizer.com/btc\n'.format(
+metallist = ['']*len(validmetals)
+for metal, price in metals.items():
+ if metal in validmetals:
+ metalindex = validmetals.index(metal)
+ if validfloat(price):
+ if not metallist[metalindex]:
+ metallist[validmetals.index(metal)] = '{:19}{} US$/troyounce'.format(
+ metal + 'price', price)
+ elif verbose:
+ stderr.write('Got value "{}" for metal "{}" but '
+ 'it is already defined\n'.format(price,metal))
+ else:
+ stderr.write('Got invalid rate "{}" for metal "{}"\n'.format(
+ price, metal))
+ elif metal != 'date' and verbose: # Don't print a message for the "date" entry
+ stderr.write('Got unknown metal "{}" with value "{}"\n',metal,price)
+metalstr = '\n'.join(metallist)
+
+if validfloat(bitcoin['usd']):
+ bitcoinstr = '{:{}}{} US$ # From services.packetizer.com/btc\n'.format(
'bitcoin',maxlen,bitcoin['usd'])
+else:
+ stderr.write('Got invalid bitcoin rate "{}"\n', bitcoint['usd'])
+ bitcointstr=''
+
outstr = (
"""# ISO Currency Codes
@@ -366,9 +404,9 @@ outstr = (
# Precious metals prices from Packetizer (services.packetizer.com/spotprices)
-{ozzystr}
+{metalstr}
-""".format(codestr=codestr, datestr=datestr, ratestr=ratestr, ozzystr=ozzystr,
+""".format(codestr=codestr, datestr=datestr, ratestr=ratestr, metalstr=metalstr,
bitcoinstr=bitcoinstr)
).replace('\n', linesep)
--
2.17.1

View File

@ -0,0 +1,26 @@
From f18e95585de3d6f94c3b64af7bcc8793063223d3 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 8 Aug 2018 18:08:34 +0200
Subject: [PATCH] Makefile.in: do not update currency.units from network
Builds of packages are supposed to be reproducible.
---
Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
index 79baf1d..2b71aeb 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -266,7 +266,7 @@ units.txt: units.1
doc: units.dvi units.info units.txt units.pdf UnitsMKS.pdf UnitsWin.pdf
-check: all currency-update-check
+check: all
@echo Checking units
@./units -f $(srcdir)/definitions.units \
'(((square(kiloinch)+2.84m2) /0.5) meters^2)^(1|4)' m \
--
2.37.2

View File

@ -1,47 +0,0 @@
From 06a4ba00e8e4188486fa962dbccbfa1e6afe2cf2 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Wed, 8 Aug 2018 18:08:34 +0200
Subject: [PATCH] Makefile.in: do not update currency.units from network
Builds of packages are supposed to be reproducible.
---
Makefile.in | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 70e2e10..7c1ee5b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -58,8 +58,6 @@ DEFS=-DUNITSFILE=\"@UDAT@definitions.units\" -DLOCALEMAP=\"@UDAT@locale_map.txt\
CFLAGS = @CFLAGS@
OBJECTS = units.@OBJEXT@ parse.tab.@OBJEXT@ getopt.@OBJEXT@ getopt1.@OBJEXT@ @STRFUNC@
-.PHONY: currency-units-update
-
.SUFFIXES:
.SUFFIXES: .c .@OBJEXT@ .rc .res .texinfo .pdf
@@ -107,7 +105,7 @@ units_cur_inst: units_cur
-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
@@ -204,11 +202,6 @@ texclean:
-rm -f units.log UnitsMKS.log UnitsWin.log \
*.aux *.cp *.fn *.ky *.op *.pg *.toc *.tp *.vr
-currency-units-update:
- @echo "Trying to update currency.units (will use existing file if this fails)"
- -$(srcdir)/units_cur currency.units
- if [ ! -s currency.units ]; then cp $(srcdir)/currency.units currency.units;fi
-
sig:
echo units-`sed -n -e '/\#.*VERSION/s/.*"\(.*\)"/\1/gp' \
$(srcdir)/units.c`.tar.gz > distname
--
2.17.1

2
ci.fmf Normal file
View File

@ -0,0 +1,2 @@
# Docs: https://docs.fedoraproject.org/en-US/ci/tmt/#_multiple_plans
resultsdb-testcase: separate

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-*
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build./plans/tier1-internal.functional}

10
plans.fmf Normal file
View File

@ -0,0 +1,10 @@
/tier1-internal:
discover:
how: fmf
url: https://pkgs.devel.redhat.com/git/tests/units
filter: 'tier: 1'
execute:
how: tmt
adjust:
enabled: false
when: distro == centos-stream or distro == fedora

View File

@ -1 +1,2 @@
SHA512 (units-2.17.tar.gz) = e4114f7dc0e40146f969375511c5d930497cb9502306ef82feac78c8e09a03e84ed0b582ff82e2878beae41702c9612f7a3d28fc6e9ed2cfae708f9feb8b737b
SHA512 (units-2.22.tar.gz) = 4ed62ce6ee861b817916bc925713794187fa63eb5320e8e720558ac1d5bd48d5f1c9500e1d1f90414a6f4410f1ab806928c2a655adf4cd8b51829cd73397ab2f
SHA512 (units-2.22.tar.gz.sig) = 50a94263631d05642e56f42805711d56a54c93c73a143cdf7c18087722b5f1fff46bb8ab56abe3ca984738d8301be75ecfd2f1f9ea1917976353357a0aaad742

Binary file not shown.

26
units-configure-c99.patch Normal file
View File

@ -0,0 +1,26 @@
diff --git a/configure b/configure
index 22c75a6222b06f68..43461d54e59f1568 100755
--- a/configure
+++ b/configure
@@ -3881,7 +3881,7 @@ else
int
main ()
{
-wchar_t *out;char *in;char *res;
+wchar_t *out;char *in;const char *res;
res=setlocale(LC_CTYPE,"");res=in;
mbsrtowcs(out, &res, 2, NULL);
wcswidth(out,2);
diff --git a/configure.ac b/configure.ac
index c728d5c15d16ab2e..cd39f96e39f7d587 100644
--- a/configure.ac
+++ b/configure.ac
@@ -121,7 +121,7 @@ AC_CACHE_CHECK([for locale and UTF-8 support], am_cv_utf8,
#include <wchar.h>
#include <locale.h>
#include <langinfo.h>
-], [wchar_t *out;char *in;char *res;
+], [wchar_t *out;char *in;const char *res;
res=setlocale(LC_CTYPE,"");res=in;
mbsrtowcs(out, &res, 2, NULL);
wcswidth(out,2);],

View File

@ -1,24 +1,20 @@
Summary: A utility for converting amounts from one unit to another
Name: units
Version: 2.17
Release: 5%{?dist}
Version: 2.22
Release: 10%{?dist}
Source: https://ftp.gnu.org/gnu/units/%{name}-%{version}.tar.gz
URL: https://www.gnu.org/software/units/units.html
License: GPLv3+
Requires(post): /sbin/install-info
Requires(preun): /sbin/install-info
BuildRequires: automake
License: GPL-3.0-or-later
BuildRequires: bison
BuildRequires: gcc
BuildRequires: make
BuildRequires: ncurses-devel
BuildRequires: python3-devel
BuildRequires: readline-devel
# units_cur: validate rate data from server (#1598913)
Patch1: 0001-units-2.17-units_cur-validate.patch
# do not update currency.units from network during build
Patch2: 0002-units-2.17-no-network.patch
Patch1: 0001-units-2.22-no-network.patch
Patch2: units-configure-c99.patch
%description
Units converts an amount from one unit to another, or tells you what
@ -29,19 +25,17 @@ well as conversions such as Fahrenheit to Celsius.
%prep
%autosetup -p1
# make units_cur use Python 3
sed -e 's|^AC_PATH_PROG(PYTHON, .*$|PYTHON=%{__python3}\nAC_SUBST(PYTHON)|' \
-i configure.ac
autoreconf -fiv
%build
%configure
make %{?_smp_mflags}
%make_build
%install
make install DESTDIR=$RPM_BUILD_ROOT
%make_install
gzip $RPM_BUILD_ROOT%{_infodir}/units.info
# replace an absolute symlink by a relative symlink
ln -fsv ../../..%{_sharedstatedir}/units/currency.units %{buildroot}%{_datadir}/units
gzip %{buildroot}%{_infodir}/units.info
# provide a man page for units_cur as a symlink to units.1
ln -s units.1 %{buildroot}%{_mandir}/man1/units_cur.1
@ -49,18 +43,8 @@ ln -s units.1 %{buildroot}%{_mandir}/man1/units_cur.1
%check
make check
%post
if [ -e %{_infodir}/units.info.gz ]; then
/sbin/install-info %{_infodir}/units.info.gz %{_infodir}/dir || :
fi
%preun
if [ $1 = 0 -a -e %{_infodir}/units.info.gz ]; then
/sbin/install-info --delete %{_infodir}/units.info.gz %{_infodir}/dir || :
fi
%files
%doc ChangeLog COPYING NEWS README
%doc COPYING NEWS README
%{_bindir}/units
%{_bindir}/units_cur
%{_datadir}/units
@ -69,6 +53,81 @@ fi
%{_mandir}/man1/*
%changelog
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 2.22-10
- Bump release for October 2024 mass rebuild:
Resolves: RHEL-64018
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 2.22-9
- Bump release for June 2024 mass rebuild
* Sat Jan 27 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.22-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
* Thu Nov 30 2023 Florian Weimer <fweimer@redhat.com> - 2.22-7
- C compatibility fix for the configure script (#2252276)
* Sat Jul 22 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.22-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild
* Thu Apr 13 2023 Lukáš Zaoral <lzaoral@redhat.com> - 2.22-5
- migrate to SPDX license format
* Sat Jan 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.22-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild
* Tue Sep 06 2022 Kamil Dudka <kdudka@redhat.com> - 2.22-3
- remove a build system tweak related to Python 3 no longer needed
* Tue Sep 06 2022 Kamil Dudka <kdudka@redhat.com> - 2.22-2
- replace an absolute symlink by a relative symlink
- use %%make_build and %%make_install RPM macros
* Tue Sep 06 2022 Kamil Dudka <kdudka@redhat.com> - 2.22-1
- new upstream release
* Sat Jul 23 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.21-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 2.21-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild
* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.21-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.21-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Nov 16 2020 Kamil Dudka <kdudka@redhat.com> - 2.21-1
- new upstream release
* Thu Oct 01 2020 Kamil Dudka <kdudka@redhat.com> - 2.20-1
- new upstream release
* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.19-5
- Second attempt - Rebuilt for
https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.19-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Fri Jan 31 2020 Fedora Release Engineering <releng@fedoraproject.org> - 2.19-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.19-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Sat Jun 01 2019 Kamil Dudka <kdudka@redhat.com> - 2.19-1
- new upstream release
* Sun Feb 17 2019 Igor Gnatenko <ignatenkobrain@fedoraproject.org> - 2.18-3
- Rebuild for readline 8.0
* Sun Feb 03 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.18-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Mon Oct 29 2018 Kamil Dudka <kdudka@redhat.com> - 2.18-1
- new upstream release
* Wed Aug 08 2018 Kamil Dudka <kdudka@redhat.com> - 2.17-5
- do not update currency.units from network during build
- units_cur: validate rate data from server (#1598913)