media-libs/gst-rtsp-server: bump to 1.12.2
[gentoo.git] / app-backup / tsm / tsm-7.1.0.0-r1.ebuild
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=5
5
6 inherit versionator multilib eutils readme.gentoo rpm systemd user
7
8 DESCRIPTION="Tivoli Storage Manager (TSM) Backup/Archive (B/A) Client and API"
9 HOMEPAGE="http://www.tivoli.com/"
10
11 MY_PV_MAJOR=$(get_major_version)
12 MY_PV_MINOR=$(get_version_component_range 2)
13 MY_PV_TINY=$(get_version_component_range 3)
14 MY_PV_PATCH=$(get_version_component_range 4)
15
16 MY_PV_NODOTS="${MY_PV_MAJOR}${MY_PV_MINOR}${MY_PV_TINY}"
17 MY_PVR_ALLDOTS=${PV}
18
19 if [[ ${MY_PV_PATCH} == 0 ]]; then
20         MY_RELEASE_PATH=maintenance
21 else
22         MY_RELEASE_PATH=patches
23 fi
24 BASE_URI="ftp://ftp.software.ibm.com/storage/tivoli-storage-management/"
25 BASE_URI+="${MY_RELEASE_PATH}/client/v${MY_PV_MAJOR}r${MY_PV_MINOR}/"
26 BASE_URI+="Linux/LinuxX86/BA/v${MY_PV_NODOTS}/"
27 SRC_TAR="${MY_PVR_ALLDOTS}-TIV-TSMBAC-LinuxX86.tar"
28 SRC_URI="${BASE_URI}${SRC_TAR}"
29
30 RESTRICT="strip" # Breaks libPiIMG.so and libPiSNAP.so
31 LICENSE="Apache-1.1 Apache-2.0 JDOM BSD-2 CC-PD Boost-1.0 MIT CPL-1.0 HPND Exolab
32         dom4j EPL-1.0 FTL icu unicode IBM Info-ZIP LGPL-2 LGPL-2.1 openafs-krb5-a
33         ZLIB MPL-1.0 MPL-1.1 NPL-1.1 openssl OPENLDAP RSA public-domain W3C
34         || ( BSD GPL-2+ ) gSOAP libpng tsm"
35
36 SLOT="0"
37 KEYWORDS="~amd64 -*"
38 IUSE="acl java +tsm_cit +tsm_hw"
39 QA_PREBUILT="*"
40
41 MY_LANGS="cs:CS_CZ de:DE_DE es:ES_ES fr:FR_FR hu:HU_HU it:IT_IT ja:JA_JP
42         ko:KO_KR pl:PL_PL pt-BR:PT_BR ru:RU_RU zh-CN:ZH_CN zh-TW:ZH_TW"
43 MY_LANG_PV="${MY_PVR_ALLDOTS}-"
44 for lang in ${MY_LANGS}; do
45         IUSE="${IUSE} l10n_${lang%:*}"
46         SRC_URI="${SRC_URI} l10n_${lang%:*}? ( \
47 ${BASE_URI}TIVsm-msg.${lang#*:}.x86_64.rpm -> \
48 ${MY_LANG_PV}TIVsm-msg.${lang#*:}.x86_64.rpm )"
49 done
50 unset lang
51
52 DEPEND=""
53 RDEPEND="
54         dev-libs/expat
55         dev-libs/libxml2
56         =sys-fs/fuse-2*
57         acl? ( sys-apps/acl )
58         java? ( virtual/jre:1.7 )
59 "
60
61 S="${WORKDIR}"
62
63 pkg_setup() {
64         enewgroup tsm
65         DOC_CONTENTS="
66                 Note that you have to be either root or member of the group tsm to
67                 be able to use the Tivoli Storage Manager client."
68 }
69
70 src_unpack() {
71         local rpm rpms lang
72         unpack ${SRC_TAR}
73
74         for rpm in *.rpm; do
75                 case ${rpm} in
76                         TIVsm-APIcit.*|TIVsm-BAcit.*)
77                                 use tsm_cit && rpms="${rpms} ./${rpm}"
78                                 ;;
79                         TIVsm-BAhdw.*)
80                                 use tsm_hw && rpms="${rpms} ./${rpm}"
81                                 ;;
82                         TIVsm-JBB.*|*-filepath-*)
83                                 # "journal based backup" for all filesystems
84                                 # requires a kernel module.
85                                 # "Linux Filepath source code" available
86                                 # by request from vendor
87                                 ;;
88                         *)
89                                 rpms="${rpms} ./${rpm}"
90                                 ;;
91                 esac
92         done
93         for rpm in ${A}; do
94                 case ${rpm} in
95                         *.rpm)
96                                 rpms="${rpms} ${rpm}"
97                                 ;;
98                 esac
99         done
100
101         rpm_unpack ${rpms}
102
103         # Avoid strange error messages caused by read-only files
104         chmod -R u+w "${S}" || die
105 }
106
107 src_prepare() {
108         # Avoid unnecessary dependency on ksh
109         sed -i 's:^#!/usr/bin/ksh:#!/bin/bash:' \
110                 opt/tivoli/tsm/client/ba/bin/dsmj || die
111 }
112
113 src_install() {
114         cp -a opt "${D}" || die
115         cp -a usr "${D}" || die
116
117         # The RPM files contain postinstall scripts which can be extracted
118         # e.g. using https://bugs.gentoo.org/attachment.cgi?id=234663 .
119         # Below we try to mimic the behaviour of these scripts.
120         # We don't deal with SELinux compliance (yet), though.
121         local RPM_INSTALL_PREFIX CLIENTDIR i
122         RPM_INSTALL_PREFIX=/opt
123         CLIENTDIR=$RPM_INSTALL_PREFIX/tivoli/tsm/client
124
125         # We don't bother setting timestamps to build dates.
126         # But we should delete the corresponding files.
127         rm -f "${D}"$CLIENTDIR/api/bin*/.buildDate || die
128         rm -f "${D}"$CLIENTDIR/ba/bin*/.buildDate || die
129         rm -f "${D}"$CLIENTDIR/lang/.buildDate || die
130
131         # Create links for messages; this is spread over several postin scripts.
132         for i in $(cd "${D}"${CLIENTDIR}/lang; ls -1d ??_??); do
133                 dosym ../../lang/${i} $CLIENTDIR/ba/bin/${i}
134                 dosym ../../lang/${i} $CLIENTDIR/api/bin64/${i}
135         done
136
137         # Mimic TIVsm-API64 postinstall script
138         for i in libgpfs.so libdmapi.so; do
139                 dosym ../..$CLIENTDIR/api/bin64/${i} /usr/lib64/${i}
140         done
141
142         # The TIVsm-BA postinstall script only does messages and ancient upgrades
143
144         # The gscrypt64 postinstall script only deals with s390[x] SELinux
145         # and the symlink for the iccs library which we handle in the loop below.
146
147         # Move stuff from /usr/local to /opt, #452332
148         mv "${D}"/usr/local/ibm "${D}"/opt/ || die
149         rmdir "${D}"/usr/local || die
150
151         # Mimic gskssl64 postinstall script
152         for i in sys p11 km ssl drld kicc ldap cms acmeidup valn dbfl iccs; do
153                 dosym ../../opt/ibm/gsk8_64/lib64/libgsk8${i}_64.so \
154                         /usr/lib64/libgsk8${i}_64.so
155         done
156         for i in capicmd ver; do
157                 dosym ../../opt/ibm/gsk8_64/bin/gsk8${i}_64 /usr/bin/gsk${i}_64
158         done
159
160         # Done with the postinstall scripts as the RPMs contain them.
161         # Now on to some more Gentoo-specific installation.
162
163         [[ -d "${D}usr/lib" ]] && die "Using 32bit lib dir in 64bit only system"
164
165         # Avoid "QA Notice: Found an absolute symlink in a library directory"
166         local target
167         find "${D}"usr/lib* -lname '/*' | while read i; do
168                 target=$(readlink "${i}")
169                 rm -v "${i}" || die
170                 dosym "../..${target}" "${i#${D}}"
171         done
172
173         # Install symlinks for sonames of libraries, bug #416503
174         dosym libvixMntapi.so.1.1.0 $CLIENTDIR/ba/bin/libvixMntapi.so.1
175         dosym libvixDiskLibVim.so.5.5.0 $CLIENTDIR/ba/bin/libvixDiskLibVim.so.5
176         dosym libvixDiskLib.so.5.5.0 $CLIENTDIR/ba/bin/libvixDiskLib.so.5
177
178         fowners :tsm /opt/tivoli/tsm/client/ba/bin/dsmtca
179         fperms 4710 /opt/tivoli/tsm/client/ba/bin/dsmtca
180
181         keepdir /var/log/tsm
182         insinto /etc/logrotate.d
183         newins "${FILESDIR}/tsm.logrotate" tsm
184
185         keepdir /etc/tivoli
186
187         cp -a "${S}/opt/tivoli/tsm/client/ba/bin/dsm.sys.smp" "${D}/etc/tivoli/dsm.sys" || die
188         echo '   PasswordDir "/etc/tivoli/"' >> ${D}/etc/tivoli/dsm.sys
189         echo '   PasswordAccess generate' >> ${D}/etc/tivoli/dsm.sys
190
191         # Added the hostname to be more friendly, the admin will need to edit this file anyway
192         echo '   NodeName' `hostname` >> ${D}/etc/tivoli/dsm.sys
193         echo '   ErrorLogName "/var/log/tsm/dsmerror.log"' >> ${D}/etc/tivoli/dsm.sys
194         echo '   SchedLogName "/var/log/tsm/dsmsched.log"' >> ${D}/etc/tivoli/dsm.sys
195         dosym ../../../../../../etc/tivoli/dsm.sys /opt/tivoli/tsm/client/ba/bin/dsm.sys
196
197         cp -a "${S}/opt/tivoli/tsm/client/ba/bin/dsm.opt.smp" "${D}/etc/tivoli/dsm.opt"
198         dosym ../../../../../../etc/tivoli/dsm.opt /opt/tivoli/tsm/client/ba/bin/dsm.opt
199
200         # Setup the env
201         dodir /etc/env.d
202         ENV_FILE="${D}/etc/env.d/80tivoli"
203         echo 'DSM_CONFIG="/etc/tivoli/dsm.opt"' >> ${ENV_FILE}
204         echo 'DSM_DIR="/opt/tivoli/tsm/client/ba/bin"' >> ${ENV_FILE}
205         echo 'DSM_LOG="/var/log/tsm"' >> ${ENV_FILE}
206         echo 'ROOTPATH="/opt/tivoli/tsm/client/ba/bin"' >> ${ENV_FILE}
207
208         newconfd "${FILESDIR}/dsmc.conf.d" dsmc
209         newinitd "${FILESDIR}/dsmc.init.d" dsmc
210         newinitd "${FILESDIR}/dsmcad.init.d-r1" dsmcad
211
212         systemd_dounit "${FILESDIR}/dsmc.service"
213         systemd_dounit "${FILESDIR}/dsmcad.service"
214
215         readme.gentoo_create_doc
216 }
217
218 pkg_postinst() {
219         local i dirs
220         for i in /var/log/tsm/dsm{error,sched,j,webcl}.log; do
221                 if [[ ! -e $i ]]; then
222                         touch $i || die
223                         chown :tsm $i || die
224                         chmod 0660 $i || die
225                 fi
226         done
227
228         # Bug #375041: the log directory itself should not be world writable.
229         # Have to do this in postinst due to bug #141619
230         chown root:tsm /var/log/tsm || die
231         chmod 0750 /var/log/tsm || die
232
233         # Bug 508052: directories used to be too restrictive, have to widen perms.
234         dirs=( /opt/tivoli $(find /opt/tivoli/tsm -type d) )
235         chown root:root "${dirs[@]}" || die
236         chmod 0755 "${dirs[@]}" || die
237
238         readme.gentoo_print_elog
239 }