openSUSE / python-rpm-macros

Multi-Python, Single-Spec macros generator
Other
22 stars 20 forks source link

Additional flags in scriptlets (like `%pre -f`) #141

Closed tacerus closed 2 years ago

tacerus commented 2 years ago

Hello,

is there a way to pass additional pre-scripts to %{python_subpackages}? Currently, adding a custom %pre -f section in the spec file results in:

error: line 72: Too many names: %pre -n python310-limnoria--f %{appname}.pre

I am trying to add a system user for the package, and /usr/lib/rpm/macros.d/macros.sysusers states:

add "%sysusers_generate_pre []" to build section add "%pre -f .pre" to spec file

Thanks for any insight!

tacerus commented 2 years ago

For now, I am working around the issue by dumping the contents of the sysusers script and inserting it manually into my spec file, without the -f:

%pre
/usr/sbin/sysusers2shadow system-user-limnoria.conf <<"EOF" || [ -f /.buildenv ]
u limnoria - "Limnoria IRC Bot" /var/lib/empty -
EOF
bnavigator commented 2 years ago

What do you mean by "additional"? There is always only one %pre scriptlet per package, which will be copied over to the flavor subpackages using the -n pkgname flag. I cannot find any documentation on the -f flag for scriptlets. I am assuming it works the same way as %files -f <file>.

It looks like there is a - instead of a whitespace before the -f flag. You may have found a bug in python-rpm-macros. Do you have an example specfile, where this can be investigated?

tacerus commented 2 years ago

Hi,

sorry for the confusion. I'm not sure about upstream documentation about -f, but our sysuser macros package demands on using it, and this is what we document in the Wiki as well: https://en.opensuse.org/openSUSE:Packaging_guidelines#Users_and_Groups.

The whitespace was just an attempt on circumventing the error - it did not change the result.

Here is an example spec file which currently has the dumped sysuser script in its %pre section (as the -f route resulted in the "Too many names" error): https://build.opensuse.org/package/view_file/home:crameleon:LibertaCasa/python-limnoria/python-limnoria.spec?expand=1

bnavigator commented 2 years ago

Thanks for the report. Indeed we do not allow extra parameters in copied section headers except for -f in %files

I have drafted a fix in #142. https://build.opensuse.org/package/show/home:bnavigator:python-rpm-macros/python-limnoria gets past the initial error and only fails in the test suite afterwards just as with your work around.

You will have to keep the workaround until #142 lands in python-rpm-macros for Factory.

tacerus commented 2 years ago

Thank you so much for this, that's very promising! It's not urgent for me. :-)

bnavigator commented 2 years ago

Something is still wrong:

https://build.opensuse.org/package/show/home:bnavigator:python-rpm-macros/python-limnoria indefinitely hangs for me here:

Index: python-limnoria.spec
===================================================================
--- python-limnoria.spec        (revision ec42e831bd71ea14bdf774d7007f0172)
+++ python-limnoria.spec        (working copy)
@@ -133,11 +133,7 @@
 %{buildroot}%{_bindir}/supybot-test-%{$python_bin_suffix} -c -v --plugins-dir=%{buildroot}%{$python_sitelib}/supybot/plugins/ --no-network
 }

