File s390-tools.spec of Package s390-tools

#
# spec file for package s390-tools
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#



Name:           s390-tools
BuildRequires:  fuse-devel gcc-c++ gettext-tools mkinitrd ncurses-devel net-snmp-devel tcpd-devel
Url:            http://www10.software.ibm.com/developerworks/opensource/linux390
Summary:        S/390 tools like zipl and dasdfmt
Version:        1.15.0
Release:        0.<RELEASE85>
PreReq:         %insserv_prereq %fillup_prereq mkinitrd >= 2.4
License:        GPL-2.0+
Provides:       s390utils:/sbin/dasdfmt
Group:          System/Kernel
Source:         s390-tools-%{version}.tar.bz2
AutoReqProv:    yes
Source1:        s390-tools-rpmlintrc
Source2:        zipl.conf
Source10:       hsnc
Source11:       sysconfig.hsnc
Source12:       xpram
Source13:       sysconfig.xpram
Source14:       appldata
Source15:       sysconfig.appldata
Source16:       vmlogrdr
Source17:       vmlogrdr.hotplug
Source40:       dasd_configure
Source41:       zfcp_host_configure
Source42:       zfcp_disk_configure
Source43:       dasdro
Source44:       dasd_reload
Source45:       mkdump.pl
Source46:       sysconfig.osasnmpd
Source47:       zfcp_san_disc
Source48:       iucv_configure
Source49:       ctc_configure
Source50:       qeth_configure
Source51:       mkinitrd-setup-dasd.sh
Source52:       mkinitrd-boot-dasd.sh
Source53:       mkinitrd-setup-zfcp.sh
Source54:       mkinitrd-boot-zfcp.sh
Source55:       blktrace_api.h
Source56:       boot.cpi
Source57:       sysconfig.cpi
Source58:       mkinitrd-setup-zfcpdump.sh
Source59:       mkinitrd-boot-zfcpdump.sh
Source60:       README.SUSE
Source61:       mkinitrd-setup-qeth.sh
Source62:       mkinitrd-boot-qeth.sh
Source63:       zpxe.rexx
Source64:       rules.xpram
Source65:       rules.hw_random
Patch1:         s390tools-160-pardasdfmt.patch
Patch4:         s390tools-160-zipl_boot_msg.patch
Patch45:        s390-tools-zfcpdump-remove-static-link.patch
Patch79:        s390-tools-fdasd-0001-add-f-flag.patch
Patch107:       s390-tools-sles11sp2-cpuplugd_man_page.patch
Patch108:       s390-tools-sles11sp2-fdasd-fix-auto-label.patch
Patch109:       s390-tools-sles11sp2-sysconfig-compatible-dumpconf.patch
Patch110:       s390-tools-sles11sp2-mkdump-manpage.patch
Patch111:       s390-tools-sles11sp2-dumpconf-restart-delay.patch
Patch112:       s390-tools-sles11sp2-dumpconf-8vmcmd.patch
Patch113:       s390-tools-sles11sp2-lsluns-fix_help_option_ports_to_port.patch
Patch114:       s390-tools-sles11sp2-zipl_helper_locale.patch
Patch115:       s390-tools-sles11sp2-cpuplugd_parse_config.patch
Patch116:       s390-tools-sles11sp2-dasdfmt-percentage-conflict.patch
Patch117:       s390-tools-sles11sp2-qetharp-buffer-overflow.patch
Patch118:       s390-tools-sles11sp2-lsqeth-new-attribute-hsuid.patch
Patch119:       s390-tools-sles11sp2-afiucv-manpage-1-2.patch
Patch120:       s390-tools-sles11sp2-dbginfo-fix-kernel-version-checks.patch
Patch121:       s390-tools-sles11sp2-lscss,lsdasd_unsettled_sysfs.patch
Patch122:       s390-tools-sles11sp2-lsluns-fix_generate_msg_if_sg_functionality_not_available.patch
Patch123:       s390-tools-sles11sp2-zipl_parmfile_addr.patch
Patch124:       s390-tools-sles11sp2-lsmem-chmem-memory_hole.patch
Patch125:       s390-tools-sles11sp2-dasdview-fix-busid-output.patch
Patch126:       s390-tools-sles11sp2-zfcpdbf-fix-disply-messages-problem.patch
Patch127:       s390-tools-sles11sp2-zfcpdbf-add-version-to-help-options.patch
Patch128:       s390-tools-sles11sp2-cmsfs-fuse_large_files.patch
Patch129:       s390-tools-sles11sp2-cmsfs-fuse_big_writes.patch
Patch130:       s390-tools-sles11sp2-cmsfs-fuse_cont_write.patch
Patch131:       s390-tools-sles11sp2-cmsfs-fuse-eof.patch
Patch132:       s390-tools-sles11sp2-zipl-fix_scsi_dump.patch
Patch133:       s390-tools-sles11sp2-cmsfs-fuse-amap.patch
Patch134:       s390-tools-sles11sp2-cmsfs-fuse-disk_full.patch
Patch135:       s390-tools-sles11sp2-cmsfs-fuse-fba.patch
Patch136:       s390-tools-sles11sp2-dumpconf-fix-killproc.patch
Patch137:       s390-tools-sles11sp2-zfcpdbf-fix-timediff.patch
Patch138:       s390-tools-sles11sp2-lsmem-chmem-dev_size.patch
Patch139:       s390-tools-sles11sp2-lsdasd-improve-performance.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
ExclusiveArch:  s390 s390x
%define _sbindir /sbin
%define _datadir /usr/lib

