Bluecat RH 8.0 port

This status entry is to hold a log of the issues and resolutions for getting the Bluecat build process from the ancient RH 6.1 to the a little less ancient RH 8.0.

  1. Fun with eval, echo and new shell
  2. Bug in rpm configure
  3. Static vs. Shared

Fun with eval, echo and new shell

One of the things that the Bluecat do_it script does is to define the series of "steps" that need to be performed in terms of command lines in variables. Later on the $BUILD_STEP is evaluated to determine which set of commands need to be done as follows:

echo "---- Step $BUILD_STEP started at `date` ----"
su $BUILD_CMD_OWNER -c "mkdir -p $LOGS_PREFIX/step${BUILD_STEP}"
cmd=`eval echo $"STEP${BUILD_STEP}_CMD"`
su $BUILD_CMD_OWNER -c "$cmd $*"

Effectively the name of the environment variable holding the proper command(s) for the step is composed with the echo portion. The eval statement is used to "evaluate" that environment variable thus storing the string of commands into the environment variable cmd. This works well in past versions of the OS but it fails in RH 8.0. First here's the behavior on RH 6.1:

RH6.1:export STEP1_CMD="ls /tmp"
RH6.1:export BUILD_STEP=1
RH6.1:echo $"STEP${BUILD_STEP}_CMD"
$STEP1_CMD

However hears the same commands on RH8.0:

RH8.0:export STEP1_CMD="ls /tmp"
RH8.0:export BUILD_STEP=1
RH8.0:echo $"STEP${BUILD_STEP}_CMD"
STEP1_CMD

As you can see the result is missing a $. Prepending a leading \ before the $ fixes this. Adding in the eval portion also works:

RH8.0:eval echo \$"STEP${BUILD_STEP}_CMD"
ls /tmp

However when this is assigned to another environment variable (i.e. cmd) the result is not correct:

RH8.0:cmd=`eval echo \$"STEP${BUILD_STEP}_CMD"`
RH8.0:echo $cmd
STEP1_CMD

Subsituting the syntax of $() for `

RH8.0:cmd=$(eval echo \$"STEP${BUILD_STEP}_CMD")
RH8.0:echo $cmd
ls /tmp

Note that the shell (bash) has been majorly updated for RH8.0:

RH6.1:bash -version
GNU bash, version 1.14.7(1)

Versus:

RH8.0:bash -version
GNU bash, version 2.05b.0(1)-release (i686-pc-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.

Please note that this new syntax also works flawlessly on the older RH 6.1.

Bug in rpm configure

When trying to build Bluecat on RH 8.0 and running mktools (to build the local gnutools) I get the following:

[int@europa make]$ autoreconf -f -i
autoreconf: `aclocal.m4' is updated
Makefile.am: installing `./depcomp'
WARNING: Using auxiliary files such as `acconfig.h', `config.h.bot'
WARNING: and `config.h.top', to define templates for `config.h.in'
WARNING: is deprecated and discouraged.

WARNING: Using the third argument of `AC_DEFINE' and
WARNING: `AC_DEFINE_UNQUOTED' allows to define a template without
WARNING: `acconfig.h':

WARNING:   AC_DEFINE([NEED_MAIN], 1,
WARNING:             [Define if a function `main' is needed.])

WARNING: More sophisticated templates can also be produced, see the
WARNING: documentation.
autoheader-2.53: `config.h.in' is updated

Further, after running configure I get the following odd file in /usr/local/bluecat/eng/bluecat/make/.deps: remote-$(REMOTE).Po which causes the make to fail:

[int@europa make]$ make
Makefile:329: .deps/remote-stub.Po: No such file or directory
make: *** No rule to make target `.deps/remote-stub.Po'.  Stop.

Renaming .deps/remote-$(REMOTE).Po -> .deps/remote-stub.Po allows the make to proceed.

Static vs. Shared - Cannot find -lnss_dns

During the first real build step, step 2, the build fails when trying to build rpm. ld is unable to find the library nss_dns. Initial investigation shows that there is a nss_dns libs under /usr/lib as .so files but there is no .a file on RH 8.0. There is a .a file on RH 6.1 in /usr/lib. Apparently RH 8.0 no longer offers archive libraries for this. The solution to this problem is to pass -shared to gcc.

The specific gcc command line is:

int@europa tools:pwd
/var/tmp/rpm-4.2/tools
int@europa tools:gcc -Wl,--verbose -O2 -D_GNU_SOURCE -D_REENTRANT -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wno-char-subscripts -o rpmgraph -static rpmgraph.o  ../lib/.libs/librpm.a /var/tmp/rpm-4.2/rpmdb/.libs/librpmdb.a -L/var/tmp/rpm-4.2/zlib -L/usr/local/lib /var/tmp/rpm-4.2/rpmio/.libs/librpmio.a /var/tmp/rpm-4.2/popt/.libs/libpopt.a ../beecrypt/.libs/libbeecrypt.a -lrt -lpthread -lc -lnss_dns -lnss_files -lresolv
...
(/usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../libc.a)truncate64.o
(/usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../libc.a)truncate.o
attempt to open /var/tmp/rpm-4.2/zlib/libnss_dns.a failed
attempt to open /usr/local/lib/libnss_dns.a failed
attempt to open /usr/lib/gcc-lib/i386-redhat-linux/3.2/libnss_dns.a failed
attempt to open /usr/lib/gcc-lib/i386-redhat-linux/3.2/../../../libnss_dns.a failed
attempt to open /usr/i386-redhat-linux/lib/libnss_dns.a failed
attempt to open /usr/lib/libnss_dns.a failed
attempt to open /usr/local/lib/libnss_dns.a failed
attempt to open /lib/libnss_dns.a failed
collect2: ld returned 1 exit status

This is probably due to the -static above. Removing -static fixes this. The question is: Is it OK to remove -static? Second question is how?