-%pre
-# https://github.com/openSUSE/python-rpm-macros/issues/141
-/usr/sbin/sysusers2shadow system-user-limnoria.conf <<"EOF" || [ -f /.buildenv ]
-u limnoria - "Limnoria IRC Bot" /var/lib/empty -
-EOF
+%pre -f %{appname}.pre

 %post
 %{python_install_alternative supybot supybot-adduser supybot-botchk
[  361s] Executing(%clean): /usr/bin/bash -e /var/tmp/rpm-tmp.FHfsZf
[  361s] + umask 022
[  361s] + cd /home/abuild/rpmbuild/BUILD
[  361s] + cd /home/abuild/rpmbuild/SOURCES/Limnoria-20220814
[  361s] + /usr/bin/rm -rf /home/abuild/rpmbuild/BUILDROOT/python-limnoria-20220814-65.1.x86_64
[  361s] + RPM_EC=0
[  361s] ++ jobs -p
[  361s] + exit 0
[  361s] 
[  361s] RPM build warnings:
[  361s]     absolute symlink: /usr/bin/supybot -> /etc/alternatives/supybot
[  361s]     absolute symlink: /usr/bin/supybot-adduser -> /etc/alternatives/supybot-adduser
[  361s]     absolute symlink: /usr/bin/supybot-botchk -> /etc/alternatives/supybot-botchk
[  361s]     absolute symlink: /usr/bin/supybot-plugin-create -> /etc/alternatives/supybot-plugin-create
[  361s]     absolute symlink: /usr/bin/supybot-plugin-doc -> /etc/alternatives/supybot-plugin-doc
[  361s]     absolute symlink: /usr/bin/supybot-reset-password -> /etc/alternatives/supybot-reset-password
[  361s]     absolute symlink: /usr/bin/supybot-test -> /etc/alternatives/supybot-test
[  361s]     absolute symlink: /usr/bin/supybot-wizard -> /etc/alternatives/supybot-wizard
[  361s]     absolute symlink: /usr/bin/supybot-wizard-suse -> /etc/alternatives/supybot-wizard-suse
[  361s]     absolute symlink: /usr/share/man/man1/supybot-adduser.1.gz -> /etc/alternatives/supybot-adduser.1.gz
[  361s]     absolute symlink: /usr/share/man/man1/supybot-botchk.1.gz -> /etc/alternatives/supybot-botchk.1.gz
[  361s]     absolute symlink: /usr/share/man/man1/supybot-plugin-create.1.gz -> /etc/alternatives/supybot-plugin-create.1.gz
[  361s]     absolute symlink: /usr/share/man/man1/supybot-plugin-doc.1.gz -> /etc/alternatives/supybot-plugin-doc.1.gz
[  361s]     absolute symlink: /usr/share/man/man1/supybot-reset-password.1.gz -> /etc/alternatives/supybot-reset-password.1.gz
[  361s]     absolute symlink: /usr/share/man/man1/supybot-test.1.gz -> /etc/alternatives/supybot-test.1.gz
[  361s]     absolute symlink: /usr/share/man/man1/supybot-wizard.1.gz -> /etc/alternatives/supybot-wizard.1.gz
[  361s]     absolute symlink: /usr/share/man/man1/supybot.1.gz -> /etc/alternatives/supybot.1.gz
[  361s] ... checking for files with abuild user/group
[  361s] ... running 00-check-install-rpms
[  361s] ... installing all built rpms
[  361s] Verifying packages...
[  361s] Preparing packages...
[  361s] python310-limnoria-20220814-65.1.noarch
[  361s] warning: user limnoria does not exist - using root
[  361s] warning: group limnoria does not exist - using root
[  361s] warning: user limnoria does not exist - using root
[  361s] warning: group limnoria does not exist - using root
[  361s] warning: user limnoria does not exist - using root
[  361s] warning: group limnoria does not exist - using root
[  361s] warning: user limnoria does not exist - using root
[  361s] warning: group limnoria does not exist - using root
[  361s] warning: user limnoria does not exist - using root
[  361s] warning: group limnoria does not exist - using root
[  362s] /var/tmp/rpm-tmp.yTbZS6: line 2: supybot-plugin-create: command not found
[  362s] /var/tmp/rpm-tmp.yTbZS6: line 3: supybot.1: command not found
[  362s] /var/tmp/rpm-tmp.yTbZS6: line 4: supybot-plugin-doc.1: command not found
[  362s] ... running 50-check-binary-kernel-log
[  362s] ... running 50-check-core-files
[  362s] ... checking for core files
[  362s] ... running 50-check-debuginfo
[  362s] ... testing for empty debuginfo packages
[  362s] ... running 50-check-filelist
[  362s] ... checking filelist
[  362s] ... running 50-check-gconf-scriptlets
[  362s] ... testing GConf scriptlet presence
[  362s] ... running 50-check-installtest
[  362s] ... testing for pre/postinstall scripts that are not idempotent
rpm -q --scripts /var/tmp/build-root/openSUSE_Tumbleweed-x86_64/home/abuild/rpmbuild/RPMS/noarch/python310-limnoria-20220814-0.noarch.rpm
preinstall program: /bin/sh
postinstall scriptlet (using /bin/sh):
...

There is no content for the %pre scriptlet

bnavigator commented 2 years ago

Oh, and #138 does not allow newlines in the argument for %python_install_alternatives. :(

bnavigator commented 2 years ago

After fixing #138, the hang disappears, but rpm -q --scripts does not show any content for preinstall?

> rpm -q --scripts /var/tmp/build-root/openSUSE_Tumbleweed-x86_64/home/abuild/rpmbuild/RPMS/noarch/python310-limnoria-20220814-0.noarch.rpm

preinstall program: /bin/sh
postinstall scriptlet (using /bin/sh):
# python310_install_alternative: 
update-alternatives --quiet --install /usr/bin/supybot supybot /usr/bin/supybot-3.10 1310 \
   --slave /usr/bin/supybot-adduser supybot-adduser /usr/bin/supybot-adduser-3.10 \
   --slave /usr/bin/supybot-botchk supybot-botchk /usr/bin/supybot-botchk-3.10 \
   --slave /usr/bin/supybot-plugin-create supybot-plugin-create /usr/bin/supybot-plugin-create-3.10 \
   --slave /usr/bin/supybot-plugin-doc supybot-plugin-doc /usr/bin/supybot-plugin-doc-3.10 \
   --slave /usr/bin/supybot-reset-password supybot-reset-password /usr/bin/supybot-reset-password-3.10 \
   --slave /usr/bin/supybot-test supybot-test /usr/bin/supybot-test-3.10 \
   --slave /usr/bin/supybot-wizard supybot-wizard /usr/bin/supybot-wizard-3.10 \
   --slave /usr/bin/supybot-wizard-suse supybot-wizard-suse /usr/bin/supybot-wizard-suse-3.10 \
   --slave /usr/share/man/man1/supybot.1.gz supybot.1.gz /usr/share/man/man1/supybot-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-adduser.1.gz supybot-adduser.1.gz /usr/share/man/man1/supybot-adduser-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-botchk.1.gz supybot-botchk.1.gz /usr/share/man/man1/supybot-botchk-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-plugin-create.1.gz supybot-plugin-create.1.gz /usr/share/man/man1/supybot-plugin-create-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-plugin-doc.1.gz supybot-plugin-doc.1.gz /usr/share/man/man1/supybot-plugin-doc-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-reset-password.1.gz supybot-reset-password.1.gz /usr/share/man/man1/supybot-reset-password-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-test.1.gz supybot-test.1.gz /usr/share/man/man1/supybot-test-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-wizard.1.gz supybot-wizard.1.gz /usr/share/man/man1/supybot-wizard-3.10.1.gz
postuninstall scriptlet (using /bin/sh):
# python310_uninstall_alternative: 

if [ ! -e "/usr/bin/supybot-3.10" ]; then 
    update-alternatives --quiet --remove "supybot" "/usr/bin/supybot-3.10" 
fi
tacerus commented 2 years ago

Weird, I branched your home:bnavigator:python-rpm-macros and %pre -f works fine with it - you can debug it by putting cat %{appname}.pre into the %check section. I committed my working copy here if you want to check, but it's still blocked, so might take a while til it starts building: https://build.opensuse.org/package/show/home:crameleon:LibertaCasa/python-limnoria.

tacerus commented 2 years ago

does not allow newlines in the argument for %python_install_alternatives.

That's interesting - I actually never modified this section, I forked this package from devel:languages:python and added some bits, but left the alternatives as they are - never had any issues with it, it builds and installs fine - maybe I should verify the alternatives after installing the package on a system?

bnavigator commented 2 years ago

Weird, I branched your home:bnavigator:python-rpm-macros and %pre -f works fine with it - you can debug it by putting cat %{appname}.pre into the %check section. I committed my working copy here if you want to check, but it's still blocked, so might take a while til it starts building: https://build.opensuse.org/package/show/home:crameleon:LibertaCasa/python-limnoria.

The package in home:bnavigator:python-rpm-macros/python-limnoria is a branch of yours I did the exactly same locally before you wrote.

That's interesting - I actually never modified this section, I forked this package from devel:languages:python and added some bits, but left the alternatives as they are - never had any issues with it, it builds and installs fine - maybe I should verify the alternatives after installing the package on a system?

It's a still open PR and part of the python-rpm-macros of the testing project. I have already fixed it and that's why yoru limnoria sucessfully builds.

I am just a bit confused that rpm -q --scripts shows that there is a preinstall scriptlet using /bin/sh but does not show the content of the limnoria.pre file.

bnavigator commented 2 years ago

When I disable the subpackage rewriter, I get this:

Index: python-limnoria.spec
===================================================================
--- python-limnoria.spec        (revision 85f78fb293f32f05ead90969f2b60a1e)
+++ python-limnoria.spec        (working copy)
@@ -76,7 +76,7 @@
 Provides:       Supybot = %{version}
 Obsoletes:      Supybot < 1.0
 BuildArch:      noarch
-%python_subpackages
+#%%python_subpackages

 %description
 Limnoria is a Python IRC bot with a plugin API. It is equipped with
@@ -132,10 +132,7 @@
 install -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}

 %check
