copy-jdk-configs/copy-jdk-configs.spec

79 lines
2.2 KiB
RPMSpec
Raw Normal View History

2015-12-04 13:39:35 +00:00
%global project copy_jdk_configs
%global file %{project}.lua
%global rpm_state_dir %{_localstatedir}/lib/rpm-state
2015-12-04 13:39:35 +00:00
Name: copy-jdk-configs
Version: 1.1
Release: 3%{?dist}
2015-12-04 13:39:35 +00:00
Summary: JDKs configuration files copier
License: BSD
URL: https://hg.fedorahosted.org/hg/%{project}
Source0: https://hg.fedorahosted.org/hg/copy_jdk_configs/raw-file/%{project}-%{version}/%{file}
Source1: https://hg.fedorahosted.org/hg/copy_jdk_configs/raw-file/%{project}-%{version}/LICENSE
# we need to duplicate msot of the percents in that script so they survive rpm expansion (even in that sed they have to be duplicated)
%global pretrans_install %(cat %{SOURCE0} | sed s/%%/%%%%/g | sed s/\\^%%%%/^%%/g)
2015-12-04 13:39:35 +00:00
BuildArch: noarch
Requires: lua
Requires: lua-posix
%description
Utility script to transfer JDKs configuration files between updates or for
archiving.
%prep
cp -a %{SOURCE1} .
%build
#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}"
-- print("generating " .. temp_path)
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
2015-12-04 13:39:35 +00:00
%install
mkdir -p $RPM_BUILD_ROOT/%{_libexecdir}
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}" || :
2015-12-04 13:39:35 +00:00
%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
2015-12-04 13:39:35 +00:00
* Wed Nov 25 2015 Jiri Vanek <jvanek@redhat.com> - 1.1-1
- initial package