%description
This package contains the tools needed to use Linux on the S/390:
dasdfmt  - low-level format tool for ECKD DASDs fdasd	 - partitions
ECKD DASDs with z/OS compatible disk layout zipl     - boot loader and
dump DASD initializer zgetdump - tool to get linux system dumps from
DASDs



%package -n osasnmpd
License:        GPL-2.0+
Summary:        OSA-Express SNMP subagent
Group:          Productivity/Networking/Other
Requires:       perl

%description -n osasnmpd
Supports management information bases (MIBs) provided by OSA-Express
Fast Ethernet, Gigabit Ethernet, High Speed Token Ring and ATM Ethernet
LAN Emulation features in QDIO mode.

It extends the capabilities of the ucd-snmp master agent (snmpd) and
communicates with him via the AgentX protocol.



%prep
if file /bin/bash | grep 32-bit.*390 && [ `arch` != s390 ]; then exit 1;fi
# %setup -q -T -n SuSE-tools     -b 6
%setup -q -n %{name}-%{version}
### This will copy the blktrace_api.h file into place so that the tools will
### build.  As soon as the kernel headers are fixed, this should be removed.
mkdir -p include/linux
cp -v %{S:55} include/linux/
### End of blktrace_api.h hack.  Please remove when possible.
%patch1 -p1
%patch4 -p1
%patch45 -p1
%patch79 -p1
%patch107 -p1
%patch108 -p1
%patch109 -p1
%patch110 -p1
%patch111 -p1
%patch112 -p1
%patch113 -p1
%patch114 -p1
%patch115 -p1
%patch116 -p1
%patch117 -p1
%patch118 -p1
%patch119 -p1
%patch120 -p1
%patch121 -p1
%patch122 -p1
%patch123 -p1
%patch124 -p1
%patch125 -p1
%patch126 -p1
%patch127 -p1
%patch128 -p1
%patch129 -p1
%patch130 -p1
%patch131 -p1
%patch132 -p1
%patch133 -p1
%patch134 -p1
%patch135 -p1
%patch136 -p1
%patch137 -p1
%patch138 -p1
%patch139 -p1

%build
export OPT_FLAGS="$RPM_OPT_FLAGS"
%define ucdsnmp %(test -f /usr/bin/net-snmp-config && echo 0 || echo 1)
%if %{ucdsnmp}
# tcpd/libwrap.a of SLES8 expects the caller to provide these symbols:
echo "int allow_severity, deny_severity;" >> osasnmpd/ibmOSAMib.c
%endif
export KERNELIMAGE_MAKEFLAGS="%{?_smp_mflags}"
# Work around broken inter-libary-dependendies of lib*mibs.so:(-lwrap ...)
make KERNEL_DIR=/usr/src/linux CRYPTO='-lcrypto -lwrap' \
        SUB_DIRS="libvtoc zipl zdump fdasd dasdfmt dasdview tunedasd tape390 osasnmpd qetharp ip_watcher qethconf scripts zconf vmconvert vmcp man mon_tools dasdinfo vmur cpuplugd ipl_tools ziomon iucvterm hyptop cmsfs-fuse" ZFCPDUMP_DIR=/usr/lib/s390-tools DISTRELEASE=%{release}
