Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package libreoffice-share-linker for
openSUSE:Factory checked in at 2023-03-25 18:53:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libreoffice-share-linker (Old)
and /work/SRC/openSUSE:Factory/.libreoffice-share-linker.new.31432 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libreoffice-share-linker"
Sat Mar 25 18:53:58 2023 rev:6 rq:1073833 version:1
Changes:
--------
---
/work/SRC/openSUSE:Factory/libreoffice-share-linker/libreoffice-share-linker.changes
2019-07-08 14:59:10.386366556 +0200
+++
/work/SRC/openSUSE:Factory/.libreoffice-share-linker.new.31432/libreoffice-share-linker.changes
2023-03-25 18:53:59.858237777 +0100
@@ -1,0 +2,14 @@
+Thu Mar 16 07:30:43 UTC 2023 - Martin Liška <[email protected]>
+
+- Rewrite the script to Python:
+ * the current script is quite slow and delays libreoffice package
+ build where we install all packages and then uninstall them
+ * the script uses linkfile=${file/${datadir}/${libdir}} for replacement
+ of $datadir prefix with $libdir (if the $file path starts with $datadir;
+ if not, we end up with an empty string and we execute various shell
+ scripts with it
+ * the Python implementation should be more readable
+ * the Python version runs about 200s faster when it comes to libreoffice
+ package build (on a recent Ryzen 9 machine)
+
+-------------------------------------------------------------------
Old:
----
link-to-ooo-home
New:
----
libreoffice-share-linker.py
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ libreoffice-share-linker.spec ++++++
--- /var/tmp/diff_new_pack.bUfIVW/_old 2023-03-25 18:54:00.406240641 +0100
+++ /var/tmp/diff_new_pack.bUfIVW/_new 2023-03-25 18:54:00.410240662 +0100
@@ -1,7 +1,7 @@
#
# spec file for package libreoffice-share-linker
#
-# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2023 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -22,9 +22,10 @@
Summary: Script to link/unlink files to libreoffice home
License: MIT
Group: Productivity/Office/Suite
-Url: http://www.opensuse.org/
-Source0: link-to-ooo-home
+URL: http://www.opensuse.org/
+Source0: libreoffice-share-linker.py
BuildRoot: %{_tmppath}/%{name}-%{version}-build
+Requires: python3
BuildArch: noarch
%description
@@ -42,13 +43,13 @@
# compat for migration from older releases openSUSE-13.1 and older
mkdir -p %{buildroot}%{_datadir}/libreoffice
pushd %{buildroot}%{_datadir}/libreoffice > /dev/null
-ln -s %{_bindir}/%{name} link-to-ooo-home
+ln -s %{_bindir}/%{name} libreoffice-share-linker.py
popd > /dev/null
%files
%defattr(-,root,root)
%{_bindir}/%{name}
%dir %{_datadir}/libreoffice/
-%{_datadir}/libreoffice/link-to-ooo-home
+%{_datadir}/libreoffice/libreoffice-share-linker.py
%changelog
++++++ libreoffice-share-linker.py ++++++
#!/usr/bin/env python3
import argparse
import subprocess
from pathlib import Path
PREFIX = '/usr/share/libreoffice'
DATADIR = '/usr/share'
LIBDIRS = (
Path('/usr/lib/'),
Path('/usr/lib64/'),
Path('/usr/lib32/'),
)
LEFTOVER_DIRS = (
Path('/usr/share/libreoffice/help'),
Path('/usr/share/libreoffice/program'),
Path('/usr/share/libreoffice/share'),
Path('/usr/share/libreoffice'),
)
parser = argparse.ArgumentParser(description='This script (un)links or unlinks
the given to/from libreoffice home')
parser.add_argument('filelist', help='List of files')
parser.add_argument('--unlink', action='store_true', help='Unlink the files
during package removal')
args = parser.parse_args()
files = sorted([Path(x) for x in open(args.filelist).read().splitlines() if
x.startswith(PREFIX)])
def get_relative_folder(file, libdir):
try:
return libdir / file.relative_to(DATADIR)
except ValueError:
return None
for libdir in LIBDIRS:
# for each dir verify there is libreoffice folder, otherwise skip
lodir = libdir / 'libreoffice'
if not lodir.is_dir():
continue
# Decide if we are linking or wiping first
if args.unlink:
for file in files:
link = get_relative_folder(file, libdir)
if link:
# first just remove the symlinks
if link.is_symlink() and not link.is_dir():
link.unlink()
# continue by wiping out all EMPTY dirs
# we have to be sure it is not owned by anything else
# doing in 2nd run to ensure avoiding collisions
if link.is_dir() and not any(link.iterdir()):
r = subprocess.run(f'rpm -qf {file}', shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL)
if not r.stdout:
link.rmdir()
else:
for file in files:
# if we get ourselves folder then just create it
# it might not be around so lets be safe
link = get_relative_folder(file, libdir)
if link:
if file.is_dir():
if not link.exists():
link.mkdir(parents=True)
link.chmod(file.stat().st_mode)
else:
# if the file is already there, skip it
# this is true when the parent folder is link
if not link.exists():
link.symlink_to(file)
for leftover in LEFTOVER_DIRS:
if leftover.is_dir() and not any(leftover.iterdir()):
leftover.rmdir()
# remove dangling links as they might happen when migratin from older
# libreoffice versions
# Run find directly as it's faster than os.walk run and a os.path.islink!
subprocess.run(f'find {str(lodir)} -type l -xtype l -delete',
shell=True, stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)