--- /dev/null
+From 1f2ece2868f370bda1c4c01be401bcfb137f383d Mon Sep 17 00:00:00 2001
+From: Michael Tremer <michael.tremer@ipfire.org>
+Date: Mon, 3 Jul 2023 15:05:13 +0000
+Subject: [PATCH 2/2] export: Raise an error when trying to export ipset for
+ both families
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
+Signed-off-by: Petr Písař <ppisar@redhat.com>
+---
+ src/python/location/export.py | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/python/location/export.py b/src/python/location/export.py
+index 25a532e..1d147b1 100644
+--- a/src/python/location/export.py
++++ b/src/python/location/export.py
+@@ -147,6 +147,10 @@ class IpsetOutputWriter(OutputWriter):
+ # Count all networks
+ self.networks = 0
+
++ # Check that family is being set
++ if not self.family:
++ raise ValueError("%s requires family being set" % self.__class__.__name__)
++
+ @property
+ def hashsize(self):
+ """
+--
+2.41.0
+
--- /dev/null
+From 76852f60da75827f1296358e6be511a04355d073 Mon Sep 17 00:00:00 2001
+From: Michael Tremer <michael.tremer@ipfire.org>
+Date: Mon, 3 Jul 2023 14:53:50 +0000
+Subject: [PATCH 1/2] location: Fix correct set name when family is selected
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This does however not fix the problem if no --family= parameter is being
+given because we will then export for multiple families in one file.
+
+This is for example not supported for ipset.
+
+Fixes: #12897
+Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
+Signed-off-by: Petr Písař <ppisar@redhat.com>
+---
+ src/scripts/location.in | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/scripts/location.in b/src/scripts/location.in
+index be13156..60b11d6 100644
+--- a/src/scripts/location.in
++++ b/src/scripts/location.in
+@@ -514,7 +514,7 @@ class CLI(object):
+ writer = self.__get_output_formatter(ns)
+
+ for asn in ns.asn:
+- f = writer("AS%s" % asn, f=sys.stdout)
++ f = writer("AS%s" % asn, family=ns.family, f=sys.stdout)
+
+ # Print all matching networks
+ for n in db.search_networks(asns=[asn], family=ns.family):
+@@ -527,7 +527,7 @@ class CLI(object):
+
+ for country_code in ns.country_code:
+ # Open standard output
+- f = writer(country_code, f=sys.stdout)
++ f = writer(country_code, family=ns.family, f=sys.stdout)
+
+ # Print all matching networks
+ for n in db.search_networks(country_codes=[country_code], family=ns.family):
+@@ -554,7 +554,7 @@ class CLI(object):
+ raise ValueError(_("You must at least pass one flag"))
+
+ writer = self.__get_output_formatter(ns)
+- f = writer("custom", f=sys.stdout)
++ f = writer("custom", family=ns.family, f=sys.stdout)
+
+ for n in db.search_networks(flags=flags, family=ns.family):
+ f.write(n)
+@@ -563,7 +563,7 @@ class CLI(object):
+
+ def handle_list_bogons(self, db, ns):
+ writer = self.__get_output_formatter(ns)
+- f = writer("bogons", f=sys.stdout)
++ f = writer("bogons", family=ns.family, f=sys.stdout)
+
+ for n in db.list_bogons(family=ns.family):
+ f.write(n)
+--
+2.41.0
+
Name: libloc
Version: 0.9.16
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Library to determine a location of an IP address in the Internet
# COPYING: LGPL-2.1 text
# data/database.db: CC-BY-SA-4.0
License: LGPL-2.1-or-later
URL: https://location.ipfire.org/
Source0: https://source.ipfire.org/releases/%{name}/%{name}-%{version}.tar.gz
+# 1/2 Fix "location list-networks-by-as --format ipset" output,
+# in upstream after 0.9.16, upstream bug #12897
+Patch0: libloc-0.9.16-location-Fix-correct-set-name-when-family-is-selecte.patch
+# 2/2 Fix "location list-networks-by-as --format ipset" output,
+# in upstream after 0.9.16, upstream bug #12897
+Patch1: libloc-0.9.16-export-Raise-an-error-when-trying-to-export-ipset-fo.patch
BuildRequires: asciidoc
BuildRequires: autoconf >= 2.60
# autoconf-archive for unbundled m4/ax_prog_perl_modules.m4
BuildRequires: pkgconf-pkg-config
BuildRequires: pkgconfig(libsystemd)
BuildRequires: pkgconfig(python) >= 3.4
-# pkgconfig(systemd) no needed, we configure a value from systemd-rpm-macros
+# pkgconfig(systemd) not needed, we configure a value from systemd-rpm-macros
BuildRequires: python3-devel
BuildRequires: sed
BuildRequires: systemd-rpm-macros
%{_unitdir}/*
%changelog
+* Mon Jul 24 2023 Petr Pisar <ppisar@redhat.com> - 0.9.16-2
+- Fix "location list-networks-by-as --format ipset" output
+ (upstream bug #12897)
+
* Mon Oct 31 2022 Petr Pisar <ppisar@redhat.com> - 0.9.16-1
- 0.9.16 bump
- A database snapshot from 2022-10-20T06:27:23 is included