-%{python_expand export PYTHONDONTWRITEBYTECODE=1
-export PYTHONPATH=%{buildroot}%{$python_sitelib}/
-%{buildroot}%{_bindir}/supybot-test-%{$python_bin_suffix} -c --plugins-dir=%{buildroot}%{$python_sitelib}/supybot/plugins/ --no-network
-}
+cat %{appname}.pre

 %pre -f %{appname}.pre

@@ -149,7 +146,8 @@
 %postun
 %{python_uninstall_alternative supybot}

-%files %{python_files}
+%files
+#%%{python_files}
 %doc README.md CONTRIBUTING.md ChangeLog RELNOTES README.SUSE
 %license LICENSE.md
 %dir %attr (755,%{appname},%{appname}) %{_sysconfdir}/%{appname}
[    3s] Executing(%check): /usr/bin/bash -e /var/tmp/rpm-tmp.lJhPTJ
[    3s] + umask 022
[    3s] + cd /home/abuild/rpmbuild/BUILD
[    3s] + cd /home/abuild/rpmbuild/SOURCES/Limnoria-20220814
[    3s] + cat limnoria.pre
[    3s] /usr/sbin/sysusers2shadow system-user-limnoria.conf <<"EOF" || [ -f /.buildenv ]
[    3s] u limnoria - "Limnoria IRC Bot" /var/lib/empty -
[    3s] EOF
[    3s] + RPM_EC=0
[    3s] ++ jobs -p
[    3s] + exit 0
[    3s] Processing files: python-limnoria-20220814-0.noarch
...
[    4s] Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/abuild/rpmbuild/BUILDROOT/python-limnoria-20220814-0.x86_64
[    4s] Wrote: /home/abuild/rpmbuild/SRPMS/python-limnoria-20220814-0.src.rpm
[    4s] error: Could not open Prein file /home/abuild/rpmbuild/BUILD/home/abuild/rpmbuild/SOURCES/Limnoria-20220814/limnoria.pre: No such file or directory
[    4s] 
[    4s] RPM build warnings:
[    4s]     absolute symlink: /usr/bin/supybot -> /etc/alternatives/supybot
[    4s]     absolute symlink: /usr/bin/supybot-adduser -> /etc/alternatives/supybot-adduser
[    4s]     absolute symlink: /usr/bin/supybot-botchk -> /etc/alternatives/supybot-botchk
[    4s]     absolute symlink: /usr/bin/supybot-plugin-create -> /etc/alternatives/supybot-plugin-create
[    4s]     absolute symlink: /usr/bin/supybot-plugin-doc -> /etc/alternatives/supybot-plugin-doc
[    4s]     absolute symlink: /usr/bin/supybot-reset-password -> /etc/alternatives/supybot-reset-password
[    4s]     absolute symlink: /usr/bin/supybot-test -> /etc/alternatives/supybot-test
[    4s]     absolute symlink: /usr/bin/supybot-wizard -> /etc/alternatives/supybot-wizard
[    4s]     absolute symlink: /usr/bin/supybot-wizard-suse -> /etc/alternatives/supybot-wizard-suse
[    4s]     absolute symlink: /usr/share/man/man1/supybot-adduser.1.gz -> /etc/alternatives/supybot-adduser.1.gz
[    4s]     absolute symlink: /usr/share/man/man1/supybot-botchk.1.gz -> /etc/alternatives/supybot-botchk.1.gz
[    4s]     absolute symlink: /usr/share/man/man1/supybot-plugin-create.1.gz -> /etc/alternatives/supybot-plugin-create.1.gz
[    4s]     absolute symlink: /usr/share/man/man1/supybot-plugin-doc.1.gz -> /etc/alternatives/supybot-plugin-doc.1.gz
[    4s]     absolute symlink: /usr/share/man/man1/supybot-reset-password.1.gz -> /etc/alternatives/supybot-reset-password.1.gz
[    4s]     absolute symlink: /usr/share/man/man1/supybot-test.1.gz -> /etc/alternatives/supybot-test.1.gz
[    4s]     absolute symlink: /usr/share/man/man1/supybot-wizard.1.gz -> /etc/alternatives/supybot-wizard.1.gz
[    4s]     absolute symlink: /usr/share/man/man1/supybot.1.gz -> /etc/alternatives/supybot.1.gz
[    4s] 
[    4s] RPM build errors:
[    4s]     Could not open Prein file /home/abuild/rpmbuild/BUILD/home/abuild/rpmbuild/SOURCES/Limnoria-20220814/limnoria.pre: No such file or directory
tacerus commented 2 years ago

