[lsb-discuss] /etc/profile.d and LSB (test procedure missing?)
Till Kamppeter
till.kamppeter at gmail.com
Thu Mar 22 05:07:02 PDT 2007
The LSB specification requires that a login shell sources all the *.sh
scripts in the /etc/profile.d directory:
http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/etc.html
In reality this is not done by all LSB-compliant distros, especially not
by Debian, Ubuntu, and the LSB Build Environment. As Debian and Ubuntu
are most probably LSB-certified I assume that the testing framework of
the LSB is missing the test of whether /etc/profile.d is functional (for
example add a shell script setting some environment variables to
/etc/profile.d, calling "sh -l -c 'echo <new variable>'" and see whether
the variable is set).
I discovered that when making a CUPS package for the LSB DDK. In the
maintainer scripts of the RPM (see below) I had to add the script to the
end of /etc/profile (and remove this on uninstall) for non-conforming
distros.
Till
----------------------------------------------------------------------
%post
[...]
%if %{optinstall}
# LSB requires that a login shell executes all .sh scripts in the
# /etc/profile.d directory, unfortunately, many distros (Debian, Ubuntu,
# LSB Build Environment) do not fulfill this. So work around by appending
# the /etc/profile.d/cups.sh script to the file /etc/profile if the distro
# is Debian-based ($1 is a string and not a number in a .deb package) or
# if /etc/profile.d is missing (for example in the LSB Build Environment).
if test $1 -ge 0 2>/dev/null && test $1 -le 9 2>/dev/null && \
[ -d /etc/profile.d ]; then
# RPM-based distro of no /etc/profile.d
( /usr/lib/lsb/lsbinstall --package=cups --type=profile
%{_sysconfdir}/%{name}/profile.d/cups.sh 2>/dev/null || \
ln -sf %{_sysconfdir}/%{name}/profile.d/cups.sh /etc/profile.d/
2>/dev/null )
else
# Debian-based distro (/etc/profile.d/ not supported, not
LSB-compliant)
# Remove old script
perl -e 'my $a = join("", <>); $a =~ s/### LSB-RPM %{name}\n.*\n###
LSN-RPM %{name}\n//sg; print $a' /etc/profile > /etc/profile.new && \
mv -f /etc/profile.new /etc/profile
# Add current script
( echo '### LSB-RPM %{name}'; \
cat %{_sysconfdir}/%{name}/profile.d/cups.sh; \
echo '### LSB-RPM %{name}' ) >> /etc/profile
fi
%endif
[...]
%preun
[...]
%if %{optinstall}
if test $1 != 1; then
# Remove the script to add the tool directories to the $PATH
if test $1 -ge 0 2>/dev/null && test $1 -le 9 2>/dev/null && \
[ -d /etc/profile.d ]; then
# RPM-based distro
/usr/lib/lsb/lsbinstall --package=cups --remove --type=profile
%{_sysconfdir}/%{name}/profile.d/cups.sh 2>/dev/null || :
if [ -h /etc/profile.d/cups.sh ]; then
rm -f /etc/profile.d/cups.sh 2>/dev/null
fi
else
# Debian-based distro (/etc/profile.d/ not supported, not
LSB-compliant)
perl -e 'my $a = join("", <>); $a =~ s/### LSB-RPM %{name}\n.*\n###
LSB-RPM %{name}\n//sg; print $a' /etc/profile > /etc/profile.new && \
mv -f /etc/profile.new /etc/profile
fi
fi
%endif
More information about the lsb-discuss
mailing list