From e846b9f2c4f9aa1ea0cc1c2ee3886f97dc3101c2 Mon Sep 17 00:00:00 2001
From: zyppe <210hcl@gmail.com>
Date: Thu, 29 Feb 2024 14:14:41 +0800
Subject: [PATCH] Initialize for libpsl

---
 .gitignore                 |   1 +
 .libpsl.metadata           |   1 +
 baselibs.conf              |   1 +
 libpsl-fix-test-data.patch |  16 +++++
 libpsl.changes             |  97 ++++++++++++++++++++++++++++
 libpsl.spec                | 129 +++++++++++++++++++++++++++++++++++++
 6 files changed, 245 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 .libpsl.metadata
 create mode 100644 baselibs.conf
 create mode 100644 libpsl-fix-test-data.patch
 create mode 100644 libpsl.changes
 create mode 100644 libpsl.spec

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9a4b8d0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+libpsl-0.20.1.tar.gz
diff --git a/.libpsl.metadata b/.libpsl.metadata
new file mode 100644
index 0000000..b757675
--- /dev/null
+++ b/.libpsl.metadata
@@ -0,0 +1 @@
+fe6ce19b3ce78d16ba8a74ed0826d27339d1258025f542860a7d842d4ee9e5c4 libpsl-0.20.1.tar.gz
diff --git a/baselibs.conf b/baselibs.conf
new file mode 100644
index 0000000..35f93a6
--- /dev/null
+++ b/baselibs.conf
@@ -0,0 +1 @@
+libpsl5
diff --git a/libpsl-fix-test-data.patch b/libpsl-fix-test-data.patch
new file mode 100644
index 0000000..f9a0402
--- /dev/null
+++ b/libpsl-fix-test-data.patch
@@ -0,0 +1,16 @@
+diff --git a/tests/test-is-public-builtin.c b/tests/test-is-public-builtin.c
+index e9963b5..ea3a434 100644
+--- a/tests/test-is-public-builtin.c
++++ b/tests/test-is-public-builtin.c
+@@ -82,8 +82,8 @@ static void test_psl(void)
+ 		{ ".forgot.his.name", 1, 1 },
+ 		{ "whoever.his.name", 0, 0 },
+ 		{ "whoever.forgot.his.name", 0, 0 },
+-		{ "whatever.platform.sh", 1, 1 },
+-		{ ".platform.sh", 1, 1 },
++		{ "whatever.platformsh.site", 1, 1 },
++		{ ".platformsh.site", 1, 1 },
+ 		{ "whatever.yokohama.jp", 1, 1 },
+ 		{ ".yokohama.jp", 1, 1 },
+ 		{ ".", 1, 0 }, /* special case */
+
diff --git a/libpsl.changes b/libpsl.changes
new file mode 100644
index 0000000..0b42a60
--- /dev/null
+++ b/libpsl.changes
@@ -0,0 +1,97 @@
+* Wed Apr 13 2022 pgajdos@suse.com
+- fix [bsc#1197771] - FTBFS: libpsl won't compile on SP4
+- added patches
+  https://github.com/rockdaboot/libpsl/commit/f364cea73e351ce62e0b337fd1fbc21e70b52d56
+  + libpsl-fix-test-data.patch
+* Tue Feb 27 2018 astieger@suse.com
+- update to 0.20.1:
+  * Fix issue introduced with PSL_TYPE_NO_STAR_RULE in V0.20.0
+  * Fix SO_VERSION to 8:0:3
+  * Improve unit tests
+* Thu Feb 22 2018 fvogt@suse.com
+- Use %%license (boo#1082318)
+* Thu Feb 22 2018 astieger@suse.com
+- update to 0.20.0:
+  * Remove hard-coded gcc flag in Makefile.am
+  * Prevent excessive CPU cycles on large inputs
+  * New flag PSL_TYPE_NO_STAR_RULE to skip star rule
+* Wed Jan  3 2018 tchvatal@suse.com
+- Make sure to use python3 during build instead of calling env
+* Thu Nov  9 2017 astieger@suse.com
+- update to 0.19.1:
+  * New function psl_free_string()
+  * psl_make_dafsa now works with python2 and python3
+  * psl_*count() functions now return -1 if info is not available
+  * Fixed unsigned integer overflow in _mem_is_ascii()
+  * Add -fsanitize-address-use-after-scope to --enable-asan if
+    available
+* Thu Jul 20 2017 astieger@suse.com
+- update to 0.18.0:
+  * Fix order of files in psl_latest()
+  * Add fuzzing architecture
+  * Fix memleak in _psl_is_public_suffix()
+  * Add configure option --enable-asan (Address sanitizer)
+  * Add configure option --enable-usan (Undefined sanitizer)
+  * Add configure option --enable-cfi (Control Flow Integrity)
+  * Fix finding libidn2 for static builds
+  * Fix use of uninitialized stack value
+  * Fix buffer overflow in libicu build
+  * Use libidn2 as default for builds (former libicu)
+  * Add pkg-config support for libidn and libidn2
+* Thu Apr  6 2017 coolo@suse.com
+- Use idn2 runtime instead of libicu - as libicu requires 30MB
+  of unicode data - while idn2 is already part of minimal system
+* Thu Jan 19 2017 shshyukriev@suse.com
+- libpsl 0.17.0:
+  * Use TR46 non-transitional for IDNA (libicu, libidn2 >= 0.14)
+  * Fix coverage upload from TravisCI to Coveralls
+  * New tests to cover psl_latest() and psl_dist_filename()
+* Thu Dec 15 2016 astieger@suse.com
+- libpsl 0.16.1:
+  This version enables consumers of the library to dynamically load
+  the latest public suffix data from a binary data file in the
+  publicsuffix package which can then updated without re-building
+  libpsl.
+  * Add functions psl_latest() and psl_dist_filename()
+  * Do not taint out variable on error in psl_str_to_utf8lower()
+  * Replace psl2c by psl-make-dafsa
+- correct licenses for package and subpackages
+- package HTML docs in -devel package
+* Mon Nov 14 2016 astieger@suse.com
+- libpsl 0.15.0:
+  * Python3 compatibility for psl-make-dafsa
+  * Support for UTF-8 in DAFSA data
+  * Skip punycode conversion if DAFSA has UTF-8
+  * Better code coverage by test suite
+  * Code cleanup and enhancements
+  * Install man pages for psl-make-dafsa and psl
+  * Enhancements to the documentation
+* Mon Aug  1 2016 astieger@suse.com
+- libpsl 0.14.0:
+  * Remove unneeded libraries from tools/psl link step
+  * Use https instead of http where possible
+  * Add man page for tools/psl
+  * Add header magic to DAFSA files
+  * Rename make_dafsa.py to psl-make-dafsa
+  * Add man page for psl-make-dafsa
+* Wed Mar  9 2016 astieger@suse.com
+- libpsl 0.13.0:
+  * Use tests.txt as PSL test file by default
+  * Slightly shorter DAFSA array when sorting input
+  * Check for python 2.7+ in configure.ac
+  * Fix python3 incompatibilities in make_dafsa.py
+* Fri Feb  5 2016 idonmez@suse.com
+- Add baselibs.conf
+* Thu Jan  7 2016 astieger@suse.com
+- libpsl 0.12.0 (libpsl.so.5 5:0:0)
+  * Remove psl_builtin_compile_time()
+  * Add function psl_is_public_suffix2()
+  * Avoid libicu dependency with --enable-runtime=no
+- drop upstreamed 0001-Remove-include-of-bits-stat.h.patch
+* Sat Nov 28 2015 astieger@suse.com
+- fix SLE 11 build:
+  * adding 0001-Remove-include-of-bits-stat.h.patch
+  * skip IDN feature
+- update descriptions and categories
+* Sun Nov 15 2015 astieger@suse.com
+- initial package for libpsl based on Fedora Spec
diff --git a/libpsl.spec b/libpsl.spec
new file mode 100644
index 0000000..f767729
--- /dev/null
+++ b/libpsl.spec
@@ -0,0 +1,129 @@
+#
+# spec file for package libpsl
+#
+# Copyright (c) 2022-2023 ZhuningOS
+#
+#
+
+
+%define somajor 5
+Name:           libpsl
+Version:        0.20.1
+Release:        150000.3.3.1
+Summary:        C library for the Publix Suffix List
+License:        MIT AND MPL-2.0 AND BSD-3-Clause
+Group:          Development/Libraries/C and C++
+Url:            https://rockdaboot.github.io/libpsl
+Source:         https://github.com/rockdaboot/libpsl/releases/download/%{name}-%{version}/%{name}-%{version}.tar.gz
+Source1000:     baselibs.conf
+# https://github.com/rockdaboot/libpsl/commit/f364cea73e351ce62e0b337fd1fbc21e70b52d56
+Patch0:          libpsl-fix-test-data.patch
+BuildRequires:  libidn2-devel >= 0.14
+BuildRequires:  libunistring-devel
+BuildRequires:  pkgconfig >= 0.9.0
+BuildRequires:  publicsuffix
+BuildRequires:  python3-base
+
+%description
+libpsl is a C library to handle the Public Suffix List. A "public suffix" is a
+domain name under which Internet users can directly register own names.
+
+HTTP user agents can use it to avoid privacy-leaking "supercookies" and "super
+domain" certificates. It is also use do highlight domain parts in a user interface
+and sorting domain lists by site.
+
+%package -n %{name}%{somajor}
+Summary:        C library for the Publix Suffix List
+# The libary code is MIT, with built-in data from publicsuffix
+License:        MIT AND MPL-2.0
+Group:          System/Libraries
+Recommends:     publicsuffix
+
+%description -n %{name}%{somajor}
+libpsl is a C library to handle the Public Suffix List. A "public suffix" is a
+domain name under which Internet users can directly register own names.
+
+HTTP user agents can use it to avoid privacy-leaking "supercookies" and "super
+domain" certificates. It is also use do highlight domain parts in a user interface
+and sorting domain lists by site.
+
+%package        devel
+Summary:        Development files for %{name}
+License:        MIT
+Group:          Development/Libraries/C and C++
+Requires:       %{name}%{somajor} = %{version}
+
+%description    devel
+libpsl is a C library to handle the Public Suffix List. A "public suffix" is a
+domain name under which Internet users can directly register own names.
+
+HTTP user agents can use it to avoid privacy-leaking "supercookies" and "super
+domain" certificates. It is also use do highlight domain parts in a user interface
+and sorting domain lists by site.
+
+This package contains libraries and header files.
+Developer documentation is in %{_docdir}/libpsl-devel/html .
+
+%package -n     psl
+Summary:        Commandline utility to explore the Public Suffix List
+License:        MIT
+Group:          Productivity/Networking/Other
+
+%description -n psl
+This package contains a commandline utility to explore the Public Suffix List,
+for example it checks if domains are public suffixes, checks if cookie-domain
+is acceptable for domains and so on.
+
+HTTP user agents can use it to avoid privacy-leaking "supercookies" and "super
+domain" certificates. It is also use do highlight domain parts in a user interface
+and sorting domain lists by site.
+
+%prep
+%setup -q
+%patch0 -p1
+# fix env shebang to call py3 directly
+sed -i -e "1s|#!.*|#!/usr/bin/python3|" src/psl-make-dafsa
+
+%build
+# default is libicu, but this just too heavy dependency. This library is part of the
+# minimal system as curl uses it - but libidn2 is already used by curl directly, while
+# icu is not
+%configure \
+	--disable-silent-rules \
+	--disable-static \
+	--with-psl-file=%{_datadir}/publicsuffix/public_suffix_list.dat \
+	--with-psl-distfile=%{_datadir}/publicsuffix/public_suffix_list.dafsa
+make %{?_smp_mflags}
+
+%install
+%make_install
+find %{buildroot} -type f -name "*.la" -delete -print
+# in psl-make-dafsa package to break build cycle
+make DESTDIR=%{buildroot} install-man
+rm %{buildroot}%{_mandir}/man1/psl-make-dafsa.1
+
+%check
+make %{?_smp_mflags} check || (cat tests/test-suite.log; exit 42)
+
+%post -n %{name}%{somajor} -p /sbin/ldconfig
+%postun -n %{name}%{somajor} -p /sbin/ldconfig
+
+%files -n %{name}%{somajor}
+%license COPYING
+%{_libdir}/libpsl.so.%{somajor}*
+
+%files devel
+%license COPYING
+%doc AUTHORS NEWS
+%doc docs/libpsl/html
+%{_includedir}/libpsl.h
+%{_libdir}/libpsl.so
+%{_libdir}/pkgconfig/libpsl.pc
+
+%files -n psl
+%license COPYING
+%doc AUTHORS NEWS
+%{_bindir}/psl
+%{_mandir}/man1/psl.1%{ext_man}
+
+%changelog