1 ## Written 2006 by Martin Bartosch for the OpenXPKI project
2 ## Copyright (C) 2005-2006 by The OpenXPKI Project
5 # - OpenXPKI deployment package -
8 %define pkgname openxpki
-deployment
9 %define filelist
%{pkgname}-%{version}-filelist
10 %define NVR
%{pkgname}-%{version}-%{release}
11 %define instancedir
/etc
/openxpki
/instances
12 %define instance trustcenter1
13 %define install_prefix _PREFIX_
15 name
: openxpki
-deployment
16 summary
: OpenXPKI Deployment Tools
19 vendor
: OpenXPKI Project
20 packager
: Martin Bartosch
<m.bartosch@cynops.de
>
22 group
: Applications
/CPAN
23 url
: http
://www.openxpki.org
24 buildroot
: %{_tmppath}/%{name}-%{version}-%
(id
-u
-n
)
25 prefix
: %
(echo %{_prefix})
26 source0
: openxpki
-deployment
-%{version}.tar.gz
27 source1
: openxpki
-deployment
-susefiles.tar.gz
30 OpenXPKI deployment and administration tools.
33 %setup -q
-n
%{pkgname}-%{version}
35 chmod
-R u
+w
%{_builddir}/%{pkgname}-%{version}
38 .
/configure _CONFIGURE_ARGS_
-- \
39 --setcfg dir.sysconfdir
=/etc \
40 --setcfg dir.openxpkiconfdir
=%{instancedir}/%{instance} \
41 --setcfg dir.localstatedir
=/var \
42 --setcfg server.pidfile
=/var
/run
/openxpkid.pid \
43 --setcfg server.admgroup
=openxpki \
46 # Debian used this (does not take into account %prefix properly)
47 # --setcfg dir.mandir=/usr/share/man \
48 # --setcfg dir.sysconfdir=/etc \
49 # --setcfg dir.openxpkiconfdir=%{instancedir}/%{instance} \
50 # --setcfg dir.localedir=/usr/share/locale \
51 # --setcfg dir.localstatedir=/var \
52 # --setcfg server.pidfile=/var/run/openxpkid.pid \
53 # --setcfg server.admgroup=openxpki \
59 [ "
%{buildroot}" != "/" ] && rm -rf %{buildroot}
60 DESTDIR
=%{buildroot} make install
62 install -D
-m
755 etc
/init.d
/openxpki
%{buildroot}/etc
/init.d
/openxpki
63 install -D
-m
644 etc
/sysconfig
/openxpki
%{buildroot}/etc
/sysconfig
/openxpki
65 cmd
=/usr
/share
/spec
-helper
/compress_files
66 [ -x $cmd
] || cmd
=/usr
/lib
/rpm
/brp
-compress
70 if [ -e
/etc
/SuSE
-release
-o
-e
/etc
/UnitedLinux
-release
]
75 # remove special files
77 # no empty directories
78 find
%{buildroot}%{_prefix} \
80 -exec rmdir {} \
; 2>/dev
/null
82 %{__perl} -MFile
::Find
-le '
83 find
({ wanted
=> \
&wanted
, no_chdir
=> 1}, "
%{buildroot}"
);
84 print "
%doc README\n"
;
85 print "
%config /etc
/sysconfig
/openxpki"
;
86 for my $x
(sort @
dirs, @files
) {
87 push @ret
, $x unless indirs
($x
);
89 print join "\n"
, sort @ret
;
93 return if /etc\
/sysconfig\
/openxpki$
/;
95 local $_
= $File
::Find
::name
;
96 my $f
= $_
; s|^\Q
%{buildroot}\E||
;
98 return $files
[@files
] = $_
if -f $f
;
101 /\Q$d\E
/ && return for reverse sort @INC
;
102 $d
=~
/\Q$_\E
/ && return
103 for qw|
/etc
%_prefix/man
%_prefix/bin
%_prefix/share|
;
110 $x
=~
/^\Q$_\E\
// && $x ne $_
&& return 1 for @
dirs;
115 [ -z
%filelist ] && {
116 echo "ERROR
: empty
%files listing"
122 # find unused user/group id
124 while cut
/etc
/passwd
-f3
-d
: | egrep "^$id\$"
>/dev
/null || cut
/etc
/group
-f3
-d
: | egrep "^$id\$"
>/dev
/null
; do
128 if ! cut
-f1
-d
: /etc
/group | egrep "^openxpki\$"
>/dev
/null
; then
129 echo "Creating openxpki group
($id
)"
>&2
130 /usr
/sbin
/groupadd
-g $id openxpki
2>/dev
/null
134 if ! id openxpki
>/dev
/null
2>&1 ; then
135 echo "Creating openxpki user
($id
)"
>&2
136 /usr
/sbin
/useradd
-c "OpenXPKI User"
-r
-s
/bin
/false
-u $id
-g $id
-d
/tmp openxpki
2>/dev
/null
141 export PATH
=%{install_prefix}/bin
:$PATH
142 # check for already configured trustcenter1
143 if [ -e
%{instancedir}/%{instance}/openxpki.conf
]; then
144 echo "Detected an existing deployment
(leaving it untouched
)."
>&2
146 install -d
-m
750 -o root
-g openxpki
%{instancedir}/%{instance}
147 install -m
750 -o root
-g openxpki
%{install_prefix}/share/openxpki/templates/default/openxpki.conf %{instancedir}/%{instance}
148 echo -n "Deploying instance '
%{instance}'... "
>&2
149 openxpkiadm deploy
-- --setcfg dir.openxpkiconfdir
=%{instancedir}/%{instance} 2>>/var
/log
/messages
151 cd %{instancedir}/%{instance}
152 echo -n "Configuring instance '
%{instance}'... "
>&2
153 openxpki
-configure
--batch
--createdirs
>>/var
/log
/messages
158 [ "
%{buildroot}" != "/" ] && rm -rf %{buildroot}
161 %defattr(-,root
,root
)
162 %config(noreplace
) %attr(644,root
,root
) /etc
/sysconfig
/openxpki
165 * Mon Nov
27 2006 m.bartosch@cynops.de