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 source: openxpki
-deployment
-%{version}.tar.gz
29 OpenXPKI deployment and administration tools.
32 %setup -q
-n
%{pkgname}-%{version}
33 chmod
-R u
+w
%{_builddir}/%{pkgname}-%{version}
36 .
/configure _CONFIGURE_ARGS_
-- \
37 --setcfg dir.sysconfdir
=/etc \
38 --setcfg dir.openxpkiconfdir
=%{instancedir}/%{instance} \
39 --setcfg dir.localstatedir
=/var \
40 --setcfg server.pidfile
=/var
/run
/openxpkid.pid \
41 --setcfg server.admgroup
=openxpki \
44 # Debian used this (does not take into account %prefix properly)
45 # --setcfg dir.mandir=/usr/share/man \
46 # --setcfg dir.sysconfdir=/etc \
47 # --setcfg dir.openxpkiconfdir=%{instancedir}/%{instance} \
48 # --setcfg dir.localedir=/usr/share/locale \
49 # --setcfg dir.localstatedir=/var \
50 # --setcfg server.pidfile=/var/run/openxpkid.pid \
51 # --setcfg server.admgroup=openxpki \
57 [ "
%{buildroot}" != "/" ] && rm -rf %{buildroot}
58 DESTDIR
=%{buildroot} make install
60 install -D
-m
755 -o root
-g openxpki etc
/initscripts
/suse
/openxpki.rc
%{buildroot}/etc
/init.d
/openxpki
61 install -D
-m
644 -o root
-g openxpki etc
/initscripts
/suse
/openxpki.sysconfig
%{buildroot}/etc
/sysconfig
/openxpki
63 cmd
=/usr
/share
/spec
-helper
/compress_files
64 [ -x $cmd
] || cmd
=/usr
/lib
/rpm
/brp
-compress
68 if [ -e
/etc
/SuSE
-release
-o
-e
/etc
/UnitedLinux
-release
]
73 # remove special files
75 # no empty directories
76 find
%{buildroot}%{_prefix} \
78 -exec rmdir {} \
; 2>/dev
/null
80 %{__perl} -MFile
::Find
-le '
81 find
({ wanted
=> \
&wanted
, no_chdir
=> 1}, "
%{buildroot}"
);
82 print "
%doc README\n"
;
83 print "
%config /etc
/sysconfig
/openxpki"
;
84 for my $x
(sort @
dirs, @files
) {
85 push @ret
, $x unless indirs
($x
);
87 print join "\n"
, sort @ret
;
91 return if /etc\
/sysconfig\
/openxpki$
/;
93 local $_
= $File
::Find
::name
;
94 my $f
= $_
; s|^\Q
%{buildroot}\E||
;
96 return $files
[@files
] = $_
if -f $f
;
99 /\Q$d\E
/ && return for reverse sort @INC
;
100 $d
=~
/\Q$_\E
/ && return
101 for qw|
/etc
%_prefix/man
%_prefix/bin
%_prefix/share|
;
108 $x
=~
/^\Q$_\E\
// && $x ne $_
&& return 1 for @
dirs;
113 [ -z
%filelist ] && {
114 echo "ERROR
: empty
%files listing"
120 # find unused user/group id
122 while cut
/etc
/passwd
-f3
-d
: | egrep "^$id\$"
>/dev
/null || cut
/etc
/group
-f3
-d
: | egrep "^$id\$"
>/dev
/null
; do
126 if ! cut
-f1
-d
: /etc
/group | egrep "^openxpki\$"
>/dev
/null
; then
127 echo "Creating openxpki group
($id
)"
>&2
128 /usr
/sbin
/groupadd
-g $id openxpki
2>/dev
/null
132 if ! id openxpki
>/dev
/null
2>&1 ; then
133 echo "Creating openxpki user
($id
)"
>&2
134 /usr
/sbin
/useradd
-c "OpenXPKI User"
-r
-s
/bin
/false
-u $id
-g $id
-d
/tmp openxpki
2>/dev
/null
139 export PATH
=%{install_prefix}/bin
:$PATH
140 # check for already configured trustcenter1
141 if [ -e
%{instancedir}/%{instance}/openxpki.conf
]; then
142 echo "Detected an existing deployment
(leaving it untouched
)."
>&2
144 install -d
-m
750 -o root
-g openxpki
%{instancedir}/%{instance}
145 install -m
750 -o root
-g openxpki
%{install_prefix}/share/openxpki/templates/default/openxpki.conf %{instancedir}/%{instance}
146 echo -n "Deploying instance '
%{instance}'... "
>&2
147 openxpkiadm deploy
-- --setcfg dir.openxpkiconfdir
=%{instancedir}/%{instance} 2>>/var
/log
/messages
149 cd %{instancedir}/%{instance}
150 echo -n "Configuring instance '
%{instance}'... "
>&2
151 openxpki
-configure
--batch
--createdirs
>>/var
/log
/messages
156 [ "
%{buildroot}" != "/" ] && rm -rf %{buildroot}
159 %defattr(-,root
,root
)
162 * Mon Nov
27 2006 m.bartosch@cynops.de