test/zip.spec
author J. Ali Harlow <ali@juiblex.co.uk>
Thu Feb 09 20:45:27 2012 +0000 (2012-02-09)
changeset 418 33b825d3128d
parent 393 d16ac3fb05fa
permissions -rw-r--r--
Add transaction barriers
These allow packages to be installed and removed which have scripts
that depend on each other when atomic transactions are involved.
Note that yum supports pre, but not other requires flags. post will
need similar support to the post scripts themselves pulling in the
requires flags from the rpms. Likewise preun and postun will need
similar handling to those scrips since the requires flags will need
to be stored in the razor database.
ali@393
     1
%define _source_payload w9.gzdio
ali@393
     2
%define _binary_payload w9.gzdio
ali@393
     3
ali@351
     4
Name:      zip
ali@351
     5
Summary:   Test package
ali@351
     6
Group:     Test
ali@351
     7
License:   GPL
ali@382
     8
Version:   %{_version}
ali@351
     9
Release:   1
ali@351
    10
Source:    zip.tar
ali@351
    11
BuildArch: noarch
ali@351
    12
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
ali@351
    13
Prefix:    /usr
ali@351
    14
Requires:  zap
ali@418
    15
Requires(pre,postun):  zap
ali@351
    16
ali@351
    17
%description
ali@351
    18
Test package
ali@351
    19
ali@351
    20
%prep
ali@351
    21
ali@351
    22
%build
ali@351
    23
ali@351
    24
%install
ali@351
    25
mkdir -p $RPM_BUILD_ROOT/usr/bin
ali@382
    26
echo %{name}-%{version}-%{release} > $RPM_BUILD_ROOT/usr/bin/zip
ali@351
    27
ali@351
    28
%clean
ali@351
    29
ali@367
    30
%pre -p <lua>
ali@367
    31
function mkdir_missing(dir)
ali@367
    32
    if posix.stat(dir)==nil then
ali@367
    33
	posix.mkdir(dir)
ali@367
    34
    end
ali@367
    35
end
ali@367
    36
prefix=posix.getenv("RPM_INSTALL_PREFIX0")
ali@367
    37
if prefix==nil then
ali@367
    38
    prefix="/usr"
ali@367
    39
end
ali@376
    40
if arg[2]==1 and posix.stat(prefix.."/bin/zap")~=nil then
ali@367
    41
    mkdir_missing(prefix.."/var")
ali@367
    42
    mkdir_missing(prefix.."/var/lib")
ali@367
    43
    posix.mkdir(prefix.."/var/lib/zip")
ali@367
    44
    io.output(prefix.."/var/lib/zip/data.zap")
ali@367
    45
    io.write("Important data\n");
ali@367
    46
    io.close()
ali@367
    47
end
ali@367
    48
ali@367
    49
%postun -p <lua>
ali@367
    50
prefix=posix.getenv("RPM_INSTALL_PREFIX0")
ali@367
    51
if prefix==nil then
ali@367
    52
    prefix="/usr"
ali@367
    53
end
ali@376
    54
if arg[2]==0 and posix.stat(prefix.."/bin/zap")~=nil then
ali@367
    55
    os.remove(prefix.."/var/lib/zip/data.zap")
ali@367
    56
    os.remove(prefix.."/var/lib/zip")
ali@367
    57
end
ali@367
    58
ali@351
    59
%files
ali@351
    60
/usr/bin/zip