4 # Script creates wireshark RPM and an separate RPM with the wireshare lnet/lustre plugins,
5 # installs and test whether the plugins can be selected as filters.
9 # H E L P E R F U N C T I O N S
16 [ -n "$msg" ] && echo -e "\n${0##*/}: $msg" >&1
26 # Wipe away the temporary build / install directory + content
29 echo "Cleanup ${BUILD_DIR}"
31 if [ $? -ne 0 ] ; then
32 echo "Can't change to ${BUILD_DIR} for clean-up. No clean-up performed."
35 # remove wireshark source directory and tarball and auxiliary directory to tar plugin sources
36 rm -rf wireshark-${WS_VERSION} wireshark-${WS_VERSION}.tar.bz2 ${PLUGIN_RPM_NAME}-${WS_VERSION}/ ${PLUGIN_RPM_NAME}-${WS_VERSION}-root/
44 # Enable download and compile environment settings
45 source ${0%/wsbuild}/wsconfig.sh
46 if [ $? -ne 0 ] ; then
48 fatal 1 "Can't source download and compile evironmnent defined in ${0%/wsbuild}/wsconfig.sh"
51 # Check whether prereqisited software is installed
52 echo "Prerequisite software installations:"
53 for pkg in $PREREQUISITE_RPMS
55 echo -e "\tPackage '$pkg'\t installed: \c"
56 rpm -q $pkg > /dev/null 2>&1
57 if [ $? -ne 0 ] ; then
59 fatal 1 "RPM (software) '$pkg' not installed. Can't compile wireshark."
65 # Change CWD to top level build directory
66 echo -e "Change to top level builddir: \c"
68 if [ $? -ne 0 ] ; then
70 fatal 1 "Can't change to directory '${BUILD_DIR}'. Make sure that directory exist."
76 if [ ! -x /usr/bin/curl ] ; then
77 fatal 1 "curl not installed. Can't download wireshark."
79 ws_file_name=`basename ${WS_SOURCE_URL}`
80 # echo "ws_file_name: $ws_file_name"
81 echo -e "Download wireshare source tarball: \c"
82 # Download desired wireshark tarball
83 /usr/bin/curl ${WS_SOURCE_URL} --output ${BUILD_DIR}/${ws_file_name}
84 if [ $? -ne 0 ] ; then
86 fatal 1 "Can't download wireshark version ${WS_VERSION}. Check configuration."
92 echo -e "Inflating wireshark tarball: \c"
93 ${UNTAR} ${ws_file_name}
94 if [ $? -ne 0 ] ; then
96 fatal 1 "Can't untar file '${ws_file_name}'."
101 # Build wireshark software
102 cd ${BUILD_DIR}/wireshark-${WS_VERSION}
103 if [ $? -ne 0 ] ; then
104 fatal 1 "Can't change to directory '${BUILD_DIR}/wireshark-${WS_VERSION}'."
108 # Executing configure first to create the make file and
109 # rpm spec file. Procedure is a bit ood, since `make rpm-package'
110 # is running configure again.
111 echo -e "Execute wireshark's configure script: \c"
113 if [ $? -ne 0 ] ; then
115 echo "----------- configure output ---------------------"
117 echo "--------------------------------"
118 fatal 1 "configure script in ${BUILD_DIR}/wireshark-${WS_VERSION} stops with errors"
123 # Currently code works distribution using RPM for package management only, i.e.:
124 # for RHEL/CentOS, SLES (suse)
126 # Code to support distributions using debian software packaging
129 # SLES SP1, 2 specific handling
130 if [ -r /etc/SuSE-release ] ; then
132 # Correct RPM spec file to build correctly:
133 # Note: changes are based on wireshark version 1.6.8
135 # -1- Adjust BuildRoot macro.
136 # Otherwise packaging will fail since SuSe expand BuildRoot to '/tmp/...'
137 # Files can't be found by packaging program
139 # -2- Correct libdir macro.
140 # Set library prefix to '/usr/lib64'
142 # -3- Correct file globing used for packaging library files
143 # Globbing pattern set to '%prefix/lib64/*' in %files section
144 # to capture the accordingly to change -2-
146 sed -e "s#\(BuildRoot:[[:space:]]*\)/[a-zA-Z0-9_]*\(/wireshark-%{PACKAGE_VERSION}-root\)#\1${BUILD_DIR}packaging/rpm/BUILD\2#" \
147 -e 's#\(.* \./configure .*\)#\1 --libdir=/usr/lib64#' \
148 -e 's#^\(%prefix/lib\)/\*#\164/\*#' ./packaging/rpm/SPECS/wireshark.spec > new-$$.spec
149 if [ $? -ne 0 ] ; then
150 fatal 1 "Can't modify wireshark SPEC file to build under SLES"
152 # Move modified SPEC into effect
153 mv new-$$.spec ./packaging/rpm/SPECS/wireshark.spec
154 if [ $? -ne 0 ] ; then
155 fatal 1 "Can't copy modified wireshark SPEC file (SLES to ${BUILD_DIR}/packaging/rpm/SPECS/wireshark.spec"
161 echo -e "Create wireshark RPM: \c"
163 if [ $? -ne 0 ] ; then
165 echo "----------- make rpm-package output ---------------------"
167 echo "--------------------------------"
168 fatal 1 "make rmp-package failed in ${BUILD_DIR}/wireshark-${WS_VERSION}"
170 # Package successfully built in ${BUILD_DIR}/wireshark-${WS_VERSION}/packaging/rpm/RPMS.
175 if [ $? -ne 0 ] ; then
176 fatal 1 "Can't change into directory ${BUILD_DIR}"
180 # SLES SP1, 2 installs 64Bit libs and binaries into /usr/lib64
182 if [ -r /etc/SuSE-release ] ; then
184 PLUGINS_LIBDIR='/usr/lib64/wireshark/plugins/%ver/*'
186 PLUGINS_LIBDIR='/usr/lib/wireshark/plugins/%ver/*'
189 echo -e "Create Lustre/LNet wireshark plugin RPM: \c"
191 # Insert the associated version, name and build directory info
192 # to the SPEC template. Use '#'
193 # as delimiters since path info will be substituted
194 sed -e "s#XXX-TOP-LEVEL-BUILD-DIR-XXX#${BUILD_DIR}#" \
195 -e "s#XXX-LUSTRE-PLUGIN-VERSION-XXX#${WS_VERSION}#" \
196 -e "s#XXX-LUSTRE-PLUGIN-RPM-NAME-XXX#${PLUGIN_RPM_NAME}#" \
197 -e "s#XXX-LUSTRE-PLUGIN-LIBDIR-XXX#${PLUGINS_LIBDIR}#" \
198 lustre-wireshark-plugins-template.spec > ${PLUGIN_RPM_NAME}.spec
199 if [ $? -ne 0 ] ; then
201 fatal 1 "Can't create SPEC file for Lustre/LNet wireshark plugins"
205 # Create tarball containing source files plugins to be used rpmbuid mechanism
206 if [ -d ${PLUGIN_RPM_NAME}-${WS_VERSION} ] ; then
207 rm -rf lustre-wireshark-plugins-1.6.8
208 if [ $? -ne 0 ] ; then
209 fatal 1 "Can't cleanup auxiliary directory to create tarball of Lustre/LNet plugins"
212 # Create auxiliary directory
213 mkdir ${PLUGIN_RPM_NAME}-${WS_VERSION}
214 if [ $? -ne 0 ] ; then
216 fatal 1 "Can't create packaging directory to create source tarball for lustre wireshark plugins"
218 cp README Makefile packet-lnet.c packet-lustre.c ${PLUGIN_RPM_NAME}-${WS_VERSION}
219 if [ $? -ne 0 ] ; then
221 fatal 1 "Can't copy files for rpm source tar ball into helper directory for Lustre/LNet wireshark plugins"
224 $TAR ${PLUGIN_RPM_NAME}-${WS_VERSION}.tar.bz2 ${PLUGIN_RPM_NAME}-${WS_VERSION}/
225 if [ $? -ne 0 ] ; then
227 fatal 1 "Can't create rpm source tar ball for Lustre/LNet wireshark plugins"
230 # install source tarball into build directory
231 cp ${PLUGIN_RPM_NAME}-${WS_VERSION}.tar.bz2 ${BUILD_DIR}/wireshark-${WS_VERSION}/packaging/rpm/SOURCES
232 if [ $? -ne 0 ] ; then
234 fatal 1 "Can't copy source tar ball for Lustre/LNet wireshark plugins build directory"
237 rpmbuild -bb --define "_topdir ${BUILD_DIR}/wireshark-${WS_VERSION}/packaging/rpm" ${PLUGIN_RPM_NAME}.spec
238 if [ $? -ne 0 ] ; then
240 fatal 1 "Can't create RPM for Lustre/LNet wireshark plugins"