make -C zfcpdump_v2 zfcpdump

%install
mkdir -p $RPM_BUILD_ROOT/boot/zipl
make INSTROOT=$RPM_BUILD_ROOT			\
        SUB_DIRS="libvtoc zipl zdump fdasd dasdfmt dasdview tunedasd tape390 qetharp ip_watcher qethconf scripts zconf vmconvert vmcp man mon_tools dasdinfo vmur cpuplugd ipl_tools ziomon iucvterm hyptop cmsfs-fuse" \
	ZIPLDIR=$RPM_BUILD_ROOT/boot/zipl	\
	BINDIR=$RPM_BUILD_ROOT/sbin		\
	USRBINDIR=$RPM_BUILD_ROOT/usr/bin      	\
	LIBDIR=$RPM_BUILD_ROOT/%_lib		\
	SYSCONFDIR=$RPM_BUILD_ROOT/etc		\
	MANDIR=$RPM_BUILD_ROOT/%{_mandir} \
	DISTRELEASE=%{release} install
mkdir -p $RPM_BUILD_ROOT%{_datadir}/s390-tools
install -D -m755 zfcpdump_v2/zfcpdump $RPM_BUILD_ROOT%{_datadir}/s390-tools
install -D -m644 etc/sysconfig/dumpconf $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.dumpconf
install -D -m755 etc/init.d/dumpconf $RPM_BUILD_ROOT/etc/init.d/dumpconf
install -D -m644 etc/udev/rules.d/60-readahead.rules $RPM_BUILD_ROOT/etc/udev/rules.d/60-readahead.rules
install -D -m644 etc/udev/rules.d/59-dasd.rules $RPM_BUILD_ROOT/etc/udev/rules.d/59-dasd.rules
install -D -m644 etc/udev/rules.d/57-osasnmpd.rules $RPM_BUILD_ROOT/etc/udev/rules.d/57-osasnmpd.rules
install -D -m644 etc/sysconfig/mon_statd $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.mon_statd
install -D -m755 etc/init.d/mon_statd $RPM_BUILD_ROOT/etc/init.d/mon_statd
install -D -m644 etc/sysconfig/cpuplugd $RPM_BUILD_ROOT/var/adm/fillup-templates/sysconfig.cpuplugd
install -D -m755 etc/init.d/cpuplugd $RPM_BUILD_ROOT/etc/init.d/cpuplugd
install -D -m755 osasnmpd/osasnmpd $RPM_BUILD_ROOT/usr/sbin/osasnmpd-2.6
install -D -m644 osasnmpd/osasnmpd.8 $RPM_BUILD_ROOT/%_mandir/man8
mv iucvterm/doc/ts-shell/iucvconn_on_login $RPM_BUILD_ROOT/usr/bin/iucvconn_on_login
cp  %{S:60} README.SUSE
cp  %{S:63} zpxe.rexx
cd $RPM_BUILD_ROOT
install -D -m644 %{S:2}  etc/zipl.conf.sample
install -D -m755 %{S:10} etc/init.d/hsnc
install -D -m644 %{S:11} var/adm/fillup-templates/sysconfig.hsnc
install -D -m755 %{S:12} etc/init.d/xpram
install -D -m644 %{S:13} var/adm/fillup-templates/sysconfig.xpram
install -D -m755 %{S:14} etc/init.d/appldata
install -D -m644 %{S:15} var/adm/fillup-templates/sysconfig.appldata
install -D -m755 %{S:16} etc/init.d/vmlogrdr
install -D -m755 %{S:40} sbin/dasd_configure
install -D -m755 %{S:41} sbin/zfcp_host_configure
install -D -m755 %{S:42} sbin/zfcp_disk_configure
install -D -m755 %{S:43} sbin/dasdro
install -D -m755 %{S:44} sbin/dasd_reload
install -D -m755 %{S:45} sbin/mkdump
install -D -m644 %{S:46} var/adm/fillup-templates/sysconfig.osasnmpd
install -D -m755 %{S:47} sbin/zfcp_san_disc
install -D -m755 %{S:48} sbin/iucv_configure
install -D -m755 %{S:49} sbin/ctc_configure
install -D -m755 %{S:50} sbin/qeth_configure
install -D -m755 %{S:51} lib/mkinitrd/scripts/setup-dasd.sh
install -D -m755 %{S:52} lib/mkinitrd/scripts/boot-dasd.sh
install -D -m755 %{S:53} lib/mkinitrd/scripts/setup-zfcp.sh
install -D -m755 %{S:54} lib/mkinitrd/scripts/boot-zfcp.sh
install -D -m755 %{S:56} etc/init.d/boot.cpi
install -D -m644 %{S:57} var/adm/fillup-templates/sysconfig.cpi
install -D -m755 %{S:58} usr/lib/s390-tools/mkinitrd/scripts/setup-zfcpdump.sh
install -D -m755 %{S:59} usr/lib/s390-tools/mkinitrd/scripts/boot-zfcpdump.sh
install -D -m755 %{S:61} usr/lib/s390-tools/mkinitrd/scripts/setup-qeth.sh
install -D -m755 %{S:62} usr/lib/s390-tools/mkinitrd/scripts/boot-qeth.sh
install -D -m644 %{S:64} $RPM_BUILD_ROOT/etc/udev/rules.d/52-xpram.rules
install -D -m644 %{S:65} $RPM_BUILD_ROOT/etc/udev/rules.d/52-hw_random.rules
mkdir usr/lib/s390-tools/mkinitrd/bin
mkdir usr/lib/s390-tools/mkinitrd/setup
mkdir usr/lib/s390-tools/mkinitrd/boot
(cd usr/lib/s390-tools/mkinitrd/bin; ln -sf ../../zfcpdump linuxrc)
cp /lib/mkinitrd/scripts/setup-modules.sh usr/lib/s390-tools/mkinitrd/scripts
cp /lib/mkinitrd/scripts/setup-prepare.sh usr/lib/s390-tools/mkinitrd/scripts
cp /lib/mkinitrd/scripts/setup-progs.sh usr/lib/s390-tools/mkinitrd/scripts
cp /lib/mkinitrd/scripts/setup-sharedlibs.sh usr/lib/s390-tools/mkinitrd/scripts
cp /lib/mkinitrd/scripts/setup-done.sh usr/lib/s390-tools/mkinitrd/scripts
if [ ! -d usr/sbin ]; then
    rm -f usr/sbin
    mkdir -p usr/sbin
