pretrasn lua call now done in pcall (protected call)

This commit is contained in:
Jiri 2016-01-08 11:57:55 +01:00
parent 0cf022a219
commit 5ab2a1f2e5

View File

@ -5,7 +5,7 @@
Name: copy-jdk-configs Name: copy-jdk-configs
Version: 1.1 Version: 1.1
Release: 2%{?dist} Release: 3%{?dist}
Summary: JDKs configuration files copier Summary: JDKs configuration files copier
License: BSD License: BSD
@ -33,14 +33,24 @@ cp -a %{SOURCE1} .
#blob #blob
%pretrans -p <lua> %pretrans -p <lua>
function createPretransScript()
-- the sript must be available during pretrans, so multiply it to tmp -- the sript must be available during pretrans, so multiply it to tmp
os.execute("mkdir -p " .. "%{rpm_state_dir}") os.execute("mkdir -p %{rpm_state_dir}")
temp_path="%{rpm_state_dir}" .. "/" .. "%{file}" temp_path="%{rpm_state_dir}/%{file}"
-- print("generating " .. temp_path) -- print("generating " .. temp_path)
file = io.open(temp_path, "w") file = io.open(temp_path, "w")
file:write([[%{pretrans_install}]]) file:write([[%{pretrans_install}]])
file:close() file:close()
end
-- in netinst, the above call may fail. pcall should save instalation (as there is nothing to copy anyway)
-- https://bugzilla.redhat.com/show_bug.cgi?id=1295701
-- todo, decide whether to check for {rpm_state_dir} and skip on not-existing, or keep creating
if pcall(createPretransScript) then
-- ok
else
-- print("Error running %{name} pretrans.")
end
%install %install
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir} mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}
@ -48,14 +58,18 @@ cp -a %{SOURCE0} $RPM_BUILD_ROOT/%{_libexecdir}/%{file}
%posttrans %posttrans
# remove file created in pretrans # remove file created in pretrans
# echo "removing %{rpm_state_dir}/%{file}" # echo "removing %{rpm_state_dir}/%{file}" || :
rm "%{rpm_state_dir}/%{file}" rm "%{rpm_state_dir}/%{file}" || :
%files %files
%{_libexecdir}/%{file} %{_libexecdir}/%{file}
%license LICENSE %license LICENSE
%changelog %changelog
* Fri Jan 08 2016 Jiri Vanek <jvanek@redhat.com> - 1.1-3
- pretrasn lua call now done in pcall (protected call)
- also posttrans now always return 0
* Wed Dec 16 2015 Jiri Vanek <jvanek@redhat.com> - 1.1-2 * Wed Dec 16 2015 Jiri Vanek <jvanek@redhat.com> - 1.1-2
- package now "installs" also during pretrans, so pretrasn scripts can use it - package now "installs" also during pretrans, so pretrasn scripts can use it
- pretrasn "install" is removed in postrans - pretrasn "install" is removed in postrans