Accepting request 684638 from home:coolo:branches:openSUSE:Factory

- my attempt to rewrite %post in lua (bsc#1129036)

OBS-URL: https://build.opensuse.org/request/show/684638
OBS-URL: https://build.opensuse.org/package/show/system:packagemanager/dpkg?expand=0&rev=69
This commit is contained in:
Tomáš Chvátal 2019-03-13 10:05:44 +00:00 committed by Git OBS Bridge
parent 11299112e6
commit 03729a1ecb
2 changed files with 23 additions and 14 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Wed Mar 13 09:15:51 UTC 2019 - Stephan Kulow <coolo@suse.com>
- my attempt to rewrite %post in lua (bsc#1129036)
------------------------------------------------------------------- -------------------------------------------------------------------
Mon Jan 14 15:49:09 CET 2019 - kukuk@suse.de Mon Jan 14 15:49:09 CET 2019 - kukuk@suse.de

View File

@ -31,8 +31,6 @@ BuildRequires: automake
BuildRequires: libtool BuildRequires: libtool
BuildRequires: ncurses-devel BuildRequires: ncurses-devel
BuildRequires: pkgconfig BuildRequires: pkgconfig
Requires(post): coreutils
Requires(post): update-alternatives
Provides: alternatives = %{version} Provides: alternatives = %{version}
%description %description
@ -71,18 +69,24 @@ install -pm 0755 utils/%{name} %{buildroot}/%{_sbindir}
ln -s %{name} %{buildroot}/%{_sbindir}/alternatives ln -s %{name} %{buildroot}/%{_sbindir}/alternatives
install -pm 0644 man/%{name}.1 %{buildroot}/%{_mandir}/man1/ install -pm 0644 man/%{name}.1 %{buildroot}/%{_mandir}/man1/
%post %post -p <lua>
# Migrate to new location -- Migrate to new location
if [ -d var/lib/rpm/alternatives ]; then if posix.access('var/lib/rpm/alternatives', 'x') then
echo "migrating update alternatives database to new location" print("migrating update alternatives database to new location")
# We proceed even if no alternatives directory exists, such situation -- We proceed even if no alternatives directory exists, such situation
# occurs in buildroot environment (we can't buildrequire package -- occurs in buildroot environment
# itself). new_location=rpm.expand('%{_localstatedir}/lib/alternatives/')
mv -f var/lib/rpm/alternatives/* %{_localstatedir}/lib/alternatives/ || : for i,old_file in pairs(posix.dir("var/lib/rpm/alternatives/")) do
rmdir var/lib/rpm/alternatives ||: print(old_file.."\n")
fi new_file = string.gsub(old_file, "(.*/)(.*)", new_location .. "%2")
print(new_file.."\n")
touch %{_localstatedir}/log/alternatives.log os.rename(old_file, new_file)
end
posix.rmdir('var/lib/rpm/alternatives')
end
-- touch file
new_file = io.open(rpm.expand('%{_localstatedir}/log/alternatives.log'), "w")
new_file.close()
%files %files
%license COPYING %license COPYING