fi
(cd usr/sbin; ln -s ../../etc/init.d/hsnc rchsnc)
(cd usr/sbin; ln -s ../../etc/init.d/xpram rcxpram)
(cd usr/sbin; ln -s ../../etc/init.d/appldata rcappldata)
(cd usr/sbin; ln -s ../../etc/init.d/vmlogrdr rcvmlogrdr)
(cd usr/sbin; ln -s ../../etc/init.d/dumpconf rcdumpconf)
(cd usr/sbin; ln -s osasnmpd-2.6 osasnmpd)
find . ! -type d |
    %__sed 's/^.//;\-/man/-s/^.*$/%doc &.gz/'  > %{_builddir}/%{name}-filelist
#echo %{_docdir}/%{name}		>> %{_builddir}/%{name}-filelist
#cp -a $RPM_BUILD_DIR/SuSE-tools/* $RPM_BUILD_ROOT
grep -v -E 'osasnmp|*\.conf$' %{_builddir}/%{name}-filelist >%{_builddir}/%{name}.list
grep    osasnmp[^-] %{_builddir}/%{name}-filelist >%{_builddir}/%{name}.osasnmp
%define snmp %(test -f /usr/bin/net-snmp-config && echo net-snmp || echo ucd-snmp)
mkdir -p usr/lib/%{snmp}/agents
cd	 usr/lib/%{snmp}/agents
cat <<EOT >osasnmpd
#!/bin/sh
PIDFILE=/var/run/osasnmpd.pid
function cleanup
{
        rm -f \$PIDFILE
        kill \`cat /var/run/osasnmpd.real.pid\`
}
. /etc/sysconfig/osasnmpd
trap cleanup 0
echo \$\$ >\$PIDFILE
/usr/sbin/osasnmpd -f -P /var/run/osasnmpd.real.pid \$OSASNMPD_PARAMETERS "\$@"
EOT
chmod 755 osasnmpd

%pre
# check for ts-shell group or create it
getent group ts-shell >/dev/null 2>&1 || groupadd -r ts-shell

%post
echo "Run zipl after updating this package to update the IPL record!!!"
mkinitrd_setup
mkinitrd_setup -s /usr/lib/s390-tools/mkinitrd/scripts -i /usr/lib/s390-tools/mkinitrd
# -i: skip insserv parts - has to be configured before use:
%{fillup_and_insserv -i -n dumpconf}
%{fillup_and_insserv -i -n hsnc}
%{fillup_and_insserv -i -n xpram}
%{fillup_and_insserv -i -n appldata}
%{fillup_and_insserv -i -n vmlogrdr}
%{fillup_and_insserv -i -n cpuplugd}
%{fillup_and_insserv -i -n mon_statd}
%{fillup_and_insserv -y -n cpi boot.cpi}
# Create the zfcpdump image and initrd
if test -e /boot/image ; then
  echo "Creating zfcpdump image"
  cp /boot/image /usr/lib/s390-tools/zfcpdump.image
  /sbin/mkinitrd -f zfcpdump -B \
      -l /usr/lib/s390-tools/mkinitrd \
      -k /usr/lib/s390-tools/zfcpdump.image \
      -i /usr/lib/s390-tools/zfcpdump.rd
fi

%triggerin -- kernel-default
# Create the zfcpdump image and initrd
if test -e /boot/image ; then
  echo "Creating zfcpdump image"
  cp /boot/image /usr/lib/s390-tools/zfcpdump.image
  /sbin/mkinitrd -f zfcpdump -B \
      -l /usr/lib/s390-tools/mkinitrd \
      -k /usr/lib/s390-tools/zfcpdump.image \
      -i /usr/lib/s390-tools/zfcpdump.rd
fi
grep -q '^/usr/bin/ts-shell$' /etc/shells \
	|| echo "/usr/bin/ts-shell" >> /etc/shells

%post -n osasnmpd
%{fillup_and_insserv -i -n osasnmpd}

%preun
%{stop_on_removal mon_statd}
%{stop_on_removal cpuplugd}
%{stop_on_removal vmlogrdr}
%{stop_on_removal appldata}
%{stop_on_removal xpram}
%{stop_on_removal hsnc}
%{stop_on_removal dumpconf}
[ -e /usr/lib/s390-tools/zfcpdump.image ] && rm /usr/lib/s390-tools/zfcpdump.image || true
[ -e /usr/lib/s390-tools/zfcpdump.rd ] && rm /usr/lib/s390-tools/zfcpdump.rd || true

%postun
if [ ! -x /boot/zipl ]; then
	echo "Attention, after uninstalling this package,"
	echo "you will NOT be able to IPL from DASD anymore!!!"
fi
[ -x /sbin/mkinitrd_setup ] && mkinitrd_setup
%{insserv_cleanup}
if test x$1 = x0; then
	# remove ts-shell from /etc/shells
	grep -v '^/usr/bin/ts-shell$' /etc/shells > /etc/shells.ts-new
	mv /etc/shells.ts-new /etc/shells
	chmod 0644 /etc/shells
fi

%preun -n osasnmpd
%{stop_on_removal osasnmpd}

%clean
rm -rf $RPM_BUILD_ROOT

%files -f %{_builddir}/%{name}.list
%defattr(-,root,root)
%doc README
%doc README.SUSE
%doc iucvterm/doc/ts-shell
%doc zpxe.rexx
%dir /etc/iucvterm
%config %attr(0640,root,ts-shell) /etc/iucvterm/ts-audit-systems.conf
%config %attr(0640,root,ts-shell) /etc/iucvterm/ts-authorization.conf
%config %attr(0640,root,ts-shell) /etc/iucvterm/ts-shell.conf
%config %attr(0640,root,ts-shell) /etc/iucvterm/unrestricted.conf
%dir %attr(2770,root,ts-shell) /var/log/ts-shell
%dir /etc/cmsfs-fuse
%config %attr(0640,root,root) /etc/cmsfs-fuse/filetypes.conf
%dir %{_datadir}/s390-tools
%dir %{_datadir}/s390-tools/mkinitrd
%dir %{_datadir}/s390-tools/mkinitrd/bin
%dir %{_datadir}/s390-tools/mkinitrd/scripts
%dir %{_datadir}/s390-tools/mkinitrd/setup
%dir %{_datadir}/s390-tools/mkinitrd/boot
%dir /etc/udev
%dir /etc/udev/rules.d
%config /etc/udev/rules.d/*
%dir /boot/zipl
%dir /lib/s390-tools/

%files -n osasnmpd -f %{_builddir}/%{name}.osasnmp
%defattr(-,root,root)
/usr/lib/%{snmp}/agents/osasnmpd

%changelog