I'm not exactly sure how rpm -q --scripts works - but the script seems to work. Since the rpm output says the pre-install script is /bin/sh, not like the Python alternatives script where it says it is using /bin/sh, I think it may just be the format of what the sysusers macro generates making rpm --scripts parse it differently.

bnavigator commented 2 years ago

That's an evil way to hide scriptlet content from users then, isn't it?

tacerus commented 2 years ago

Hah.. :-) I found the source code for it, but can't really make sense of it:

https://github.com/rpm-software-management/rpm/blob/2a8d89a1c390e6ca1de0ece49aa11012b1d0ff89/rpmpopt.in#L15

bnavigator commented 2 years ago

When I look at other packages using ths %pre -f name.pre syntax, their output is okay however:

avahi.spec:

%pre -f avahi.pre
> rpm -q --scripts avahi
preinstall scriptlet (using /bin/sh):

if [ -x /usr/bin/systemctl ]; then
        for service in avahi-dnsconfd.service avahi-daemon.service ; do
                if [ ! -e "/usr/lib/systemd/system/$service" ]; then
                        mkdir -p /run/systemd/rpm/needs-preset
                        touch "/run/systemd/rpm/needs-preset/$service"
                fi
        done
fi

# bnc#853845,bnc#851953: do not start by default under
# sysconfig as this breaks vlan,bridge,bonding setups
# in pre to revert old default setting from template.
if test -f /usr/share/fillup-templates/sysconfig.avahi-autoipd -a \
        -f etc/sysconfig/avahi ; then
        .  /usr/share/fillup-templates/sysconfig.avahi-autoipd
        if test "X$AVAHI_AUTOIPD_ENABLE" = "Xyes" ; then
                sed -i etc/sysconfig/avahi \
                    -e 's/^\(AVAHI_AUTOIPD_ENABLE\)=.*/\1="no"/'
        fi
