pretrasn lua call now done in pcall (protected call)
This commit is contained in:
parent
0cf022a219
commit
5ab2a1f2e5
@ -5,7 +5,7 @@
|
||||
Name: copy-jdk-configs
|
||||
|
||||
Version: 1.1
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
Summary: JDKs configuration files copier
|
||||
|
||||
License: BSD
|
||||
@ -33,14 +33,24 @@ cp -a %{SOURCE1} .
|
||||
#blob
|
||||
|
||||
%pretrans -p <lua>
|
||||
function createPretransScript()
|
||||
-- the sript must be available during pretrans, so multiply it to tmp
|
||||
os.execute("mkdir -p " .. "%{rpm_state_dir}")
|
||||
temp_path="%{rpm_state_dir}" .. "/" .. "%{file}"
|
||||
os.execute("mkdir -p %{rpm_state_dir}")
|
||||
temp_path="%{rpm_state_dir}/%{file}"
|
||||
-- print("generating " .. temp_path)
|
||||
file = io.open(temp_path, "w")
|
||||
file:write([[%{pretrans_install}]])
|
||||
file:close()
|
||||
file = io.open(temp_path, "w")
|
||||
file:write([[%{pretrans_install}]])
|
||||
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
|
||||
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}
|
||||
@ -48,14 +58,18 @@ cp -a %{SOURCE0} $RPM_BUILD_ROOT/%{_libexecdir}/%{file}
|
||||
|
||||
%posttrans
|
||||
# remove file created in pretrans
|
||||
# echo "removing %{rpm_state_dir}/%{file}"
|
||||
rm "%{rpm_state_dir}/%{file}"
|
||||
# echo "removing %{rpm_state_dir}/%{file}" || :
|
||||
rm "%{rpm_state_dir}/%{file}" || :
|
||||
|
||||
%files
|
||||
%{_libexecdir}/%{file}
|
||||
%license LICENSE
|
||||
|
||||
%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
|
||||
- package now "installs" also during pretrans, so pretrasn scripts can use it
|
||||
- pretrasn "install" is removed in postrans
|
||||
|
Loading…
Reference in New Issue
Block a user