openSUSE / python-rpm-macros

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

libalternatives handling wrong #133

Closed AdamMajer closed 2 years ago

AdamMajer commented 2 years ago

While looking at,

# rpm -V python310-chardet
.M.......  g /usr/share/libalternatives/chardetect
.M.......  g /usr/share/libalternatives/chardetect/1310.conf

and then at scripts

# rpm -q --scripts python310-chardet
preinstall scriptlet (using /bin/sh):
# If libalternatives is used: Removing old update-alternatives entries.

if [ "$1" -gt 0 ] && [ -f /usr/sbin/update-alternatives ]; then 
    update-alternatives --quiet --remove "chardetect" "/usr/bin/chardetect-3.10" 
fi
postinstall scriptlet (using /bin/sh):

mkdir -p /usr/share/libalternatives/chardetect
echo binary=/usr/bin/chardetect-3.10 >/usr/share/libalternatives/chardetect/1310.conf
echo group=chardetect >>/usr/share/libalternatives/chardetect/1310.conf
postuninstall scriptlet (using /bin/sh):

: # no uninstall action for libalternatives

The most obvious problems here are:

  1. these is not suppose to be ghost files
  2. the files are to be installed, not generated by script

So if these are to be generated by some macro, it must be part of the %build or %install.

bnavigator commented 2 years ago

---> @schubi2

bnavigator commented 2 years ago

I wouldnt't call it "wrong". In fact in rpmlint it is specifically okayed:

https://github.com/rpm-software-management/rpmlint/blob/af399ec51490836aebfbbe1fd5a0bc9ec8fcc1bd/rpmlint/descriptions/AlternativesCheck.toml#L41

But I agree that installing it in %install is better: #135

AdamMajer commented 2 years ago

Yes, and that is wrong too :smile: These are meant to be simple files that are immutable and are installed. They are not meant to be ghosts like with update-alternatives where they can change or are created after installation.

Thank you for the quick patch. I will test it now.