fi
/usr/sbin/sysusers2shadow avahi.conf <<"EOF" || [ -f /.buildenv ]
u     avahi -  "User for Avahi" /run/avahi-daemon -
EOF
bnavigator commented 2 years ago

My bad. The LUA pattern was wrong: https://github.com/openSUSE/python-rpm-macros/blob/2a68d52ebc188145735a4b013162867de2dfdad4/macros.lua#L228 it should read https://github.com/openSUSE/python-rpm-macros/blob/a038e7351cea607e0b001b76a7acc194aaa1a364/macros.lua#L227

bnavigator commented 2 years ago

Now that the python_subpackages rewriter works as intended, the "could not open prein file in ...SOURCES" error (https://github.com/openSUSE/python-rpm-macros/issues/141#issuecomment-1223945596) is back. When I add tar and ?recompress to _service instead of hacking SOURCES to be BUILD, everything is fine.

working copy against last committed version

Index: _service
===================================================================
--- _service    (revision 10d1f4a540c12b0cf53ca2cbe392df6a)
+++ _service    (working copy)
@@ -17,6 +17,11 @@
     <param name="versionrewrite-replacement">\1\2\3</param>
     <param name="changesgenerate">enable</param>
   </service>
+  <service name="tar" mode="buildtime" />
+  <service name="recompress" mode="buildtime">
+    <param name="file">*.tar</param>
+    <param name="compression">xz</param>
+  </service>
   <service name="set_version" mode="disabled"/>
 </services>

Index: python-limnoria.spec
===================================================================
--- python-limnoria.spec    (revision 10d1f4a540c12b0cf53ca2cbe392df6a)
+++ python-limnoria.spec    (working copy)
@@ -16,10 +16,13 @@
 #

-%define skip_python2 1
 %define appname limnoria
 %define appnameUpper Limnoria
 %define srcver 2022-07-03
+
+# only primary python flavor for the app
+%define pythons python3
+
 Name:           python-limnoria
 Version:        20220814
 Release:        0
@@ -27,7 +30,7 @@
 License:        BSD-3-Clause
 Group:          Development/Languages/Python
 URL:            https://github.com/ProgVal/Limnoria
-Source0:        _service
+Source0:        %{appnameUpper}-%{version}.tar.xz
 Source1:        system-user-%{appname}.conf
 Source2:        %{appname}@.service
 Source3:        README.SUSE
@@ -35,7 +38,6 @@
 # `diff -uI '^#!/usr/bin/' Limnoria/scripts/supybot-wizard supybot-wizard-suse > supybot-wizard-suse.patch` & adjust 1st line
 Patch0:         supybot-wizard-suse.patch
 # full python for sqlite3 module
-%define pythons python310
 BuildRequires:  %pythons
 BuildRequires:  %{python_module PySocks}
 BuildRequires:  %{python_module chardet}
@@ -84,7 +86,7 @@
 granularity. Numerous plugins are included.

 %prep
-%setup -q -n %{_sourcedir}/%{appnameUpper}-%{version} -T -D
+%setup -q -n %{appnameUpper}-%{version}
 sed -i "1,4{/\/usr\/bin\/python/d}" plugins/Debug/plugin.py
 sed -i "1,4{/\/usr\/bin\/env/d}" plugins/SedRegex/constants.py
 chmod -x supybot/plugins/*/locales/fi.po
@@ -95,6 +97,7 @@
 %build
 %python_build
 %sysusers_generate_pre %{SOURCE1} %{appname} system-user-%{appname}.conf
+echo 'echo Yes I did something' >> %{appname}.pre

 %install
 %python_install
@@ -132,10 +135,7 @@
 install -m 0644 %{SOURCE1} %{buildroot}%{_sysusersdir}

 %check
-%{python_expand export PYTHONDONTWRITEBYTECODE=1
-export PYTHONPATH=%{buildroot}%{$python_sitelib}/
-%{buildroot}%{_bindir}/supybot-test-%{$python_bin_suffix} -c --plugins-dir=%{buildroot}%{$python_sitelib}/supybot/plugins/ --no-network
-}
+cat %{appname}.pre

 %pre -f %{appname}.pre
[    8s] Verifying packages...
[    8s] Preparing packages...
[    8s] Yes I did something
[    8s] python3-limnoria-20220814-0.noarch
[    8s] ... running 50-check-binary-kernel-log
[    8s] ... running 50-check-core-files
[    8s] ... running 50-check-debuginfo
[    8s] ... testing for empty debuginfo packages
[    8s] ... running 50-check-filelist
[    8s] ... checking filelist
[    8s] ... running 50-check-gconf-scriptlets
[    8s] ... testing GConf scriptlet presence
[    8s] ... running 50-check-installtest
[    8s] ... testing for pre/postinstall scripts that are not idempotent
[    8s] Yes I did something
[    8s] ... running 50-check-invalid-provides
> rpm -q --scripts /var/tmp/build-root/openSUSE_Tumbleweed-x86_64/home/abuild/rpmbuild/RPMS/noarch/python3-limnoria-20220814-0.noarch.rpm
preinstall scriptlet (using /bin/sh):
/usr/sbin/sysusers2shadow system-user-limnoria.conf <<"EOF" || [ -f /.buildenv ]
u limnoria - "Limnoria IRC Bot" /var/lib/empty -
EOF
echo Yes I did something

postinstall scriptlet (using /bin/sh):
# python3_install_alternative: 
update-alternatives --quiet --install /usr/bin/supybot supybot /usr/bin/supybot-3.10 310 \
   --slave /usr/bin/supybot-adduser supybot-adduser /usr/bin/supybot-adduser-3.10 \
   --slave /usr/bin/supybot-botchk supybot-botchk /usr/bin/supybot-botchk-3.10 \
   --slave /usr/bin/supybot-plugin-create supybot-plugin-create /usr/bin/supybot-plugin-create-3.10 \
   --slave /usr/bin/supybot-plugin-doc supybot-plugin-doc /usr/bin/supybot-plugin-doc-3.10 \
   --slave /usr/bin/supybot-reset-password supybot-reset-password /usr/bin/supybot-reset-password-3.10 \
   --slave /usr/bin/supybot-test supybot-test /usr/bin/supybot-test-3.10 \
   --slave /usr/bin/supybot-wizard supybot-wizard /usr/bin/supybot-wizard-3.10 \
   --slave /usr/bin/supybot-wizard-suse supybot-wizard-suse /usr/bin/supybot-wizard-suse-3.10 \
   --slave /usr/share/man/man1/supybot.1.gz supybot.1.gz /usr/share/man/man1/supybot-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-adduser.1.gz supybot-adduser.1.gz /usr/share/man/man1/supybot-adduser-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-botchk.1.gz supybot-botchk.1.gz /usr/share/man/man1/supybot-botchk-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-plugin-create.1.gz supybot-plugin-create.1.gz /usr/share/man/man1/supybot-plugin-create-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-plugin-doc.1.gz supybot-plugin-doc.1.gz /usr/share/man/man1/supybot-plugin-doc-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-reset-password.1.gz supybot-reset-password.1.gz /usr/share/man/man1/supybot-reset-password-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-test.1.gz supybot-test.1.gz /usr/share/man/man1/supybot-test-3.10.1.gz \
   --slave /usr/share/man/man1/supybot-wizard.1.gz supybot-wizard.1.gz /usr/share/man/man1/supybot-wizard-3.10.1.gz
postuninstall scriptlet (using /bin/sh):
# python3_uninstall_alternative: 

if [ ! -e "/usr/bin/supybot-3.10" ]; then 
    update-alternatives --quiet --remove "supybot" "/usr/bin/supybot-3.10" 
fi
tacerus commented 2 years ago

Interesting findings - but I'm not sure they are related to python-rpm-macros - with your patched version of the macros my spec file is building fine - maybe something else is different in your project? I can't quite explain why rpm would care about the SOURCES/BUILD structure to determine its scripts though - I think this is either an upstream bug or some poorly documented behavior of rpm. Maybe it tries to store the scripts in some specific directory structure? I'll have to try and understand the rpm internal logic for this.

bnavigator commented 2 years ago

It is not building fine. The original patch did not install the pre script at all. Check the output near the end when rpm runs some final checks (https://github.com/openSUSE/python-rpm-macros/issues/141#issuecomment-1223907005). You will notice complaints about not having the correct user.

bnavigator commented 2 years ago

I checked out home:crameleon:LibertaCasa/python-limnoria and built it locally:

[  249s] error: Could not open Prein file /home/abuild/rpmbuild/BUILD/home/abuild/rpmbuild/SOURCES/Limnoria-20220814/limnoria.pre: No such file or directory

Note the wrong path .../BUILD/home...

But I agree that %pre -f %{appname}.pre not working with %setup -n %{_sourcedir}/%{appdir} -D -T is not related to python-rpm-macros. The python-rpm-macros bug about not correctly copying %pre -f %{appname}.pre should be fixed by the updated #142 now.